@ -6672,7 +6672,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
if ( ! is_multi_select )
return false ;
// Extra layer of "no logic clip" for box-select support
if ( ! g . BoxSelectState . BoxSelect UnclipMode | | ! g . BoxSelectState . BoxSelect UnclipRect. Overlaps ( bb ) )
if ( ! g . BoxSelectState . UnclipMode | | ! g . BoxSelectState . UnclipRect . Overlaps ( bb ) )
return false ;
}
@ -7005,11 +7005,11 @@ static void BoxSelectStart(ImGuiID id, ImGuiSelectionUserData clicked_item)
{
ImGuiContext & g = * GImGui ;
ImGuiBoxSelectState * bs = & g . BoxSelectState ;
bs - > BoxSelectId = id ;
bs - > BoxSelect Starting = true ; // Consider starting box-select.
bs - > BoxSelect FromVoid = ( clicked_item = = ImGuiSelectionUserData_Invalid ) ;
bs - > BoxSelect KeyMods = g . IO . KeyMods ;
bs - > BoxSelect StartPosRel = bs - > BoxSelect EndPosRel = ImGui : : WindowPosAbsToRel ( g . CurrentWindow , g . IO . MousePos ) ;
bs - > ID = id ;
bs - > Is Starting = true ; // Consider starting box-select.
bs - > IsStarted FromVoid = ( clicked_item = = ImGuiSelectionUserData_Invalid ) ;
bs - > KeyMods = g . IO . KeyMods ;
bs - > StartPosRel = bs - > EndPosRel = ImGui : : WindowPosAbsToRel ( g . CurrentWindow , g . IO . MousePos ) ;
}
static void BoxSelectScrollWithMouseDrag ( ImGuiWindow * window , const ImRect & inner_r )
@ -7142,38 +7142,38 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags)
ms - > BoxSelectId = GetID ( " ##BoxSelect " ) ;
KeepAliveID ( ms - > BoxSelectId ) ;
}
if ( ( flags & ImGuiMultiSelectFlags_BoxSelect ) & & ms - > BoxSelectId = = bs - > BoxSelectId )
if ( ( flags & ImGuiMultiSelectFlags_BoxSelect ) & & ms - > BoxSelectId = = bs - > ID )
{
bs - > BoxSelect UnclipMode = false ;
bs - > UnclipMode = false ;
// BoxSelectStarting is set by MultiSelectItemFooter() when considering a possible box-select. We validate it here and lock geometry.
if ( bs - > BoxSelect Starting & & IsMouseDragPastThreshold ( 0 ) )
if ( bs - > Is Starting & & IsMouseDragPastThreshold ( 0 ) )
{
bs - > BoxSelect Active = true ;
bs - > BoxSelect Window = ms - > Storage - > Window ;
bs - > BoxSelect Starting = false ;
bs - > Is Active = true ;
bs - > Window = ms - > Storage - > Window ;
bs - > Is Starting = false ;
SetActiveID ( ms - > BoxSelectId , window ) ;
if ( bs - > BoxSelect FromVoid & & ( bs - > BoxSelect KeyMods & ImGuiMod_Shift ) = = 0 )
if ( bs - > IsStarted FromVoid & & ( bs - > KeyMods & ImGuiMod_Shift ) = = 0 )
request_clear = true ;
}
else if ( ( bs - > BoxSelect Starting | | bs - > BoxSelect Active) & & g . IO . MouseDown [ 0 ] = = false )
else if ( ( bs - > Is Starting | | bs - > Is Active) & & g . IO . MouseDown [ 0 ] = = false )
{
bs - > BoxSelectId = 0 ;
bs - > BoxSelect Active = bs - > BoxSelect Starting = false ;
bs - > ID = 0 ;
bs - > Is Active = bs - > Is Starting = false ;
if ( g . ActiveId = = ms - > BoxSelectId )
ClearActiveID ( ) ;
}
if ( bs - > BoxSelect Active)
if ( bs - > Is Active)
{
// Current frame absolute prev/current rectangles are used to toggle selection.
// They are derived from positions relative to scrolling space.
const ImRect scope_rect = window - > InnerClipRect ;
ImVec2 start_pos_abs = WindowPosRelToAbs ( window , bs - > BoxSelect StartPosRel) ;
ImVec2 prev_end_pos_abs = WindowPosRelToAbs ( window , bs - > BoxSelect EndPosRel) ; // Clamped already
ImVec2 start_pos_abs = WindowPosRelToAbs ( window , bs - > StartPosRel ) ;
ImVec2 prev_end_pos_abs = WindowPosRelToAbs ( window , bs - > EndPosRel ) ; // Clamped already
ImVec2 curr_end_pos_abs = g . IO . MousePos ;
if ( ms - > Flags & ImGuiMultiSelectFlags_ScopeWindow ) // Box-select scrolling only happens with ScopeWindow
curr_end_pos_abs = ImClamp ( curr_end_pos_abs , scope_rect . Min , scope_rect . Max ) ;
bs - > BoxSelectLastitem = - 1 ;
bs - > LastSubmittedItem = ImGuiSelectionUserData_Invalid ;
bs - > BoxSelectRectPrev . Min = ImMin ( start_pos_abs , prev_end_pos_abs ) ;
bs - > BoxSelectRectPrev . Max = ImMax ( start_pos_abs , prev_end_pos_abs ) ;
bs - > BoxSelectRectCurr . Min = ImMin ( start_pos_abs , curr_end_pos_abs ) ;
@ -7184,9 +7184,9 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags)
if ( flags & ImGuiMultiSelectFlags_BoxSelect2d )
if ( bs - > BoxSelectRectPrev . Min . x ! = bs - > BoxSelectRectCurr . Min . x | | bs - > BoxSelectRectPrev . Max . x ! = bs - > BoxSelectRectCurr . Max . x )
{
bs - > BoxSelect UnclipRect = bs - > BoxSelectRectPrev ;
bs - > BoxSelect UnclipRect. Add ( bs - > BoxSelectRectCurr ) ;
bs - > BoxSelect UnclipMode = true ;
bs - > UnclipRect = bs - > BoxSelectRectPrev ;
bs - > UnclipRect . Add ( bs - > BoxSelectRectCurr ) ;
bs - > UnclipMode = true ;
}
//GetForegroundDrawList()->AddRect(ms->BoxSelectNoClipRect.Min, ms->BoxSelectNoClipRect.Max, IM_COL32(255,0,0,200), 0.0f, 0, 3.0f);
@ -7240,7 +7240,7 @@ ImGuiMultiSelectIO* ImGui::EndMultiSelect()
if ( ( ms - > Flags & ImGuiMultiSelectFlags_BoxSelect ) & & bs ! = NULL )
{
// Box-select: render selection rectangle
bs - > BoxSelect EndPosRel = WindowPosAbsToRel ( window , ImClamp ( g . IO . MousePos , scope_rect . Min , scope_rect . Max ) ) ; // Clamp stored position according to current scrolling view
bs - > EndPosRel = WindowPosAbsToRel ( window , ImClamp ( g . IO . MousePos , scope_rect . Min , scope_rect . Max ) ) ; // Clamp stored position according to current scrolling view
ImRect box_select_r = bs - > BoxSelectRectCurr ;
box_select_r . ClipWith ( scope_rect ) ;
window - > DrawList - > AddRectFilled ( box_select_r . Min , box_select_r . Max , GetColorU32 ( ImGuiCol_SeparatorHovered , 0.30f ) ) ; // FIXME-MULTISELECT: Styling
@ -7253,7 +7253,7 @@ ImGuiMultiSelectIO* ImGui::EndMultiSelect()
if ( ( ms - > Flags & ImGuiMultiSelectFlags_ScopeWindow ) & & ( ms - > Flags & ImGuiMultiSelectFlags_BoxSelectNoScroll ) = = 0 & & ! scroll_r . Contains ( g . IO . MousePos ) )
BoxSelectScrollWithMouseDrag ( window , scroll_r ) ;
bs - > BoxSelect UnclipMode = false ;
bs - > UnclipMode = false ;
}
}
@ -7266,7 +7266,7 @@ ImGuiMultiSelectIO* ImGui::EndMultiSelect()
if ( scope_hovered & & g . HoveredId = = 0 & & g . ActiveId = = 0 )
{
if ( ms - > Flags & ImGuiMultiSelectFlags_BoxSelect )
if ( ! g . BoxSelectState . BoxSelect Active & & ! g . BoxSelectState . BoxSelect Starting & & g . IO . MouseClickedCount [ 0 ] = = 1 )
if ( ! g . BoxSelectState . Is Active & & ! g . BoxSelectState . Is Starting & & g . IO . MouseClickedCount [ 0 ] = = 1 )
BoxSelectStart ( ms - > BoxSelectId , ImGuiSelectionUserData_Invalid ) ;
if ( ms - > Flags & ImGuiMultiSelectFlags_ClearOnClickVoid )
@ -7426,12 +7426,12 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed)
selected = ! selected ;
ImGuiSelectionRequest req = { ImGuiSelectionRequestType_SetRange , selected , item_data , item_data } ;
ImGuiSelectionRequest * prev_req = ( ms - > IO . Requests . Size > 0 ) ? & ms - > IO . Requests . Data [ ms - > IO . Requests . Size - 1 ] : NULL ;
if ( prev_req & & prev_req - > Type = = ImGuiSelectionRequestType_SetRange & & prev_req - > RangeLastItem = = bs - > BoxSelect Lastitem & & prev_req - > RangeSelected = = selected )
if ( prev_req & & prev_req - > Type = = ImGuiSelectionRequestType_SetRange & & prev_req - > RangeLastItem = = bs - > LastSubm ittedI tem & & prev_req - > RangeSelected = = selected )
prev_req - > RangeLastItem = item_data ; // Merge span into same request
else
ms - > IO . Requests . push_back ( req ) ;
}
bs - > BoxSelect Lastitem = item_data ;
bs - > LastSubm ittedI tem = item_data ;
}
// Right-click handling: this could be moved at the Selectable() level.
@ -7459,7 +7459,7 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed)
// Box-select
ImGuiInputSource input_source = ( g . NavJustMovedToId = = id | | g . NavActivateId = = id ) ? g . NavInputSource : ImGuiInputSource_Mouse ;
if ( ms - > Flags & ImGuiMultiSelectFlags_BoxSelect )
if ( selected = = false & & ! g . BoxSelectState . BoxSelect Active & & ! g . BoxSelectState . BoxSelect Starting & & input_source = = ImGuiInputSource_Mouse & & g . IO . MouseClickedCount [ 0 ] = = 1 )
if ( selected = = false & & ! g . BoxSelectState . Is Active & & ! g . BoxSelectState . Is Starting & & input_source = = ImGuiInputSource_Mouse & & g . IO . MouseClickedCount [ 0 ] = = 1 )
BoxSelectStart ( ms - > BoxSelectId , item_data ) ;
//----------------------------------------------------------------------------------------