1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Demo: (Refactor) Added new empty sections.. Renamed existing helper functions.

This commit is contained in:
ocornut 2025-03-03 17:38:09 +01:00
parent ce13f6b73e
commit eefd2da0f6
2 changed files with 154 additions and 38 deletions

View file

@ -110,6 +110,7 @@ Other changes:
to allow disabled Item Picker suggestion in user facing builds. (#7961, #7669) to allow disabled Item Picker suggestion in user facing builds. (#7961, #7669)
- Misc: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursors - Misc: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursors
(busy/wait/hourglass shape, with or without an arrow cursor). (busy/wait/hourglass shape, with or without an arrow cursor).
- Demo: Reorganized "Widgets" section to be alphabetically ordered and split in more functions.
- Demo: Combos: demonstrate a very simple way to add a filter to a combo, - Demo: Combos: demonstrate a very simple way to add a filter to a combo,
by showing the filter inside the combo contents. (#718) by showing the filter inside the combo contents. (#718)
- Backends: GLFW: Fixed clipboard handler assertion when using GLFW <= 3.2.1 compiled - Backends: GLFW: Fixed clipboard handler assertion when using GLFW <= 3.2.1 compiled

View file

@ -72,13 +72,36 @@ Index of this file:
// [SECTION] Helpers // [SECTION] Helpers
// [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor & Multi-Select demos) // [SECTION] Helpers: ExampleTreeNode, ExampleMemberInfo (for use by Property Editor & Multi-Select demos)
// [SECTION] Demo Window / ShowDemoWindow() // [SECTION] Demo Window / ShowDemoWindow()
// [SECTION] ShowDemoWindowMenuBar() // [SECTION] DemoWindowMenuBar()
// [SECTION] ShowDemoWindowWidgets() // [SECTION] DemoWindowWidgets()
// [SECTION] ShowDemoWindowMultiSelect() // [SECTION] DemoWindowWidgetsBasic()
// [SECTION] ShowDemoWindowLayout() // [SECTION] DemoWindowWidgetsBullets()
// [SECTION] ShowDemoWindowPopups() // [SECTION] DemoWindowWidgetsCollapsingHeaders()
// [SECTION] ShowDemoWindowTables() // [SECTION] DemoWindowWidgetsComboBoxes()
// [SECTION] ShowDemoWindowInputs() // [SECTION] DemoWindowWidgetsColorAndPickers()
// [SECTION] DemoWindowWidgetsDataTypes()
// [SECTION] DemoWindowWidgetsDisableBlocks()
// [SECTION] DemoWindowWidgetsDragAndDrop()
// [SECTION] DemoWindowWidgetsDragsAndSliders()
// [SECTION] DemoWindowWidgetsImages()
// [SECTION] DemoWindowWidgetsListBoxes()
// [SECTION] DemoWindowWidgetsMultiComponents()
// [SECTION] DemoWindowWidgetsPlotting()
// [SECTION] DemoWindowWidgetsProgressBars()
// [SECTION] DemoWindowWidgetsQueryingStatuses()
// [SECTION] DemoWindowWidgetsSelectables()
// [SECTION] DemoWindowWidgetsSelectionAndMultiSelect()
// [SECTION] DemoWindowWidgetsTabs()
// [SECTION] DemoWindowWidgetsText()
// [SECTION] DemoWindowWidgetsTextFilter()
// [SECTION] DemoWindowWidgetsTextInput()
// [SECTION] DemoWindowWidgetsTooltips()
// [SECTION] DemoWindowWidgetsTreeNodes()
// [SECTION] DemoWindowWidgetsVerticalSliders()
// [SECTION] DemoWindowLayout()
// [SECTION] DemoWindowPopups()
// [SECTION] DemoWindowTables()
// [SECTION] DemoWindowInputs()
// [SECTION] About Window / ShowAboutWindow() // [SECTION] About Window / ShowAboutWindow()
// [SECTION] Style Editor / ShowStyleEditor() // [SECTION] Style Editor / ShowStyleEditor()
// [SECTION] User Guide / ShowUserGuide() // [SECTION] User Guide / ShowUserGuide()
@ -225,14 +248,14 @@ static void ShowExampleMenuFile();
// We split the contents of the big ShowDemoWindow() function into smaller functions // We split the contents of the big ShowDemoWindow() function into smaller functions
// (because the link time of very large functions tends to grow non-linearly) // (because the link time of very large functions tends to grow non-linearly)
static void ShowDemoWindowMenuBar(ImGuiDemoWindowData* demo_data); static void DemoWindowMenuBar(ImGuiDemoWindowData* demo_data);
static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data); static void DemoWindowWidgets(ImGuiDemoWindowData* demo_data);
static void ShowDemoWindowMultiSelect(ImGuiDemoWindowData* demo_data); static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_data);
static void ShowDemoWindowLayout(); static void DemoWindowLayout();
static void ShowDemoWindowPopups(); static void DemoWindowPopups();
static void ShowDemoWindowTables(); static void DemoWindowTables();
static void ShowDemoWindowColumns(); static void DemoWindowColumns();
static void ShowDemoWindowInputs(); static void DemoWindowInputs();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] Helpers // [SECTION] Helpers
@ -475,7 +498,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
//ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f); // 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. Use 2/3 of the space for widgets and 1/3 for labels (right align)
// Menu Bar // Menu Bar
ShowDemoWindowMenuBar(&demo_data); DemoWindowMenuBar(&demo_data);
ImGui::Text("dear imgui says hello! (%s) (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM); ImGui::Text("dear imgui says hello! (%s) (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM);
ImGui::Spacing(); ImGui::Spacing();
@ -683,11 +706,11 @@ void ImGui::ShowDemoWindow(bool* p_open)
} }
// All demo contents // All demo contents
ShowDemoWindowWidgets(&demo_data); DemoWindowWidgets(&demo_data);
ShowDemoWindowLayout(); DemoWindowLayout();
ShowDemoWindowPopups(); DemoWindowPopups();
ShowDemoWindowTables(); DemoWindowTables();
ShowDemoWindowInputs(); DemoWindowInputs();
// End of ShowDemoWindow() // End of ShowDemoWindow()
ImGui::PopItemWidth(); ImGui::PopItemWidth();
@ -695,10 +718,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] ShowDemoWindowMenuBar() // [SECTION] DemoWindowMenuBar()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowMenuBar(ImGuiDemoWindowData* demo_data) static void DemoWindowMenuBar(ImGuiDemoWindowData* demo_data)
{ {
IMGUI_DEMO_MARKER("Menu"); IMGUI_DEMO_MARKER("Menu");
if (ImGui::BeginMenuBar()) if (ImGui::BeginMenuBar())
@ -770,10 +793,10 @@ static void ShowDemoWindowMenuBar(ImGuiDemoWindowData* demo_data)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] ShowDemoWindowWidgets() // [SECTION] DemoWindowWidgets()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data) static void DemoWindowWidgets(ImGuiDemoWindowData* demo_data)
{ {
IMGUI_DEMO_MARKER("Widgets"); IMGUI_DEMO_MARKER("Widgets");
//ImGui::SetNextItemOpen(true, ImGuiCond_Once); //ImGui::SetNextItemOpen(true, ImGuiCond_Once);
@ -1680,7 +1703,7 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
ImGui::TreePop(); ImGui::TreePop();
} }
ShowDemoWindowMultiSelect(demo_data); DemoWindowWidgetsSelectionAndMultiSelect(demo_data);
// To wire InputText() with std::string or any other custom string type, // 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. // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
@ -2986,6 +3009,70 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
} }
} }
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsBasic()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsBullets()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsCollapsingHeaders()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsColorAndPickers()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsComboBoxes()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsDataTypes()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsDisableBlocks()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsDragAndDrop()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsDragsAndSliders()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsImages()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsListBoxes()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsMultiComponents()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsPlotting()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsProgressBars()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsQueryingStatuses()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsSelectables()
//-----------------------------------------------------------------------------
static const char* ExampleNames[] = static const char* ExampleNames[] =
{ {
"Artichoke", "Arugula", "Asparagus", "Avocado", "Bamboo Shoots", "Bean Sprouts", "Beans", "Beet", "Belgian Endive", "Bell Pepper", "Artichoke", "Arugula", "Asparagus", "Avocado", "Bamboo Shoots", "Bean Sprouts", "Beans", "Beet", "Belgian Endive", "Bell Pepper",
@ -3212,13 +3299,13 @@ struct ExampleDualListBox
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] ShowDemoWindowMultiSelect() // [SECTION] DemoWindowWidgetsSelectionAndMultiSelect()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Multi-selection demos // Multi-selection demos
// Also read: https://github.com/ocornut/imgui/wiki/Multi-Select // Also read: https://github.com/ocornut/imgui/wiki/Multi-Select
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowMultiSelect(ImGuiDemoWindowData* demo_data) static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_data)
{ {
IMGUI_DEMO_MARKER("Widgets/Selection State & Multi-Select"); IMGUI_DEMO_MARKER("Widgets/Selection State & Multi-Select");
if (ImGui::TreeNode("Selection State & Multi-Select")) if (ImGui::TreeNode("Selection State & Multi-Select"))
@ -3954,10 +4041,38 @@ static void ShowDemoWindowMultiSelect(ImGuiDemoWindowData* demo_data)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] ShowDemoWindowLayout() // [SECTION] DemoWindowWidgetsTabs()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowLayout() //-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsText()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsTextFilter()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsTextInput()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsTooltips()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsTreeNodes()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsVerticalSliders()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// [SECTION] DemoWindowLayout()
//-----------------------------------------------------------------------------
static void DemoWindowLayout()
{ {
IMGUI_DEMO_MARKER("Layout"); IMGUI_DEMO_MARKER("Layout");
if (!ImGui::CollapsingHeader("Layout & Scrolling")) if (!ImGui::CollapsingHeader("Layout & Scrolling"))
@ -4820,10 +4935,10 @@ static void ShowDemoWindowLayout()
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] ShowDemoWindowPopups() // [SECTION] DemoWindowPopups()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowPopups() static void DemoWindowPopups()
{ {
IMGUI_DEMO_MARKER("Popups"); IMGUI_DEMO_MARKER("Popups");
if (!ImGui::CollapsingHeader("Popups & Modal windows")) if (!ImGui::CollapsingHeader("Popups & Modal windows"))
@ -5284,10 +5399,10 @@ static void ShowTableColumnsStatusFlags(ImGuiTableColumnFlags flags)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] ShowDemoWindowTables() // [SECTION] DemoWindowTables()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowTables() static void DemoWindowTables()
{ {
//ImGui::SetNextItemOpen(true, ImGuiCond_Once); //ImGui::SetNextItemOpen(true, ImGuiCond_Once);
IMGUI_DEMO_MARKER("Tables"); IMGUI_DEMO_MARKER("Tables");
@ -7184,7 +7299,7 @@ static void ShowDemoWindowTables()
ImGui::PopID(); ImGui::PopID();
ShowDemoWindowColumns(); DemoWindowColumns();
if (disable_indent) if (disable_indent)
ImGui::PopStyleVar(); ImGui::PopStyleVar();
@ -7192,7 +7307,7 @@ static void ShowDemoWindowTables()
// Demonstrate old/legacy Columns API! // Demonstrate old/legacy Columns API!
// [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!] // [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!]
static void ShowDemoWindowColumns() static void DemoWindowColumns()
{ {
IMGUI_DEMO_MARKER("Columns (legacy API)"); IMGUI_DEMO_MARKER("Columns (legacy API)");
bool open = ImGui::TreeNode("Legacy Columns API"); bool open = ImGui::TreeNode("Legacy Columns API");
@ -7399,10 +7514,10 @@ static void ShowDemoWindowColumns()
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] ShowDemoWindowInputs() // [SECTION] DemoWindowInputs()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void ShowDemoWindowInputs() static void DemoWindowInputs()
{ {
IMGUI_DEMO_MARKER("Inputs & Focus"); IMGUI_DEMO_MARKER("Inputs & Focus");
if (ImGui::CollapsingHeader("Inputs & Focus")) if (ImGui::CollapsingHeader("Inputs & Focus"))