|
|
@@ -1,4 +1,4 @@
|
|
|
-// dear imgui, v1.69 WIP
|
|
|
+// dear imgui, v1.70 WIP
|
|
|
// (demo code)
|
|
|
|
|
|
// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
|
|
|
@@ -50,7 +50,7 @@ Index of this file:
|
|
|
#endif
|
|
|
|
|
|
#include "imgui.h"
|
|
|
-#include <ctype.h> // toupper, isprint
|
|
|
+#include <ctype.h> // toupper
|
|
|
#include <limits.h> // INT_MIN, INT_MAX
|
|
|
#include <math.h> // sqrtf, powf, cosf, sinf, floorf, ceilf
|
|
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
|
|
@@ -128,6 +128,7 @@ static void ShowExampleAppCustomRendering(bool* p_open);
|
|
|
static void ShowExampleMenuFile();
|
|
|
|
|
|
// Helper to display a little (?) mark which shows a tooltip when hovered.
|
|
|
+// In your own code you may want to display an actual icon if you are using a merged icon fonts (see misc/fonts/README.txt)
|
|
|
static void HelpMarker(const char* desc)
|
|
|
{
|
|
|
ImGui::TextDisabled("(?)");
|
|
|
@@ -154,12 +155,13 @@ static void ShowDockingDisabledMessage()
|
|
|
// Helper to display basic user controls.
|
|
|
void ImGui::ShowUserGuide()
|
|
|
{
|
|
|
+ ImGuiIO& io = ImGui::GetIO();
|
|
|
ImGui::BulletText("Double-click on title bar to collapse window.");
|
|
|
ImGui::BulletText("Click and drag on lower right corner to resize window\n(double-click to auto fit window to its contents).");
|
|
|
ImGui::BulletText("Click and drag on any empty space to move window.");
|
|
|
ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
|
|
|
ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text.");
|
|
|
- if (ImGui::GetIO().FontAllowUserScaling)
|
|
|
+ if (io.FontAllowUserScaling)
|
|
|
ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
|
|
|
ImGui::BulletText("Mouse Wheel to scroll.");
|
|
|
ImGui::BulletText("While editing text:\n");
|
|
|
@@ -189,6 +191,8 @@ static void ShowDemoWindowMisc();
|
|
|
// You may execute this function to experiment with the UI and understand what it does. You may then search for keywords in the code when you are interested by a specific feature.
|
|
|
void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
{
|
|
|
+ IM_ASSERT(ImGui::GetCurrentContext() != NULL && "Missing dear imgui context. Refer to examples app!"); // Exceptionally add an extra assert here for people confused with initial dear imgui setup
|
|
|
+
|
|
|
// Examples Apps (accessible from the "Examples" menu)
|
|
|
static bool show_app_dockspace = false;
|
|
|
static bool show_app_documents = false;
|
|
|
@@ -265,13 +269,12 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::End();
|
|
|
return;
|
|
|
}
|
|
|
- ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
|
|
|
|
|
|
// Most "big" widgets share a common width settings by default.
|
|
|
//ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.65f); // Use 2/3 of the space for widgets and 1/3 for labels (default)
|
|
|
ImGui::PushItemWidth(ImGui::GetFontSize() * -12); // Use fixed width for labels (by passing a negative value), the rest goes to widgets. We choose a width proportional to our font size.
|
|
|
|
|
|
- // Menu
|
|
|
+ // Menu Bar
|
|
|
if (ImGui::BeginMenuBar())
|
|
|
{
|
|
|
if (ImGui::BeginMenu("Menu"))
|
|
|
@@ -306,7 +309,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::EndMenuBar();
|
|
|
}
|
|
|
|
|
|
+ ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION);
|
|
|
ImGui::Spacing();
|
|
|
+
|
|
|
if (ImGui::CollapsingHeader("Help"))
|
|
|
{
|
|
|
ImGui::Text("PROGRAMMER GUIDE:");
|
|
|
@@ -373,7 +378,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the task bar icon state right away).");
|
|
|
ImGui::Checkbox("io.ConfigViewportsNoDecoration", &io.ConfigViewportsNoDecoration);
|
|
|
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the decoration right away).");
|
|
|
- ImGui::Checkbox("io.ConfigViewportsNoParent", &io.ConfigViewportsNoParent);
|
|
|
+ ImGui::Checkbox("io.ConfigViewportsNoDefaultParent", &io.ConfigViewportsNoDefaultParent);
|
|
|
ImGui::SameLine(); HelpMarker("Toggling this at runtime is normally unsupported (most platform back-ends won't refresh the parenting right away).");
|
|
|
ImGui::Unindent();
|
|
|
}
|
|
|
@@ -392,7 +397,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
if (ImGui::TreeNode("Backend Flags"))
|
|
|
{
|
|
|
HelpMarker("Those flags are set by the back-ends (imgui_impl_xxx files) to specify their capabilities.");
|
|
|
- ImGuiBackendFlags backend_flags = io.BackendFlags; // Make a local copy to avoid modifying the back-end flags.
|
|
|
+ ImGuiBackendFlags backend_flags = io.BackendFlags; // Make a local copy to avoid modifying actual back-end flags.
|
|
|
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasGamepad);
|
|
|
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasMouseCursors);
|
|
|
ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", (unsigned int *)&backend_flags, ImGuiBackendFlags_HasSetMousePos);
|
|
|
@@ -600,9 +605,8 @@ static void ShowDemoWindowWidgets()
|
|
|
ImGui::ListBox("listbox\n(single select)", &listbox_item_current, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
|
|
|
|
|
|
//static int listbox_item_current2 = 2;
|
|
|
- //ImGui::PushItemWidth(-1);
|
|
|
+ //ImGui::SetNextItemWidth(-1);
|
|
|
//ImGui::ListBox("##listbox2", &listbox_item_current2, listbox_items, IM_ARRAYSIZE(listbox_items), 4);
|
|
|
- //ImGui::PopItemWidth();
|
|
|
}
|
|
|
|
|
|
ImGui::TreePop();
|
|
|
@@ -631,7 +635,7 @@ static void ShowDemoWindowWidgets()
|
|
|
|
|
|
if (ImGui::TreeNode("Advanced, with Selectable nodes"))
|
|
|
{
|
|
|
- HelpMarker("This is a more standard looking tree with selectable nodes.\nClick to select, CTRL+Click to toggle, click on arrows or double-click to open.");
|
|
|
+ HelpMarker("This is a more typical looking tree with selectable nodes.\nClick to select, CTRL+Click to toggle, click on arrows or double-click to open.");
|
|
|
static bool align_label_with_current_x_position = false;
|
|
|
ImGui::Checkbox("Align label with current X position)", &align_label_with_current_x_position);
|
|
|
ImGui::Text("Hello!");
|
|
|
@@ -644,10 +648,12 @@ static void ShowDemoWindowWidgets()
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
{
|
|
|
// Disable the default open on single-click behavior and pass in Selected flag according to our selection state.
|
|
|
- ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0);
|
|
|
+ ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
|
|
|
+ if (selection_mask & (1 << i))
|
|
|
+ node_flags |= ImGuiTreeNodeFlags_Selected;
|
|
|
if (i < 3)
|
|
|
{
|
|
|
- // Node
|
|
|
+ // Items 0..2 are Tree Node
|
|
|
bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i);
|
|
|
if (ImGui::IsItemClicked())
|
|
|
node_clicked = i;
|
|
|
@@ -659,7 +665,9 @@ static void ShowDemoWindowWidgets()
|
|
|
}
|
|
|
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().
|
|
|
+ // Items 3..5 are Tree Leaves
|
|
|
+ // The only reason we use 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
|
|
|
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
|
|
|
if (ImGui::IsItemClicked())
|
|
|
@@ -685,7 +693,7 @@ static void ShowDemoWindowWidgets()
|
|
|
if (ImGui::TreeNode("Collapsing Headers"))
|
|
|
{
|
|
|
static bool closable_group = true;
|
|
|
- ImGui::Checkbox("Enable extra group", &closable_group);
|
|
|
+ ImGui::Checkbox("Show 2nd header", &closable_group);
|
|
|
if (ImGui::CollapsingHeader("Header"))
|
|
|
{
|
|
|
ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered());
|
|
|
@@ -789,7 +797,7 @@ static void ShowDemoWindowWidgets()
|
|
|
|
|
|
ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h);
|
|
|
ImVec2 pos = ImGui::GetCursorScreenPos();
|
|
|
- ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), ImVec2(0,0), ImVec2(1,1), ImColor(255,255,255,255), ImColor(255,255,255,128));
|
|
|
+ ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), ImVec2(0,0), ImVec2(1,1), ImVec4(1.0f,1.0f,1.0f,1.0f), ImVec4(1.0f,1.0f,1.0f,0.5f));
|
|
|
if (ImGui::IsItemHovered())
|
|
|
{
|
|
|
ImGui::BeginTooltip();
|
|
|
@@ -801,7 +809,7 @@ static void ShowDemoWindowWidgets()
|
|
|
ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz);
|
|
|
ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h);
|
|
|
ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h);
|
|
|
- ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, ImColor(255,255,255,255), ImColor(255,255,255,128));
|
|
|
+ ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, ImVec4(1.0f, 1.0f, 1.0f, 1.0f), ImVec4(1.0f, 1.0f, 1.0f, 0.5f));
|
|
|
ImGui::EndTooltip();
|
|
|
}
|
|
|
ImGui::TextWrapped("And now some textured buttons..");
|
|
|
@@ -810,7 +818,7 @@ static void ShowDemoWindowWidgets()
|
|
|
{
|
|
|
ImGui::PushID(i);
|
|
|
int frame_padding = -1 + i; // -1 = uses default padding
|
|
|
- if (ImGui::ImageButton(my_tex_id, ImVec2(32,32), ImVec2(0,0), ImVec2(32.0f/my_tex_w,32/my_tex_h), frame_padding, ImColor(0,0,0,255)))
|
|
|
+ if (ImGui::ImageButton(my_tex_id, ImVec2(32,32), ImVec2(0,0), ImVec2(32.0f/my_tex_w,32/my_tex_h), frame_padding, ImVec4(0.0f,0.0f,0.0f,1.0f)))
|
|
|
pressed_count += 1;
|
|
|
ImGui::PopID();
|
|
|
ImGui::SameLine();
|
|
|
@@ -976,48 +984,90 @@ static void ShowDemoWindowWidgets()
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
- if (ImGui::TreeNode("Filtered Text Input"))
|
|
|
+ if (ImGui::TreeNode("Text Input"))
|
|
|
{
|
|
|
- static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
|
|
|
- static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
|
|
|
- static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
|
|
- static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
|
|
|
- static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
|
|
|
- struct TextFilters { static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } };
|
|
|
- static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
|
|
-
|
|
|
- ImGui::Text("Password input");
|
|
|
- static char bufpass[64] = "password123";
|
|
|
- ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
|
|
- ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
|
|
- ImGui::InputTextWithHint("password (w/ hint)", "<password>", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
|
|
- ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
|
|
|
+ if (ImGui::TreeNode("Multi-line Text Input"))
|
|
|
+ {
|
|
|
+ // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize
|
|
|
+ // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
|
|
|
+ static char text[1024 * 16] =
|
|
|
+ "/*\n"
|
|
|
+ " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
|
|
|
+ " the hexadecimal encoding of one offending instruction,\n"
|
|
|
+ " more formally, the invalid operand with locked CMPXCHG8B\n"
|
|
|
+ " instruction bug, is a design flaw in the majority of\n"
|
|
|
+ " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
|
|
|
+ " processors (all in the P5 microarchitecture).\n"
|
|
|
+ "*/\n\n"
|
|
|
+ "label:\n"
|
|
|
+ "\tlock cmpxchg8b eax\n";
|
|
|
+
|
|
|
+ static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput;
|
|
|
+ HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)");
|
|
|
+ ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", (unsigned int*)&flags, ImGuiInputTextFlags_ReadOnly);
|
|
|
+ ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", (unsigned int*)&flags, ImGuiInputTextFlags_AllowTabInput);
|
|
|
+ ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", (unsigned int*)&flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
|
|
|
+ ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags);
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
|
|
|
- ImGui::TreePop();
|
|
|
- }
|
|
|
+ if (ImGui::TreeNode("Filtered Text Input"))
|
|
|
+ {
|
|
|
+ static char buf1[64] = ""; ImGui::InputText("default", buf1, 64);
|
|
|
+ static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
|
|
|
+ static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
|
|
+ static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
|
|
|
+ static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank);
|
|
|
+ struct TextFilters { static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) { if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) return 0; return 1; } };
|
|
|
+ static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
|
|
+
|
|
|
+ ImGui::Text("Password input");
|
|
|
+ static char bufpass[64] = "password123";
|
|
|
+ ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
|
|
+ ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
|
|
+ ImGui::InputTextWithHint("password (w/ hint)", "<password>", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
|
|
+ ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ImGui::TreeNode("Resize Callback"))
|
|
|
+ {
|
|
|
+ // If you have a custom string type you would typically create a ImGui::InputText() wrapper than takes your type as input.
|
|
|
+ // See misc/cpp/imgui_stdlib.h and .cpp for an implementation of this using std::string.
|
|
|
+ HelpMarker("Demonstrate using ImGuiInputTextFlags_CallbackResize to wire your resizable string type to InputText().\n\nSee misc/cpp/imgui_stdlib.h for an implementation of this for std::string.");
|
|
|
+ struct Funcs
|
|
|
+ {
|
|
|
+ static int MyResizeCallback(ImGuiInputTextCallbackData* data)
|
|
|
+ {
|
|
|
+ if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
|
|
|
+ {
|
|
|
+ ImVector<char>* my_str = (ImVector<char>*)data->UserData;
|
|
|
+ IM_ASSERT(my_str->begin() == data->Buf);
|
|
|
+ my_str->resize(data->BufSize); // NB: On resizing calls, generally data->BufSize == data->BufTextLen + 1
|
|
|
+ data->Buf = my_str->begin();
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Tip: Because ImGui:: is a namespace you would typicall add your own function into the namespace in your own source files.
|
|
|
+ // For example, you may add a function called ImGui::InputText(const char* label, MyString* my_str).
|
|
|
+ static bool MyInputTextMultiline(const char* label, ImVector<char>* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0)
|
|
|
+ {
|
|
|
+ IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
|
|
|
+ return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, Funcs::MyResizeCallback, (void*)my_str);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // For this demo we are using ImVector as a string container.
|
|
|
+ // Note that because we need to store a terminating zero character, our size/capacity are 1 more than usually reported by a typical string class.
|
|
|
+ static ImVector<char> my_str;
|
|
|
+ if (my_str.empty())
|
|
|
+ my_str.push_back(0);
|
|
|
+ Funcs::MyInputTextMultiline("##MyStr", &my_str, ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16));
|
|
|
+ ImGui::Text("Data: %p\nSize: %d\nCapacity: %d", (void*)my_str.begin(), my_str.size(), my_str.capacity());
|
|
|
+ ImGui::TreePop();
|
|
|
+ }
|
|
|
|
|
|
- if (ImGui::TreeNode("Multi-line Text Input"))
|
|
|
- {
|
|
|
- // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize
|
|
|
- // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings.
|
|
|
- static char text[1024*16] =
|
|
|
- "/*\n"
|
|
|
- " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
|
|
|
- " the hexadecimal encoding of one offending instruction,\n"
|
|
|
- " more formally, the invalid operand with locked CMPXCHG8B\n"
|
|
|
- " instruction bug, is a design flaw in the majority of\n"
|
|
|
- " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
|
|
|
- " processors (all in the P5 microarchitecture).\n"
|
|
|
- "*/\n\n"
|
|
|
- "label:\n"
|
|
|
- "\tlock cmpxchg8b eax\n";
|
|
|
-
|
|
|
- static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput;
|
|
|
- HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp)");
|
|
|
- ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", (unsigned int*)&flags, ImGuiInputTextFlags_ReadOnly);
|
|
|
- ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", (unsigned int*)&flags, ImGuiInputTextFlags_AllowTabInput);
|
|
|
- ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", (unsigned int*)&flags, ImGuiInputTextFlags_CtrlEnterForNewLine);
|
|
|
- ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-1.0f, ImGui::GetTextLineHeight() * 16), flags);
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
@@ -1056,7 +1106,8 @@ static void ShowDemoWindowWidgets()
|
|
|
};
|
|
|
static int func_type = 0, display_count = 70;
|
|
|
ImGui::Separator();
|
|
|
- ImGui::PushItemWidth(100); ImGui::Combo("func", &func_type, "Sin\0Saw\0"); ImGui::PopItemWidth();
|
|
|
+ ImGui::SetNextItemWidth(100);
|
|
|
+ ImGui::Combo("func", &func_type, "Sin\0Saw\0");
|
|
|
ImGui::SameLine();
|
|
|
ImGui::SliderInt("Sample count", &display_count, 1, 400);
|
|
|
float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw;
|
|
|
@@ -1226,6 +1277,16 @@ static void ShowDemoWindowWidgets()
|
|
|
if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
|
|
|
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
|
|
|
|
|
|
+ // HSV encoded support (to avoid RGB<>HSV round trips and singularities when S==0 or V==0)
|
|
|
+ static ImVec4 color_stored_as_hsv(0.23f, 1.0f, 1.0f, 1.0f);
|
|
|
+ ImGui::Spacing();
|
|
|
+ ImGui::Text("HSV encoded colors");
|
|
|
+ ImGui::SameLine(); HelpMarker("By default, colors are given to ColorEdit and ColorPicker in RGB, but ImGuiColorEditFlags_InputHSV allows you to store colors as HSV and pass them to ColorEdit and ColorPicker as HSV. This comes with the added benefit that you can manipulate hue values with the picker even when saturation or value are zero.");
|
|
|
+ ImGui::Text("Color widget with InputHSV:");
|
|
|
+ ImGui::ColorEdit4("HSV shown as HSV##1", (float*)&color_stored_as_hsv, ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputHSV | ImGuiColorEditFlags_Float);
|
|
|
+ ImGui::ColorEdit4("HSV shown as RGB##1", (float*)&color_stored_as_hsv, ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_InputHSV | ImGuiColorEditFlags_Float);
|
|
|
+ ImGui::DragFloat4("Raw HSV values", (float*)&color_stored_as_hsv, 0.01f, 0.0f, 1.0f);
|
|
|
+
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
@@ -1528,7 +1589,9 @@ static void ShowDemoWindowWidgets()
|
|
|
ImGui::RadioButton("SliderFloat", &item_type, 3);
|
|
|
ImGui::RadioButton("InputText", &item_type, 4);
|
|
|
ImGui::RadioButton("ColorEdit4", &item_type, 5);
|
|
|
- ImGui::RadioButton("ListBox", &item_type, 6);
|
|
|
+ ImGui::RadioButton("MenuItem", &item_type, 6);
|
|
|
+ ImGui::RadioButton("TreeNode (w/ double-click)", &item_type, 7);
|
|
|
+ ImGui::RadioButton("ListBox", &item_type, 8);
|
|
|
ImGui::Separator();
|
|
|
bool ret = false;
|
|
|
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
|
|
@@ -1537,7 +1600,9 @@ static void ShowDemoWindowWidgets()
|
|
|
if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
|
|
if (item_type == 4) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing)
|
|
|
if (item_type == 5) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
|
|
- if (item_type == 6) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
|
|
+ if (item_type == 6) { ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy)
|
|
|
+ if (item_type == 7) { ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
|
|
|
+ if (item_type == 8) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
|
|
ImGui::BulletText(
|
|
|
"Return value = %d\n"
|
|
|
"IsItemFocused() = %d\n"
|
|
|
@@ -1550,8 +1615,9 @@ static void ShowDemoWindowWidgets()
|
|
|
"IsItemEdited() = %d\n"
|
|
|
"IsItemActivated() = %d\n"
|
|
|
"IsItemDeactivated() = %d\n"
|
|
|
- "IsItemDeactivatedEdit() = %d\n"
|
|
|
+ "IsItemDeactivatedAfterEdit() = %d\n"
|
|
|
"IsItemVisible() = %d\n"
|
|
|
+ "IsItemClicked() = %d\n"
|
|
|
"GetItemRectMin() = (%.1f, %.1f)\n"
|
|
|
"GetItemRectMax() = (%.1f, %.1f)\n"
|
|
|
"GetItemRectSize() = (%.1f, %.1f)",
|
|
|
@@ -1568,6 +1634,7 @@ static void ShowDemoWindowWidgets()
|
|
|
ImGui::IsItemDeactivated(),
|
|
|
ImGui::IsItemDeactivatedAfterEdit(),
|
|
|
ImGui::IsItemVisible(),
|
|
|
+ ImGui::IsItemClicked(),
|
|
|
ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y,
|
|
|
ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y,
|
|
|
ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y
|
|
|
@@ -1598,6 +1665,7 @@ static void ShowDemoWindowWidgets()
|
|
|
"IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n"
|
|
|
"IsWindowHovered(_ChildWindows) = %d\n"
|
|
|
"IsWindowHovered(_ChildWindows|_RootWindow) = %d\n"
|
|
|
+ "IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n"
|
|
|
"IsWindowHovered(_RootWindow) = %d\n"
|
|
|
"IsWindowHovered(_AnyWindow) = %d\n",
|
|
|
ImGui::IsWindowHovered(),
|
|
|
@@ -1605,6 +1673,7 @@ static void ShowDemoWindowWidgets()
|
|
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
|
|
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows),
|
|
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow),
|
|
|
+ ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByPopup),
|
|
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow),
|
|
|
ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow));
|
|
|
|
|
|
@@ -1629,7 +1698,6 @@ static void ShowDemoWindowWidgets()
|
|
|
if (ImGui::MenuItem("Close")) { test_window = false; }
|
|
|
ImGui::EndPopup();
|
|
|
}
|
|
|
- //if (IsItemHovered() || IsItemActive()) { printf("[%05d] Hovered %d Active %d\n", GetFrameCount(), IsItemHovered(), IsItemActive()); } // [DEBUG]
|
|
|
ImGui::Text(
|
|
|
"IsItemHovered() after begin = %d (== is title bar hovered)\n"
|
|
|
"IsItemActive() after begin = %d (== is window being clicked/moved)\n",
|
|
|
@@ -1657,9 +1725,8 @@ static void ShowDemoWindowLayout()
|
|
|
static int line = 50;
|
|
|
bool goto_line = ImGui::Button("Goto");
|
|
|
ImGui::SameLine();
|
|
|
- ImGui::PushItemWidth(100);
|
|
|
+ ImGui::SetNextItemWidth(100);
|
|
|
goto_line |= ImGui::InputInt("##Line", &line, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue);
|
|
|
- ImGui::PopItemWidth();
|
|
|
|
|
|
// Child 1: no border, enable horizontal scrollbar
|
|
|
{
|
|
|
@@ -1730,35 +1797,36 @@ static void ShowDemoWindowLayout()
|
|
|
|
|
|
if (ImGui::TreeNode("Widgets Width"))
|
|
|
{
|
|
|
+ // Use SetNextItemWidth() to set the width of a single upcoming item.
|
|
|
+ // Use PushItemWidth()/PopItemWidth() to set the width of a group of items.
|
|
|
static float f = 0.0f;
|
|
|
- ImGui::Text("PushItemWidth(100)");
|
|
|
+ ImGui::Text("SetNextItemWidth/PushItemWidth(100)");
|
|
|
ImGui::SameLine(); HelpMarker("Fixed width.");
|
|
|
- ImGui::PushItemWidth(100);
|
|
|
+ ImGui::SetNextItemWidth(100);
|
|
|
ImGui::DragFloat("float##1", &f);
|
|
|
- ImGui::PopItemWidth();
|
|
|
|
|
|
- ImGui::Text("PushItemWidth(GetWindowWidth() * 0.5f)");
|
|
|
+ ImGui::Text("SetNextItemWidth/PushItemWidth(GetWindowWidth() * 0.5f)");
|
|
|
ImGui::SameLine(); HelpMarker("Half of window width.");
|
|
|
- ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
|
|
+ ImGui::SetNextItemWidth(ImGui::GetWindowWidth() * 0.5f);
|
|
|
ImGui::DragFloat("float##2", &f);
|
|
|
- ImGui::PopItemWidth();
|
|
|
|
|
|
- ImGui::Text("PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
|
|
|
+ ImGui::Text("SetNextItemWidth/PushItemWidth(GetContentRegionAvailWidth() * 0.5f)");
|
|
|
ImGui::SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)");
|
|
|
- ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
|
|
|
+ ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth() * 0.5f);
|
|
|
ImGui::DragFloat("float##3", &f);
|
|
|
- ImGui::PopItemWidth();
|
|
|
|
|
|
- ImGui::Text("PushItemWidth(-100)");
|
|
|
+ ImGui::Text("SetNextItemWidth/PushItemWidth(-100)");
|
|
|
ImGui::SameLine(); HelpMarker("Align to right edge minus 100");
|
|
|
- ImGui::PushItemWidth(-100);
|
|
|
+ ImGui::SetNextItemWidth(-100);
|
|
|
ImGui::DragFloat("float##4", &f);
|
|
|
- ImGui::PopItemWidth();
|
|
|
|
|
|
- ImGui::Text("PushItemWidth(-1)");
|
|
|
+ // Demonstrate using PushItemWidth to surround three items. Calling SetNextItemWidth() before each of them would have the same effect.
|
|
|
+ ImGui::Text("SetNextItemWidth/PushItemWidth(-1)");
|
|
|
ImGui::SameLine(); HelpMarker("Align to right edge");
|
|
|
ImGui::PushItemWidth(-1);
|
|
|
- ImGui::DragFloat("float##5", &f);
|
|
|
+ ImGui::DragFloat("float##5a", &f);
|
|
|
+ ImGui::DragFloat("float##5b", &f);
|
|
|
+ ImGui::DragFloat("float##5c", &f);
|
|
|
ImGui::PopItemWidth();
|
|
|
|
|
|
ImGui::TreePop();
|
|
|
@@ -2093,7 +2161,8 @@ static void ShowDemoWindowLayout()
|
|
|
ImGui::PopID();
|
|
|
}
|
|
|
}
|
|
|
- float scroll_x = ImGui::GetScrollX(), scroll_max_x = ImGui::GetScrollMaxX();
|
|
|
+ float scroll_x = ImGui::GetScrollX();
|
|
|
+ float scroll_max_x = ImGui::GetScrollMaxX();
|
|
|
ImGui::EndChild();
|
|
|
ImGui::PopStyleVar(2);
|
|
|
float scroll_x_delta = 0.0f;
|
|
|
@@ -2230,9 +2299,8 @@ static void ShowDemoWindowPopups()
|
|
|
{
|
|
|
if (ImGui::Selectable("Set to zero")) value = 0.0f;
|
|
|
if (ImGui::Selectable("Set to PI")) value = 3.1415f;
|
|
|
- ImGui::PushItemWidth(-1);
|
|
|
+ ImGui::SetNextItemWidth(-1);
|
|
|
ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f);
|
|
|
- ImGui::PopItemWidth();
|
|
|
ImGui::EndPopup();
|
|
|
}
|
|
|
|
|
|
@@ -2573,10 +2641,11 @@ static void ShowDemoWindowMisc()
|
|
|
ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); }
|
|
|
ImGui::Text("Mouse wheel: %.1f", io.MouseWheel);
|
|
|
|
|
|
- ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (%.02f secs)", i, io.KeysDownDuration[i]); }
|
|
|
- ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
|
|
|
- ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d", i); }
|
|
|
+ ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (io.KeysDownDuration[i] >= 0.0f) { ImGui::SameLine(); ImGui::Text("%d (0x%X) (%.02f secs)", i, i, io.KeysDownDuration[i]); }
|
|
|
+ ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); }
|
|
|
+ ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); }
|
|
|
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
|
|
+ ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
|
|
|
|
|
|
ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f", i, io.NavInputs[i]); }
|
|
|
ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); }
|
|
|
@@ -2654,22 +2723,17 @@ static void ShowDemoWindowMisc()
|
|
|
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",
|
|
|
button, ImGui::IsMouseDragging(button), ImGui::IsMouseDragging(button, 0.0f), ImGui::IsMouseDragging(button, 20.0f));
|
|
|
+
|
|
|
ImGui::Button("Drag Me");
|
|
|
if (ImGui::IsItemActive())
|
|
|
- {
|
|
|
- // Draw a line between the button and the mouse cursor
|
|
|
- ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
|
|
- draw_list->PushClipRectFullScreen();
|
|
|
- draw_list->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f);
|
|
|
- draw_list->PopClipRect();
|
|
|
-
|
|
|
- // Drag operations gets "unlocked" when the mouse has moved past a certain threshold (the default threshold is stored in io.MouseDragThreshold)
|
|
|
- // You can request a lower or higher threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta()
|
|
|
- ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
|
|
|
- ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
|
|
|
- ImVec2 mouse_delta = io.MouseDelta;
|
|
|
- ImGui::SameLine(); ImGui::Text("Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f), MouseDelta (%.1f, %.1f)", value_raw.x, value_raw.y, value_with_lock_threshold.x, value_with_lock_threshold.y, mouse_delta.x, mouse_delta.y);
|
|
|
- }
|
|
|
+ ImGui::GetForegroundDrawList()->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f); // Draw a line between the button and the mouse cursor
|
|
|
+
|
|
|
+ // Drag operations gets "unlocked" when the mouse has moved past a certain threshold (the default threshold is stored in io.MouseDragThreshold)
|
|
|
+ // You can request a lower or higher threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta()
|
|
|
+ ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
|
|
|
+ ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
|
|
|
+ ImVec2 mouse_delta = io.MouseDelta;
|
|
|
+ ImGui::Text("GetMouseDragDelta(0):\n w/ default threshold: (%.1f, %.1f),\n w/ zero threshold: (%.1f, %.1f)\nMouseDelta: (%.1f, %.1f)", value_with_lock_threshold.x, value_with_lock_threshold.y, value_raw.x, value_raw.y, mouse_delta.x, mouse_delta.y);
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
@@ -2802,7 +2866,7 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|
|
if (io.ConfigViewportsNoAutoMerge) ImGui::Text("io.ConfigViewportsNoAutoMerge");
|
|
|
if (io.ConfigViewportsNoTaskBarIcon) ImGui::Text("io.ConfigViewportsNoTaskBarIcon");
|
|
|
if (io.ConfigViewportsNoDecoration) ImGui::Text("io.ConfigViewportsNoDecoration");
|
|
|
- if (io.ConfigViewportsNoParent) ImGui::Text("io.ConfigViewportsNoParent");
|
|
|
+ if (io.ConfigViewportsNoDefaultParent) ImGui::Text("io.ConfigViewportsNoDefaultParent");
|
|
|
if (io.ConfigDockingNoSplit) ImGui::Text("io.ConfigDockingNoSplit");
|
|
|
if (io.ConfigDockingWithShift) ImGui::Text("io.ConfigDockingWithShift");
|
|
|
if (io.ConfigDockingTabBarOnSingleWindows) ImGui::Text("io.ConfigDockingTabBarOnSingleWindows");
|
|
|
@@ -2982,7 +3046,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|
|
}
|
|
|
ImGui::LogFinish();
|
|
|
}
|
|
|
- ImGui::SameLine(); ImGui::PushItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); ImGui::PopItemWidth();
|
|
|
+ ImGui::SameLine(); ImGui::SetNextItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0");
|
|
|
ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified);
|
|
|
|
|
|
static ImGuiTextFilter filter;
|
|
|
@@ -3092,7 +3156,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|
|
}
|
|
|
if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
|
|
{
|
|
|
- ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
|
|
|
+ ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
|
|
+ ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f);
|
|
|
+ ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col);
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
@@ -3128,7 +3194,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|
|
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
-// Demonstrate creating a fullscreen menu bar and populating it.
|
|
|
+// Demonstrate creating a "main" fullscreen menu bar and populating it.
|
|
|
+// Note the difference between BeginMainMenuBar() and BeginMenuBar():
|
|
|
+// - BeginMenuBar() = menu-bar inside current window we Begin()-ed into (the window needs the ImGuiWindowFlags_MenuBar flag)
|
|
|
+// - BeginMainMenuBar() = helper to create menu-bar-sized window at the top of the main viewport + call BeginMenuBar() into it.
|
|
|
static void ShowExampleAppMainMenuBar()
|
|
|
{
|
|
|
if (ImGui::BeginMainMenuBar())
|
|
|
@@ -3152,6 +3221,7 @@ static void ShowExampleAppMainMenuBar()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Note that shortcuts are currently provided for display only (future version will add flags to BeginMenu to process shortcuts)
|
|
|
static void ShowExampleMenuFile()
|
|
|
{
|
|
|
ImGui::MenuItem("(dummy menu)", NULL, false, false);
|
|
|
@@ -3685,7 +3755,7 @@ static void ShowExampleAppLog(bool* p_open)
|
|
|
static ExampleAppLog log;
|
|
|
|
|
|
// For the demo: add a debug button _BEFORE_ the normal log window contents
|
|
|
- // We take advantage of the fact that multiple calls to Begin()/End() are appending to the same window.
|
|
|
+ // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window.
|
|
|
// Most of the contents of the window will be added by the log.Draw() call.
|
|
|
ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
|
|
|
ImGui::Begin("Example: Log", p_open);
|
|
|
@@ -3703,6 +3773,7 @@ static void ShowExampleAppLog(bool* p_open)
|
|
|
}
|
|
|
ImGui::End();
|
|
|
|
|
|
+ // Actually call in the regular Log helper (which will Begin() into the same window as we just did)
|
|
|
log.Draw("Example: Log", p_open);
|
|
|
}
|
|
|
|
|
|
@@ -3814,12 +3885,11 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
|
|
ImGui::AlignTextToFramePadding();
|
|
|
ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet, "Field_%d", i);
|
|
|
ImGui::NextColumn();
|
|
|
- ImGui::PushItemWidth(-1);
|
|
|
+ ImGui::SetNextItemWidth(-1);
|
|
|
if (i >= 5)
|
|
|
ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
|
|
|
else
|
|
|
ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
|
|
|
- ImGui::PopItemWidth();
|
|
|
ImGui::NextColumn();
|
|
|
}
|
|
|
ImGui::PopID();
|
|
|
@@ -3961,10 +4031,10 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
|
|
|
if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine();
|
|
|
if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine();
|
|
|
if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); }
|
|
|
- ImGui::PushItemWidth(200);
|
|
|
+ ImGui::SetNextItemWidth(200);
|
|
|
ImGui::Combo("Constraint", &type, desc, IM_ARRAYSIZE(desc));
|
|
|
+ ImGui::SetNextItemWidth(200);
|
|
|
ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100);
|
|
|
- ImGui::PopItemWidth();
|
|
|
ImGui::Checkbox("Auto-resize", &auto_resize);
|
|
|
for (int i = 0; i < display_lines; i++)
|
|
|
ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, "");
|
|
|
@@ -3979,7 +4049,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 ShowExampleAppSimpleOverlay(bool* p_open)
|
|
|
{
|
|
|
- // FIXME-VIEWPORT-ABS: Select a default viewport
|
|
|
+ // FIXME-VIEWPORT: Select a default viewport
|
|
|
const float DISTANCE = 10.0f;
|
|
|
static int corner = 0;
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
@@ -3991,7 +4061,7 @@ static void ShowExampleAppSimpleOverlay(bool* p_open)
|
|
|
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
|
|
ImGui::SetNextWindowViewport(viewport->ID);
|
|
|
}
|
|
|
- ImGui::SetNextWindowBgAlpha(0.3f); // Transparent background
|
|
|
+ ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
|
|
|
if (ImGui::Begin("Example: Simple overlay", p_open, (corner != -1 ? ImGuiWindowFlags_NoMove : 0) | ImGuiWindowFlags_NoDocking | 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)");
|
|
|
@@ -4083,30 +4153,30 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
{
|
|
|
// First line uses a thickness of 1.0, second line uses the configurable thickness
|
|
|
float th = (n == 0) ? 1.0f : thickness;
|
|
|
- draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 6, th); x += sz + spacing; // Hexagon
|
|
|
- draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 20, th); x += sz + spacing; // Circle
|
|
|
- draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col32, 0.0f, ImDrawCornerFlags_All, th); x += sz + spacing;
|
|
|
+ draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 6, th); x += sz + spacing; // Hexagon
|
|
|
+ draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 20, th); x += sz + spacing; // Circle
|
|
|
+ draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col32, 0.0f, ImDrawCornerFlags_All, th); x += sz + spacing;
|
|
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col32, 10.0f, ImDrawCornerFlags_All, th); x += sz + spacing;
|
|
|
draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col32, 10.0f, ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotRight, th); 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, th); x += sz + spacing;
|
|
|
- draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y), col32, th); x += sz + spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
|
|
|
- draw_list->AddLine(ImVec2(x, y), ImVec2(x, y + sz), col32, th); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
|
|
|
- draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y + sz), col32, th); x += sz + spacing; // Diagonal line
|
|
|
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y), col32, th); x += sz + spacing; // Horizontal line (note: drawing a filled rectangle will be faster!)
|
|
|
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x, y + sz), col32, th); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!)
|
|
|
+ draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y + sz), col32, th); 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, th);
|
|
|
x = p.x + 4;
|
|
|
y += sz + spacing;
|
|
|
}
|
|
|
- draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 6); x += sz + spacing; // Hexagon
|
|
|
- draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 32); x += sz + spacing; // Circle
|
|
|
+ draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 6); x += sz + spacing; // Hexagon
|
|
|
+ draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col32, 32); x += sz + spacing; // Circle
|
|
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col32); x += sz + spacing;
|
|
|
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 + 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));
|
|
|
+ ImGui::Dummy(ImVec2((sz + spacing) * 9.5f, (sz + spacing) * 3));
|
|
|
ImGui::EndTabItem();
|
|
|
}
|
|
|
|
|
|
@@ -4171,7 +4241,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
ImVec2 window_size = ImGui::GetWindowSize();
|
|
|
ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f);
|
|
|
if (draw_bg)
|
|
|
- ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 32, 10);
|
|
|
+ ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 32, 10+4);
|
|
|
if (draw_fg)
|
|
|
ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 32, 10);
|
|
|
ImGui::EndTabItem();
|
|
|
@@ -4193,8 +4263,8 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|
|
void ShowExampleAppDockSpace(bool* p_open)
|
|
|
{
|
|
|
static bool opt_fullscreen_persistant = true;
|
|
|
- static ImGuiDockNodeFlags opt_flags = ImGuiDockNodeFlags_None;
|
|
|
bool opt_fullscreen = opt_fullscreen_persistant;
|
|
|
+ static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
|
|
|
|
|
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
|
|
|
// because it would be confusing to have two docking targets within each others.
|
|
|
@@ -4211,8 +4281,8 @@ void ShowExampleAppDockSpace(bool* p_open)
|
|
|
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
|
|
}
|
|
|
|
|
|
- // When using ImGuiDockNodeFlags_PassthruDockspace, DockSpace() will render our background and handle the pass-thru hole, so we ask Begin() to not render a background.
|
|
|
- if (opt_flags & ImGuiDockNodeFlags_PassthruDockspace)
|
|
|
+ // When using ImGuiDockNodeFlags_PassthruCentralNode, DockSpace() will render our background and handle the pass-thru hole, so we ask Begin() to not render a background.
|
|
|
+ if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
|
|
|
window_flags |= ImGuiWindowFlags_NoBackground;
|
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
|
|
@@ -4222,12 +4292,12 @@ void ShowExampleAppDockSpace(bool* p_open)
|
|
|
if (opt_fullscreen)
|
|
|
ImGui::PopStyleVar(2);
|
|
|
|
|
|
- // Dockspace
|
|
|
+ // DockSpace
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
if (io.ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
|
|
{
|
|
|
- ImGuiID dockspace_id = ImGui::GetID("MyDockspace");
|
|
|
- ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), opt_flags);
|
|
|
+ ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
|
|
+ ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -4242,18 +4312,22 @@ void ShowExampleAppDockSpace(bool* p_open)
|
|
|
// which we can't undo at the moment without finer window depth/z control.
|
|
|
//ImGui::MenuItem("Fullscreen", NULL, &opt_fullscreen_persistant);
|
|
|
|
|
|
- if (ImGui::MenuItem("Flag: NoSplit", "", (opt_flags & ImGuiDockNodeFlags_NoSplit) != 0)) opt_flags ^= ImGuiDockNodeFlags_NoSplit;
|
|
|
- if (ImGui::MenuItem("Flag: NoDockingInCentralNode", "", (opt_flags & ImGuiDockNodeFlags_NoDockingInCentralNode) != 0)) opt_flags ^= ImGuiDockNodeFlags_NoDockingInCentralNode;
|
|
|
- if (ImGui::MenuItem("Flag: NoResize", "", (opt_flags & ImGuiDockNodeFlags_NoResize) != 0)) opt_flags ^= ImGuiDockNodeFlags_NoResize;
|
|
|
- if (ImGui::MenuItem("Flag: PassthruDockspace", "", (opt_flags & ImGuiDockNodeFlags_PassthruDockspace) != 0)) opt_flags ^= ImGuiDockNodeFlags_PassthruDockspace;
|
|
|
- if (ImGui::MenuItem("Flag: AutoHideTabBar", "", (opt_flags & ImGuiDockNodeFlags_AutoHideTabBar) != 0)) opt_flags ^= ImGuiDockNodeFlags_AutoHideTabBar;
|
|
|
+ if (ImGui::MenuItem("Flag: NoSplit", "", (dockspace_flags & ImGuiDockNodeFlags_NoSplit) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_NoSplit;
|
|
|
+ if (ImGui::MenuItem("Flag: NoResize", "", (dockspace_flags & ImGuiDockNodeFlags_NoResize) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_NoResize;
|
|
|
+ if (ImGui::MenuItem("Flag: NoDockingInCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_NoDockingInCentralNode) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_NoDockingInCentralNode;
|
|
|
+ if (ImGui::MenuItem("Flag: PassthruCentralNode", "", (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_PassthruCentralNode;
|
|
|
+ if (ImGui::MenuItem("Flag: AutoHideTabBar", "", (dockspace_flags & ImGuiDockNodeFlags_AutoHideTabBar) != 0)) dockspace_flags ^= ImGuiDockNodeFlags_AutoHideTabBar;
|
|
|
ImGui::Separator();
|
|
|
if (ImGui::MenuItem("Close DockSpace", NULL, false, p_open != NULL))
|
|
|
*p_open = false;
|
|
|
ImGui::EndMenu();
|
|
|
}
|
|
|
HelpMarker(
|
|
|
- "You can _always_ dock _any_ window into another by holding the SHIFT key while moving a window. Try it now!" "\n"
|
|
|
+ "When docking is enabled, you can ALWAYS dock MOST window into another! Try it now!" "\n\n"
|
|
|
+ " > if io.ConfigDockingWithShift==false (default):" "\n"
|
|
|
+ " drag windows from title bar to dock" "\n"
|
|
|
+ " > if io.ConfigDockingWithShift==true:" "\n"
|
|
|
+ " drag windows from anywhere and hold Shift to dock" "\n\n"
|
|
|
"This demo app has nothing to do with it!" "\n\n"
|
|
|
"This demo app only demonstrate the use of ImGui::DockSpace() which allows you to manually create a docking node _within_ another window. This is useful so you can decorate your main application window (e.g. with a menu bar)." "\n\n"
|
|
|
"ImGui::DockSpace() comes with one hard constraint: it needs to be submitted _before_ any window which may be docked into it. Therefore, if you use a dock spot as the central point of your application, you'll probably want it to be part of the very first window you are submitting to imgui every frame." "\n\n"
|
|
|
@@ -4368,13 +4442,13 @@ void ShowExampleAppDocuments(bool* p_open)
|
|
|
{
|
|
|
Target_None,
|
|
|
Target_Tab, // Create documents as local tab into a local tab bar
|
|
|
- Target_DockspaceAndWindow // Create documents as regular windows, and create an embedded dockspace
|
|
|
+ Target_DockSpaceAndWindow // Create documents as regular windows, and create an embedded dockspace
|
|
|
};
|
|
|
static Target opt_target = Target_Tab;
|
|
|
static bool opt_reorderable = true;
|
|
|
static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_;
|
|
|
|
|
|
- // When (opt_target == Target_DockspaceAndWindow) there is the possibily that one of our child Document window (e.g. "Eggplant")
|
|
|
+ // When (opt_target == Target_DockSpaceAndWindow) there is the possibily that one of our child Document window (e.g. "Eggplant")
|
|
|
// that we emit gets docked into the same spot as the parent window ("Example: Documents").
|
|
|
// This would create a problematic feedback loop because selecting the "Eggplant" tab would make the "Example: Documents" tab
|
|
|
// not visible, which in turn would stop submitting the "Eggplant" window.
|
|
|
@@ -4382,7 +4456,7 @@ void ShowExampleAppDocuments(bool* p_open)
|
|
|
// Another solution may be to make the "Example: Documents" window use the ImGuiWindowFlags_NoDocking.
|
|
|
|
|
|
bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar);
|
|
|
- if (!window_contents_visible && opt_target != Target_DockspaceAndWindow)
|
|
|
+ if (!window_contents_visible && opt_target != Target_DockSpaceAndWindow)
|
|
|
{
|
|
|
ImGui::End();
|
|
|
return;
|
|
|
@@ -4434,7 +4508,7 @@ void ShowExampleAppDocuments(bool* p_open)
|
|
|
ImGui::PopItemWidth();
|
|
|
bool redock_all = false;
|
|
|
if (opt_target == Target_Tab) { ImGui::SameLine(); ImGui::Checkbox("Reorderable Tabs", &opt_reorderable); }
|
|
|
- if (opt_target == Target_DockspaceAndWindow) { ImGui::SameLine(); redock_all = ImGui::Button("Redock all"); }
|
|
|
+ if (opt_target == Target_DockSpaceAndWindow) { ImGui::SameLine(); redock_all = ImGui::Button("Redock all"); }
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
@@ -4479,7 +4553,7 @@ void ShowExampleAppDocuments(bool* p_open)
|
|
|
ImGui::EndTabBar();
|
|
|
}
|
|
|
}
|
|
|
- else if (opt_target == Target_DockspaceAndWindow)
|
|
|
+ else if (opt_target == Target_DockSpaceAndWindow)
|
|
|
{
|
|
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
|
|
{
|
|
|
@@ -4496,9 +4570,6 @@ void ShowExampleAppDocuments(bool* p_open)
|
|
|
if (!doc->Open)
|
|
|
continue;
|
|
|
|
|
|
- // FIXME-DOCK: SetNextWindowDock()
|
|
|
- //ImGuiID default_dock_id = GetDockspaceRootDocumentDockID();
|
|
|
- //ImGuiID default_dock_id = GetDockspacePreferedDocumentDockID();
|
|
|
ImGui::SetNextWindowDockID(dockspace_id, redock_all ? ImGuiCond_Always : ImGuiCond_FirstUseEver);
|
|
|
ImGuiWindowFlags window_flags = (doc->Dirty ? ImGuiWindowFlags_UnsavedDocument : 0);
|
|
|
bool visible = ImGui::Begin(doc->Name, &doc->Open, window_flags);
|
|
|
@@ -4568,12 +4639,14 @@ void ShowExampleAppDocuments(bool* p_open)
|
|
|
if (ImGui::BeginPopupModal("Save?"))
|
|
|
{
|
|
|
ImGui::Text("Save change to the following items?");
|
|
|
- ImGui::PushItemWidth(-1.0f);
|
|
|
- ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6);
|
|
|
- for (int n = 0; n < close_queue.Size; n++)
|
|
|
- if (close_queue[n]->Dirty)
|
|
|
- ImGui::Text("%s", close_queue[n]->Name);
|
|
|
- ImGui::ListBoxFooter();
|
|
|
+ ImGui::SetNextItemWidth(-1.0f);
|
|
|
+ if (ImGui::ListBoxHeader("##", close_queue_unsaved_documents, 6))
|
|
|
+ {
|
|
|
+ for (int n = 0; n < close_queue.Size; n++)
|
|
|
+ if (close_queue[n]->Dirty)
|
|
|
+ ImGui::Text("%s", close_queue[n]->Name);
|
|
|
+ ImGui::ListBoxFooter();
|
|
|
+ }
|
|
|
|
|
|
if (ImGui::Button("Yes", ImVec2(80, 0)))
|
|
|
{
|