@ -5578,15 +5578,11 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
ImRect bb_inner ( pos , pos + size ) ;
ItemSize ( size , 0.0f ) ;
// Fill horizontal space.
ImVec2 window_padding = window - > WindowPadding ;
float max_x = ( flags & ImGuiSelectableFlags_SpanAllColumns ) ? GetWindowContentRegionMax ( ) . x + window - > Pos . x : GetContentRegionMaxAbs ( ) . x ;
float w_draw = ImMax ( label_size . x , max_x - window_padding . x - pos . x ) ;
ImVec2 size_draw ( ( size_arg . x ! = 0 & & ! ( flags & ImGuiSelectableFlags_DrawFillAvailWidth ) ) ? size_arg . x : w_draw , size . y ) ;
ImRect bb_align ( pos , pos + size_draw ) ;
// Fill horizontal space
const float max_x = ( flags & ImGuiSelectableFlags_SpanAllColumns ) ? GetWindowContentRegionMax ( ) . x + window - > Pos . x : GetContentRegionMaxAbs ( ) . x ;
if ( size_arg . x = = 0.0f | | ( flags & ImGuiSelectableFlags_DrawFillAvailWidth ) )
bb_align . Max . x + = window_padding . x ;
size . x = ImMax ( label_size . x , max_x - window - > WindowPadding . x - pos . x ) + window - > WindowPadding . x ;
ImRect bb_align ( pos , pos + size ) ;
// Selectables are meant to be tightly packed together with no click-gap, so we extend the box to cover spacing between selectable.
ImRect bb_enlarged = bb_align ;
@ -6228,10 +6224,12 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
else
{
// Menu inside a menu
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
popup_pos = ImVec2 ( pos . x , pos . y - style . WindowPadding . y ) ;
float w = window - > DC . MenuColumns . DeclColumns ( label_size . x , 0.0f , IM_FLOOR ( g . FontSize * 1.20f ) ) ; // Feedback to next frame
float extra_w = ImMax ( 0.0f , GetContentRegionAvail ( ) . x - w) ;
pressed = Selectable ( label , menu_is_open , ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | ( ! enabled ? ImGuiSelectableFlags_Disabled : 0 ) , ImVec2 ( w, 0.0f ) ) ;
float min_ w = window - > DC . MenuColumns . DeclColumns ( label_size . x , 0.0f , IM_FLOOR ( g . FontSize * 1.20f ) ) ; // Feedback to next frame
float extra_w = ImMax ( 0.0f , GetContentRegionAvail ( ) . x - min_ w) ;
pressed = Selectable ( label , menu_is_open , ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_DrawFillAvailWidth | ( ! enabled ? ImGuiSelectableFlags_Disabled : 0 ) , ImVec2 ( min_ w, 0.0f ) ) ;
ImU32 text_col = GetColorU32 ( enabled ? ImGuiCol_Text : ImGuiCol_TextDisabled ) ;
RenderArrow ( window - > DrawList , pos + ImVec2 ( window - > DC . MenuColumns . Pos [ 2 ] + extra_w + g . FontSize * 0.30f , 0.0f ) , text_col , ImGuiDir_Right ) ;
}
@ -6376,11 +6374,14 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
}
else
{
ImVec2 shortcut_size = shortcut ? CalcTextSize ( shortcut , NULL ) : ImVec2 ( 0.0f , 0.0f ) ;
float w = window - > DC . MenuColumns . DeclColumns ( label_size . x , shortcut_size . x , IM_FLOOR ( g . FontSize * 1.20f ) ) ; // Feedback for next frame
float extra_w = ImMax ( 0.0f , GetContentRegionAvail ( ) . x - w ) ;
pressed = Selectable ( label , false , flags | ImGuiSelectableFlags_DrawFillAvailWidth , ImVec2 ( w , 0.0f ) ) ;
if ( shortcut_size . x > 0.0f )
// Menu item inside a vertical menu
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
float shortcut_w = shortcut ? CalcTextSize ( shortcut , NULL ) . x : 0.0f ;
float min_w = window - > DC . MenuColumns . DeclColumns ( label_size . x , shortcut_w , IM_FLOOR ( g . FontSize * 1.20f ) ) ; // Feedback for next frame
float extra_w = ImMax ( 0.0f , GetContentRegionAvail ( ) . x - min_w ) ;
pressed = Selectable ( label , false , flags | ImGuiSelectableFlags_DrawFillAvailWidth , ImVec2 ( min_w , 0.0f ) ) ;
if ( shortcut_w > 0.0f )
{
PushStyleColor ( ImGuiCol_Text , g . Style . Colors [ ImGuiCol_TextDisabled ] ) ;
RenderText ( pos + ImVec2 ( window - > DC . MenuColumns . Pos [ 1 ] + extra_w , 0.0f ) , shortcut , NULL , false ) ;