mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 15:50:25 +01:00
Internals: Columns: Poke into WorkRect and use them in the GetContentRegionMax() functions. This should be a no-op, but preparing us to transition toward using WorkRect instead of ContentRegionRect.
Removed one use of ContentsRegionRect.
This commit is contained in:
parent
e9b92d1cef
commit
ae2c9f7101
35
imgui.cpp
35
imgui.cpp
@ -2249,8 +2249,8 @@ static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
|
|||||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() 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 SetScrollHereY() can properly function after the end of our clipper usage.
|
||||||
window->DC.PrevLineSize.y = (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.PrevLineSize.y = (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.CurrentColumns)
|
if (ImGuiColumns* columns = window->DC.CurrentColumns)
|
||||||
window->DC.CurrentColumns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
columns->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
|
||||||
@ -3423,7 +3423,7 @@ void ImGui::UpdateMouseWheel()
|
|||||||
const bool scroll_allowed = !(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs);
|
const bool scroll_allowed = !(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs);
|
||||||
if (scroll_allowed && (g.IO.MouseWheel != 0.0f || g.IO.MouseWheelH != 0.0f) && !g.IO.KeyCtrl)
|
if (scroll_allowed && (g.IO.MouseWheel != 0.0f || g.IO.MouseWheelH != 0.0f) && !g.IO.KeyCtrl)
|
||||||
{
|
{
|
||||||
ImVec2 max_step = (window->ContentsRegionRect.GetSize() + window->WindowPadding * 2.0f) * 0.67f;
|
ImVec2 max_step = window->InnerRect.GetSize() * 0.67f;
|
||||||
|
|
||||||
// Vertical Mouse Wheel Scrolling (hold Shift to scroll horizontally)
|
// Vertical Mouse Wheel Scrolling (hold Shift to scroll horizontally)
|
||||||
if (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift)
|
if (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift)
|
||||||
@ -5872,7 +5872,7 @@ void ImGui::End()
|
|||||||
|
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
|
||||||
if (window->DC.CurrentColumns != NULL)
|
if (window->DC.CurrentColumns)
|
||||||
EndColumns();
|
EndColumns();
|
||||||
PopClipRect(); // Inner window clip rectangle
|
PopClipRect(); // Inner window clip rectangle
|
||||||
|
|
||||||
@ -6649,7 +6649,7 @@ ImVec2 ImGui::GetContentRegionMax()
|
|||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
|
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
|
||||||
if (window->DC.CurrentColumns)
|
if (window->DC.CurrentColumns)
|
||||||
mx.x = GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
|
mx.x = window->WorkRect.Max.x - window->Pos.x;
|
||||||
return mx;
|
return mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6659,7 +6659,7 @@ ImVec2 ImGui::GetContentRegionMaxAbs()
|
|||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
ImVec2 mx = window->ContentsRegionRect.Max;
|
ImVec2 mx = window->ContentsRegionRect.Max;
|
||||||
if (window->DC.CurrentColumns)
|
if (window->DC.CurrentColumns)
|
||||||
mx.x = window->Pos.x + GetColumnOffset(window->DC.CurrentColumns->Current + 1) - window->WindowPadding.x;
|
mx.x = window->WorkRect.Max.x;
|
||||||
return mx;
|
return mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6672,19 +6672,19 @@ ImVec2 ImGui::GetContentRegionAvail()
|
|||||||
// In window space (not screen space!)
|
// In window space (not screen space!)
|
||||||
ImVec2 ImGui::GetWindowContentRegionMin()
|
ImVec2 ImGui::GetWindowContentRegionMin()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
return window->ContentsRegionRect.Min - window->Pos;
|
return window->ContentsRegionRect.Min - window->Pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 ImGui::GetWindowContentRegionMax()
|
ImVec2 ImGui::GetWindowContentRegionMax()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
return window->ContentsRegionRect.Max - window->Pos;
|
return window->ContentsRegionRect.Max - window->Pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::GetWindowContentRegionWidth()
|
float ImGui::GetWindowContentRegionWidth()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
return window->ContentsRegionRect.GetWidth();
|
return window->ContentsRegionRect.GetWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8655,7 +8655,13 @@ void ImGui::NextColumn()
|
|||||||
window->DC.CurrLineTextBaseOffset = 0.0f;
|
window->DC.CurrLineTextBaseOffset = 0.0f;
|
||||||
|
|
||||||
PushColumnClipRect(columns->Current); // FIXME-COLUMNS: Could it be an overwrite?
|
PushColumnClipRect(columns->Current); // FIXME-COLUMNS: Could it be an overwrite?
|
||||||
PushItemWidth(GetColumnWidth() * 0.65f); // FIXME-COLUMNS: Move on columns setup
|
|
||||||
|
// FIXME-COLUMNS: Share code with BeginColumns() - move code on columns setup.
|
||||||
|
float offset_0 = GetColumnOffset(columns->Current);
|
||||||
|
float offset_1 = GetColumnOffset(columns->Current + 1);
|
||||||
|
float width = offset_1 - offset_0;
|
||||||
|
PushItemWidth(width * 0.65f);
|
||||||
|
window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImGui::GetColumnIndex()
|
int ImGui::GetColumnIndex()
|
||||||
@ -8851,6 +8857,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
|||||||
columns->HostCursorPosY = window->DC.CursorPos.y;
|
columns->HostCursorPosY = window->DC.CursorPos.y;
|
||||||
columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x;
|
columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x;
|
||||||
columns->HostClipRect = window->ClipRect;
|
columns->HostClipRect = window->ClipRect;
|
||||||
|
columns->HostWorkRect = window->WorkRect;
|
||||||
columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
|
columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
|
||||||
window->DC.ColumnsOffset.x = 0.0f;
|
window->DC.ColumnsOffset.x = 0.0f;
|
||||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||||
@ -8888,7 +8895,12 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
|||||||
window->DrawList->ChannelsSetCurrent(1);
|
window->DrawList->ChannelsSetCurrent(1);
|
||||||
PushColumnClipRect(0);
|
PushColumnClipRect(0);
|
||||||
}
|
}
|
||||||
PushItemWidth(GetColumnWidth() * 0.65f);
|
|
||||||
|
float offset_0 = GetColumnOffset(columns->Current);
|
||||||
|
float offset_1 = GetColumnOffset(columns->Current + 1);
|
||||||
|
float width = offset_1 - offset_0;
|
||||||
|
PushItemWidth(width * 0.65f);
|
||||||
|
window->WorkRect.Max.x = window->Pos.x + offset_1 - window->WindowPadding.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::EndColumns()
|
void ImGui::EndColumns()
|
||||||
@ -8960,6 +8972,7 @@ void ImGui::EndColumns()
|
|||||||
}
|
}
|
||||||
columns->IsBeingResized = is_being_resized;
|
columns->IsBeingResized = is_being_resized;
|
||||||
|
|
||||||
|
window->WorkRect = columns->HostWorkRect;
|
||||||
window->DC.CurrentColumns = NULL;
|
window->DC.CurrentColumns = NULL;
|
||||||
window->DC.ColumnsOffset.x = 0.0f;
|
window->DC.ColumnsOffset.x = 0.0f;
|
||||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||||
|
@ -703,6 +703,7 @@ struct ImGuiColumns
|
|||||||
float HostCursorPosY; // Backup of CursorPos at the time of BeginColumns()
|
float HostCursorPosY; // Backup of CursorPos at the time of BeginColumns()
|
||||||
float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns()
|
float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns()
|
||||||
ImRect HostClipRect; // Backup of ClipRect at the time of BeginColumns()
|
ImRect HostClipRect; // Backup of ClipRect at the time of BeginColumns()
|
||||||
|
ImRect HostWorkRect; // Backup of WorkRect at the time of BeginColumns()
|
||||||
ImVector<ImGuiColumnData> Columns;
|
ImVector<ImGuiColumnData> Columns;
|
||||||
|
|
||||||
ImGuiColumns() { Clear(); }
|
ImGuiColumns() { Clear(); }
|
||||||
@ -1298,7 +1299,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
// The best way to understand what those rectangles are is to use the 'Metrics -> Tools -> Show windows rectangles' viewer.
|
// The best way to understand what those rectangles are is to use the 'Metrics -> Tools -> Show windows rectangles' viewer.
|
||||||
// The main 'OuterRect', omitted as a field, is window->Rect().
|
// The main 'OuterRect', omitted as a field, is window->Rect().
|
||||||
ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
|
ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
|
||||||
ImRect InnerRect; // Inner rectangle (omit title bar, menu bar)
|
ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar)
|
||||||
ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
|
ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect.
|
||||||
ImRect WorkRect; // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentsRegionRect over time (from 1.71+ onward).
|
ImRect WorkRect; // Cover the whole scrolling region, shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentsRegionRect over time (from 1.71+ onward).
|
||||||
ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
|
ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back().
|
||||||
|
Loading…
Reference in New Issue
Block a user