mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 21:17:01 +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
67
imgui.cpp
67
imgui.cpp
@ -9893,37 +9893,62 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
// Horizontal separating line.
|
// Horizontal separating line.
|
||||||
void ImGui::Separator()
|
void ImGui::Separator()
|
||||||
{
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window->DC.ColumnsCount > 1)
|
ImGuiWindowFlags flags = 0;
|
||||||
PopClipRect();
|
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
|
||||||
|
|
||||||
float x1 = window->Pos.x;
|
if (flags & ImGuiSeparatorFlags_Horizontal)
|
||||||
float x2 = window->Pos.x + window->Size.x;
|
|
||||||
if (!window->DC.GroupStack.empty())
|
|
||||||
x1 += window->DC.IndentX;
|
|
||||||
|
|
||||||
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y+1.0f));
|
|
||||||
ItemSize(ImVec2(0.0f, 0.0f)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit, we don't provide height to not alter layout.
|
|
||||||
if (!ItemAdd(bb, NULL))
|
|
||||||
{
|
{
|
||||||
if (window->DC.ColumnsCount > 1)
|
if (window->DC.ColumnsCount > 1)
|
||||||
|
PopClipRect();
|
||||||
|
|
||||||
|
float x1 = window->Pos.x;
|
||||||
|
float x2 = window->Pos.x + window->Size.x;
|
||||||
|
if (!window->DC.GroupStack.empty())
|
||||||
|
x1 += window->DC.IndentX;
|
||||||
|
|
||||||
|
const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y+1.0f));
|
||||||
|
ItemSize(ImVec2(0.0f, 0.0f)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit, we don't provide height to not alter layout.
|
||||||
|
if (!ItemAdd(bb, NULL))
|
||||||
|
{
|
||||||
|
if (window->DC.ColumnsCount > 1)
|
||||||
|
PushColumnClipRect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x,bb.Min.y), GetColorU32(ImGuiCol_Separator));
|
||||||
|
|
||||||
|
if (g.LogEnabled)
|
||||||
|
LogText(IM_NEWLINE "--------------------------------");
|
||||||
|
|
||||||
|
if (window->DC.ColumnsCount > 1)
|
||||||
|
{
|
||||||
PushColumnClipRect();
|
PushColumnClipRect();
|
||||||
return;
|
window->DC.ColumnsCellMinY = window->DC.CursorPos.y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (flags & ImGuiSeparatorFlags_Vertical)
|
||||||
window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x,bb.Min.y), GetColorU32(ImGuiCol_Separator));
|
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
if (g.LogEnabled)
|
|
||||||
LogText(IM_NEWLINE "--------------------------------");
|
|
||||||
|
|
||||||
if (window->DC.ColumnsCount > 1)
|
|
||||||
{
|
{
|
||||||
PushColumnClipRect();
|
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(1.0f, window->DC.CurrentLineHeight));
|
||||||
window->DC.ColumnsCellMinY = window->DC.CursorPos.y;
|
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("|");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
|||||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
||||||
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
||||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
||||||
|
typedef int ImGuiSeparatorFlags; // enum ImGuiSeparatorFlags_
|
||||||
typedef int ImGuiItemFlags; // enum ImGuiItemFlags_
|
typedef int ImGuiItemFlags; // enum ImGuiItemFlags_
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -203,6 +204,12 @@ enum ImGuiSelectableFlagsPrivate_
|
|||||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
|
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.
|
// FIXME: this is in development, not exposed/functional as a generic feature yet.
|
||||||
enum ImGuiLayoutType_
|
enum ImGuiLayoutType_
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user