|
@@ -11,7 +11,7 @@
|
|
|
// Get the latest version at https://github.com/ocornut/imgui
|
|
|
|
|
|
// How to easily locate code?
|
|
|
-// - Use the Item Picker to debug break in code by clicking any widgets: https://github.com/ocornut/imgui/wiki/Debug-Tools
|
|
|
+// - Use Tools->Item Picker to debug break in code by clicking any widgets: https://github.com/ocornut/imgui/wiki/Debug-Tools
|
|
|
// - Browse an online version the demo with code linked to hovered widgets: https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html
|
|
|
// - Find a visible string and search for it in the code!
|
|
|
|
|
@@ -62,6 +62,7 @@
|
|
|
// - In Visual Studio: CTRL+comma ("Edit.GoToAll") can follow symbols inside comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
|
|
// - In Visual Studio w/ Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols inside comments.
|
|
|
// - In VS Code, CLion, etc.: CTRL+click can follow symbols inside comments.
|
|
|
+// - You can search/grep for all sections listed in the index to find the section.
|
|
|
|
|
|
/*
|
|
|
|
|
@@ -69,14 +70,15 @@ Index of this file:
|
|
|
|
|
|
// [SECTION] Forward Declarations
|
|
|
// [SECTION] Helpers
|
|
|
+// [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor & Multi-Select demos)
|
|
|
// [SECTION] Demo Window / ShowDemoWindow()
|
|
|
-// - ShowDemoWindow()
|
|
|
-// - sub section: ShowDemoWindowWidgets()
|
|
|
-// - sub section: ShowDemoWindowMultiSelect()
|
|
|
-// - sub section: ShowDemoWindowLayout()
|
|
|
-// - sub section: ShowDemoWindowPopups()
|
|
|
-// - sub section: ShowDemoWindowTables()
|
|
|
-// - sub section: ShowDemoWindowInputs()
|
|
|
+// [SECTION] ShowDemoWindowMenuBar()
|
|
|
+// [SECTION] ShowDemoWindowWidgets()
|
|
|
+// [SECTION] ShowDemoWindowMultiSelect()
|
|
|
+// [SECTION] ShowDemoWindowLayout()
|
|
|
+// [SECTION] ShowDemoWindowPopups()
|
|
|
+// [SECTION] ShowDemoWindowTables()
|
|
|
+// [SECTION] ShowDemoWindowInputs()
|
|
|
// [SECTION] About Window / ShowAboutWindow()
|
|
|
// [SECTION] Style Editor / ShowStyleEditor()
|
|
|
// [SECTION] User Guide / ShowUserGuide()
|
|
@@ -84,7 +86,6 @@ Index of this file:
|
|
|
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
|
|
// [SECTION] Example App: Debug Log / ShowExampleAppLog()
|
|
|
// [SECTION] Example App: Simple Layout / ShowExampleAppLayout()
|
|
|
-// [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor etc.)
|
|
|
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
|
|
// [SECTION] Example App: Long Text / ShowExampleAppLongText()
|
|
|
// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize()
|
|
@@ -193,7 +194,7 @@ Index of this file:
|
|
|
#endif
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-// [SECTION] Forward Declarations, Helpers
|
|
|
+// [SECTION] Forward Declarations
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
#if !defined(IMGUI_DISABLE_DEMO_WINDOWS)
|
|
@@ -217,9 +218,11 @@ static void ShowExampleAppWindowTitles(bool* p_open);
|
|
|
static void ShowExampleMenuFile();
|
|
|
|
|
|
// We split the contents of the big ShowDemoWindow() function into smaller functions
|
|
|
-// (because the link time of very large functions grow non-linearly)
|
|
|
-static void ShowDemoWindowWidgets();
|
|
|
-static void ShowDemoWindowMultiSelect();
|
|
|
+// (because the link time of very large functions tends to grow non-linearly)
|
|
|
+struct DemoWindowData;
|
|
|
+static void ShowDemoWindowMenuBar(DemoWindowData* demo_data);
|
|
|
+static void ShowDemoWindowWidgets(DemoWindowData* demo_data);
|
|
|
+static void ShowDemoWindowMultiSelect(DemoWindowData* demo_data);
|
|
|
static void ShowDemoWindowLayout();
|
|
|
static void ShowDemoWindowPopups();
|
|
|
static void ShowDemoWindowTables();
|
|
@@ -263,18 +266,114 @@ void* GImGuiDemoMarkerCallbackUserData = NULL;
|
|
|
#define IMGUI_DEMO_MARKER(section) do { if (GImGuiDemoMarkerCallback != NULL) GImGuiDemoMarkerCallback(__FILE__, __LINE__, section, GImGuiDemoMarkerCallbackUserData); } while (0)
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-// [SECTION] Demo Window / ShowDemoWindow()
|
|
|
+// [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor etc.)
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
+// Simple representation for a tree
|
|
|
+// (this is designed to be simple to understand for our demos, not to be fancy or efficient etc.)
|
|
|
+struct ExampleTreeNode
|
|
|
+{
|
|
|
+ // Tree structure
|
|
|
+ char Name[28];
|
|
|
+ int UID = 0;
|
|
|
+ ExampleTreeNode* Parent = NULL;
|
|
|
+ ImVector<ExampleTreeNode*> Childs;
|
|
|
+
|
|
|
+ // Leaf Data
|
|
|
+ bool HasData = false; // All leaves have data
|
|
|
+ bool DataMyBool = false;
|
|
|
+ int DataMyInt = 128;
|
|
|
+ ImVec2 DataMyVec2 = ImVec2(0.0f, 3.141592f);
|
|
|
+};
|
|
|
+
|
|
|
+// Simple representation of struct metadata/serialization data.
|
|
|
+// (this is a minimal version of what a typical advanced application may provide)
|
|
|
+struct ExampleMemberInfo
|
|
|
+{
|
|
|
+ const char* Name; // Member name
|
|
|
+ ImGuiDataType DataType; // Member type
|
|
|
+ int DataCount; // Member count (1 when scalar)
|
|
|
+ int Offset; // Offset inside parent structure
|
|
|
+};
|
|
|
+
|
|
|
+// Metadata description of ExampleTreeNode struct.
|
|
|
+static const ExampleMemberInfo ExampleTreeNodeMemberInfos[]
|
|
|
+{
|
|
|
+ { "MyBool", ImGuiDataType_Bool, 1, offsetof(ExampleTreeNode, DataMyBool) },
|
|
|
+ { "MyInt", ImGuiDataType_S32, 1, offsetof(ExampleTreeNode, DataMyInt) },
|
|
|
+ { "MyVec2", ImGuiDataType_Float, 2, offsetof(ExampleTreeNode, DataMyVec2) },
|
|
|
+};
|
|
|
+
|
|
|
+static ExampleTreeNode* ExampleTree_CreateNode(const char* name, int uid, ExampleTreeNode* parent)
|
|
|
+{
|
|
|
+ ExampleTreeNode* node = IM_NEW(ExampleTreeNode);
|
|
|
+ snprintf(node->Name, IM_ARRAYSIZE(node->Name), "%s", name);
|
|
|
+ node->UID = uid;
|
|
|
+ node->Parent = parent;
|
|
|
+ if (parent)
|
|
|
+ parent->Childs.push_back(node);
|
|
|
+ return node;
|
|
|
+}
|
|
|
+
|
|
|
+// Create example tree data
|
|
|
+static ExampleTreeNode* ExampleTree_CreateDemoTree()
|
|
|
+{
|
|
|
+ static const char* root_names[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
|
|
|
+ char name_buf[32];
|
|
|
+ int uid = 0;
|
|
|
+ ExampleTreeNode* node_L0 = ExampleTree_CreateNode("<ROOT>", ++uid, NULL);
|
|
|
+ for (int idx_L0 = 0; idx_L0 < IM_ARRAYSIZE(root_names) * 2; idx_L0++)
|
|
|
+ {
|
|
|
+ snprintf(name_buf, 32, "%s %d", root_names[idx_L0 / 2], idx_L0 % 2);
|
|
|
+ ExampleTreeNode* node_L1 = ExampleTree_CreateNode(name_buf, ++uid, node_L0);
|
|
|
+ const int number_of_childs = (int)strlen(node_L1->Name);
|
|
|
+ for (int idx_L1 = 0; idx_L1 < number_of_childs; idx_L1++)
|
|
|
+ {
|
|
|
+ snprintf(name_buf, 32, "Child %d", idx_L1);
|
|
|
+ ExampleTreeNode* node_L2 = ExampleTree_CreateNode(name_buf, ++uid, node_L1);
|
|
|
+ node_L2->HasData = true;
|
|
|
+ if (idx_L1 == 0)
|
|
|
+ {
|
|
|
+ snprintf(name_buf, 32, "Sub-child %d", 0);
|
|
|
+ ExampleTreeNode* node_L3 = ExampleTree_CreateNode(name_buf, ++uid, node_L2);
|
|
|
+ node_L3->HasData = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return node_L0;
|
|
|
+}
|
|
|
+
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-// - ShowDemoWindow()
|
|
|
-// - ShowDemoWindowWidgets()
|
|
|
-// - ShowDemoWindowMultiSelect()
|
|
|
-// - ShowDemoWindowLayout()
|
|
|
-// - ShowDemoWindowPopups()
|
|
|
-// - ShowDemoWindowTables()
|
|
|
-// - ShowDemoWindowColumns()
|
|
|
-// - ShowDemoWindowInputs()
|
|
|
+// [SECTION] Demo Window / ShowDemoWindow()
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
+struct DemoWindowData
|
|
|
+{
|
|
|
+ // Examples Apps (accessible from the "Examples" menu)
|
|
|
+ bool ShowMainMenuBar = false;
|
|
|
+ bool ShowAppAssetsBrowser = false;
|
|
|
+ bool ShowAppConsole = false;
|
|
|
+ bool ShowAppCustomRendering = false;
|
|
|
+ bool ShowAppDocuments = false;
|
|
|
+ bool ShowAppDockSpace = false;
|
|
|
+ bool ShowAppLog = false;
|
|
|
+ bool ShowAppLayout = false;
|
|
|
+ bool ShowAppPropertyEditor = false;
|
|
|
+ bool ShowAppSimpleOverlay = false;
|
|
|
+ bool ShowAppAutoResize = false;
|
|
|
+ bool ShowAppConstrainedResize = false;
|
|
|
+ bool ShowAppFullscreen = false;
|
|
|
+ bool ShowAppLongText = false;
|
|
|
+ bool ShowAppWindowTitles = false;
|
|
|
+
|
|
|
+ // Dear ImGui Tools (accessible from the "Tools" menu)
|
|
|
+ bool ShowMetrics = false;
|
|
|
+ bool ShowDebugLog = false;
|
|
|
+ bool ShowIDStackTool = false;
|
|
|
+ bool ShowStyleEditor = false;
|
|
|
+ bool ShowAbout = false;
|
|
|
+};
|
|
|
+
|
|
|
// Demonstrate most Dear ImGui features (this is big function!)
|
|
|
// 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.
|
|
@@ -287,60 +386,37 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
// Verify ABI compatibility between caller code and compiled version of Dear ImGui. This helps detects some build issues.
|
|
|
IMGUI_CHECKVERSION();
|
|
|
|
|
|
+ // Stored data
|
|
|
+ static DemoWindowData demo;
|
|
|
+
|
|
|
// Examples Apps (accessible from the "Examples" menu)
|
|
|
- static bool show_app_main_menu_bar = false;
|
|
|
- static bool show_app_assets_browser = false;
|
|
|
- static bool show_app_console = false;
|
|
|
- static bool show_app_custom_rendering = false;
|
|
|
- static bool show_app_dockspace = false;
|
|
|
- static bool show_app_documents = false;
|
|
|
- static bool show_app_log = false;
|
|
|
- static bool show_app_layout = false;
|
|
|
- static bool show_app_property_editor = false;
|
|
|
- static bool show_app_simple_overlay = false;
|
|
|
- static bool show_app_auto_resize = false;
|
|
|
- static bool show_app_constrained_resize = false;
|
|
|
- static bool show_app_fullscreen = false;
|
|
|
- static bool show_app_long_text = false;
|
|
|
- static bool show_app_window_titles = false;
|
|
|
-
|
|
|
- if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
|
|
|
- if (show_app_dockspace) ShowExampleAppDockSpace(&show_app_dockspace); // Process the Docking app first, as explicit DockSpace() nodes needs to be submitted early (read comments near the DockSpace function)
|
|
|
- if (show_app_documents) ShowExampleAppDocuments(&show_app_documents); // Process the Document app next, as it may also use a DockSpace()
|
|
|
- if (show_app_assets_browser) ShowExampleAppAssetsBrowser(&show_app_assets_browser);
|
|
|
- if (show_app_console) ShowExampleAppConsole(&show_app_console);
|
|
|
- if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering);
|
|
|
- if (show_app_log) ShowExampleAppLog(&show_app_log);
|
|
|
- if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
|
|
|
- if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor);
|
|
|
- if (show_app_simple_overlay) ShowExampleAppSimpleOverlay(&show_app_simple_overlay);
|
|
|
- if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize);
|
|
|
- if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize);
|
|
|
- if (show_app_fullscreen) ShowExampleAppFullscreen(&show_app_fullscreen);
|
|
|
- if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text);
|
|
|
- if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles);
|
|
|
+ if (demo.ShowMainMenuBar) { ShowExampleAppMainMenuBar(); }
|
|
|
+ if (demo.ShowAppDockSpace) { ShowExampleAppDockSpace(&demo.ShowAppDockSpace); } // Important: Process the Docking app first, as explicit DockSpace() nodes needs to be submitted early (read comments near the DockSpace function)
|
|
|
+ if (demo.ShowAppDocuments) { ShowExampleAppDocuments(&demo.ShowAppDocuments); } // ...Process the Document app next, as it may also use a DockSpace()
|
|
|
+ if (demo.ShowAppAssetsBrowser) { ShowExampleAppAssetsBrowser(&demo.ShowAppAssetsBrowser); }
|
|
|
+ if (demo.ShowAppConsole) { ShowExampleAppConsole(&demo.ShowAppConsole); }
|
|
|
+ if (demo.ShowAppCustomRendering) { ShowExampleAppCustomRendering(&demo.ShowAppCustomRendering); }
|
|
|
+ if (demo.ShowAppLog) { ShowExampleAppLog(&demo.ShowAppLog); }
|
|
|
+ if (demo.ShowAppLayout) { ShowExampleAppLayout(&demo.ShowAppLayout); }
|
|
|
+ if (demo.ShowAppPropertyEditor) { ShowExampleAppPropertyEditor(&demo.ShowAppPropertyEditor); }
|
|
|
+ if (demo.ShowAppSimpleOverlay) { ShowExampleAppSimpleOverlay(&demo.ShowAppSimpleOverlay); }
|
|
|
+ if (demo.ShowAppAutoResize) { ShowExampleAppAutoResize(&demo.ShowAppAutoResize); }
|
|
|
+ if (demo.ShowAppConstrainedResize) { ShowExampleAppConstrainedResize(&demo.ShowAppConstrainedResize); }
|
|
|
+ if (demo.ShowAppFullscreen) { ShowExampleAppFullscreen(&demo.ShowAppFullscreen); }
|
|
|
+ if (demo.ShowAppLongText) { ShowExampleAppLongText(&demo.ShowAppLongText); }
|
|
|
+ if (demo.ShowAppWindowTitles) { ShowExampleAppWindowTitles(&demo.ShowAppWindowTitles); }
|
|
|
|
|
|
// Dear ImGui Tools (accessible from the "Tools" menu)
|
|
|
- static bool show_tool_metrics = false;
|
|
|
- static bool show_tool_debug_log = false;
|
|
|
- static bool show_tool_id_stack_tool = false;
|
|
|
- static bool show_tool_style_editor = false;
|
|
|
- static bool show_tool_about = false;
|
|
|
-
|
|
|
- if (show_tool_metrics)
|
|
|
- ImGui::ShowMetricsWindow(&show_tool_metrics);
|
|
|
- if (show_tool_debug_log)
|
|
|
- ImGui::ShowDebugLogWindow(&show_tool_debug_log);
|
|
|
- if (show_tool_id_stack_tool)
|
|
|
- ImGui::ShowIDStackToolWindow(&show_tool_id_stack_tool);
|
|
|
- if (show_tool_style_editor)
|
|
|
- {
|
|
|
- ImGui::Begin("Dear ImGui Style Editor", &show_tool_style_editor);
|
|
|
+ if (demo.ShowMetrics) { ImGui::ShowMetricsWindow(&demo.ShowMetrics); }
|
|
|
+ if (demo.ShowDebugLog) { ImGui::ShowDebugLogWindow(&demo.ShowDebugLog); }
|
|
|
+ if (demo.ShowIDStackTool) { ImGui::ShowIDStackToolWindow(&demo.ShowIDStackTool); }
|
|
|
+ if (demo.ShowAbout) { ImGui::ShowAboutWindow(&demo.ShowAbout); }
|
|
|
+ if (demo.ShowStyleEditor)
|
|
|
+ {
|
|
|
+ ImGui::Begin("Dear ImGui Style Editor", &demo.ShowStyleEditor);
|
|
|
ImGui::ShowStyleEditor();
|
|
|
ImGui::End();
|
|
|
}
|
|
|
- if (show_tool_about)
|
|
|
- ImGui::ShowAboutWindow(&show_tool_about);
|
|
|
|
|
|
// Demonstrate the various window flags. Typically you would just use the default!
|
|
|
static bool no_titlebar = false;
|
|
@@ -385,69 +461,11 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
}
|
|
|
|
|
|
// Most "big" widgets share a common width settings by default. See 'Demo->Layout->Widgets Width' for details.
|
|
|
- // e.g. Use 2/3 of the space for widgets and 1/3 for labels (right align)
|
|
|
- //ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f);
|
|
|
- // e.g. Leave a fixed amount of width for labels (by passing a negative value), the rest goes to widgets.
|
|
|
- ImGui::PushItemWidth(ImGui::GetFontSize() * -12);
|
|
|
+ ImGui::PushItemWidth(ImGui::GetFontSize() * -12); // e.g. Leave a fixed amount of width for labels (by passing a negative value), the rest goes to widgets.
|
|
|
+ //ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f); // e.g. Use 2/3 of the space for widgets and 1/3 for labels (right align)
|
|
|
|
|
|
// Menu Bar
|
|
|
- if (ImGui::BeginMenuBar())
|
|
|
- {
|
|
|
- if (ImGui::BeginMenu("Menu"))
|
|
|
- {
|
|
|
- IMGUI_DEMO_MARKER("Menu/File");
|
|
|
- ShowExampleMenuFile();
|
|
|
- ImGui::EndMenu();
|
|
|
- }
|
|
|
- if (ImGui::BeginMenu("Examples"))
|
|
|
- {
|
|
|
- IMGUI_DEMO_MARKER("Menu/Examples");
|
|
|
- ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
|
|
|
-
|
|
|
- ImGui::SeparatorText("Mini apps");
|
|
|
- ImGui::MenuItem("Assets Browser", NULL, &show_app_assets_browser);
|
|
|
- ImGui::MenuItem("Console", NULL, &show_app_console);
|
|
|
- ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
|
|
|
- ImGui::MenuItem("Dockspace", NULL, &show_app_dockspace);
|
|
|
- ImGui::MenuItem("Documents", NULL, &show_app_documents);
|
|
|
- ImGui::MenuItem("Log", NULL, &show_app_log);
|
|
|
- ImGui::MenuItem("Property editor", NULL, &show_app_property_editor);
|
|
|
- ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
|
|
|
- ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
|
|
|
-
|
|
|
- ImGui::SeparatorText("Concepts");
|
|
|
- ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
|
|
|
- ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
|
|
|
- ImGui::MenuItem("Fullscreen window", NULL, &show_app_fullscreen);
|
|
|
- ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
|
|
|
- ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
|
|
|
-
|
|
|
- ImGui::EndMenu();
|
|
|
- }
|
|
|
- //if (ImGui::MenuItem("MenuItem")) {} // You can also use MenuItem() inside a menu bar!
|
|
|
- if (ImGui::BeginMenu("Tools"))
|
|
|
- {
|
|
|
- IMGUI_DEMO_MARKER("Menu/Tools");
|
|
|
-#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
|
|
- const bool has_debug_tools = true;
|
|
|
-#else
|
|
|
- const bool has_debug_tools = false;
|
|
|
-#endif
|
|
|
- ImGui::MenuItem("Metrics/Debugger", NULL, &show_tool_metrics, has_debug_tools);
|
|
|
- ImGui::MenuItem("Debug Log", NULL, &show_tool_debug_log, has_debug_tools);
|
|
|
- ImGui::MenuItem("ID Stack Tool", NULL, &show_tool_id_stack_tool, has_debug_tools);
|
|
|
- ImGui::MenuItem("Style Editor", NULL, &show_tool_style_editor);
|
|
|
- bool is_debugger_present = ImGui::GetIO().ConfigDebugIsDebuggerPresent;
|
|
|
- if (ImGui::MenuItem("Item Picker", NULL, false, has_debug_tools && is_debugger_present))
|
|
|
- ImGui::DebugStartItemPicker();
|
|
|
- if (!is_debugger_present)
|
|
|
- ImGui::SetItemTooltip("Requires io.ConfigDebugIsDebuggerPresent=true to be set.\n\nWe otherwise disable the menu option to avoid casual users crashing the application.\n\nYou can however always access the Item Picker in Metrics->Tools.");
|
|
|
- ImGui::Separator();
|
|
|
- ImGui::MenuItem("About Dear ImGui", NULL, &show_tool_about);
|
|
|
- ImGui::EndMenu();
|
|
|
- }
|
|
|
- ImGui::EndMenuBar();
|
|
|
- }
|
|
|
+ ShowDemoWindowMenuBar(&demo);
|
|
|
|
|
|
ImGui::Text("dear imgui says hello! (%s) (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
|
|
|
ImGui::Spacing();
|
|
@@ -610,7 +628,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
IMGUI_DEMO_MARKER("Configuration/Style");
|
|
|
if (ImGui::TreeNode("Style"))
|
|
|
{
|
|
|
- ImGui::Checkbox("Style Editor", &show_tool_style_editor);
|
|
|
+ ImGui::Checkbox("Style Editor", &demo.ShowStyleEditor);
|
|
|
ImGui::SameLine();
|
|
|
HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function.");
|
|
|
ImGui::TreePop();
|
|
@@ -659,7 +677,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
}
|
|
|
|
|
|
// All demo contents
|
|
|
- ShowDemoWindowWidgets();
|
|
|
+ ShowDemoWindowWidgets(&demo);
|
|
|
ShowDemoWindowLayout();
|
|
|
ShowDemoWindowPopups();
|
|
|
ShowDemoWindowTables();
|
|
@@ -670,7 +688,77 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|
|
ImGui::End();
|
|
|
}
|
|
|
|
|
|
-static void ShowDemoWindowWidgets()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] ShowDemoWindowMenuBar()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
+static void ShowDemoWindowMenuBar(DemoWindowData* demo_data)
|
|
|
+{
|
|
|
+ IMGUI_DEMO_MARKER("Menu");
|
|
|
+ if (ImGui::BeginMenuBar())
|
|
|
+ {
|
|
|
+ if (ImGui::BeginMenu("Menu"))
|
|
|
+ {
|
|
|
+ IMGUI_DEMO_MARKER("Menu/File");
|
|
|
+ ShowExampleMenuFile();
|
|
|
+ ImGui::EndMenu();
|
|
|
+ }
|
|
|
+ if (ImGui::BeginMenu("Examples"))
|
|
|
+ {
|
|
|
+ IMGUI_DEMO_MARKER("Menu/Examples");
|
|
|
+ ImGui::MenuItem("Main menu bar", NULL, &demo_data->ShowMainMenuBar);
|
|
|
+
|
|
|
+ ImGui::SeparatorText("Mini apps");
|
|
|
+ ImGui::MenuItem("Assets Browser", NULL, &demo_data->ShowAppAssetsBrowser);
|
|
|
+ ImGui::MenuItem("Console", NULL, &demo_data->ShowAppConsole);
|
|
|
+ ImGui::MenuItem("Custom rendering", NULL, &demo_data->ShowAppCustomRendering);
|
|
|
+ ImGui::MenuItem("Documents", NULL, &demo_data->ShowAppDocuments);
|
|
|
+ ImGui::MenuItem("Dockspace", NULL, &demo_data->ShowAppDockSpace);
|
|
|
+ ImGui::MenuItem("Log", NULL, &demo_data->ShowAppLog);
|
|
|
+ ImGui::MenuItem("Property editor", NULL, &demo_data->ShowAppPropertyEditor);
|
|
|
+ ImGui::MenuItem("Simple layout", NULL, &demo_data->ShowAppLayout);
|
|
|
+ ImGui::MenuItem("Simple overlay", NULL, &demo_data->ShowAppSimpleOverlay);
|
|
|
+
|
|
|
+ ImGui::SeparatorText("Concepts");
|
|
|
+ ImGui::MenuItem("Auto-resizing window", NULL, &demo_data->ShowAppAutoResize);
|
|
|
+ ImGui::MenuItem("Constrained-resizing window", NULL, &demo_data->ShowAppConstrainedResize);
|
|
|
+ ImGui::MenuItem("Fullscreen window", NULL, &demo_data->ShowAppFullscreen);
|
|
|
+ ImGui::MenuItem("Long text display", NULL, &demo_data->ShowAppLongText);
|
|
|
+ ImGui::MenuItem("Manipulating window titles", NULL, &demo_data->ShowAppWindowTitles);
|
|
|
+
|
|
|
+ ImGui::EndMenu();
|
|
|
+ }
|
|
|
+ //if (ImGui::MenuItem("MenuItem")) {} // You can also use MenuItem() inside a menu bar!
|
|
|
+ if (ImGui::BeginMenu("Tools"))
|
|
|
+ {
|
|
|
+ IMGUI_DEMO_MARKER("Menu/Tools");
|
|
|
+#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
|
|
+ const bool has_debug_tools = true;
|
|
|
+#else
|
|
|
+ const bool has_debug_tools = false;
|
|
|
+#endif
|
|
|
+ ImGui::MenuItem("Metrics/Debugger", NULL, &demo_data->ShowMetrics, has_debug_tools);
|
|
|
+ ImGui::MenuItem("Debug Log", NULL, &demo_data->ShowDebugLog, has_debug_tools);
|
|
|
+ ImGui::MenuItem("ID Stack Tool", NULL, &demo_data->ShowIDStackTool, has_debug_tools);
|
|
|
+ ImGui::MenuItem("Style Editor", NULL, &demo_data->ShowStyleEditor);
|
|
|
+ bool is_debugger_present = ImGui::GetIO().ConfigDebugIsDebuggerPresent;
|
|
|
+ if (ImGui::MenuItem("Item Picker", NULL, false, has_debug_tools && is_debugger_present))
|
|
|
+ ImGui::DebugStartItemPicker();
|
|
|
+ if (!is_debugger_present)
|
|
|
+ ImGui::SetItemTooltip("Requires io.ConfigDebugIsDebuggerPresent=true to be set.\n\nWe otherwise disable the menu option to avoid casual users crashing the application.\n\nYou can however always access the Item Picker in Metrics->Tools.");
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::MenuItem("About Dear ImGui", NULL, &demo_data->ShowAbout);
|
|
|
+ ImGui::EndMenu();
|
|
|
+ }
|
|
|
+ ImGui::EndMenuBar();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] ShowDemoWindowWidgets()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
+static void ShowDemoWindowWidgets(DemoWindowData* demo_data)
|
|
|
{
|
|
|
IMGUI_DEMO_MARKER("Widgets");
|
|
|
//ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
|
@@ -1548,7 +1636,7 @@ static void ShowDemoWindowWidgets()
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
- ShowDemoWindowMultiSelect();
|
|
|
+ ShowDemoWindowMultiSelect(demo_data);
|
|
|
|
|
|
// To wire InputText() with std::string or any other custom string type,
|
|
|
// see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
|
|
@@ -3066,9 +3154,14 @@ struct ExampleDualListBox
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] ShowDemoWindowMultiSelect()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
// Multi-selection demos
|
|
|
// Also read: https://github.com/ocornut/imgui/wiki/Multi-Select
|
|
|
-static void ShowDemoWindowMultiSelect()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
+static void ShowDemoWindowMultiSelect(DemoWindowData* demo_data)
|
|
|
{
|
|
|
IMGUI_DEMO_MARKER("Widgets/Selection State & Multi-Select");
|
|
|
if (ImGui::TreeNode("Selection State & Multi-Select"))
|
|
@@ -3363,7 +3456,8 @@ static void ShowDemoWindowMultiSelect()
|
|
|
// See ShowExampleAppAssetsBrowser()
|
|
|
if (ImGui::TreeNode("Multi-Select (tiled assets browser)"))
|
|
|
{
|
|
|
- ImGui::BulletText("See 'Examples->Assets Browser' in menu");
|
|
|
+ ImGui::Checkbox("Assets Browser", &demo_data->ShowAppAssetsBrowser);
|
|
|
+ ImGui::Text("(also access from 'Examples->Assets Browser' in menu)");
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
@@ -3600,6 +3694,10 @@ static void ShowDemoWindowMultiSelect()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] ShowDemoWindowLayout()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
static void ShowDemoWindowLayout()
|
|
|
{
|
|
|
IMGUI_DEMO_MARKER("Layout");
|
|
@@ -4459,6 +4557,10 @@ static void ShowDemoWindowLayout()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] ShowDemoWindowPopups()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
static void ShowDemoWindowPopups()
|
|
|
{
|
|
|
IMGUI_DEMO_MARKER("Popups");
|
|
@@ -4919,6 +5021,10 @@ static void ShowTableColumnsStatusFlags(ImGuiTableColumnFlags flags)
|
|
|
ImGui::CheckboxFlags("_IsHovered", &flags, ImGuiTableColumnFlags_IsHovered);
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] ShowDemoWindowTables()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
static void ShowDemoWindowTables()
|
|
|
{
|
|
|
//ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
|
@@ -7012,6 +7118,10 @@ static void ShowDemoWindowColumns()
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] ShowDemoWindowInputs()
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
static void ShowDemoWindowInputs()
|
|
|
{
|
|
|
IMGUI_DEMO_MARKER("Inputs & Focus");
|
|
@@ -8583,83 +8693,6 @@ static void ShowExampleAppLayout(bool* p_open)
|
|
|
ImGui::End();
|
|
|
}
|
|
|
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
-// [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor etc.)
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
-
|
|
|
-// Simple representation for a tree
|
|
|
-// (this is designed to be simple to understand for our demos, not to be efficient etc.)
|
|
|
-struct ExampleTreeNode
|
|
|
-{
|
|
|
- char Name[28];
|
|
|
- ImGuiID UID = 0;
|
|
|
- ExampleTreeNode* Parent = NULL;
|
|
|
- ImVector<ExampleTreeNode*> Childs;
|
|
|
-
|
|
|
- // Data
|
|
|
- bool HasData = false; // All leaves have data
|
|
|
- bool DataIsEnabled = false;
|
|
|
- int DataInt = 128;
|
|
|
- ImVec2 DataVec2 = ImVec2(0.0f, 3.141592f);
|
|
|
-};
|
|
|
-
|
|
|
-// Simple representation of struct metadata/serialization data.
|
|
|
-// (this is a minimal version of what a typical advanced application may provide)
|
|
|
-struct ExampleMemberInfo
|
|
|
-{
|
|
|
- const char* Name;
|
|
|
- ImGuiDataType DataType;
|
|
|
- int DataCount;
|
|
|
- int Offset;
|
|
|
-};
|
|
|
-
|
|
|
-// Metadata description of ExampleTreeNode struct.
|
|
|
-static const ExampleMemberInfo ExampleTreeNodeMemberInfos[]
|
|
|
-{
|
|
|
- { "Enabled", ImGuiDataType_Bool, 1, offsetof(ExampleTreeNode, DataIsEnabled) },
|
|
|
- { "MyInt", ImGuiDataType_S32, 1, offsetof(ExampleTreeNode, DataInt) },
|
|
|
- { "MyVec2", ImGuiDataType_Float, 2, offsetof(ExampleTreeNode, DataVec2) },
|
|
|
-};
|
|
|
-
|
|
|
-static ExampleTreeNode* ExampleTree_CreateNode(const char* name, const ImGuiID uid, ExampleTreeNode* parent)
|
|
|
-{
|
|
|
- ExampleTreeNode* node = IM_NEW(ExampleTreeNode);
|
|
|
- snprintf(node->Name, IM_ARRAYSIZE(node->Name), "%s", name);
|
|
|
- node->UID = uid;
|
|
|
- node->Parent = parent;
|
|
|
- if (parent)
|
|
|
- parent->Childs.push_back(node);
|
|
|
- return node;
|
|
|
-}
|
|
|
-
|
|
|
-// Create example tree data
|
|
|
-static ExampleTreeNode* ExampleTree_CreateDemoTree()
|
|
|
-{
|
|
|
- static const char* root_names[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" };
|
|
|
- char name_buf[32];
|
|
|
- ImGuiID uid = 0;
|
|
|
- ExampleTreeNode* node_L0 = ExampleTree_CreateNode("<ROOT>", ++uid, NULL);
|
|
|
- for (int idx_L0 = 0; idx_L0 < IM_ARRAYSIZE(root_names) * 2; idx_L0++)
|
|
|
- {
|
|
|
- snprintf(name_buf, 32, "%s %d", root_names[idx_L0 / 2], idx_L0 % 2);
|
|
|
- ExampleTreeNode* node_L1 = ExampleTree_CreateNode(name_buf, ++uid, node_L0);
|
|
|
- const int number_of_childs = (int)strlen(node_L1->Name);
|
|
|
- for (int idx_L1 = 0; idx_L1 < number_of_childs; idx_L1++)
|
|
|
- {
|
|
|
- snprintf(name_buf, 32, "Child %d", idx_L1);
|
|
|
- ExampleTreeNode* node_L2 = ExampleTree_CreateNode(name_buf, ++uid, node_L1);
|
|
|
- node_L2->HasData = true;
|
|
|
- if (idx_L1 == 0)
|
|
|
- {
|
|
|
- snprintf(name_buf, 32, "Sub-child %d", 0);
|
|
|
- ExampleTreeNode* node_L3 = ExampleTree_CreateNode(name_buf, ++uid, node_L2);
|
|
|
- node_L3->HasData = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return node_L0;
|
|
|
-}
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
|
|
//-----------------------------------------------------------------------------
|
|
@@ -8700,7 +8733,7 @@ struct ExampleAppPropertyEditor
|
|
|
void DrawTreeNode(ExampleTreeNode* node)
|
|
|
{
|
|
|
// Object tree node
|
|
|
- ImGui::PushID((int)node->UID);
|
|
|
+ ImGui::PushID(node->UID);
|
|
|
ImGui::TableNextRow();
|
|
|
ImGui::TableSetColumnIndex(0);
|
|
|
ImGui::AlignTextToFramePadding();
|