summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorDov Alperin <dzalperin@gmail.com>2020-01-06 17:58:08 -0500
committerAndreas Kling <awesomekling@gmail.com>2020-01-08 15:20:41 +0100
commit518f4699708e6773641f7fde1ae7064d28480b4c (patch)
treedd2c9f0cedc29e7f09056905e5d0180e97a53f88 /Libraries
parente0c959ea7ff82abe499d81d54a3dd845c1f2d52d (diff)
downloadserenity-518f4699708e6773641f7fde1ae7064d28480b4c.zip
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.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/GItemView.cpp8
-rw-r--r--Libraries/LibGUI/GItemView.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GItemView.cpp b/Libraries/LibGUI/GItemView.cpp
index e4fd104400..8f025c0609 100644
--- a/Libraries/LibGUI/GItemView.cpp
+++ b/Libraries/LibGUI/GItemView.cpp
@@ -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);
}
diff --git a/Libraries/LibGUI/GItemView.h b/Libraries/LibGUI/GItemView.h
index 25986d5ea1..ee81ab87d0 100644
--- a/Libraries/LibGUI/GItemView.h
+++ b/Libraries/LibGUI/GItemView.h
@@ -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 };