@ -5889,7 +5889,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
ImGuiContext & g = * GImGui ;
const ImGuiStyle & style = g . Style ;
if ( ( flags & ImGuiSelectableFlags_SpanAllColumns ) & & window - > DC . CurrentColumns ) // FIXME-OPT: Avoid if vertically clipped.
const bool span_all_columns = ( flags & ImGuiSelectableFlags_SpanAllColumns ) ! = 0 ;
if ( span_all_columns & & 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.
@ -5901,8 +5902,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
ItemSize ( size , 0.0f ) ;
// Fill horizontal space
const float min_x = ( flags & ImGuiSelectableFlags_SpanAllColumns ) ? window - > ParentWorkRect . Min . x : pos . x ;
const float max_x = ( flags & ImGuiSelectableFlags_SpanAllColumns ) ? window - > ParentWorkRect . Max . x : window - > WorkRect . Max . x ;
const float min_x = span_all_columns ? window - > ParentWorkRect . Min . x : pos . x ;
const float max_x = span_all_columns ? window - > ParentWorkRect . Max . x : window - > WorkRect . Max . x ;
if ( size_arg . x = = 0.0f | | ( flags & ImGuiSelectableFlags_SpanAvailWidth ) )
size . x = ImMax ( label_size . x , max_x - min_x ) ;
@ -5911,33 +5912,35 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
const ImVec2 text_max ( min_x + size . x , pos . y + size . y ) ;
// 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 ( min_x , pos . y , text_max . x , text_max . y ) ;
ImRect bb ( min_x , pos . y , text_max . x , text_max . y ) ;
if ( ( flags & ImGuiSelectableFlags_NoPadWithHalfSpacing ) = = 0 )
{
const float spacing_x = style . ItemSpacing . x ;
const float spacing_y = style . ItemSpacing . y ;
const float spacing_L = IM_FLOOR ( spacing_x * 0.50f ) ;
const float spacing_U = IM_FLOOR ( spacing_y * 0.50f ) ;
bb _enlarged . Min . x - = spacing_L ;
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)); }
bb . Min . x - = spacing_L ;
bb . Min . y - = spacing_U ;
bb . Max . x + = ( spacing_x - spacing_L ) ;
bb . Max . y + = ( spacing_y - spacing_U ) ;
}
//if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb .Min, bb.Max, IM_COL32(0, 255, 0, 255)); }
bool item_add ;
if ( flags & ImGuiSelectableFlags_Disabled )
{
ImGuiItemFlags backup_item_flags = window - > DC . ItemFlags ;
window - > DC . ItemFlags | = ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNavDefaultFocus ;
item_add = ItemAdd ( bb _enlarged , id ) ;
item_add = ItemAdd ( bb , id ) ;
window - > DC . ItemFlags = backup_item_flags ;
}
else
{
item_add = ItemAdd ( bb _enlarged , id ) ;
item_add = ItemAdd ( bb , id ) ;
}
if ( ! item_add )
{
if ( ( flags & ImGuiSelectableFlags_SpanAllColumns ) & & window - > DC . CurrentColumns )
if ( span_all_columns & & window - > DC . CurrentColumns )
PopColumnsBackground ( ) ;
return false ;
}
@ -5956,7 +5959,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
const bool was_selected = selected ;
bool hovered , held ;
bool pressed = ButtonBehavior ( bb _enlarged , id , & hovered , & held , button_flags ) ;
bool pressed = ButtonBehavior ( bb , id , & hovered , & held , button_flags ) ;
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard
if ( pressed | | ( hovered & & ( flags & ImGuiSelectableFlags_SetNavIdOnHover ) ) )
@ -5983,15 +5986,15 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if ( hovered | | selected )
{
const ImU32 col = GetColorU32 ( ( held & & hovered ) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header ) ;
RenderFrame ( bb _enlarged . Min , bb _enlarged . Max , col , false , 0.0f ) ;
RenderNavHighlight ( bb _enlarged , id , ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding ) ;
RenderFrame ( bb . Min , bb . Max , col , false , 0.0f ) ;
RenderNavHighlight ( bb , id , ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding ) ;
}
if ( ( flags & ImGuiSelectableFlags_SpanAllColumns ) & & window - > DC . CurrentColumns )
if ( span_all_columns & & window - > DC . CurrentColumns )
PopColumnsBackground ( ) ;
if ( flags & ImGuiSelectableFlags_Disabled ) PushStyleColor ( ImGuiCol_Text , style . Colors [ ImGuiCol_TextDisabled ] ) ;
RenderTextClipped ( text_min , text_max , label , NULL , & label_size , style . SelectableTextAlign , & bb _enlarged ) ;
RenderTextClipped ( text_min , text_max , label , NULL , & label_size , style . SelectableTextAlign , & bb ) ;
if ( flags & ImGuiSelectableFlags_Disabled ) PopStyleColor ( ) ;
// Automatically close popups