@ -7577,8 +7577,8 @@ static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar)
// Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet,
// 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 - > ContentWidth = ( tab - > RequestedWidth > = 0.0f ) ? tab - > RequestedWidth : TabItemCalcSize ( tab_name , has_close_button ) . x ;
const bool has_close_button_or_unsaved_marker = ( tab - > Flags & ImGuiTabItemFlags_NoCloseButton ) = = 0 | | ( tab - > Flags & ImGuiTabItemFlags_UnsavedDocument ) ;
tab - > ContentWidth = ( tab - > RequestedWidth > = 0.0f ) ? tab - > RequestedWidth : TabItemCalcSize ( tab_name , has_close_button_or_unsaved_marker ) . x ;
int section_n = TabItemGetSectionIdx ( tab ) ;
ImGuiTabBarSection * section = & sections [ section_n ] ;
@ -8105,7 +8105,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
tab_bar - > LastTabItemIdx = ( ImS16 ) tab_bar - > Tabs . index_from_ptr ( tab ) ;
// Calculate tab contents size
ImVec2 size = TabItemCalcSize ( label , p_open ! = NULL ) ;
ImVec2 size = TabItemCalcSize ( label , ( p_open ! = NULL ) | | ( flags & ImGuiTabItemFlags_UnsavedDocument ) ) ;
tab - > RequestedWidth = - 1.0f ;
if ( g . NextItemData . Flags & ImGuiNextItemDataFlags_HasWidth )
size . x = tab - > RequestedWidth = g . NextItemData . Width ;
@ -8117,6 +8117,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
const bool tab_bar_appearing = ( tab_bar - > PrevFrameVisible + 1 < g . FrameCount ) ;
const bool tab_bar_focused = ( tab_bar - > Flags & ImGuiTabBarFlags_IsFocused ) ! = 0 ;
const bool tab_appearing = ( tab - > LastFrameVisible + 1 < g . FrameCount ) ;
const bool tab_just_unsaved = ( flags & ImGuiTabItemFlags_UnsavedDocument ) & & ! ( tab - > Flags & ImGuiTabItemFlags_UnsavedDocument ) ;
const bool is_tab_button = ( flags & ImGuiTabItemFlags_Button ) ! = 0 ;
tab - > LastFrameVisible = g . FrameCount ;
tab - > Flags = flags ;
@ -8248,7 +8249,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
const ImGuiID close_button_id = p_open ? GetIDWithSeed ( " #CLOSE " , NULL , id ) : 0 ;
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 ) ;
TabItemLabelAndCloseButton ( display_draw_list , bb , tab_just_unsaved ? ( flags & ~ ImGuiTabItemFlags_UnsavedDocument ) : 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 ;
@ -8292,12 +8293,12 @@ void ImGui::SetTabItemClosed(const char* label)
}
}
ImVec2 ImGui : : TabItemCalcSize ( const char * label , bool has_close_button )
ImVec2 ImGui : : TabItemCalcSize ( const char * label , bool has_close_button_or_unsaved_marker )
{
ImGuiContext & g = * GImGui ;
ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
ImVec2 size = ImVec2 ( label_size . x + g . Style . FramePadding . x , label_size . y + g . Style . FramePadding . y * 2.0f ) ;
if ( has_close_button )
if ( has_close_button_or_unsaved_marker )
size . x + = g . Style . FramePadding . x + ( g . Style . ItemInnerSpacing . x + g . FontSize ) ; // We use Y intentionally to fit the close button circle.
else
size . x + = g . Style . FramePadding . x + 1.0f ;