|
@@ -719,8 +719,10 @@ void ImGuiIO::AddInputCharacter(ImWchar c)
|
|
|
const float IM_PI = 3.14159265358979323846f;
|
|
|
|
|
|
#ifdef INT_MAX
|
|
|
+#define IM_INT_MIN INT_MIN
|
|
|
#define IM_INT_MAX INT_MAX
|
|
|
#else
|
|
|
+#define IM_INT_MIN (-2147483647-1)
|
|
|
#define IM_INT_MAX (2147483647)
|
|
|
#endif
|
|
|
|
|
@@ -6406,6 +6408,31 @@ bool ImGui::DragFloat4(const char* label, float v[2], float v_speed, float v_min
|
|
|
return DragFloatN(label, v, 4, v_speed, v_min, v_max, display_format, power);
|
|
|
}
|
|
|
|
|
|
+bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* display_format, const char* display_format_max, float power)
|
|
|
+{
|
|
|
+ ImGuiState& g = *GImGui;
|
|
|
+ ImGuiWindow* window = GetCurrentWindow();
|
|
|
+ if (window->SkipItems)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ ImGui::PushID(label);
|
|
|
+ ImGui::BeginGroup();
|
|
|
+ PushMultiItemsWidths(2);
|
|
|
+
|
|
|
+ bool value_changed = ImGui::DragFloat("##min", v_current_min, v_speed, (v_min >= v_max) ? -FLT_MAX : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), display_format, power);
|
|
|
+ ImGui::PopItemWidth();
|
|
|
+ ImGui::SameLine(0, (int)g.Style.ItemInnerSpacing.x);
|
|
|
+ value_changed |= ImGui::DragFloat("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? FLT_MAX : v_max, display_format_max ? display_format_max : display_format, power);
|
|
|
+ ImGui::PopItemWidth();
|
|
|
+ ImGui::SameLine(0, (int)g.Style.ItemInnerSpacing.x);
|
|
|
+
|
|
|
+ ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
|
|
+ ImGui::EndGroup();
|
|
|
+ ImGui::PopID();
|
|
|
+
|
|
|
+ return value_changed;
|
|
|
+}
|
|
|
+
|
|
|
// NB: v_speed is float to allow adjusting the drag speed with more precision
|
|
|
bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* display_format)
|
|
|
{
|
|
@@ -6459,6 +6486,31 @@ bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int
|
|
|
return DragIntN(label, v, 4, v_speed, v_min, v_max, display_format);
|
|
|
}
|
|
|
|
|
|
+bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* display_format, const char* display_format_max)
|
|
|
+{
|
|
|
+ ImGuiState& g = *GImGui;
|
|
|
+ ImGuiWindow* window = GetCurrentWindow();
|
|
|
+ if (window->SkipItems)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ ImGui::PushID(label);
|
|
|
+ ImGui::BeginGroup();
|
|
|
+ PushMultiItemsWidths(2);
|
|
|
+
|
|
|
+ bool value_changed = ImGui::DragInt("##min", v_current_min, v_speed, (v_min >= v_max) ? IM_INT_MIN : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), display_format);
|
|
|
+ ImGui::PopItemWidth();
|
|
|
+ ImGui::SameLine(0, (int)g.Style.ItemInnerSpacing.x);
|
|
|
+ value_changed |= ImGui::DragInt("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? IM_INT_MAX : v_max, display_format_max ? display_format_max : display_format);
|
|
|
+ ImGui::PopItemWidth();
|
|
|
+ ImGui::SameLine(0, (int)g.Style.ItemInnerSpacing.x);
|
|
|
+
|
|
|
+ ImGui::TextUnformatted(label, FindTextDisplayEnd(label));
|
|
|
+ ImGui::EndGroup();
|
|
|
+ ImGui::PopID();
|
|
|
+
|
|
|
+ return value_changed;
|
|
|
+}
|
|
|
+
|
|
|
enum ImGuiPlotType
|
|
|
{
|
|
|
ImGuiPlotType_Lines,
|
|
@@ -11171,6 +11223,19 @@ void ImGui::ShowTestWindow(bool* opened)
|
|
|
//ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
|
|
|
//ImGui::PopItemWidth();
|
|
|
|
|
|
+ if (ImGui::TreeNode("Ranges"))
|
|
|
+ {
|
|
|
+ ImGui::Unindent();
|
|
|
+
|
|
|
+ static float begin = 10, end = 90;
|
|
|
+ static int begin_i = 100, end_i = 1000;
|
|
|
+ ImGui::DragFloatRange2("range", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%");
|
|
|
+ ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %.0f units", "Max: %.0f units");
|
|
|
+
|
|
|
+ ImGui::Indent();
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
+
|
|
|
if (ImGui::TreeNode("Multi-component Widgets"))
|
|
|
{
|
|
|
ImGui::Unindent();
|