mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 07:40:22 +01:00
Internals: SeparatorEx(): expose thickness + add misc comments relating to Separators.
This commit is contained in:
parent
c8579abb43
commit
2c558d5741
@ -398,23 +398,21 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
IMGUI_DEMO_MARKER("Help");
|
IMGUI_DEMO_MARKER("Help");
|
||||||
if (ImGui::CollapsingHeader("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("Sections below are demonstrating many aspects of the library.");
|
||||||
ImGui::BulletText("The \"Examples\" menu above leads to more demo contents.");
|
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"
|
ImGui::BulletText("The \"Tools\" menu above gives access to: About Box, Style Editor,\n"
|
||||||
"and Metrics/Debugger (general purpose Dear ImGui debugging tool).");
|
"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 the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!");
|
||||||
ImGui::BulletText("See comments in imgui.cpp.");
|
ImGui::BulletText("See comments in imgui.cpp.");
|
||||||
ImGui::BulletText("See example applications in the examples/ folder.");
|
ImGui::BulletText("See example applications in the examples/ folder.");
|
||||||
ImGui::BulletText("Read the FAQ at http://www.dearimgui.com/faq/");
|
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 |= NavEnableKeyboard' for keyboard controls.");
|
||||||
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
|
ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.");
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
ImGui::Text("USER GUIDE:");
|
ImGui::SeparatorText("USER GUIDE:");
|
||||||
ImGui::ShowUserGuide();
|
ImGui::ShowUserGuide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,7 +903,7 @@ enum ImGuiSeparatorFlags_
|
|||||||
ImGuiSeparatorFlags_None = 0,
|
ImGuiSeparatorFlags_None = 0,
|
||||||
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
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_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.
|
// Flags for FocusWindow(). This is not called ImGuiFocusFlags to avoid confusion with public-facing ImGuiFocusedFlags.
|
||||||
@ -3128,7 +3128,7 @@ namespace ImGui
|
|||||||
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
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 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 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 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, ImS64* flags, ImS64 flags_value);
|
||||||
IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value);
|
IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value);
|
||||||
|
@ -1392,8 +1392,9 @@ void ImGui::AlignTextToFramePadding()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Horizontal/vertical separating line
|
// Horizontal/vertical separating line
|
||||||
// FIXME: Surprisingly, this seemingly simple widget is adjacent to MANY different legacy/tricky layout issues.
|
// FIXME: Surprisingly, this seemingly trivial widget is a victim of many different legacy/tricky layout issues.
|
||||||
void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
// 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();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
@ -1401,8 +1402,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
|||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected
|
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)
|
if (flags & ImGuiSeparatorFlags_Vertical)
|
||||||
{
|
{
|
||||||
// Vertical separator, for menu bars (use current line height).
|
// Vertical separator, for menu bars (use current line height).
|
||||||
@ -1436,6 +1437,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
|||||||
x2 = table->Columns[table->CurrentColumn].MaxX;
|
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;
|
ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL;
|
||||||
if (columns)
|
if (columns)
|
||||||
PushColumnsBackground();
|
PushColumnsBackground();
|
||||||
@ -1445,8 +1448,8 @@ void ImGui::SeparatorEx(ImGuiSeparatorFlags flags)
|
|||||||
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 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));
|
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness));
|
||||||
ItemSize(ImVec2(0.0f, thickness_for_layout));
|
ItemSize(ImVec2(0.0f, thickness_for_layout));
|
||||||
const bool item_visible = ItemAdd(bb, 0);
|
|
||||||
if (item_visible)
|
if (ItemAdd(bb, 0))
|
||||||
{
|
{
|
||||||
// Draw
|
// Draw
|
||||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator));
|
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator));
|
||||||
@ -1469,10 +1472,11 @@ void ImGui::Separator()
|
|||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return;
|
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;
|
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.
|
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)
|
void ImGui::SeparatorTextEx(ImGuiID id, const char* label, const char* label_end, float extra_w)
|
||||||
@ -1532,8 +1536,8 @@ void ImGui::SeparatorText(const char* label)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// The SeparatorText() vs SeparatorTextEx() distinction is designed to be considerate that we may want:
|
// 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)
|
// - allow separator-text 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)
|
// - 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, ...'
|
// - 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,
|
// 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.
|
// and then we can turn this into a format function.
|
||||||
|
Loading…
Reference in New Issue
Block a user