mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 14:36:34 +00:00
Internal: Columns: Allow to use BeginColumns(1) so code designed for variable number of columns can still call NextColumn etc. (#125)
This commit is contained in:
parent
e9651aaa77
commit
f717df4eb6
27
imgui.cpp
27
imgui.cpp
@ -8210,10 +8210,18 @@ void ImGui::NextColumn()
|
||||
return;
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
||||
|
||||
if (columns->Count == 1)
|
||||
{
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||
IM_ASSERT(columns->Current == 0);
|
||||
return;
|
||||
}
|
||||
|
||||
PopItemWidth();
|
||||
PopClipRect();
|
||||
|
||||
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
||||
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||
if (++columns->Current < columns->Count)
|
||||
{
|
||||
@ -8223,6 +8231,7 @@ void ImGui::NextColumn()
|
||||
}
|
||||
else
|
||||
{
|
||||
// New line
|
||||
window->DC.ColumnsOffset.x = 0.0f;
|
||||
window->DrawList->ChannelsSetCurrent(0);
|
||||
columns->Current = 0;
|
||||
@ -8377,7 +8386,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
||||
IM_ASSERT(columns_count > 1);
|
||||
IM_ASSERT(columns_count >= 1);
|
||||
IM_ASSERT(window->DC.ColumnsSet == NULL); // Nested columns are currently not supported
|
||||
|
||||
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
|
||||
@ -8431,8 +8440,11 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
column->ClipRect.ClipWith(window->ClipRect);
|
||||
}
|
||||
|
||||
window->DrawList->ChannelsSplit(columns->Count);
|
||||
PushColumnClipRect();
|
||||
if (columns->Count > 1)
|
||||
{
|
||||
window->DrawList->ChannelsSplit(columns->Count);
|
||||
PushColumnClipRect();
|
||||
}
|
||||
PushItemWidth(GetColumnWidth() * 0.65f);
|
||||
}
|
||||
|
||||
@ -8444,8 +8456,11 @@ void ImGui::EndColumns()
|
||||
IM_ASSERT(columns != NULL);
|
||||
|
||||
PopItemWidth();
|
||||
PopClipRect();
|
||||
window->DrawList->ChannelsMerge();
|
||||
if (columns->Count > 1)
|
||||
{
|
||||
PopClipRect();
|
||||
window->DrawList->ChannelsMerge();
|
||||
}
|
||||
|
||||
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||
window->DC.CursorPos.y = columns->LineMaxY;
|
||||
|
Loading…
Reference in New Issue
Block a user