mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Columns/Internals: (Breaking) renamed ImGuiColumnsFlags_* to ImGuiOldColumnFlags_*. (#125, #513, #913, #1204, #1444, #2142, #2707)
Affected: ImGuiColumnsFlags_None, ImGuiColumnsFlags_NoBorder, ImGuiColumnsFlags_NoResize, ImGuiColumnsFlags_NoPreserveWidths, ImGuiColumnsFlags_NoForceWithinWindow, ImGuiColumnsFlags_GrowParentContentsSize. Added redirection enums. Did not add redirection type.
This commit is contained in:
@ -7930,7 +7930,7 @@ static float GetDraggedColumnOffset(ImGuiColumns* columns, int column_index)
|
||||
|
||||
float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + COLUMNS_HIT_RECT_HALF_WIDTH - window->Pos.x;
|
||||
x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing);
|
||||
if ((columns->Flags & ImGuiColumnsFlags_NoPreserveWidths))
|
||||
if ((columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths))
|
||||
x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing);
|
||||
|
||||
return x;
|
||||
@ -7989,10 +7989,10 @@ void ImGui::SetColumnOffset(int column_index, float offset)
|
||||
column_index = columns->Current;
|
||||
IM_ASSERT(column_index < columns->Columns.Size);
|
||||
|
||||
const bool preserve_width = !(columns->Flags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < columns->Count - 1);
|
||||
const bool preserve_width = !(columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths) && (column_index < columns->Count - 1);
|
||||
const float width = preserve_width ? GetColumnWidthEx(columns, column_index, columns->IsBeingResized) : 0.0f;
|
||||
|
||||
if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow))
|
||||
if (!(columns->Flags & ImGuiOldColumnFlags_NoForceWithinWindow))
|
||||
offset = ImMin(offset, columns->OffMaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index));
|
||||
columns->Columns[column_index].OffsetNorm = GetColumnNormFromOffset(columns, offset - columns->OffMinX);
|
||||
|
||||
@ -8074,7 +8074,7 @@ ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count)
|
||||
return id;
|
||||
}
|
||||
|
||||
void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlags flags)
|
||||
void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -8220,16 +8220,16 @@ void ImGui::EndColumns()
|
||||
columns->Splitter.Merge(window->DrawList);
|
||||
}
|
||||
|
||||
const ImGuiColumnsFlags flags = columns->Flags;
|
||||
const ImGuiOldColumnFlags flags = columns->Flags;
|
||||
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||
window->DC.CursorPos.y = columns->LineMaxY;
|
||||
if (!(flags & ImGuiColumnsFlags_GrowParentContentsSize))
|
||||
if (!(flags & ImGuiOldColumnFlags_GrowParentContentsSize))
|
||||
window->DC.CursorMaxPos.x = columns->HostCursorMaxPosX; // Restore cursor max pos, as columns don't grow parent
|
||||
|
||||
// Draw columns borders and handle resize
|
||||
// The IsBeingResized flag ensure we preserve pre-resize columns width so back-and-forth are not lossy
|
||||
bool is_being_resized = false;
|
||||
if (!(flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
|
||||
if (!(flags & ImGuiOldColumnFlags_NoBorder) && !window->SkipItems)
|
||||
{
|
||||
// We clip Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.
|
||||
const float y1 = ImMax(columns->HostCursorPosY, window->ClipRect.Min.y);
|
||||
@ -8247,12 +8247,12 @@ void ImGui::EndColumns()
|
||||
continue;
|
||||
|
||||
bool hovered = false, held = false;
|
||||
if (!(flags & ImGuiColumnsFlags_NoResize))
|
||||
if (!(flags & ImGuiOldColumnFlags_NoResize))
|
||||
{
|
||||
ButtonBehavior(column_hit_rect, column_id, &hovered, &held);
|
||||
if (hovered || held)
|
||||
g.MouseCursor = ImGuiMouseCursor_ResizeEW;
|
||||
if (held && !(column->Flags & ImGuiColumnsFlags_NoResize))
|
||||
if (held && !(column->Flags & ImGuiOldColumnFlags_NoResize))
|
||||
dragging_column = n;
|
||||
}
|
||||
|
||||
@ -8282,14 +8282,13 @@ void ImGui::EndColumns()
|
||||
window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||
}
|
||||
|
||||
// [2018-03: This is currently the only public API, while we are working on making BeginColumns/EndColumns user-facing]
|
||||
void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
IM_ASSERT(columns_count >= 1);
|
||||
|
||||
ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder);
|
||||
//flags |= ImGuiColumnsFlags_NoPreserveWidths; // NB: Legacy behavior
|
||||
ImGuiOldColumnFlags flags = (border ? 0 : ImGuiOldColumnFlags_NoBorder);
|
||||
//flags |= ImGuiOldColumnFlags_NoPreserveWidths; // NB: Legacy behavior
|
||||
ImGuiColumns* columns = window->DC.CurrentColumns;
|
||||
if (columns != NULL && columns->Count == columns_count && columns->Flags == flags)
|
||||
return;
|
||||
|
Reference in New Issue
Block a user