@ -5570,21 +5570,21 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if ( ( flags & ImGuiSelectableFlags_SpanAllColumns ) & & window - > DC . CurrentColumns ) // FIXME-OPT: Avoid if vertically clipped.
PushColumnsBackground ( ) ;
// Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle.
ImGuiID id = window - > GetID ( label ) ;
ImVec2 label_size = CalcTextSize ( label , NULL , true ) ;
ImVec2 size ( size_arg . x ! = 0.0f ? size_arg . x : label_size . x , size_arg . y ! = 0.0f ? size_arg . y : label_size . y ) ;
ImVec2 pos = window - > DC . CursorPos ;
pos . y + = window - > DC . CurrLineTextBaseOffset ;
ImRect bb_inner ( pos , pos + size ) ;
ItemSize ( size , 0.0f ) ;
// 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_DrawFill AvailWidth ) )
size . x = ImMax ( label_size . x , max_x - window - > WindowPadding . x - pos . x ) + window - > WindowPadding . x ;
if ( size_arg . x = = 0.0f | | ( flags & ImGuiSelectableFlags_Span AvailWidth ) )
size . x = ImMax ( label_size . x , max_x - pos . 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.
// Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable.
ImRect bb_enlarged = bb_align ;
const float spacing_x = style . ItemSpacing . x ;
const float spacing_y = style . ItemSpacing . y ;
@ -5594,6 +5594,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
bb_enlarged . Min . y - = spacing_U ;
bb_enlarged . Max . x + = ( spacing_x - spacing_L ) ;
bb_enlarged . Max . y + = ( spacing_y - spacing_U ) ;
//if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb_align.Min, bb_align.Max, IM_COL32(255, 0, 0, 255)); }
//if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb_enlarged.Min, bb_enlarged.Max, IM_COL32(0, 255, 0, 255)); }
bool item_add ;
if ( flags & ImGuiSelectableFlags_Disabled )
@ -5670,7 +5672,6 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if ( pressed & & ( window - > Flags & ImGuiWindowFlags_Popup ) & & ! ( flags & ImGuiSelectableFlags_DontClosePopups ) & & ! ( window - > DC . ItemFlags & ImGuiItemFlags_SelectableDontClosePopup ) )
CloseCurrentPopup ( ) ;
//if (g.IO.KeyCtrl) { window->DrawList->AddRect(bb_align.Min, bb_align.Max, IM_COL32(0, 255, 0, 255)); }
IMGUI_TEST_ENGINE_ITEM_INFO ( id , label , window - > DC . ItemFlags ) ;
return pressed ;
}
@ -6229,7 +6230,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
popup_pos = ImVec2 ( pos . x , pos . y - style . WindowPadding . y ) ;
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_DrawFill AvailWidth | ( ! enabled ? ImGuiSelectableFlags_Disabled : 0 ) , ImVec2 ( min_w , 0.0f ) ) ;
pressed = Selectable ( label , menu_is_open , ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_Span AvailWidth | ( ! 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 ) ;
}
@ -6380,7 +6381,7 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
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_DrawFill AvailWidth , ImVec2 ( min_w , 0.0f ) ) ;
pressed = Selectable ( label , false , flags | ImGuiSelectableFlags_Span AvailWidth , ImVec2 ( min_w , 0.0f ) ) ;
if ( shortcut_w > 0.0f )
{
PushStyleColor ( ImGuiCol_Text , g . Style . Colors [ ImGuiCol_TextDisabled ] ) ;