mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 14:16:36 +00:00
Internals: Added InnerWorkRect equal to old InnerClipRect, added InnerWorkRectClipped actually clipped.
This commit is contained in:
parent
b85e97137d
commit
7bc03f7155
28
imgui.cpp
28
imgui.cpp
@ -5479,16 +5479,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->OuterRectClipped = window->Rect();
|
||||
window->OuterRectClipped.ClipWith(host_rect);
|
||||
|
||||
// Inner clipping rectangle will extend a little bit outside the work region.
|
||||
// Inner work/clipping rectangle will extend a little bit outside the work region.
|
||||
// This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space.
|
||||
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
|
||||
// FIXME: This is currently not clipped by the host rectangle, which is misleading because our call to PushClipRect() below will do it anyway.
|
||||
// If we fix the value in InnerClipRect, which is desirable, we need to fix the two lines of code relying on it.
|
||||
window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerMainRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
|
||||
window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerMainRect.Min.y);
|
||||
window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerMainRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
|
||||
window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerMainRect.Max.y);
|
||||
//window->InnerClipRect.ClipWithFull(host_rect);
|
||||
window->InnerWorkRect.Min.x = ImFloor(0.5f + window->InnerMainRect.Min.x + ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
|
||||
window->InnerWorkRect.Min.y = ImFloor(0.5f + window->InnerMainRect.Min.y);
|
||||
window->InnerWorkRect.Max.x = ImFloor(0.5f + window->InnerMainRect.Max.x - ImMax(0.0f, ImFloor(window->WindowPadding.x * 0.5f - window->WindowBorderSize)));
|
||||
window->InnerWorkRect.Max.y = ImFloor(0.5f + window->InnerMainRect.Max.y);
|
||||
window->InnerWorkRectClipped = window->InnerWorkRect;
|
||||
window->InnerWorkRectClipped.ClipWithFull(host_rect);
|
||||
|
||||
// DRAWING
|
||||
|
||||
@ -5614,7 +5613,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
SetCurrentWindow(window);
|
||||
}
|
||||
|
||||
PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
|
||||
PushClipRect(window->InnerWorkRectClipped.Min, window->InnerWorkRectClipped.Max, true);
|
||||
|
||||
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
|
||||
if (first_begin_of_the_frame)
|
||||
@ -8653,7 +8652,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
window->DC.CurrentColumns = columns;
|
||||
|
||||
// Set state for first column
|
||||
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->InnerClipRect.Max.x - window->Pos.x);
|
||||
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->InnerWorkRect.Max.x - window->Pos.x);
|
||||
columns->OffMinX = window->DC.Indent.x - g.Style.ItemSpacing.x; // Lock our horizontal range
|
||||
columns->OffMaxX = ImMax(content_region_width - window->Scroll.x, columns->OffMinX + 1.0f);
|
||||
columns->HostCursorPosY = window->DC.CursorPos.y;
|
||||
@ -9701,10 +9700,10 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
return;
|
||||
}
|
||||
|
||||
enum { RT_OuterRect, RT_OuterRectClipped, RT_InnerMainRect, RT_InnerClipRect, RT_ContentsRegionRect, RT_ContentsFullRect };
|
||||
enum { RT_OuterRect, RT_OuterRectClipped, RT_InnerMainRect, RT_InnerWorkRect, RT_InnerWorkRectClipped, RT_ContentsRegionRect, RT_ContentsFullRect };
|
||||
static bool show_windows_begin_order = false;
|
||||
static bool show_windows_rects = false;
|
||||
static int show_windows_rect_type = RT_ContentsRegionRect;
|
||||
static int show_windows_rect_type = RT_InnerWorkRect;
|
||||
static bool show_drawcmd_clip_rects = true;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -9918,7 +9917,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::Checkbox("Show windows rectangles", &show_windows_rects);
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12);
|
||||
show_windows_rects |= ImGui::Combo("##rects_type", &show_windows_rect_type, "OuterRect\0" "OuterRectClipped\0" "InnerMainRect\0" "InnerClipRect\0" "ContentsRegionRect\0");
|
||||
show_windows_rects |= ImGui::Combo("##rects_type", &show_windows_rect_type, "OuterRect\0" "OuterRectClipped\0" "InnerMainRect\0" "InnerWorkRect\0" "InnerWorkRectClipped\0" "ContentsRegionRect\0");
|
||||
ImGui::Checkbox("Show clipping rectangle when hovering ImDrawCmd node", &show_drawcmd_clip_rects);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@ -9937,7 +9936,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
if (show_windows_rect_type == RT_OuterRect) { r = window->Rect(); }
|
||||
else if (show_windows_rect_type == RT_OuterRectClipped) { r = window->OuterRectClipped; }
|
||||
else if (show_windows_rect_type == RT_InnerMainRect) { r = window->InnerMainRect; }
|
||||
else if (show_windows_rect_type == RT_InnerClipRect) { r = window->InnerClipRect; }
|
||||
else if (show_windows_rect_type == RT_InnerWorkRect) { r = window->InnerWorkRect; }
|
||||
else if (show_windows_rect_type == RT_InnerWorkRectClipped) { r = window->InnerWorkRectClipped; }
|
||||
else if (show_windows_rect_type == RT_ContentsRegionRect) { r = window->ContentsRegionRect; }
|
||||
draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255));
|
||||
}
|
||||
|
@ -1292,7 +1292,8 @@ struct IMGUI_API ImGuiWindow
|
||||
ImRect ClipRect; // Current clipping rectangle. = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
||||
ImRect OuterRectClipped; // == WindowRect just after setup in Begin(). == window->Rect() for root window.
|
||||
ImRect InnerMainRect; //
|
||||
ImRect InnerClipRect; // == InnerMainRect, minus WindowPadding on each side, clipped within viewport or parent.
|
||||
ImRect InnerWorkRect; // == InnerMainRect minus WindowPadding.x
|
||||
ImRect InnerWorkRectClipped; // == InnerMainRect minus WindowPadding.x, clipped within viewport or parent clip rect.
|
||||
ImRect ContentsRegionRect; // FIXME: This is currently confusing/misleading. Maximum visible content position ~~ Pos + (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
|
||||
int LastFrameActive; // Last frame number the window was Active.
|
||||
float ItemWidthDefault;
|
||||
|
@ -6227,7 +6227,7 @@ bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags)
|
||||
|
||||
ImGuiID id = window->GetID(str_id);
|
||||
ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id);
|
||||
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->InnerClipRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
|
||||
ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->InnerWorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2);
|
||||
tab_bar->ID = id;
|
||||
return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user