Added VerticalSeparator() entry point in imgui_internal. Seperator() in an horizontal layout context still does that.

This commit is contained in:
omar 2017-09-28 16:41:01 +02:00
parent 9142002121
commit f99348711b
3 changed files with 49 additions and 42 deletions

View File

@ -9879,23 +9879,22 @@ 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;
ImGuiContext& g = *GImGui;
ImGuiWindowFlags flags = 0;
if ((flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)) == 0)
{
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
flags |= ImGuiSeparatorFlags_Vertical;
else
flags |= ImGuiSeparatorFlags_Horizontal;
}
flags |= (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal;
IM_ASSERT(ImIsPowerOfTwo((int)(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical)))); // Check that only 1 option is selected
if (flags & ImGuiSeparatorFlags_Horizontal)
if (flags & ImGuiSeparatorFlags_Vertical)
{
VerticalSeparator();
return;
}
// Horizontal Separator
if (window->DC.ColumnsCount > 1)
PopClipRect();
@ -9924,19 +9923,25 @@ void ImGui::Separator()
window->DC.ColumnsCellMinY = window->DC.CursorPos.y;
}
}
else if (flags & ImGuiSeparatorFlags_Vertical)
void ImGui::VerticalSeparator()
{
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(1.0f, window->DC.CurrentLineHeight));
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiContext& g = *GImGui;
float y1 = window->DC.CursorPos.y;
float y2 = window->DC.CursorPos.y + window->DC.CurrentLineHeight;
const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + 1.0f, y2));
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()
{

View File

@ -209,7 +209,7 @@ namespace ImGui
IMGUI_API void PopButtonRepeat();
// Cursor / Layout
IMGUI_API void Separator(); // horizontal line
IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator.
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
IMGUI_API void NewLine(); // undo a SameLine()
IMGUI_API void Spacing(); // add vertical spacing

View File

@ -789,6 +789,8 @@ namespace ImGui
IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
IMGUI_API void VerticalSeparator(); // Vertical separator, for menu bars (use current line height). not exposed because it is misleading what it doesn't have an effect on regular layout.
// FIXME-WIP: New Columns API
IMGUI_API void BeginColumns(const char* id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
IMGUI_API void EndColumns(); // close columns