|
|
@@ -6817,18 +6817,8 @@ namespace ImGui
|
|
|
|
|
|
ImGuiTabBar::ImGuiTabBar()
|
|
|
{
|
|
|
- ID = 0;
|
|
|
- SelectedTabId = NextSelectedTabId = VisibleTabId = 0;
|
|
|
+ memset(this, 0, sizeof(*this));
|
|
|
CurrFrameVisible = PrevFrameVisible = -1;
|
|
|
- CurrTabsContentsHeight = PrevTabsContentsHeight = 0.0f;
|
|
|
- WidthAllTabs = WidthAllTabsIdeal = 0.0f;
|
|
|
- ScrollingAnim = ScrollingTarget = ScrollingTargetDistToVisibility = ScrollingSpeed = 0.0f;
|
|
|
- ScrollingRectMinX = ScrollingRectMaxX = 0.0f;
|
|
|
- Flags = ImGuiTabBarFlags_None;
|
|
|
- ReorderRequestTabId = 0;
|
|
|
- ReorderRequestDir = 0;
|
|
|
- TabsActiveCount = 0;
|
|
|
- WantLayout = VisibleTabWasSubmitted = TabsAddedNew = false;
|
|
|
LastTabItemIdx = -1;
|
|
|
}
|
|
|
|
|
|
@@ -6893,9 +6883,11 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
|
|
|
g.CurrentTabBar = tab_bar;
|
|
|
|
|
|
// Append with multiple BeginTabBar()/EndTabBar() pairs.
|
|
|
+ tab_bar->BackupCursorPos = window->DC.CursorPos;
|
|
|
if (tab_bar->CurrFrameVisible == g.FrameCount)
|
|
|
{
|
|
|
- window->DC.CursorPos = tab_bar->TabsContentsMin;
|
|
|
+ window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);
|
|
|
+ tab_bar->BeginCount++;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -6916,13 +6908,13 @@ bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImG
|
|
|
tab_bar->CurrFrameVisible = g.FrameCount;
|
|
|
tab_bar->PrevTabsContentsHeight = tab_bar->CurrTabsContentsHeight;
|
|
|
tab_bar->CurrTabsContentsHeight = 0.0f;
|
|
|
+ tab_bar->ItemSpacingY = g.Style.ItemSpacing.y;
|
|
|
tab_bar->FramePadding = g.Style.FramePadding;
|
|
|
tab_bar->TabsActiveCount = 0;
|
|
|
+ tab_bar->BeginCount = 1;
|
|
|
|
|
|
// Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap
|
|
|
- tab_bar->TabsContentsMin.x = tab_bar->BarRect.Min.x;
|
|
|
- tab_bar->TabsContentsMin.y = tab_bar->BarRect.Max.y + g.Style.ItemSpacing.y;
|
|
|
- window->DC.CursorPos = tab_bar->TabsContentsMin;
|
|
|
+ window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY);
|
|
|
|
|
|
// Draw separator
|
|
|
const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive);
|
|
|
@@ -6964,6 +6956,8 @@ void ImGui::EndTabBar()
|
|
|
{
|
|
|
window->DC.CursorPos.y = tab_bar->BarRect.Max.y + tab_bar->PrevTabsContentsHeight;
|
|
|
}
|
|
|
+ if (tab_bar->BeginCount > 1)
|
|
|
+ window->DC.CursorPos = tab_bar->BackupCursorPos;
|
|
|
|
|
|
if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0)
|
|
|
PopID();
|
|
|
@@ -6999,7 +6993,7 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
|
|
|
tab_bar->Tabs[tab_dst_n] = tab_bar->Tabs[tab_src_n];
|
|
|
|
|
|
tab = &tab_bar->Tabs[tab_dst_n];
|
|
|
- tab->IndexDuringLayout = (ImS8)tab_dst_n;
|
|
|
+ tab->IndexDuringLayout = (ImS16)tab_dst_n;
|
|
|
|
|
|
// We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another)
|
|
|
int curr_tab_section_n = (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1;
|
|
|
@@ -7558,7 +7552,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|
|
tab_bar->TabsAddedNew = true;
|
|
|
tab_is_new = true;
|
|
|
}
|
|
|
- tab_bar->LastTabItemIdx = (short)tab_bar->Tabs.index_from_ptr(tab);
|
|
|
+ tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab);
|
|
|
tab->ContentWidth = size.x;
|
|
|
tab->BeginOrder = tab_bar->TabsActiveCount++;
|
|
|
|
|
|
@@ -7698,7 +7692,9 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|
|
|
|
|
// Render tab label, process close button
|
|
|
const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, id) : 0;
|
|
|
- bool just_closed = TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible);
|
|
|
+ bool just_closed;
|
|
|
+ bool text_clipped;
|
|
|
+ TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped);
|
|
|
if (just_closed && p_open != NULL)
|
|
|
{
|
|
|
*p_open = false;
|
|
|
@@ -7712,7 +7708,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|
|
|
|
|
// Tooltip (FIXME: Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer)
|
|
|
// We test IsItemHovered() to discard e.g. when another item is active or drag and drop over the tab bar (which g.HoveredId ignores)
|
|
|
- if (g.HoveredId == id && !held && g.HoveredIdNotActiveTimer > 0.50f && IsItemHovered())
|
|
|
+ if (text_clipped && g.HoveredId == id && !held && g.HoveredIdNotActiveTimer > 0.50f && IsItemHovered())
|
|
|
if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip) && !(tab->Flags & ImGuiTabItemFlags_NoTooltip))
|
|
|
SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label);
|
|
|
|
|
|
@@ -7777,12 +7773,18 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI
|
|
|
|
|
|
// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic
|
|
|
// We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter.
|
|
|
-bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible)
|
|
|
+void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
|
+
|
|
|
+ if (out_just_closed)
|
|
|
+ *out_just_closed = false;
|
|
|
+ if (out_text_clipped)
|
|
|
+ *out_text_clipped = false;
|
|
|
+
|
|
|
if (bb.GetWidth() <= 1.0f)
|
|
|
- return false;
|
|
|
+ return;
|
|
|
|
|
|
// In Style V2 we'll have full override of all colors per state (e.g. focused, selected)
|
|
|
// But right now if you want to alter text color of tabs this is what you need to do.
|
|
|
@@ -7803,6 +7805,13 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|
|
}
|
|
|
ImRect text_ellipsis_clip_bb = text_pixel_clip_bb;
|
|
|
|
|
|
+ // Return clipped state ignoring the close button
|
|
|
+ if (out_text_clipped)
|
|
|
+ {
|
|
|
+ *out_text_clipped = (text_ellipsis_clip_bb.Min.x + label_size.x) > text_pixel_clip_bb.Max.x;
|
|
|
+ //draw_list->AddCircle(text_ellipsis_clip_bb.Min, 3.0f, *out_text_clipped ? IM_COL32(255, 0, 0, 255) : IM_COL32(0, 255, 0, 255));
|
|
|
+ }
|
|
|
+
|
|
|
// Close Button
|
|
|
// We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap()
|
|
|
// 'hovered' will be true when hovering the Tab but NOT when hovering the close button
|
|
|
@@ -7840,7 +7849,8 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|
|
g.Style.Alpha = backup_alpha;
|
|
|
#endif
|
|
|
|
|
|
- return close_button_pressed;
|
|
|
+ if (out_just_closed)
|
|
|
+ *out_just_closed = close_button_pressed;
|
|
|
}
|
|
|
|
|
|
|