Merge lp:~jeremywootten/pantheon-files/fix-select-when-scrolled-regression into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: David Hewitt
Approved revision: 2516
Merged at revision: 2529
Proposed branch: lp:~jeremywootten/pantheon-files/fix-select-when-scrolled-regression
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 144 lines (+58/-30)
3 files modified
src/View/AbstractDirectoryView.vala (+1/-25)
src/View/AbstractTreeView.vala (+24/-0)
src/View/IconView.vala (+33/-5)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-select-when-scrolled-regression
Reviewer Review Type Date Requested Status
David Hewitt code, function Approve
Review via email: mp+318655@code.launchpad.net

Commit message

Implement separate is_on_icon () method for IconView

Description of the change

This branch fixes a fairly serious regression in the selection of items in Icon View using the selection helper, which no longer works properly when the view is scrolled.

This was due to the same code being used to determine whether the pointer was on the icon or helper for all the views, but there are subtle differences in the way IconView renders the items and the coordinates it supplies to the renderer meaning that a separate slightly different method has to be used.

To post a comment you must log in.
Revision history for this message
David Hewitt (davidmhewitt) wrote :

Can confirm that it fixes the bug and selection in the other two views remains working as intended.

review: Approve (code, function)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2017-02-15 18:54:50 +0000
+++ src/View/AbstractDirectoryView.vala 2017-03-01 17:49:39 +0000
@@ -3482,31 +3482,6 @@
3482 unselect_all ();3482 unselect_all ();
3483 }3483 }
34843484
3485 protected bool is_on_icon (int x, int y, int orig_x, int orig_y, ref bool on_helper) {
3486 /* orig_x and orig_y must be top left hand corner of icon (excluding helper) */
3487 int x_offset = x - orig_x;
3488 int y_offset = y - orig_y;
3489
3490
3491 bool on_icon = (x_offset >= 0 &&
3492 x_offset <= icon_size &&
3493 y_offset >= 0 &&
3494 y_offset <= icon_size);
3495
3496 on_helper = false;
3497 if (icon_renderer.selection_helpers) {
3498 int x_helper_offset = x - icon_renderer.helper_x;
3499 int y_helper_offset = y - icon_renderer.helper_y;
3500
3501 on_helper = (x_helper_offset >= 0 &&
3502 x_helper_offset <= icon_renderer.helper_size &&
3503 y_helper_offset >= 0 &&
3504 y_helper_offset <= icon_renderer.helper_size);
3505 }
3506
3507 return on_icon;
3508 }
3509
3510 protected void invert_selection () {3485 protected void invert_selection () {
3511 GLib.List<Gtk.TreeRowReference> selected_row_refs = null;3486 GLib.List<Gtk.TreeRowReference> selected_row_refs = null;
35123487
@@ -3560,6 +3535,7 @@
3560 protected abstract void thaw_tree ();3535 protected abstract void thaw_tree ();
3561 protected new abstract void freeze_child_notify ();3536 protected new abstract void freeze_child_notify ();
3562 protected new abstract void thaw_child_notify ();3537 protected new abstract void thaw_child_notify ();
3538 protected abstract bool is_on_icon (int x, int y, int orig_x, int orig_y, ref bool on_helper);
35633539
3564/** Unimplemented methods3540/** Unimplemented methods
3565 * fm_directory_view_parent_set () - purpose unclear3541 * fm_directory_view_parent_set () - purpose unclear
35663542
=== modified file 'src/View/AbstractTreeView.vala'
--- src/View/AbstractTreeView.vala 2017-02-07 19:38:46 +0000
+++ src/View/AbstractTreeView.vala 2017-03-01 17:49:39 +0000
@@ -321,5 +321,29 @@
321 protected override void thaw_child_notify () {321 protected override void thaw_child_notify () {
322 tree.thaw_child_notify ();322 tree.thaw_child_notify ();
323 }323 }
324
325 protected override bool is_on_icon (int x, int y, int orig_x, int orig_y, ref bool on_helper) {
326 /* orig_x and orig_y must be top left hand corner of icon (excluding helper) */
327 int x_offset = x - orig_x;
328 int y_offset = y - orig_y;
329
330 bool on_icon = (x_offset >= 0 &&
331 x_offset <= icon_size &&
332 y_offset >= 0 &&
333 y_offset <= icon_size);
334
335 on_helper = false;
336 if (icon_renderer.selection_helpers) {
337 int x_helper_offset = x - icon_renderer.helper_x;
338 int y_helper_offset = y - icon_renderer.helper_y;
339
340 on_helper = (x_helper_offset >= 0 &&
341 x_helper_offset <= icon_renderer.helper_size &&
342 y_helper_offset >= 0 &&
343 y_helper_offset <= icon_renderer.helper_size);
344 }
345
346 return on_icon;
347 }
324 }348 }
325}349}
326350
=== modified file 'src/View/IconView.vala'
--- src/View/IconView.vala 2017-02-08 12:48:45 +0000
+++ src/View/IconView.vala 2017-03-01 17:49:39 +0000
@@ -225,10 +225,10 @@
225 if (x >= rect.x &&225 if (x >= rect.x &&
226 x <= rect.x + rect.width &&226 x <= rect.x + rect.width &&
227 y >= rect.y &&227 y >= rect.y &&
228 y <= rect.y + (r as Marlin.TextRenderer).text_height)228 y <= rect.y + (r as Marlin.TextRenderer).text_height) {
229229
230 zone = ClickZone.NAME;230 zone = ClickZone.NAME;
231 else if (rubberband) {231 } else if (rubberband) {
232 /* Fake location outside centre bottom of item for rubberbanding */232 /* Fake location outside centre bottom of item for rubberbanding */
233 event.x = rect.x + rect.width / 2;233 event.x = rect.x + rect.width / 2;
234 event.y = rect.y + rect.height + 10 + (int)(get_vadjustment ().value);234 event.y = rect.y + rect.height + 10 + (int)(get_vadjustment ().value);
@@ -238,11 +238,11 @@
238 bool on_helper = false;238 bool on_helper = false;
239 bool on_icon = is_on_icon (x, y, area.x, area.y, ref on_helper);239 bool on_icon = is_on_icon (x, y, area.x, area.y, ref on_helper);
240240
241 if (on_helper)241 if (on_helper) {
242 zone = ClickZone.HELPER;242 zone = ClickZone.HELPER;
243 else if (on_icon)243 } else if (on_icon) {
244 zone = ClickZone.ICON;244 zone = ClickZone.ICON;
245 else if (rubberband) {245 } else if (rubberband) {
246 /* Fake location outside centre top of item for rubberbanding */246 /* Fake location outside centre top of item for rubberbanding */
247 event.x = rect.x + rect.width / 2;247 event.x = rect.x + rect.width / 2;
248 event.y = rect.y - 10 + (int)(get_vadjustment ().value);248 event.y = rect.y - 10 + (int)(get_vadjustment ().value);
@@ -440,6 +440,34 @@
440 }440 }
441 }441 }
442442
443 protected override bool is_on_icon (int x, int y, int orig_x, int orig_y, ref bool on_helper) {
444 /* orig_x and orig_y must be top left hand corner of icon (excluding helper) */
445 int x_offset = x - orig_x;
446 int y_offset = y - orig_y;
447
448 bool on_icon = (x_offset >= 0 &&
449 x_offset <= icon_size &&
450 y_offset >= 0 &&
451 y_offset <= icon_size);
452
453 on_helper = false;
454 if (icon_renderer.selection_helpers) {
455 int x_helper_offset = x - icon_renderer.helper_x;
456 /* IconView provide IconRenderer with bin coords not widget coords (unlike TreeView) so we have to
457 * correct for scrolling */
458 int y_helper_offset = y - icon_renderer.helper_y + (int)(get_vadjustment ().value);
459
460 on_helper = (x_helper_offset >= 0 &&
461 x_helper_offset <= icon_renderer.helper_size &&
462 y_helper_offset >= 0 &&
463 y_helper_offset <= icon_renderer.helper_size);
464
465 }
466
467 return on_icon;
468 }
469
470
443 /* When Icon View is automatically adjusting column number it does not expose the actual number of471 /* When Icon View is automatically adjusting column number it does not expose the actual number of
444 * columns (get_columns () returns -1). So we have to write our own method. This is the only way472 * columns (get_columns () returns -1). So we have to write our own method. This is the only way
445 * (I can think of) that works on row 0. 473 * (I can think of) that works on row 0.

Subscribers

People subscribed via source and target branches

to all changes: