mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibGUI: clicking and dragging one item will drag other items in selection
Previously if more than one item was selected clicking on one of them and dragging would de-select everything that is not the one that was clicked on. Now, if more than one items are selected and there is a mousedown it goes into a "mightdrag" state. The user can then perform a drag, if they don't everything that is not the item being clicked gets unselected in the mouseup event, mimicking the previous behavior.
This commit is contained in:
parent
e0c959ea7f
commit
518f469970
Notes:
sideshowbarker
2024-07-19 10:15:59 +09:00
Author: https://github.com/DAlperin Commit: https://github.com/SerenityOS/serenity/commit/518f4699708 Pull-request: https://github.com/SerenityOS/serenity/pull/1032 Reviewed-by: https://github.com/awesomekling
@ -130,6 +130,8 @@ void GItemView::mousedown_event(GMouseEvent& event)
|
||||
auto index = model()->index(item_index, m_model_column);
|
||||
if (event.modifiers() & Mod_Ctrl)
|
||||
selection().toggle(index);
|
||||
else if (selection().size() > 1)
|
||||
m_might_drag = true;
|
||||
else
|
||||
selection().set(index);
|
||||
}
|
||||
@ -146,6 +148,12 @@ void GItemView::mouseup_event(GMouseEvent& event)
|
||||
update();
|
||||
return;
|
||||
}
|
||||
int item_index = item_at_event_position(event.position());
|
||||
auto index = model()->index(item_index, m_model_column);
|
||||
if((selection().size() > 1) & m_might_drag) {
|
||||
selection().set(index);
|
||||
m_might_drag = false;
|
||||
}
|
||||
GAbstractView::mouseup_event(event);
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,8 @@ private:
|
||||
int m_visual_column_count { 0 };
|
||||
int m_visual_row_count { 0 };
|
||||
|
||||
bool m_might_drag { false };
|
||||
|
||||
Point m_left_mousedown_position;
|
||||
|
||||
Size m_effective_item_size { 80, 80 };
|
||||
|
Loading…
Reference in New Issue
Block a user