Internals: SeparatorEx(): expose thickness + add misc comments relating to Separators.
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index c35f99d..2d175c9 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -398,23 +398,21 @@
IMGUI_DEMO_MARKER("Help");
if (ImGui::CollapsingHeader("Help"))
{
- ImGui::Text("ABOUT THIS DEMO:");
+ ImGui::SeparatorText("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/Debugger (general purpose Dear ImGui debugging tool).");
- ImGui::Separator();
- ImGui::Text("PROGRAMMER GUIDE:");
+ ImGui::SeparatorText("PROGRAMMER GUIDE:");
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.com/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:");
+ ImGui::SeparatorText("USER GUIDE:");
ImGui::ShowUserGuide();
}
diff --git a/imgui_internal.h b/imgui_internal.h
index 5d78f2c..3974854 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -903,7 +903,7 @@
ImGuiSeparatorFlags_None = 0,
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
ImGuiSeparatorFlags_Vertical = 1 << 1,
- ImGuiSeparatorFlags_SpanAllColumns = 1 << 2,
+ ImGuiSeparatorFlags_SpanAllColumns = 1 << 2, // Make separator cover all columns of a legacy Columns() set.
};
// Flags for FocusWindow(). This is not called ImGuiFocusFlags to avoid confusion with public-facing ImGuiFocusedFlags.
@@ -3128,7 +3128,7 @@
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags = 0);
- IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags);
+ IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags, float thickness);
IMGUI_API void SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_width);
IMGUI_API bool CheckboxFlags(const char* label, ImS64* flags, ImS64 flags_value);
IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value);
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index c451a5c..18e34e9 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -1392,8 +1392,9 @@
}
// Horizontal/vertical separating line
-// FIXME: Surprisingly, this seemingly simple widget is adjacent to MANY different legacy/tricky layout issues.
-void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
+// FIXME: Surprisingly, this seemingly trivial widget is a victim of many different legacy/tricky layout issues.
+// Note how thickness == 1.0f is handled specifically as not moving CursorPos by 'thickness', but other values are.
+void ImGui::SeparatorEx(ImGuiSeparatorFlags flags, float thickness)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
@@ -1401,8 +1402,8 @@
ImGuiContext& g = *GImGui;
IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected
+ IM_ASSERT(thickness > 0.0f);
- const float thickness = 1.0f; // Cannot use g.Style.SeparatorTextSize yet for various reasons.
if (flags & ImGuiSeparatorFlags_Vertical)
{
// Vertical separator, for menu bars (use current line height).
@@ -1436,6 +1437,8 @@
x2 = table->Columns[table->CurrentColumn].MaxX;
}
+ // Before Tables API happened, we relied on Separator() to span all columns of a Columns() set.
+ // We currently don't need to provide the same feature for tables because tables naturally have border features.
ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
if (columns)
PushColumnsBackground();
@@ -1445,8 +1448,8 @@
const float thickness_for_layout = (thickness == 1.0f) ? 0.0f : thickness; // FIXME: See 1.70/1.71 Separator() change: makes legacy 1-px separator not affect layout yet. Should change.
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness));
ItemSize(ImVec2(0.0f, thickness_for_layout));
- const bool item_visible = ItemAdd(bb, 0);
- if (item_visible)
+
+ if (ItemAdd(bb, 0))
{
// Draw
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator));
@@ -1469,10 +1472,11 @@
if (window->SkipItems)
return;
- // Those flags should eventually be overridable by the user
+ // Those flags should eventually be configurable by the user
+ // FIXME: We cannot g.Style.SeparatorTextBorderSize for thickness as it relates to SeparatorText() which is a decorated separator, not defaulting to 1.0f.
ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal;
flags |= ImGuiSeparatorFlags_SpanAllColumns; // NB: this only applies to legacy Columns() api as they relied on Separator() a lot.
- SeparatorEx(flags);
+ SeparatorEx(flags, 1.0f);
}
void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w)
@@ -1532,8 +1536,8 @@
return;
// The SeparatorText() vs SeparatorTextEx() distinction is designed to be considerate that we may want:
- // - allow headers to be draggable items (would require a stable ID + a noticeable highlight)
- // - this high-level entry point to allow formatting? (may require ID separate from formatted string)
+ // - allow separator-text to be draggable items (would require a stable ID + a noticeable highlight)
+ // - this high-level entry point to allow formatting? (which in turns may require ID separate from formatted string)
// - because of this we probably can't turn 'const char* label' into 'const char* fmt, ...'
// Otherwise, we can decide that users wanting to drag this would layout a dedicated drag-item,
// and then we can turn this into a format function.