Demo: (Refactor) Moved code into DemoWindowWidgetsDisableBlocks() section.

This commit is contained in:
ocornut
2025-03-03 18:53:45 +01:00
parent 7a919e80c9
commit 71b160cdbb
2 changed files with 23 additions and 13 deletions
+1 -1
View File
@@ -29,7 +29,7 @@
// Library Version // Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.91.9 WIP" #define IMGUI_VERSION "1.91.9 WIP"
#define IMGUI_VERSION_NUM 19185 #define IMGUI_VERSION_NUM 19186
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE
/* /*
+22 -12
View File
@@ -256,6 +256,7 @@ static void DemoWindowWidgetsCollapsingHeaders();
static void DemoWindowWidgetsComboBoxes(); static void DemoWindowWidgetsComboBoxes();
static void DemoWindowWidgetsColorAndPickers(); static void DemoWindowWidgetsColorAndPickers();
static void DemoWindowWidgetsDataTypes(); static void DemoWindowWidgetsDataTypes();
static void DemoWindowWidgetsDisableBlocks(ImGuiDemoWindowData* demo_data);
static void DemoWindowWidgetsDragAndDrop(); static void DemoWindowWidgetsDragAndDrop();
static void DemoWindowWidgetsDragsAndSliders(); static void DemoWindowWidgetsDragsAndSliders();
static void DemoWindowWidgetsImages(); static void DemoWindowWidgetsImages();
@@ -427,6 +428,7 @@ struct ImGuiDemoWindowData
bool ShowAbout = false; bool ShowAbout = false;
// Other data // Other data
bool DisableSections = false;
ExampleTreeNode* DemoTree = NULL; ExampleTreeNode* DemoTree = NULL;
~ImGuiDemoWindowData() { if (DemoTree) ExampleTree_DestroyNode(DemoTree); } ~ImGuiDemoWindowData() { if (DemoTree) ExampleTree_DestroyNode(DemoTree); }
@@ -825,7 +827,7 @@ static void DemoWindowWidgets(ImGuiDemoWindowData* demo_data)
if (!ImGui::CollapsingHeader("Widgets")) if (!ImGui::CollapsingHeader("Widgets"))
return; return;
static bool disable_all = false; // The Checkbox for that is inside the "Disabled" section at the bottom const bool disable_all = demo_data->DisableSections; // The Checkbox for that is inside the "Disabled" section at the bottom
if (disable_all) if (disable_all)
ImGui::BeginDisabled(); ImGui::BeginDisabled();
@@ -835,6 +837,13 @@ static void DemoWindowWidgets(ImGuiDemoWindowData* demo_data)
DemoWindowWidgetsComboBoxes(); DemoWindowWidgetsComboBoxes();
DemoWindowWidgetsColorAndPickers(); DemoWindowWidgetsColorAndPickers();
DemoWindowWidgetsDataTypes(); DemoWindowWidgetsDataTypes();
if (disable_all)
ImGui::EndDisabled();
DemoWindowWidgetsDisableBlocks(demo_data);
if (disable_all)
ImGui::BeginDisabled();
DemoWindowWidgetsDragAndDrop(); DemoWindowWidgetsDragAndDrop();
DemoWindowWidgetsDragsAndSliders(); DemoWindowWidgetsDragsAndSliders();
DemoWindowWidgetsImages(); DemoWindowWidgetsImages();
@@ -853,18 +862,8 @@ static void DemoWindowWidgets(ImGuiDemoWindowData* demo_data)
DemoWindowWidgetsTreeNodes(); DemoWindowWidgetsTreeNodes();
DemoWindowWidgetsVerticalSliders(); DemoWindowWidgetsVerticalSliders();
// Demonstrate BeginDisabled/EndDisabled using a checkbox located at the bottom of the section (which is a bit odd:
// logically we'd have this checkbox at the top of the section, but we don't want this feature to steal that space)
if (disable_all) if (disable_all)
ImGui::EndDisabled(); ImGui::EndDisabled();
IMGUI_DEMO_MARKER("Widgets/Disable Block");
if (ImGui::TreeNode("Disable block"))
{
ImGui::Checkbox("Disable entire section above", &disable_all);
ImGui::SameLine(); HelpMarker("Demonstrate using BeginDisabled()/EndDisabled() across this section.");
ImGui::TreePop();
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1567,6 +1566,17 @@ static void DemoWindowWidgetsDataTypes()
// [SECTION] DemoWindowWidgetsDisableBlocks() // [SECTION] DemoWindowWidgetsDisableBlocks()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void DemoWindowWidgetsDisableBlocks(ImGuiDemoWindowData* demo_data)
{
IMGUI_DEMO_MARKER("Widgets/Disable Blocks");
if (ImGui::TreeNode("Disable Blocks"))
{
ImGui::Checkbox("Disable entire section above", &demo_data->DisableSections);
ImGui::SameLine(); HelpMarker("Demonstrate using BeginDisabled()/EndDisabled() across other sections.");
ImGui::TreePop();
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] DemoWindowWidgetsDragAndDrop() // [SECTION] DemoWindowWidgetsDragAndDrop()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1872,7 +1882,7 @@ static void DemoWindowWidgetsImages()
static void DemoWindowWidgetsListBoxes() static void DemoWindowWidgetsListBoxes()
{ {
IMGUI_DEMO_MARKER("Widgets/List Boxes"); IMGUI_DEMO_MARKER("Widgets/List Boxes");
if (ImGui::TreeNode("List boxes")) if (ImGui::TreeNode("List Boxes"))
{ {
// BeginListBox() is essentially a thin wrapper to using BeginChild()/EndChild() // BeginListBox() is essentially a thin wrapper to using BeginChild()/EndChild()
// using the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label. // using the ImGuiChildFlags_FrameStyle flag for stylistic changes + displaying a label.