|
|
@@ -1,4 +1,4 @@
|
|
|
-// dear imgui, v1.61 WIP
|
|
|
+// dear imgui, v1.62 WIP
|
|
|
// (demo code)
|
|
|
|
|
|
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
|
|
@@ -12,9 +12,9 @@
|
|
|
// Thank you,
|
|
|
// -Your beloved friend, imgui_demo.cpp (that you won't delete)
|
|
|
|
|
|
-// Message to beginner C/C++ programmers. About the meaning of 'static': in this demo code, we frequently we use 'static' variables inside functions.
|
|
|
-// We do this as a way to gather code and data in the same place, just to make the demo code faster to read, faster to write, and use less code.
|
|
|
-// A static variable persist across calls, so it is essentially like a global variable but declared inside the scope of the function.
|
|
|
+// Message to beginner C/C++ programmers. About the meaning of 'static': in this demo code, we frequently we use 'static' variables inside functions.
|
|
|
+// We do this as a way to gather code and data in the same place, just to make the demo code faster to read, faster to write, and use less code.
|
|
|
+// A static variable persist across calls, so it is essentially like a global variable but declared inside the scope of the function.
|
|
|
// It also happens to be a convenient way of storing simple UI related information as long as your function doesn't need to be reentrant or used in threads.
|
|
|
// This might be a pattern you occasionally want to use in your code, but most of the real data you would be editing is likely to be stored outside your function.
|
|
|
|
|
|
@@ -24,6 +24,7 @@
|
|
|
|
|
|
#include "imgui.h"
|
|
|
#include <ctype.h> // toupper, isprint
|
|
|
+#include <limits.h> // INT_MIN, INT_MAX
|
|
|
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
|
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
|
|
#include <stdlib.h> // NULL, malloc, free, atoi
|
|
|
@@ -82,7 +83,7 @@ static void ShowExampleAppPropertyEditor(bool* p_open);
|
|
|
static void ShowExampleAppLongText(bool* p_open);
|
|
|
static void ShowExampleAppAutoResize(bool* p_open);
|
|
|
static void ShowExampleAppConstrainedResize(bool* p_open);
|
|
|
-static void ShowExampleAppFixedOverlay(bool* p_open);
|
|
|
+static void ShowExampleAppSimpleOverlay(bool* p_open);
|
|
|
static void ShowExampleAppWindowTitles(bool* p_open);
|
|
|
static void ShowExampleAppCustomRendering(bool* p_open);
|
|
|
static void ShowExampleAppMainMenuBar();
|
|
|
@@ -135,7 +136,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
static bool show_app_long_text = false;
|
|
|
static bool show_app_auto_resize = false;
|
|
|
static bool show_app_constrained_resize = false;
|
|
|
- static bool show_app_fixed_overlay = false;
|
|
|
+ static bool show_app_simple_overlay = false;
|
|
|
static bool show_app_window_titles = false;
|
|
|
static bool show_app_custom_rendering = false;
|
|
|
static bool show_app_style_editor = false;
|
|
|
@@ -151,7 +152,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
|
|
|
if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
|
|
|
if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize);
|
|
|
- if (show_app_fixed_overlay) ShowExampleAppFixedOverlay(&show_app_fixed_overlay);
|
|
|
+ if (show_app_simple_overlay) ShowExampleAppSimpleOverlay(&show_app_simple_overlay);
|
|
|
if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles);
|
|
|
if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
|
|
|
|
|
|
@@ -218,7 +219,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
|
|
|
ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
|
|
|
ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
|
|
|
- ImGui::MenuItem("Simple overlay", NULL, &show_app_fixed_overlay);
|
|
|
+ ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
|
|
|
ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
|
|
|
ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
|
|
|
ImGui::EndMenu();
|
|
|
@@ -271,7 +272,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
if (ImGui::TreeNode("Basic"))
|
|
|
{
|
|
|
static int clicked = 0;
|
|
|
- if (ImGui::Button("Button"))
|
|
|
+ if (ImGui::Button("Button"))
|
|
|
clicked++;
|
|
|
if (clicked & 1)
|
|
|
{
|
|
|
@@ -345,8 +346,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
static float f0 = 0.001f;
|
|
|
ImGui::InputFloat("input float", &f0, 0.01f, 1.0f);
|
|
|
|
|
|
- static double d0 = 999999.000001;
|
|
|
- ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.6f");
|
|
|
+ static double d0 = 999999.00000001;
|
|
|
+ ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f");
|
|
|
|
|
|
static float f1 = 1.e10f;
|
|
|
ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e");
|
|
|
@@ -361,7 +362,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::DragInt("drag int", &i1, 1);
|
|
|
ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input value.");
|
|
|
|
|
|
- ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%.0f%%");
|
|
|
+ ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%");
|
|
|
|
|
|
static float f1=1.00f, f2=0.0067f;
|
|
|
ImGui::DragFloat("drag float", &f1, 0.005f);
|
|
|
@@ -375,7 +376,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
|
|
|
static float f1=0.123f, f2=0.0f;
|
|
|
ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
|
|
|
- ImGui::SliderFloat("slider log float", &f2, -10.0f, 10.0f, "%.4f", 3.0f);
|
|
|
+ ImGui::SliderFloat("slider float (curve)", &f2, -10.0f, 10.0f, "%.4f", 2.0f);
|
|
|
static float angle = 0.0f;
|
|
|
ImGui::SliderAngle("slider angle", &angle);
|
|
|
}
|
|
|
@@ -418,7 +419,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i))
|
|
|
{
|
|
|
ImGui::Text("blah blah");
|
|
|
- ImGui::SameLine();
|
|
|
+ ImGui::SameLine();
|
|
|
if (ImGui::SmallButton("button")) { };
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
@@ -445,7 +446,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
{
|
|
|
// Node
|
|
|
bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
|
|
|
- if (ImGui::IsItemClicked())
|
|
|
+ if (ImGui::IsItemClicked())
|
|
|
node_clicked = i;
|
|
|
if (node_open)
|
|
|
{
|
|
|
@@ -456,9 +457,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
else
|
|
|
{
|
|
|
// Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text().
|
|
|
- node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet
|
|
|
+ node_flags |= ImGuiTreeNodeFlags_Leaf; // | ImGuiTreeNodeFlags_Bullet;
|
|
|
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
|
|
|
- if (ImGui::IsItemClicked())
|
|
|
+ if (ImGui::IsItemClicked())
|
|
|
node_clicked = i;
|
|
|
}
|
|
|
}
|
|
|
@@ -549,16 +550,18 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
if (ImGui::TreeNode("UTF-8 Text"))
|
|
|
{
|
|
|
// UTF-8 test with Japanese characters
|
|
|
- // (needs a suitable font, try Arial Unicode or M+ fonts http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html)
|
|
|
+ // (Needs a suitable font, try Noto, or Arial Unicode, or M+ fonts. Read misc/fonts/README.txt for details.)
|
|
|
// - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8
|
|
|
// - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. Visual Studio save your file as 'UTF-8 without signature')
|
|
|
- // - HOWEVER, FOR THIS DEMO FILE, BECAUSE WE WANT TO SUPPORT COMPILER, WE ARE *NOT* INCLUDING RAW UTF-8 CHARACTERS IN THIS SOURCE FILE.
|
|
|
- // Instead we are encoding a few string with hexadecimal constants. Don't do this in your application!
|
|
|
+ // - FOR THIS DEMO FILE ONLY, BECAUSE WE WANT TO SUPPORT OLD COMPILERS, WE ARE *NOT* INCLUDING RAW UTF-8 CHARACTERS IN THIS SOURCE FILE.
|
|
|
+ // Instead we are encoding a few strings with hexadecimal constants. Don't do this in your application!
|
|
|
+ // Please use u8"text in any language" in your application!
|
|
|
// Note that characters values are preserved even by InputText() if the font cannot be displayed, so you can safely copy & paste garbled characters into another application.
|
|
|
- ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->LoadFromFileTTF() manually to load extra character ranges.");
|
|
|
- ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)");
|
|
|
+ ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->LoadFromFileTTF() manually to load extra character ranges. Read misc/fonts/README.txt for details.");
|
|
|
+ ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string.
|
|
|
ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)");
|
|
|
- static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"; // "nihongo"
|
|
|
+ static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e";
|
|
|
+ //static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis
|
|
|
ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf));
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
@@ -577,7 +580,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
// If you decided that ImTextureID = MyEngineTexture*, then you can pass your MyEngineTexture* pointers to ImGui::Image(), and gather width/height through your own functions, etc.
|
|
|
// Using ShowMetricsWindow() as a "debugger" to inspect the draw data that are being passed to your render will help you debug issues if you are confused about this.
|
|
|
// Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage().
|
|
|
- ImTextureID my_tex_id = io.Fonts->TexID;
|
|
|
+ ImTextureID my_tex_id = io.Fonts->TexID;
|
|
|
float my_tex_w = (float)io.Fonts->TexWidth;
|
|
|
float my_tex_h = (float)io.Fonts->TexHeight;
|
|
|
|
|
|
@@ -642,7 +645,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
}
|
|
|
|
|
|
// Simplified one-liner Combo() API, using values packed in a single constant string
|
|
|
- static int item_current_2 = 0;
|
|
|
+ static int item_current_2 = 0;
|
|
|
ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
|
|
|
|
|
|
// Simplified one-liner Combo() using an array of const char*
|
|
|
@@ -682,7 +685,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
{
|
|
|
char buf[32];
|
|
|
sprintf(buf, "Object %d", n);
|
|
|
- if (ImGui::Selectable(buf, selected == n))
|
|
|
+ if (ImGui::Selectable(buf, selected == n))
|
|
|
selected = n;
|
|
|
}
|
|
|
ImGui::TreePop();
|
|
|
@@ -698,7 +701,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
if (ImGui::Selectable(buf, selection[n]))
|
|
|
{
|
|
|
if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held
|
|
|
- memset(selection, 0, sizeof(selection));
|
|
|
+ memset(selection, 0, sizeof(selection));
|
|
|
selection[n] ^= 1;
|
|
|
}
|
|
|
}
|
|
|
@@ -789,7 +792,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
- if (ImGui::TreeNode("Plots widgets"))
|
|
|
+ if (ImGui::TreeNode("Plots Widgets"))
|
|
|
{
|
|
|
static bool animate = true;
|
|
|
ImGui::Checkbox("Animate", &animate);
|
|
|
@@ -859,13 +862,15 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
|
|
|
static bool alpha_preview = true;
|
|
|
static bool alpha_half_preview = false;
|
|
|
+ static bool drag_and_drop = true;
|
|
|
static bool options_menu = true;
|
|
|
static bool hdr = false;
|
|
|
ImGui::Checkbox("With Alpha Preview", &alpha_preview);
|
|
|
ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
|
|
|
+ ImGui::Checkbox("With Drag and Drop", &drag_and_drop);
|
|
|
ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); ShowHelpMarker("Right-click on the individual color widget to show options.");
|
|
|
ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
|
|
|
- int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
|
|
|
+ int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions);
|
|
|
|
|
|
ImGui::Text("Color widget:");
|
|
|
ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nCTRL+click on individual component to input value.\n");
|
|
|
@@ -980,13 +985,12 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
if (inputs_mode == 4) flags |= ImGuiColorEditFlags_HEX;
|
|
|
ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
|
|
|
|
|
|
- ImGui::Text("Programmatically set defaults/options:");
|
|
|
+ ImGui::Text("Programmatically set defaults:");
|
|
|
ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible.");
|
|
|
- if (ImGui::Button("Uint8 + HSV"))
|
|
|
- ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV);
|
|
|
- ImGui::SameLine();
|
|
|
- if (ImGui::Button("Float + HDR"))
|
|
|
- ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_RGB);
|
|
|
+ if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
|
|
|
+ ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_HSV | ImGuiColorEditFlags_PickerHueBar);
|
|
|
+ if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
|
|
|
+ ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
|
|
|
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
@@ -996,7 +1000,80 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
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::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units");
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ImGui::TreeNode("Data Types"))
|
|
|
+ {
|
|
|
+ // The DragScalar, InputScalar, SliderScalar functions allow manipulating most common data types: signed/unsigned int/long long and float/double
|
|
|
+ // To avoid polluting the public API with all possible combinations, we use the ImGuiDataType enum to pass the type, and argument-by-values are turned into argument-by-address.
|
|
|
+ // This is the reason the test code below creates local variables to hold "zero" "one" etc. for each types.
|
|
|
+ // In practice, if you frequently use a given type that is not covered by the normal API entry points, you may want to wrap it yourself inside a 1 line function
|
|
|
+ // which can take typed values argument instead of void*, and then pass their address to the generic function. For example:
|
|
|
+ // bool SliderU64(const char *label, u64* value, u64 min = 0, u64 max = 0, const char* format = "%lld") { return SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format); }
|
|
|
+ // Below are helper variables we can take the address of to work-around this:
|
|
|
+ // Note that the SliderScalar function has a maximum usable range of half the natural type maximum, hence the /2 below.
|
|
|
+ const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2;
|
|
|
+ const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2;
|
|
|
+ const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2;
|
|
|
+ const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2;
|
|
|
+ const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f;
|
|
|
+ const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000, f64_hi_a = +1000000000000000;
|
|
|
+
|
|
|
+ // State
|
|
|
+ static ImS32 s32_v = -1;
|
|
|
+ static ImU32 u32_v = (ImU32)-1;
|
|
|
+ static ImS64 s64_v = -1;
|
|
|
+ static ImU64 u64_v = (ImU64)-1;
|
|
|
+ static float f32_v = 0.123f;
|
|
|
+ static double f64_v = 90000.01234567890123456789;
|
|
|
+
|
|
|
+ const float drag_speed = 0.2f;
|
|
|
+ static bool drag_clamp = false;
|
|
|
+ ImGui::Text("Drags:");
|
|
|
+ ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); ImGui::SameLine(); ShowHelpMarker("As with every widgets in dear imgui, we never modify values unless there is a user interaction.\nYou can override the clamping limits by using CTRL+Click to input a value.");
|
|
|
+ ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL);
|
|
|
+ ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms");
|
|
|
+ ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL);
|
|
|
+ ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL);
|
|
|
+ ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 1.0f);
|
|
|
+ ImGui::DragScalar("drag float ^2", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", 2.0f); ImGui::SameLine(); ShowHelpMarker("You can use the 'power' parameter to increase tweaking precision on one side of the range.");
|
|
|
+ ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams", 1.0f);
|
|
|
+ ImGui::DragScalar("drag double ^2", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", 2.0f);
|
|
|
+
|
|
|
+ ImGui::Text("Sliders");
|
|
|
+ ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d");
|
|
|
+ ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d");
|
|
|
+ ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d");
|
|
|
+ ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u");
|
|
|
+ ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u");
|
|
|
+ ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u");
|
|
|
+ ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%I64d");
|
|
|
+ ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%I64d");
|
|
|
+ ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%I64d");
|
|
|
+ ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%I64u ms");
|
|
|
+ ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%I64u ms");
|
|
|
+ ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%I64u ms");
|
|
|
+ ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one);
|
|
|
+ ImGui::SliderScalar("slider float low^2", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", 2.0f);
|
|
|
+ ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e");
|
|
|
+ ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams", 1.0f);
|
|
|
+ ImGui::SliderScalar("slider double low^2",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", 2.0f);
|
|
|
+ ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams", 1.0f);
|
|
|
+
|
|
|
+ static bool inputs_step = true;
|
|
|
+ ImGui::Text("Inputs");
|
|
|
+ ImGui::Checkbox("Show step buttons", &inputs_step);
|
|
|
+ ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d");
|
|
|
+ ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
|
|
|
+ ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u");
|
|
|
+ ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal);
|
|
|
+ ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL);
|
|
|
+ ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL);
|
|
|
+ ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL);
|
|
|
+ ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL);
|
|
|
+
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
@@ -1008,16 +1085,16 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::InputFloat2("input float2", vec4f);
|
|
|
ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f);
|
|
|
ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f);
|
|
|
- ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
|
|
|
ImGui::InputInt2("input int2", vec4i);
|
|
|
+ ImGui::DragInt2("drag int2", vec4i, 1, 0, 255);
|
|
|
ImGui::SliderInt2("slider int2", vec4i, 0, 255);
|
|
|
ImGui::Spacing();
|
|
|
|
|
|
ImGui::InputFloat3("input float3", vec4f);
|
|
|
ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f);
|
|
|
ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f);
|
|
|
- ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
|
|
|
ImGui::InputInt3("input int3", vec4i);
|
|
|
+ ImGui::DragInt3("drag int3", vec4i, 1, 0, 255);
|
|
|
ImGui::SliderInt3("slider int3", vec4i, 0, 255);
|
|
|
ImGui::Spacing();
|
|
|
|
|
|
@@ -1371,9 +1448,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
static int track_line = 50, scroll_to_px = 200;
|
|
|
ImGui::Checkbox("Track", &track);
|
|
|
ImGui::PushItemWidth(100);
|
|
|
- ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %.0f");
|
|
|
+ ImGui::SameLine(130); track |= ImGui::DragInt("##line", &track_line, 0.25f, 0, 99, "Line = %d");
|
|
|
bool scroll_to = ImGui::Button("Scroll To Pos");
|
|
|
- ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %.0f px");
|
|
|
+ ImGui::SameLine(130); scroll_to |= ImGui::DragInt("##pos_y", &scroll_to_px, 1.00f, 0, 9999, "Y = %d px");
|
|
|
ImGui::PopItemWidth();
|
|
|
if (scroll_to) track = false;
|
|
|
|
|
|
@@ -1416,7 +1493,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::BeginChild("scrolling", ImVec2(0, ImGui::GetFrameHeightWithSpacing()*7 + 30), true, ImGuiWindowFlags_HorizontalScrollbar);
|
|
|
for (int line = 0; line < lines; line++)
|
|
|
{
|
|
|
- // Display random stuff (for the sake of this trivial demo we are using basic Button+SameLine. If you want to create your own time line for a real application you may be better off
|
|
|
+ // Display random stuff (for the sake of this trivial demo we are using basic Button+SameLine. If you want to create your own time line for a real application you may be better off
|
|
|
// manipulating the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets yourself. You may also want to use the lower-level ImDrawList API)
|
|
|
int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3);
|
|
|
for (int n = 0; n < num_buttons; n++)
|
|
|
@@ -1439,9 +1516,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::EndChild();
|
|
|
ImGui::PopStyleVar(2);
|
|
|
float scroll_x_delta = 0.0f;
|
|
|
- ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
|
|
|
+ ImGui::SmallButton("<<"); if (ImGui::IsItemActive()) scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
|
|
|
ImGui::Text("Scroll from code"); ImGui::SameLine();
|
|
|
- ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
|
|
|
+ ImGui::SmallButton(">>"); if (ImGui::IsItemActive()) scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; ImGui::SameLine();
|
|
|
ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x);
|
|
|
if (scroll_x_delta != 0.0f)
|
|
|
{
|
|
|
@@ -1856,11 +1933,11 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
|
|
|
ImGui::SameLine(); ShowHelpMarker("Instruct ImGui to render a mouse cursor for you in software. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
|
|
|
|
|
|
- ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
|
|
|
- ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
|
|
|
- ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos);
|
|
|
+ ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad [beta]", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
|
|
|
+ ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard [beta]", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
|
|
|
+ ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos);
|
|
|
ImGui::SameLine(); ShowHelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos.");
|
|
|
- ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
|
|
|
+ ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange);
|
|
|
ImGui::SameLine(); ShowHelpMarker("Instruct back-end to not alter mouse cursor shape and visibility.");
|
|
|
|
|
|
if (ImGui::TreeNode("Keyboard, Mouse & Navigation State"))
|
|
|
@@ -2016,7 +2093,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
{
|
|
|
ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget.");
|
|
|
for (int button = 0; button < 3; button++)
|
|
|
- ImGui::Text("IsMouseDragging(%d):\n w/ default threshold: %d,\n w/ zero threshold: %d\n w/ large threshold: %d",
|
|
|
+ ImGui::Text("IsMouseDragging(%d):\n w/ default threshold: %d,\n w/ zero threshold: %d\n w/ large threshold: %d",
|
|
|
button, ImGui::IsMouseDragging(button), ImGui::IsMouseDragging(button, 0.0f), ImGui::IsMouseDragging(button, 20.0f));
|
|
|
ImGui::Button("Drag Me");
|
|
|
if (ImGui::IsItemActive())
|
|
|
@@ -2091,7 +2168,7 @@ void ImGui::ShowFontSelector(const char* label)
|
|
|
io.FontDefault = io.Fonts->Fonts[n];
|
|
|
ImGui::EndCombo();
|
|
|
}
|
|
|
- ImGui::SameLine();
|
|
|
+ ImGui::SameLine();
|
|
|
ShowHelpMarker(
|
|
|
"- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
|
|
|
"- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
|
|
|
@@ -2120,7 +2197,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|
|
ImGui::ShowFontSelector("Fonts##Selector");
|
|
|
|
|
|
// Simplified Settings
|
|
|
- if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
|
|
|
+ if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
|
|
|
style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding
|
|
|
{ bool window_border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &window_border)) style.WindowBorderSize = window_border ? 1.0f : 0.0f; }
|
|
|
ImGui::SameLine();
|
|
|
@@ -2208,8 +2285,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|
|
filter.Draw("Filter colors", 200);
|
|
|
|
|
|
static ImGuiColorEditFlags alpha_flags = 0;
|
|
|
- ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
|
|
|
- ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine();
|
|
|
+ ImGui::RadioButton("Opaque", &alpha_flags, 0); ImGui::SameLine();
|
|
|
+ ImGui::RadioButton("Alpha", &alpha_flags, ImGuiColorEditFlags_AlphaPreview); ImGui::SameLine();
|
|
|
ImGui::RadioButton("Both", &alpha_flags, ImGuiColorEditFlags_AlphaPreviewHalf);
|
|
|
|
|
|
ImGui::BeginChild("#colors", ImVec2(0, 300), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened);
|
|
|
@@ -2288,7 +2365,8 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|
|
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
|
|
|
const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base+n));
|
|
|
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255,255,255,100) : IM_COL32(255,255,255,50));
|
|
|
- font->RenderChar(draw_list, cell_size, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
|
|
|
+ if (glyph)
|
|
|
+ font->RenderChar(draw_list, cell_size, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
|
|
|
if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
|
|
|
{
|
|
|
ImGui::BeginTooltip();
|
|
|
@@ -2450,7 +2528,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|
|
ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0;
|
|
|
if (ImGui::Begin("Example: Constrained Resize", p_open, flags))
|
|
|
{
|
|
|
- const char* desc[] =
|
|
|
+ const char* desc[] =
|
|
|
{
|
|
|
"Resize vertical only",
|
|
|
"Resize horizontal only",
|
|
|
@@ -2475,7 +2553,7 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|
|
}
|
|
|
|
|
|
// Demonstrate creating a simple static window with no decoration + a context-menu to choose which corner of the screen to use.
|
|
|
-static void ShowExampleAppFixedOverlay(bool* p_open)
|
|
|
+static void ShowExampleAppSimpleOverlay(bool* p_open)
|
|
|
{
|
|
|
const float DISTANCE = 10.0f;
|
|
|
static int corner = 0;
|
|
|
@@ -2484,7 +2562,7 @@ static void ShowExampleAppFixedOverlay(bool* p_open)
|
|
|
if (corner != -1)
|
|
|
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
|
|
ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
|
|
|
- if (ImGui::Begin("Example: Fixed Overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_NoNav))
|
|
|
+ if (ImGui::Begin("Example: Simple Overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_NoNav))
|
|
|
{
|
|
|
ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)");
|
|
|
ImGui::Separator();
|
|
|
@@ -2499,7 +2577,7 @@ static void ShowExampleAppFixedOverlay(bool* p_open)
|
|
|
if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1;
|
|
|
if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2;
|
|
|
if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3;
|
|
|
- if (p_open && ImGui::MenuItem("Close")) *p_open = false;
|
|
|
+ if (p_open && ImGui::MenuItem("Close")) *p_open = false;
|
|
|
ImGui::EndPopup();
|
|
|
}
|
|
|
ImGui::End();
|
|
|
@@ -2533,7 +2611,7 @@ static void ShowExampleAppWindowTitles(bool*)
|
|
|
ImGui::End();
|
|
|
}
|
|
|
|
|
|
-// Demonstrate using the low-level ImDrawList to draw custom shapes.
|
|
|
+// Demonstrate using the low-level ImDrawList to draw custom shapes.
|
|
|
static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
{
|
|
|
ImGui::SetNextWindowSize(ImVec2(350,560), ImGuiCond_FirstUseEver);
|
|
|
@@ -2552,8 +2630,10 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
// Primitives
|
|
|
ImGui::Text("Primitives");
|
|
|
static float sz = 36.0f;
|
|
|
+ static float thickness = 4.0f;
|
|
|
static ImVec4 col = ImVec4(1.0f,1.0f,0.4f,1.0f);
|
|
|
ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 72.0f, "%.0f");
|
|
|
+ ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f");
|
|
|
ImGui::ColorEdit3("Color", &col.x);
|
|
|
{
|
|
|
const ImVec2 p = ImGui::GetCursorScreenPos();
|
|
|
@@ -2561,16 +2641,16 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
float x = p.x + 4.0f, y = p.y + 4.0f, spacing = 8.0f;
|
|
|
for (int n = 0; n < 2; n++)
|
|
|
{
|
|
|
- float thickness = (n == 0) ? 1.0f : 4.0f;
|
|
|
- draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, thickness); x += sz+spacing;
|
|
|
- draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ImDrawCornerFlags_All, thickness); x += sz+spacing;
|
|
|
- draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_All, thickness); x += sz+spacing;
|
|
|
- draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight, thickness); x += sz+spacing;
|
|
|
- draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, thickness); x += sz+spacing;
|
|
|
- draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, thickness); x += sz+spacing;
|
|
|
- draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, thickness); x += sz+spacing;
|
|
|
- draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, thickness); x += spacing;
|
|
|
- draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, thickness);
|
|
|
+ float curr_thickness = (n == 0) ? 1.0f : thickness;
|
|
|
+ draw_list->AddCircle(ImVec2(x+sz*0.5f, y+sz*0.5f), sz*0.5f, col32, 20, curr_thickness); x += sz+spacing;
|
|
|
+ draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 0.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
|
|
|
+ draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_All, curr_thickness); x += sz+spacing;
|
|
|
+ draw_list->AddRect(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight, curr_thickness); x += sz+spacing;
|
|
|
+ draw_list->AddTriangle(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32, curr_thickness); x += sz+spacing;
|
|
|
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y ), col32, curr_thickness); x += sz+spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
|
|
|
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x, y+sz), col32, curr_thickness); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
|
|
|
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, curr_thickness); x += sz+spacing; // Diagonal line
|
|
|
+ draw_list->AddBezierCurve(ImVec2(x, y), ImVec2(x+sz*1.3f,y+sz*0.3f), ImVec2(x+sz-sz*1.3f,y+sz-sz*0.3f), ImVec2(x+sz, y+sz), col32, curr_thickness);
|
|
|
x = p.x + 4;
|
|
|
y += sz+spacing;
|
|
|
}
|
|
|
@@ -2579,6 +2659,9 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f); x += sz+spacing;
|
|
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+sz), col32, 10.0f, ImDrawCornerFlags_TopLeft|ImDrawCornerFlags_BotRight); x += sz+spacing;
|
|
|
draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f, y), ImVec2(x+sz,y+sz-0.5f), ImVec2(x,y+sz-0.5f), col32); x += sz+spacing;
|
|
|
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+sz, y+thickness), col32); x += sz+spacing; // Horizontal line (faster than AddLine, but only handle integer thickness)
|
|
|
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+thickness, y+sz), col32); x += spacing+spacing; // Vertical line (faster than AddLine, but only handle integer thickness)
|
|
|
+ draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x+1, y+1), col32); x += sz; // Pixel (faster than AddLine)
|
|
|
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x+sz, y+sz), IM_COL32(0,0,0,255), IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255));
|
|
|
ImGui::Dummy(ImVec2((sz+spacing)*8, (sz+spacing)*3));
|
|
|
}
|
|
|
@@ -2592,7 +2675,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
ImGui::Text("Left-click and drag to add lines,\nRight-click to undo");
|
|
|
|
|
|
// Here we are using InvisibleButton() as a convenience to 1) advance the cursor and 2) allows us to use IsItemHovered()
|
|
|
- // However you can draw directly and poll mouse/keyboard by yourself. You can manipulate the cursor using GetCursorPos() and SetCursorPos().
|
|
|
+ // But you can also draw directly and poll mouse/keyboard by yourself. You can manipulate the cursor using GetCursorPos() and SetCursorPos().
|
|
|
// If you only use the ImDrawList API, you can notify the owner window of its extends by using SetCursorPos(max).
|
|
|
ImVec2 canvas_pos = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates!
|
|
|
ImVec2 canvas_size = ImGui::GetContentRegionAvail(); // Resize canvas to what's available
|
|
|
@@ -2655,7 +2738,7 @@ struct ExampleAppConsole
|
|
|
Commands.push_back("HISTORY");
|
|
|
Commands.push_back("CLEAR");
|
|
|
Commands.push_back("CLASSIFY"); // "classify" is here to provide an example of "C"+[tab] completing to "CL" and displaying matches.
|
|
|
- AddLog("Welcome to ImGui!");
|
|
|
+ AddLog("Welcome to Dear ImGui!");
|
|
|
}
|
|
|
~ExampleAppConsole()
|
|
|
{
|
|
|
@@ -2668,6 +2751,7 @@ struct ExampleAppConsole
|
|
|
static int Stricmp(const char* str1, const char* str2) { int d; while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } return d; }
|
|
|
static int Strnicmp(const char* str1, const char* str2, int n) { int d = 0; while (n > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; n--; } return d; }
|
|
|
static char* Strdup(const char *str) { size_t len = strlen(str) + 1; void* buff = malloc(len); return (char*)memcpy(buff, (const void*)str, len); }
|
|
|
+ static void Strtrim(char* str) { char* str_end = str + strlen(str); while (str_end > str && str_end[-1] == ' ') str_end--; *str_end = 0; }
|
|
|
|
|
|
void ClearLog()
|
|
|
{
|
|
|
@@ -2743,7 +2827,7 @@ struct ExampleAppConsole
|
|
|
// ImGuiListClipper clipper(Items.Size);
|
|
|
// while (clipper.Step())
|
|
|
// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
|
|
- // However take note that you can not use this code as is if a filter is active because it breaks the 'cheap random-access' property. We would need random-access on the post-filtered list.
|
|
|
+ // However, note that you can not use this code as is if a filter is active because it breaks the 'cheap random-access' property. We would need random-access on the post-filtered list.
|
|
|
// A typical application wanting coarse clipping and filtering may want to pre-compute an array of indices that passed the filtering test, recomputing this array when user changes the filter,
|
|
|
// and appending newly elements as they are inserted. This is left as a task to the user until we can manage to improve this example code!
|
|
|
// If your items are of variable size you may want to implement code similar to what ImGuiListClipper does. Or split your data into fixed height items to allow random-seeking into your list.
|
|
|
@@ -2766,7 +2850,7 @@ struct ExampleAppConsole
|
|
|
if (copy_to_clipboard)
|
|
|
ImGui::LogFinish();
|
|
|
if (ScrollToBottom)
|
|
|
- ImGui::SetScrollHere();
|
|
|
+ ImGui::SetScrollHere(1.0f);
|
|
|
ScrollToBottom = false;
|
|
|
ImGui::PopStyleVar();
|
|
|
ImGui::EndChild();
|
|
|
@@ -2776,8 +2860,7 @@ struct ExampleAppConsole
|
|
|
bool reclaim_focus = false;
|
|
|
if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_CallbackHistory, &TextEditCallbackStub, (void*)this))
|
|
|
{
|
|
|
- char* input_end = InputBuf+strlen(InputBuf);
|
|
|
- while (input_end > InputBuf && input_end[-1] == ' ') { input_end--; } *input_end = 0;
|
|
|
+ Strtrim(InputBuf);
|
|
|
if (InputBuf[0])
|
|
|
ExecCommand(InputBuf);
|
|
|
strcpy(InputBuf, "");
|
|
|
@@ -3107,13 +3190,9 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ // Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well)
|
|
|
ImGui::AlignTextToFramePadding();
|
|
|
- // Here we use a Selectable (instead of Text) to highlight on hover
|
|
|
- //ImGui::Text("Field_%d", i);
|
|
|
- char label[32];
|
|
|
- sprintf(label, "Field_%d", i);
|
|
|
- ImGui::Bullet();
|
|
|
- ImGui::Selectable(label);
|
|
|
+ ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet, "Field_%d", i);
|
|
|
ImGui::NextColumn();
|
|
|
ImGui::PushItemWidth(-1);
|
|
|
if (i >= 5)
|