mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 23:31:08 +01:00
Internals: Renaming for consistency.
This commit is contained in:
parent
5006639526
commit
8fee5a4349
30
imgui.cpp
30
imgui.cpp
@ -5689,14 +5689,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->WorkRect.Max.x = window->WorkRect.Min.x + work_rect_size_x;
|
||||
window->WorkRect.Max.y = window->WorkRect.Min.y + work_rect_size_y;
|
||||
|
||||
// [LEGACY] Contents Region
|
||||
// FIXME-OBSOLETE: window->ContentsRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
|
||||
// [LEGACY] Content Region
|
||||
// FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
|
||||
// Used by:
|
||||
// - Mouse wheel scrolling + many other things
|
||||
window->ContentsRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
|
||||
window->ContentsRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height;
|
||||
window->ContentsRegionRect.Max.x = window->ContentsRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
|
||||
window->ContentsRegionRect.Max.y = window->ContentsRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
|
||||
window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
|
||||
window->ContentRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height;
|
||||
window->ContentRegionRect.Max.x = window->ContentRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
|
||||
window->ContentRegionRect.Max.y = window->ContentRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
|
||||
|
||||
// Setup drawing context
|
||||
// (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.)
|
||||
@ -6599,7 +6599,7 @@ ImVec2 ImGui::GetContentRegionMax()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
|
||||
ImVec2 mx = window->ContentRegionRect.Max - window->Pos;
|
||||
if (window->DC.CurrentColumns)
|
||||
mx.x = window->WorkRect.Max.x - window->Pos.x;
|
||||
return mx;
|
||||
@ -6610,7 +6610,7 @@ ImVec2 ImGui::GetContentRegionMaxAbs()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImVec2 mx = window->ContentsRegionRect.Max;
|
||||
ImVec2 mx = window->ContentRegionRect.Max;
|
||||
if (window->DC.CurrentColumns)
|
||||
mx.x = window->WorkRect.Max.x;
|
||||
return mx;
|
||||
@ -6626,19 +6626,19 @@ ImVec2 ImGui::GetContentRegionAvail()
|
||||
ImVec2 ImGui::GetWindowContentRegionMin()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->ContentsRegionRect.Min - window->Pos;
|
||||
return window->ContentRegionRect.Min - window->Pos;
|
||||
}
|
||||
|
||||
ImVec2 ImGui::GetWindowContentRegionMax()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->ContentsRegionRect.Max - window->Pos;
|
||||
return window->ContentRegionRect.Max - window->Pos;
|
||||
}
|
||||
|
||||
float ImGui::GetWindowContentRegionWidth()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->ContentsRegionRect.GetWidth();
|
||||
return window->ContentRegionRect.GetWidth();
|
||||
}
|
||||
|
||||
float ImGui::GetTextLineHeight()
|
||||
@ -9594,8 +9594,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
}
|
||||
|
||||
// State
|
||||
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Contents, WRT_ContentsRegionRect, WRT_Count }; // Windows Rect Type
|
||||
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Contents", "ContentsRegionRect" };
|
||||
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
|
||||
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" };
|
||||
static bool show_windows_rects = false;
|
||||
static int show_windows_rect_type = WRT_WorkRect;
|
||||
static bool show_windows_begin_order = false;
|
||||
@ -9626,8 +9626,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
else if (rect_type == WRT_InnerRect) { return window->InnerRect; }
|
||||
else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; }
|
||||
else if (rect_type == WRT_WorkRect) { return window->WorkRect; }
|
||||
else if (rect_type == WRT_Contents) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
|
||||
else if (rect_type == WRT_ContentsRegionRect) { return window->ContentsRegionRect; }
|
||||
else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
|
||||
else if (rect_type == WRT_ContentRegionRect) { return window->ContentRegionRect; }
|
||||
IM_ASSERT(0);
|
||||
return ImRect();
|
||||
}
|
||||
|
@ -1338,9 +1338,9 @@ struct IMGUI_API ImGuiWindow
|
||||
ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window.
|
||||
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 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 ContentRegionRect 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 ContentsRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
|
||||
ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on.
|
||||
|
||||
int LastFrameActive; // Last frame number the window was Active.
|
||||
float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there)
|
||||
@ -1415,7 +1415,7 @@ enum ImGuiTabBarFlagsPrivate_
|
||||
// Extend ImGuiTabItemFlags_
|
||||
enum ImGuiTabItemFlagsPrivate_
|
||||
{
|
||||
ImGuiTabItemFlags_NoCloseButton = 1 << 20 // Store whether p_open is set or not, which we need to recompute WidthContents during layout.
|
||||
ImGuiTabItemFlags_NoCloseButton = 1 << 20 // Store whether p_open is set or not, which we need to recompute ContentWidth during layout.
|
||||
};
|
||||
|
||||
// Storage for one active tab item (sizeof() 26~32 bytes)
|
||||
@ -1428,9 +1428,9 @@ struct ImGuiTabItem
|
||||
int NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames
|
||||
float Offset; // Position relative to beginning of tab
|
||||
float Width; // Width currently displayed
|
||||
float WidthContents; // Width of actual contents, stored during BeginTabItem() call
|
||||
float ContentWidth; // Width of actual contents, stored during BeginTabItem() call
|
||||
|
||||
ImGuiTabItem() { ID = Flags = 0; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = WidthContents = 0.0f; }
|
||||
ImGuiTabItem() { ID = Flags = 0; LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; Offset = Width = ContentWidth = 0.0f; }
|
||||
};
|
||||
|
||||
// Storage for a tab bar (sizeof() 92~96 bytes)
|
||||
|
@ -6566,13 +6566,13 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
// and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
|
||||
const char* tab_name = tab_bar->GetTabName(tab);
|
||||
const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true;
|
||||
tab->WidthContents = TabItemCalcSize(tab_name, has_close_button).x;
|
||||
tab->ContentWidth = TabItemCalcSize(tab_name, has_close_button).x;
|
||||
|
||||
width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->WidthContents;
|
||||
width_total_contents += (tab_n > 0 ? g.Style.ItemInnerSpacing.x : 0.0f) + tab->ContentWidth;
|
||||
|
||||
// Store data so we can build an array sorted by width if we need to shrink tabs down
|
||||
g.ShrinkWidthBuffer[tab_n].Index = tab_n;
|
||||
g.ShrinkWidthBuffer[tab_n].Width = tab->WidthContents;
|
||||
g.ShrinkWidthBuffer[tab_n].Width = tab->ContentWidth;
|
||||
}
|
||||
|
||||
// Compute width
|
||||
@ -6592,7 +6592,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
|
||||
{
|
||||
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
|
||||
tab->Width = ImMin(tab->WidthContents, tab_max_width);
|
||||
tab->Width = ImMin(tab->ContentWidth, tab_max_width);
|
||||
IM_ASSERT(tab->Width > 0.0f);
|
||||
}
|
||||
}
|
||||
@ -6608,7 +6608,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
||||
if (scroll_track_selected_tab_id == 0 && g.NavJustMovedToId == tab->ID)
|
||||
scroll_track_selected_tab_id = tab->ID;
|
||||
offset_x += tab->Width + g.Style.ItemInnerSpacing.x;
|
||||
offset_x_ideal += tab->WidthContents + g.Style.ItemInnerSpacing.x;
|
||||
offset_x_ideal += tab->ContentWidth + g.Style.ItemInnerSpacing.x;
|
||||
}
|
||||
tab_bar->OffsetMax = ImMax(offset_x - g.Style.ItemInnerSpacing.x, 0.0f);
|
||||
tab_bar->OffsetMaxIdeal = ImMax(offset_x_ideal - g.Style.ItemInnerSpacing.x, 0.0f);
|
||||
@ -6929,7 +6929,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
tab_is_new = true;
|
||||
}
|
||||
tab_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab);
|
||||
tab->WidthContents = size.x;
|
||||
tab->ContentWidth = size.x;
|
||||
|
||||
if (p_open == NULL)
|
||||
flags |= ImGuiTabItemFlags_NoCloseButton;
|
||||
@ -7040,10 +7040,10 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->WidthContents)
|
||||
if (hovered && g.HoveredIdNotActiveTimer > 0.50f && bb.GetWidth() < tab->ContentWidth)
|
||||
{
|
||||
// Enlarge tab display when hovering
|
||||
bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->WidthContents, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f)));
|
||||
bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->ContentWidth, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f)));
|
||||
display_draw_list = GetForegroundDrawList(window);
|
||||
TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user