mirror of
https://github.com/shadps4-emu/ext-imgui.git
synced 2024-11-23 18:29:42 +00:00
Separator(): output vertical separator when used in horizontal layout mode, so it works in menu bars.
This commit is contained in:
parent
c7a606ab7e
commit
be03882a15
27
imgui.cpp
27
imgui.cpp
@ -9893,10 +9893,23 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
// Horizontal separating line.
|
||||
void ImGui::Separator()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiWindowFlags flags = 0;
|
||||
if ((flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)) == 0)
|
||||
{
|
||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||
flags |= ImGuiSeparatorFlags_Vertical;
|
||||
else
|
||||
flags |= ImGuiSeparatorFlags_Horizontal;
|
||||
}
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)))); // Check that only 1 option is selected
|
||||
|
||||
if (flags & ImGuiSeparatorFlags_Horizontal)
|
||||
{
|
||||
if (window->DC.ColumnsCount > 1)
|
||||
PopClipRect();
|
||||
|
||||
@ -9916,7 +9929,6 @@ void ImGui::Separator()
|
||||
|
||||
window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x,bb.Min.y), GetColorU32(ImGuiCol_Separator));
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.LogEnabled)
|
||||
LogText(IM_NEWLINE "--------------------------------");
|
||||
|
||||
@ -9926,6 +9938,19 @@ void ImGui::Separator()
|
||||
window->DC.ColumnsCellMinY = window->DC.CursorPos.y;
|
||||
}
|
||||
}
|
||||
else if (flags & ImGuiSeparatorFlags_Vertical)
|
||||
{
|
||||
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(1.0f, window->DC.CurrentLineHeight));
|
||||
ItemSize(ImVec2(bb.GetWidth(), 0.0f));
|
||||
if (!ItemAdd(bb, NULL))
|
||||
return;
|
||||
|
||||
window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator));
|
||||
|
||||
if (g.LogEnabled)
|
||||
LogText("|");
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::Spacing()
|
||||
{
|
||||
|
@ -48,6 +48,7 @@ typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
||||
typedef int ImGuiSeparatorFlags; // enum ImGuiSeparatorFlags_
|
||||
typedef int ImGuiItemFlags; // enum ImGuiItemFlags_
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -203,6 +204,12 @@ enum ImGuiSelectableFlagsPrivate_
|
||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
|
||||
};
|
||||
|
||||
enum ImGuiSeparatorFlags_
|
||||
{
|
||||
ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar
|
||||
ImGuiSeparatorFlags_Vertical = 1 << 1
|
||||
};
|
||||
|
||||
// FIXME: this is in development, not exposed/functional as a generic feature yet.
|
||||
enum ImGuiLayoutType_
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user