mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Internals: Columns renaming fields
This commit is contained in:
parent
1f6ad7a894
commit
b9ac127b0b
19
imgui.cpp
19
imgui.cpp
@ -1807,13 +1807,14 @@ float ImGuiMenuColumns::CalcExtraSpace(float avail_w)
|
|||||||
static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
|
static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
|
||||||
{
|
{
|
||||||
// Set cursor position and a few other things so that SetScrollHere() and Columns() can work when seeking cursor.
|
// Set cursor position and a few other things so that SetScrollHere() and Columns() can work when seeking cursor.
|
||||||
// FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. Consider moving within SetCursorXXX functions?
|
// FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue.
|
||||||
|
// The clipper should probably have a 4th step to display the last item in a regular manner.
|
||||||
ImGui::SetCursorPosY(pos_y);
|
ImGui::SetCursorPosY(pos_y);
|
||||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage.
|
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage.
|
||||||
window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
|
window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
|
||||||
if (window->DC.ColumnsSet)
|
if (window->DC.ColumnsSet)
|
||||||
window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
window->DC.ColumnsSet->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1
|
// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1
|
||||||
@ -12103,7 +12104,7 @@ void ImGui::Separator()
|
|||||||
if (window->DC.ColumnsSet)
|
if (window->DC.ColumnsSet)
|
||||||
{
|
{
|
||||||
PushColumnClipRect();
|
PushColumnClipRect();
|
||||||
window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y;
|
window->DC.ColumnsSet->LineMinY = window->DC.CursorPos.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12322,7 +12323,7 @@ void ImGui::NextColumn()
|
|||||||
PopClipRect();
|
PopClipRect();
|
||||||
|
|
||||||
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
||||||
columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
|
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||||
if (++columns->Current < columns->Count)
|
if (++columns->Current < columns->Count)
|
||||||
{
|
{
|
||||||
// Columns 1+ cancel out IndentX
|
// Columns 1+ cancel out IndentX
|
||||||
@ -12334,10 +12335,10 @@ void ImGui::NextColumn()
|
|||||||
window->DC.ColumnsOffsetX = 0.0f;
|
window->DC.ColumnsOffsetX = 0.0f;
|
||||||
window->DrawList->ChannelsSetCurrent(0);
|
window->DrawList->ChannelsSetCurrent(0);
|
||||||
columns->Current = 0;
|
columns->Current = 0;
|
||||||
columns->CellMinY = columns->CellMaxY;
|
columns->LineMinY = columns->LineMaxY;
|
||||||
}
|
}
|
||||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
||||||
window->DC.CursorPos.y = columns->CellMinY;
|
window->DC.CursorPos.y = columns->LineMinY;
|
||||||
window->DC.CurrentLineHeight = 0.0f;
|
window->DC.CurrentLineHeight = 0.0f;
|
||||||
window->DC.CurrentLineTextBaseOffset = 0.0f;
|
window->DC.CurrentLineTextBaseOffset = 0.0f;
|
||||||
|
|
||||||
@ -12508,7 +12509,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
|||||||
columns->MaxX = ImMax(content_region_width - window->Scroll.x, columns->MinX + 1.0f);
|
columns->MaxX = ImMax(content_region_width - window->Scroll.x, columns->MinX + 1.0f);
|
||||||
columns->StartPosY = window->DC.CursorPos.y;
|
columns->StartPosY = window->DC.CursorPos.y;
|
||||||
columns->StartMaxPosX = window->DC.CursorMaxPos.x;
|
columns->StartMaxPosX = window->DC.CursorMaxPos.x;
|
||||||
columns->CellMinY = columns->CellMaxY = window->DC.CursorPos.y;
|
columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
|
||||||
window->DC.ColumnsOffsetX = 0.0f;
|
window->DC.ColumnsOffsetX = 0.0f;
|
||||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
||||||
|
|
||||||
@ -12555,8 +12556,8 @@ void ImGui::EndColumns()
|
|||||||
PopClipRect();
|
PopClipRect();
|
||||||
window->DrawList->ChannelsMerge();
|
window->DrawList->ChannelsMerge();
|
||||||
|
|
||||||
columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
|
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||||
window->DC.CursorPos.y = columns->CellMaxY;
|
window->DC.CursorPos.y = columns->LineMaxY;
|
||||||
if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
|
if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
|
||||||
window->DC.CursorMaxPos.x = ImMax(columns->StartMaxPosX, columns->MaxX); // Restore cursor max pos, as columns don't grow parent
|
window->DC.CursorMaxPos.x = ImMax(columns->StartMaxPosX, columns->MaxX); // Restore cursor max pos, as columns don't grow parent
|
||||||
|
|
||||||
|
@ -462,9 +462,9 @@ struct ImGuiColumnsSet
|
|||||||
int Current;
|
int Current;
|
||||||
int Count;
|
int Count;
|
||||||
float MinX, MaxX;
|
float MinX, MaxX;
|
||||||
float StartPosY;
|
float LineMinY, LineMaxY;
|
||||||
float StartMaxPosX; // Backup of CursorMaxPos
|
float StartPosY; // Copy of CursorPos
|
||||||
float CellMinY, CellMaxY;
|
float StartMaxPosX; // Copy of CursorMaxPos
|
||||||
ImVector<ImGuiColumnData> Columns;
|
ImVector<ImGuiColumnData> Columns;
|
||||||
|
|
||||||
ImGuiColumnsSet() { Clear(); }
|
ImGuiColumnsSet() { Clear(); }
|
||||||
@ -477,9 +477,9 @@ struct ImGuiColumnsSet
|
|||||||
Current = 0;
|
Current = 0;
|
||||||
Count = 1;
|
Count = 1;
|
||||||
MinX = MaxX = 0.0f;
|
MinX = MaxX = 0.0f;
|
||||||
|
LineMinY = LineMaxY = 0.0f;
|
||||||
StartPosY = 0.0f;
|
StartPosY = 0.0f;
|
||||||
StartMaxPosX = 0.0f;
|
StartMaxPosX = 0.0f;
|
||||||
CellMinY = CellMaxY = 0.0f;
|
|
||||||
Columns.clear();
|
Columns.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user