Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'imgui/imgui_demo.cpp')
-rw-r--r--imgui/imgui_demo.cpp333
1 files changed, 215 insertions, 118 deletions
diff --git a/imgui/imgui_demo.cpp b/imgui/imgui_demo.cpp
index ec1ada82..7e475992 100644
--- a/imgui/imgui_demo.cpp
+++ b/imgui/imgui_demo.cpp
@@ -1,4 +1,4 @@
-// dear imgui, v1.73
+// dear imgui, v1.74
// (demo code)
// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
@@ -100,12 +100,17 @@ Index of this file:
// Play it nice with Windows users. Notepad in 2017 still doesn't display text data with Unix-style \n.
#ifdef _WIN32
#define IM_NEWLINE "\r\n"
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
#else
#define IM_NEWLINE "\n"
#endif
+#if defined(_MSC_VER) && !defined(snprintf)
+#define snprintf _snprintf
+#endif
+#if defined(_MSC_VER) && !defined(vsnprintf)
+#define vsnprintf _vsnprintf
+#endif
+
//-----------------------------------------------------------------------------
// [SECTION] Forward Declarations, Helpers
//-----------------------------------------------------------------------------
@@ -132,7 +137,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)
+// In your own code you may want to display an actual icon if you are using a merged icon fonts (see docs/FONTS.txt)
static void HelpMarker(const char* desc)
{
ImGui::TextDisabled("(?)");
@@ -152,25 +157,28 @@ void ImGui::ShowUserGuide()
ImGuiIO& io = ImGui::GetIO();
ImGui::BulletText("Double-click on title bar to collapse window.");
ImGui::BulletText("Click and drag on lower corner to resize window\n(double-click to auto fit window to its contents).");
- if (io.ConfigWindowsMoveFromTitleBarOnly)
- ImGui::BulletText("Click and drag on title bar to move window.");
- else
- 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.");
+ ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields.");
if (io.FontAllowUserScaling)
ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents.");
- ImGui::BulletText("Mouse Wheel to scroll.");
- ImGui::BulletText("While editing text:\n");
+ ImGui::BulletText("While inputing text:\n");
ImGui::Indent();
- ImGui::BulletText("Hold SHIFT or use mouse to select text.");
ImGui::BulletText("CTRL+Left/Right to word jump.");
ImGui::BulletText("CTRL+A or double-click to select all.");
- ImGui::BulletText("CTRL+X,CTRL+C,CTRL+V to use clipboard.");
+ ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste.");
ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo.");
ImGui::BulletText("ESCAPE to revert.");
ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract.");
ImGui::Unindent();
+ ImGui::BulletText("With keyboard navigation enabled:");
+ ImGui::Indent();
+ ImGui::BulletText("Arrow keys to navigate.");
+ ImGui::BulletText("Space to activate a widget.");
+ ImGui::BulletText("Return to input text into a widget.");
+ ImGui::BulletText("Escape to deactivate a widget, close popup, exit child window.");
+ ImGui::BulletText("Alt to jump to the menu layer of a window.");
+ ImGui::BulletText("CTRL+Tab to select a window.");
+ ImGui::Unindent();
}
//-----------------------------------------------------------------------------
@@ -311,12 +319,20 @@ void ImGui::ShowDemoWindow(bool* p_open)
if (ImGui::CollapsingHeader("Help"))
{
+ ImGui::Text("ABOUT THIS DEMO:");
+ ImGui::BulletText("Sections below are demonstrating many aspects of the library.");
+ ImGui::BulletText("The \"Examples\" menu above leads to more demo contents.");
+ ImGui::BulletText("The \"Tools\" menu above gives access to: About Box, Style Editor,\n"
+ "and Metrics (general purpose Dear ImGui debugging tool).");
+ ImGui::Separator();
+
ImGui::Text("PROGRAMMER GUIDE:");
- ImGui::BulletText("Please see the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
- ImGui::BulletText("Please see the comments in imgui.cpp.");
- ImGui::BulletText("Please see the examples/ application.");
- ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
- ImGui::BulletText("Enable 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
+ ImGui::BulletText("See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
+ ImGui::BulletText("See comments in imgui.cpp.");
+ ImGui::BulletText("See example applications in the examples/ folder.");
+ ImGui::BulletText("Read the FAQ at http://www.dearimgui.org/faq/");
+ ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.");
+ ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
ImGui::Separator();
ImGui::Text("USER GUIDE:");
@@ -360,7 +376,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.");
+ HelpMarker("Those flags are set by the back-ends (imgui_impl_xxx files) to specify their capabilities.\nHere we expose then as read-only fields to avoid breaking interactions with your back-end.");
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);
@@ -372,6 +388,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
if (ImGui::TreeNode("Style"))
{
+ HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function.");
ImGui::ShowStyleEditor();
ImGui::TreePop();
ImGui::Separator();
@@ -753,14 +770,14 @@ static void ShowDemoWindowWidgets()
if (ImGui::TreeNode("UTF-8 Text"))
{
// UTF-8 test with Japanese characters
- // (Needs a suitable font, try Noto, or Arial Unicode, or M+ fonts. Read misc/fonts/README.txt for details.)
+ // (Needs a suitable font, try Noto, or Arial Unicode, or M+ fonts. Read docs/FONTS.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')
// - 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->AddFontFromFileTTF() manually to load extra character ranges. Read misc/fonts/README.txt for details.");
+ ImGui::TextWrapped("CJK text will only appears if the font was loaded with the appropriate CJK character ranges. Call io.Font->AddFontFromFileTTF() manually to load extra character ranges. Read docs/FONTS.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";
@@ -923,7 +940,7 @@ static void ShowDemoWindowWidgets()
if (ImGui::TreeNode("In columns"))
{
ImGui::Columns(3, NULL, false);
- static bool selected[16] = { 0 };
+ static bool selected[16] = {};
for (int i = 0; i < 16; i++)
{
char label[32]; sprintf(label, "Item %d", i);
@@ -1075,7 +1092,7 @@ static void ShowDemoWindowWidgets()
// Create a dummy array of contiguous float values to plot
// Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float and the sizeof() of your structure in the Stride parameter.
- static float values[90] = { 0 };
+ static float values[90] = {};
static int values_offset = 0;
static double refresh_time = 0.0;
if (!animate || refresh_time == 0.0)
@@ -1176,7 +1193,7 @@ static void ShowDemoWindowWidgets()
// Generate a dummy default palette. The palette will persist and can be edited.
static bool saved_palette_init = true;
- static ImVec4 saved_palette[32] = { };
+ static ImVec4 saved_palette[32] = {};
if (saved_palette_init)
{
for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
@@ -1506,24 +1523,21 @@ static void ShowDemoWindowWidgets()
if (ImGui::TreeNode("Drag and Drop"))
{
+ if (ImGui::TreeNode("Drag and drop in standard widgets"))
{
// ColorEdit widgets automatically act as drag source and drag target.
// They are using standardized payload strings IMGUI_PAYLOAD_TYPE_COLOR_3F and IMGUI_PAYLOAD_TYPE_COLOR_4F to allow your own widgets
// to use colors in their drag and drop interaction. Also see the demo in Color Picker -> Palette demo.
- ImGui::BulletText("Drag and drop in standard widgets");
- ImGui::SameLine();
HelpMarker("You can drag from the colored squares.");
- ImGui::Indent();
- static float col1[3] = { 1.0f,0.0f,0.2f };
- static float col2[4] = { 0.4f,0.7f,0.0f,0.5f };
+ static float col1[3] = { 1.0f, 0.0f, 0.2f };
+ static float col2[4] = { 0.4f, 0.7f, 0.0f, 0.5f };
ImGui::ColorEdit3("color 1", col1);
ImGui::ColorEdit4("color 2", col2);
- ImGui::Unindent();
+ ImGui::TreePop();
}
+ if (ImGui::TreeNode("Drag and drop to copy/swap items"))
{
- ImGui::BulletText("Drag and drop to copy/swap items");
- ImGui::Indent();
enum Mode
{
Mode_Copy,
@@ -1577,7 +1591,31 @@ static void ShowDemoWindowWidgets()
}
ImGui::PopID();
}
- ImGui::Unindent();
+ ImGui::TreePop();
+ }
+
+ if (ImGui::TreeNode("Drag to reorder items (simple)"))
+ {
+ // Simple reordering
+ HelpMarker("We don't use the drag and drop api at all here! Instead we query when the item is held but not hovered, and order items accordingly.");
+ static const char* item_names[] = { "Item One", "Item Two", "Item Three", "Item Four", "Item Five" };
+ for (int n = 0; n < IM_ARRAYSIZE(item_names); n++)
+ {
+ const char* item = item_names[n];
+ ImGui::Selectable(item);
+
+ if (ImGui::IsItemActive() && !ImGui::IsItemHovered())
+ {
+ int n_next = n + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1);
+ if (n_next >= 0 && n_next < IM_ARRAYSIZE(item_names))
+ {
+ item_names[n] = item_names[n_next];
+ item_names[n_next] = item;
+ ImGui::ResetMouseDragDelta();
+ }
+ }
+ }
+ ImGui::TreePop();
}
ImGui::TreePop();
@@ -1587,7 +1625,7 @@ static void ShowDemoWindowWidgets()
{
// Submit an item (various types available) so we can query their status in the following block.
static int item_type = 1;
- ImGui::Combo("Item Type", &item_type, "Text\0Button\0Button (w/ repeat)\0Checkbox\0SliderFloat\0InputText\0InputFloat\0InputFloat3\0ColorEdit4\0MenuItem\0TreeNode (w/ double-click)\0ListBox\0");
+ ImGui::Combo("Item Type", &item_type, "Text\0Button\0Button (w/ repeat)\0Checkbox\0SliderFloat\0InputText\0InputFloat\0InputFloat3\0ColorEdit4\0MenuItem\0TreeNode\0TreeNode (w/ double-click)\0ListBox\0", 20);
ImGui::SameLine();
HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions.");
bool ret = false;
@@ -1604,13 +1642,14 @@ static void ShowDemoWindowWidgets()
if (item_type == 7) { ret = ImGui::InputFloat3("ITEM: InputFloat3", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
if (item_type == 8) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
if (item_type == 9) { ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy)
- if (item_type == 10){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
- if (item_type == 11){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", &current, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
+ if (item_type == 10){ ret = ImGui::TreeNode("ITEM: TreeNode"); if (ret) ImGui::TreePop(); } // Testing tree node
+ if (item_type == 11){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy.
+ if (item_type == 12){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", &current, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
- // Display the value of IsItemHovered() and other common item state functions.
+ // Display the value of IsItemHovered() and other common item state functions.
// Note that the ImGuiHoveredFlags_XXX flags can be combined.
- // Because BulletText is an item itself and that would affect the output of IsItemXXX functions,
- // we query every state in a single call to avoid storing them and to simplify the code
+ // Because BulletText is an item itself and that would affect the output of IsItemXXX functions,
+ // we query every state in a single call to avoid storing them and to simplify the code
ImGui::BulletText(
"Return value = %d\n"
"IsItemFocused() = %d\n"
@@ -1626,6 +1665,7 @@ static void ShowDemoWindowWidgets()
"IsItemDeactivatedAfterEdit() = %d\n"
"IsItemVisible() = %d\n"
"IsItemClicked() = %d\n"
+ "IsItemToggledOpen() = %d\n"
"GetItemRectMin() = (%.1f, %.1f)\n"
"GetItemRectMax() = (%.1f, %.1f)\n"
"GetItemRectSize() = (%.1f, %.1f)",
@@ -1643,6 +1683,7 @@ static void ShowDemoWindowWidgets()
ImGui::IsItemDeactivatedAfterEdit(),
ImGui::IsItemVisible(),
ImGui::IsItemClicked(),
+ ImGui::IsItemToggledOpen(),
ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y,
ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y,
ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y
@@ -1653,7 +1694,7 @@ static void ShowDemoWindowWidgets()
if (embed_all_inside_a_child_window)
ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20), true);
- // Testing IsWindowFocused() function with its various flags.
+ // Testing IsWindowFocused() function with its various flags.
// Note that the ImGuiFocusedFlags_XXX flags can be combined.
ImGui::BulletText(
"IsWindowFocused() = %d\n"
@@ -2047,55 +2088,99 @@ static void ShowDemoWindowLayout()
if (ImGui::TreeNode("Text Baseline Alignment"))
{
- HelpMarker("This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets.");
-
- ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
- ImGui::Text("Hello\nWorld"); ImGui::SameLine();
- ImGui::Text("Banana");
-
- ImGui::Text("Banana"); ImGui::SameLine();
- ImGui::Text("Hello\nWorld"); ImGui::SameLine();
- ImGui::Text("One\nTwo\nThree");
-
- ImGui::Button("HOP##1"); ImGui::SameLine();
- ImGui::Text("Banana"); ImGui::SameLine();
- ImGui::Text("Hello\nWorld"); ImGui::SameLine();
- ImGui::Text("Banana");
-
- ImGui::Button("HOP##2"); ImGui::SameLine();
- ImGui::Text("Hello\nWorld"); ImGui::SameLine();
- ImGui::Text("Banana");
-
- ImGui::Button("TEST##1"); ImGui::SameLine();
- ImGui::Text("TEST"); ImGui::SameLine();
- ImGui::SmallButton("TEST##2");
-
- ImGui::AlignTextToFramePadding(); // If your line starts with text, call this to align it to upcoming widgets.
- ImGui::Text("Text aligned to Widget"); ImGui::SameLine();
- ImGui::Button("Widget##1"); ImGui::SameLine();
- ImGui::Text("Widget"); ImGui::SameLine();
- ImGui::SmallButton("Widget##2"); ImGui::SameLine();
- ImGui::Button("Widget##3");
-
- // Tree
- const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
- ImGui::Button("Button##1");
- ImGui::SameLine(0.0f, spacing);
- if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
+ {
+ ImGui::BulletText("Text baseline:");
+ ImGui::SameLine();
+ HelpMarker("This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. Lines only composed of text or \"small\" widgets fit in less vertical spaces than lines with normal widgets.");
+ ImGui::Indent();
- ImGui::AlignTextToFramePadding(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
- bool node_open = ImGui::TreeNode("Node##2"); // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
- ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
- if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
+ ImGui::Text("KO Blahblah"); ImGui::SameLine();
+ ImGui::Button("Some framed item"); ImGui::SameLine();
+ HelpMarker("Baseline of button will look misaligned with text..");
- // Bullet
- ImGui::Button("Button##3");
- ImGui::SameLine(0.0f, spacing);
- ImGui::BulletText("Bullet text");
+ // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets.
+ // Because we don't know what's coming after the Text() statement, we need to move the text baseline down by FramePadding.y
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("OK Blahblah"); ImGui::SameLine();
+ ImGui::Button("Some framed item"); ImGui::SameLine();
+ HelpMarker("We call AlignTextToFramePadding() to vertically align the text baseline by +FramePadding.y");
- ImGui::AlignTextToFramePadding();
- ImGui::BulletText("Node");
- ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
+ // SmallButton() uses the same vertical padding as Text
+ ImGui::Button("TEST##1"); ImGui::SameLine();
+ ImGui::Text("TEST"); ImGui::SameLine();
+ ImGui::SmallButton("TEST##2");
+
+ // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets.
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("Text aligned to framed item"); ImGui::SameLine();
+ ImGui::Button("Item##1"); ImGui::SameLine();
+ ImGui::Text("Item"); ImGui::SameLine();
+ ImGui::SmallButton("Item##2"); ImGui::SameLine();
+ ImGui::Button("Item##3");
+
+ ImGui::Unindent();
+ }
+
+ ImGui::Spacing();
+
+ {
+ ImGui::BulletText("Multi-line text:");
+ ImGui::Indent();
+ ImGui::Text("One\nTwo\nThree"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("Banana");
+
+ ImGui::Text("Banana"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("One\nTwo\nThree");
+
+ ImGui::Button("HOP##1"); ImGui::SameLine();
+ ImGui::Text("Banana"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("Banana");
+
+ ImGui::Button("HOP##2"); ImGui::SameLine();
+ ImGui::Text("Hello\nWorld"); ImGui::SameLine();
+ ImGui::Text("Banana");
+ ImGui::Unindent();
+ }
+
+ ImGui::Spacing();
+
+ {
+ ImGui::BulletText("Misc items:");
+ ImGui::Indent();
+
+ // SmallButton() sets FramePadding to zero. Text baseline is aligned to match baseline of previous Button
+ ImGui::Button("80x80", ImVec2(80, 80));
+ ImGui::SameLine();
+ ImGui::Button("50x50", ImVec2(50, 50));
+ ImGui::SameLine();
+ ImGui::Button("Button()");
+ ImGui::SameLine();
+ ImGui::SmallButton("SmallButton()");
+
+ // Tree
+ const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
+ ImGui::Button("Button##1");
+ ImGui::SameLine(0.0f, spacing);
+ if (ImGui::TreeNode("Node##1")) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
+
+ ImGui::AlignTextToFramePadding(); // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. Otherwise you can use SmallButton (smaller fit).
+ bool node_open = ImGui::TreeNode("Node##2");// Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add child content.
+ ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
+ if (node_open) { for (int i = 0; i < 6; i++) ImGui::BulletText("Item %d..", i); ImGui::TreePop(); } // Dummy tree data
+
+ // Bullet
+ ImGui::Button("Button##3");
+ ImGui::SameLine(0.0f, spacing);
+ ImGui::BulletText("Bullet text");
+
+ ImGui::AlignTextToFramePadding();
+ ImGui::BulletText("Node");
+ ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
+ ImGui::Unindent();
+ }
ImGui::TreePop();
}
@@ -2142,7 +2227,7 @@ static void ShowDemoWindowLayout()
ImGui::TextUnformatted(names[i]);
ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
- ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags);
+ bool window_visible = ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags);
if (ImGui::BeginMenuBar())
{
ImGui::TextUnformatted("abc");
@@ -2152,16 +2237,19 @@ static void ShowDemoWindowLayout()
ImGui::SetScrollY(scroll_to_off_px);
if (scroll_to_pos)
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
- for (int item = 0; item < 100; item++)
+ if (window_visible) // Avoid calling SetScrollHereY when running with culled items
{
- if (enable_track && item == track_item)
- {
- ImGui::TextColored(ImVec4(1,1,0,1), "Item %d", item);
- ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
- }
- else
+ for (int item = 0; item < 100; item++)
{
- ImGui::Text("Item %d", item);
+ if (enable_track && item == track_item)
+ {
+ ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
+ ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
+ }
+ else
+ {
+ ImGui::Text("Item %d", item);
+ }
}
}
float scroll_y = ImGui::GetScrollY();
@@ -2180,23 +2268,26 @@ static void ShowDemoWindowLayout()
{
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0);
- ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, child_flags);
+ bool window_visible = ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, child_flags);
if (scroll_to_off)
ImGui::SetScrollX(scroll_to_off_px);
if (scroll_to_pos)
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
- for (int item = 0; item < 100; item++)
+ if (window_visible) // Avoid calling SetScrollHereY when running with culled items
{
- if (enable_track && item == track_item)
- {
- ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
- ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
- }
- else
+ for (int item = 0; item < 100; item++)
{
- ImGui::Text("Item %d", item);
+ if (enable_track && item == track_item)
+ {
+ ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
+ ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
+ }
+ else
+ {
+ ImGui::Text("Item %d", item);
+ }
+ ImGui::SameLine();
}
- ImGui::SameLine();
}
float scroll_x = ImGui::GetScrollX();
float scroll_max_x = ImGui::GetScrollMaxX();
@@ -3027,11 +3118,17 @@ void ImGui::ShowAboutWindow(bool* p_open)
#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS
ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS");
#endif
-#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
- ImGui::Text("define: IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS");
+#ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS");
+#endif
+#ifdef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS");
#endif
-#ifdef IMGUI_DISABLE_MATH_FUNCTIONS
- ImGui::Text("define: IMGUI_DISABLE_MATH_FUNCTIONS");
+#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
+ ImGui::Text("define: IMGUI_DISABLE_FILE_FUNCTIONS");
#endif
#ifdef IMGUI_DISABLE_DEFAULT_ALLOCATORS
ImGui::Text("define: IMGUI_DISABLE_DEFAULT_ALLOCATORS");
@@ -3158,7 +3255,7 @@ void ImGui::ShowFontSelector(const char* label)
HelpMarker(
"- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
"- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
- "- Read FAQ and documentation in misc/fonts/ for more details.\n"
+ "- Read FAQ and docs/FONTS.txt for more details.\n"
"- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
}
@@ -3198,7 +3295,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
if (ImGui::Button("Revert Ref"))
style = *ref;
ImGui::SameLine();
- HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export Colors\" below to save them somewhere.");
+ HelpMarker("Save/Revert in local non-persistent storage. Default Colors definition are not affected. Use \"Export\" below to save them somewhere.");
ImGui::Separator();
@@ -3246,7 +3343,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
{
static int output_dest = 0;
static bool output_only_modified = true;
- if (ImGui::Button("Export Unsaved"))
+ if (ImGui::Button("Export"))
{
if (output_dest == 0)
ImGui::LogToClipboard();
@@ -3286,7 +3383,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0)
{
// Tips: in a real user application, you may want to merge and use an icon font into the main font, so instead of "Save"/"Revert" you'd use icons.
- // Read the FAQ and misc/fonts/README.txt about using icon fonts. It's really easy and super convenient!
+ // Read the FAQ and docs/FONTS.txt about using icon fonts. It's really easy and super convenient!
ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) ref->Colors[i] = style.Colors[i];
ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) style.Colors[i] = ref->Colors[i];
}
@@ -3304,7 +3401,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
{
ImGuiIO& io = ImGui::GetIO();
ImFontAtlas* atlas = io.Fonts;
- HelpMarker("Read FAQ and misc/fonts/README.txt for details on font loading.");
+ HelpMarker("Read FAQ and docs/FONTS.txt for details on font loading.");
ImGui::PushItemWidth(120);
for (int i = 0; i < atlas->Fonts.Size; i++)
{
@@ -3324,17 +3421,17 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::Text("Fallback character: '%c' (U+%04X)", font->FallbackChar, font->FallbackChar);
ImGui::Text("Ellipsis character: '%c' (U+%04X)", font->EllipsisChar, font->EllipsisChar);
const float surface_sqrt = sqrtf((float)font->MetricsTotalSurface);
- ImGui::Text("Texture surface: %d pixels (approx) ~ %dx%d", font->MetricsTotalSurface, (int)surface_sqrt, (int)surface_sqrt);
+ ImGui::Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, (int)surface_sqrt, (int)surface_sqrt);
for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
if (const ImFontConfig* cfg = &font->ConfigData[config_i])
ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH);
if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
{
// Display all glyphs of the fonts in separate pages of 256 characters
- for (int base = 0; base < 0x10000; base += 256)
+ for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
{
int count = 0;
- for (int n = 0; n < 256; n++)
+ for (unsigned int n = 0; n < 256; n++)
count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0;
if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
{
@@ -3342,7 +3439,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
float cell_spacing = style.ItemSpacing.y;
ImVec2 base_pos = ImGui::GetCursorScreenPos();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
- for (int n = 0; n < 256; n++)
+ for (unsigned int n = 0; n < 256; n++)
{
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);