@@ -1262,16 +1262,16 @@ static void ShowDemoWindowWidgets()
1262
1262
IMGUI_DEMO_MARKER("Widgets/Selectables/Basic");
1263
1263
if (ImGui::TreeNode("Basic"))
1264
1264
{
1265
- static bool selection[5] = { false, true, false, false, false };
1265
+ static bool selection[5] = { false, true, false, false };
1266
1266
ImGui::Selectable("1. I am selectable", &selection[0]);
1267
1267
ImGui::Selectable("2. I am selectable", &selection[1]);
1268
- ImGui::Text("(I am not selectable)");
1269
- ImGui::Selectable("4. I am selectable", &selection[3]);
1270
- if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick))
1268
+ ImGui::Selectable("3. I am selectable", &selection[2]);
1269
+ if (ImGui::Selectable("4. I am double clickable", selection[3], ImGuiSelectableFlags_AllowDoubleClick))
1271
1270
if (ImGui::IsMouseDoubleClicked(0))
1272
- selection[4 ] = !selection[4 ];
1271
+ selection[3 ] = !selection[3 ];
1273
1272
ImGui::TreePop();
1274
1273
}
1274
+
1275
1275
IMGUI_DEMO_MARKER("Widgets/Selectables/Single Selection");
1276
1276
if (ImGui::TreeNode("Selection State: Single Selection"))
1277
1277
{
@@ -1303,17 +1303,18 @@ static void ShowDemoWindowWidgets()
1303
1303
}
1304
1304
ImGui::TreePop();
1305
1305
}
1306
- IMGUI_DEMO_MARKER("Widgets/Selectables/Rendering more text into the same line");
1307
- if (ImGui::TreeNode("Rendering more text into the same line"))
1306
+ IMGUI_DEMO_MARKER("Widgets/Selectables/Rendering more items on the same line");
1307
+ if (ImGui::TreeNode("Rendering more items on the same line"))
1308
1308
{
1309
- // Using the Selectable() override that takes "bool* p_selected" parameter,
1310
- // this function toggle your bool value automatically.
1309
+ // (1) Using SetNextItemAllowOverlap()
1310
+ // (2) Using the Selectable() override that takes " bool* p_selected" parameter, the bool value is toggled automatically.
1311
1311
static bool selected[3] = { false, false, false };
1312
- ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300 ); ImGui::Text(" 2,345 bytes ");
1313
- ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300 ); ImGui::Text("12,345 bytes ");
1314
- ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300 ); ImGui::Text(" 2,345 bytes ");
1312
+ ImGui::SetNextItemAllowOverlap(); ImGui:: Selectable("main.c", &selected[0]); ImGui::SameLine(); ImGui::SmallButton("Link 1 ");
1313
+ ImGui::SetNextItemAllowOverlap(); ImGui:: Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(); ImGui::SmallButton("Link 2 ");
1314
+ ImGui::SetNextItemAllowOverlap(); ImGui:: Selectable("Hello.h", &selected[2]); ImGui::SameLine(); ImGui::SmallButton("Link 3 ");
1315
1315
ImGui::TreePop();
1316
1316
}
1317
+
1317
1318
IMGUI_DEMO_MARKER("Widgets/Selectables/In columns");
1318
1319
if (ImGui::TreeNode("In columns"))
1319
1320
{
@@ -1349,6 +1350,7 @@ static void ShowDemoWindowWidgets()
1349
1350
}
1350
1351
ImGui::TreePop();
1351
1352
}
1353
+
1352
1354
IMGUI_DEMO_MARKER("Widgets/Selectables/Grid");
1353
1355
if (ImGui::TreeNode("Grid"))
1354
1356
{
@@ -2795,11 +2797,11 @@ static void ShowDemoWindowLayout()
2795
2797
// Text
2796
2798
IMGUI_DEMO_MARKER("Layout/Basic Horizontal Layout/SameLine");
2797
2799
ImGui::Text("Two items: Hello"); ImGui::SameLine();
2798
- ImGui::TextColored(ImVec4(1,1,0, 1), "Sailor");
2800
+ ImGui::TextColored(ImVec4(1, 1, 0, 1), "Sailor");
2799
2801
2800
2802
// Adjust spacing
2801
2803
ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20);
2802
- ImGui::TextColored(ImVec4(1,1,0, 1), "Sailor");
2804
+ ImGui::TextColored(ImVec4(1, 1, 0, 1), "Sailor");
2803
2805
2804
2806
// Button
2805
2807
ImGui::AlignTextToFramePadding();
@@ -3397,6 +3399,36 @@ static void ShowDemoWindowLayout()
3397
3399
3398
3400
ImGui::TreePop();
3399
3401
}
3402
+
3403
+ IMGUI_DEMO_MARKER("Layout/Overlap Mode");
3404
+ if (ImGui::TreeNode("Overlap Mode"))
3405
+ {
3406
+ static bool enable_allow_overlap = true;
3407
+
3408
+ HelpMarker(
3409
+ "Hit-testing is by default performed in item submission order, which generally is perceived as 'back-to-front'.\n\n"
3410
+ "By using SetNextItemAllowOverlap() you can notify that an item may be overlapped by another. Doing so alters the hovering logic: items using AllowOverlap mode requires an extra frame to accept hovered state.");
3411
+ ImGui::Checkbox("Enable AllowOverlap", &enable_allow_overlap);
3412
+
3413
+ ImVec2 button1_pos = ImGui::GetCursorScreenPos();
3414
+ ImVec2 button2_pos = ImVec2(button1_pos.x + 50.0f, button1_pos.y + 50.0f);
3415
+ if (enable_allow_overlap)
3416
+ ImGui::SetNextItemAllowOverlap();
3417
+ ImGui::Button("Button 1", ImVec2(80, 80));
3418
+ ImGui::SetCursorScreenPos(button2_pos);
3419
+ ImGui::Button("Button 2", ImVec2(80, 80));
3420
+
3421
+ // This is typically used with width-spanning items.
3422
+ // (note that Selectable() has a dedicated flag ImGuiSelectableFlags_AllowOverlap, which is a shortcut
3423
+ // for using SetNextItemAllowOverlap(). For demo purpose we use SetNextItemAllowOverlap() here.)
3424
+ if (enable_allow_overlap)
3425
+ ImGui::SetNextItemAllowOverlap();
3426
+ ImGui::Selectable("Some Selectable", false);
3427
+ ImGui::SameLine();
3428
+ ImGui::SmallButton("++");
3429
+
3430
+ ImGui::TreePop();
3431
+ }
3400
3432
}
3401
3433
3402
3434
static void ShowDemoWindowPopups()
0 commit comments