|
@@ -7677,7 +7677,9 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|
|
|
|
|
// Render tab label, process close button
|
|
// Render tab label, process close button
|
|
const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, id) : 0;
|
|
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)
|
|
if (just_closed && p_open != NULL)
|
|
{
|
|
{
|
|
*p_open = false;
|
|
*p_open = false;
|
|
@@ -7691,7 +7693,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)
|
|
// 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)
|
|
// 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))
|
|
if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip) && !(tab->Flags & ImGuiTabItemFlags_NoTooltip))
|
|
SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label);
|
|
SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label);
|
|
|
|
|
|
@@ -7756,12 +7758,18 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI
|
|
|
|
|
|
// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic
|
|
// 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.
|
|
// 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;
|
|
ImGuiContext& g = *GImGui;
|
|
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
|
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)
|
|
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)
|
|
// 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.
|
|
// But right now if you want to alter text color of tabs this is what you need to do.
|
|
@@ -7782,6 +7790,13 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|
}
|
|
}
|
|
ImRect text_ellipsis_clip_bb = text_pixel_clip_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
|
|
// 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()
|
|
// 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
|
|
// 'hovered' will be true when hovering the Tab but NOT when hovering the close button
|
|
@@ -7819,7 +7834,8 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
|
g.Style.Alpha = backup_alpha;
|
|
g.Style.Alpha = backup_alpha;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- return close_button_pressed;
|
|
|
|
|
|
+ if (out_just_closed)
|
|
|
|
+ *out_just_closed = close_button_pressed;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|