Re: [PATCH] Fix shift-select in manual icon layout mode



Am Donnerstag, den 14.07.2005, 10:50 +0200 schrieb Alexander Larsson:
> On Thu, 2005-07-14 at 10:34 +0200, Christian Neumair wrote:
> > Am Mittwoch, den 13.07.2005, 14:09 +0200 schrieb Alexander Larsson:
> > > On Wed, 2005-07-13 at 13:51 +0200, Christian Neumair wrote:
> > > > Am Mittwoch, den 13.07.2005, 13:45 +0200 schrieb Alexander Larsson:
> > > > > On Tue, 2005-07-12 at 18:19 +0200, Christian Neumair wrote:
> > > > > > From bug 150116 [1]:
> > > > > > 
> > > > > > "When trying to select a range of files if ordering is set to manual,
> > > > > > the range of files is determined by file names instead of spatial
> > > > > > location.
> > > > > > 
> > > > > > This is especially obvious on the desktop where there is no auto-sort."
> > > > > > 
> > > > > > Proposed patch attached.
> > > > > > 
> > > > > > [1] http://bugzilla.gnome.org/show_bug.cgi?id=150116
> > > > > > 
> > > > > 
> > > > > +		x0 = MIN (icon1->x, icon2->x);
> > > > > +		x1 = MAX (icon1->x, icon2->x);
> > > > > +		y0 = MIN (icon1->y, icon2->y);
> > > > > +		y1 = MAX (icon1->y, icon2->y);
> > > > > 
> > > > > This doesn't look entierly right. Surely you want the whole part of the
> > > > > icons, not just its position (which i think is the corner? don't
> > > > > remember exactly).
> > > > 
> > > > Yes, as far as I know it's the upper-left corner. What's wrong with it?
> > > > You think we should also select items which just "touch"/intersect the
> > > > range to be selected instead of matching only those that are actually
> > > > contained within the range?
> > > 
> > > consider this case:
> > > 
> > >  a 
> > >   bc
> > >   
> > > where b and c really overlap vertically, except c is one pixel above b.
> > > [...]

> [...]
> 
> In the attached image of my desktop, your range select algorithm doesn't
> include the middle icon. I'm pretty sure this is not what most people
> expect.

The attached patch produces acceptable results at least on my desktop,
since the vertical grid space is 20 px. 25 px should also be enough to
handle some additional icon height-related displacement.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.392
diff -u -p -r1.392 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	6 Jul 2005 12:18:27 -0000	1.392
+++ libnautilus-private/nautilus-icon-container.c	14 Jul 2005 20:35:52 -0000
@@ -134,6 +134,10 @@
 #define SNAP_CEIL_HORIZONTAL(x) SNAP_HORIZONTAL (ceil, x)
 #define SNAP_CEIL_VERTICAL(y) SNAP_VERTICAL (ceil, y)
 
+/* max. offset for icons from selection area which are still considered
+ * as being selected when shift-selecting in manual layout mode*/
+#define MAX_FUZZY_SELECT_OFFSET 25
+
 enum {
 	ACTION_ACTIVATE,
 	ACTION_MENU,
@@ -1771,26 +1775,50 @@ select_range (NautilusIconContainer *con
 
 	unmatched_icon = NULL;
 	select = FALSE;
-	for (p = container->details->icons; p != NULL; p = p->next) {
-		icon = p->data;
+	if (container->details->auto_layout) {
+		for (p = container->details->icons; p != NULL; p = p->next) {
+			icon = p->data;
 
-		if (unmatched_icon == NULL) {
-			if (icon == icon1) {
-				unmatched_icon = icon2;
-				select = TRUE;
-			} else if (icon == icon2) {
-				unmatched_icon = icon1;
-				select = TRUE;
+			if (unmatched_icon == NULL) {
+				if (icon == icon1) {
+					unmatched_icon = icon2;
+					select = TRUE;
+				} else if (icon == icon2) {
+					unmatched_icon = icon1;
+					select = TRUE;
+				}
+			}
+			
+			selection_changed |= icon_set_selected
+				(container, icon, select);
+
+			if (unmatched_icon != NULL && icon == unmatched_icon) {
+				select = FALSE;
 			}
+			
 		}
-		
-		selection_changed |= icon_set_selected
-			(container, icon, select);
+	} else {
+		double x0, x1, y0, y1;
+
+		x0 = MIN (icon1->x, icon2->x) - MAX_FUZZY_SELECT_OFFSET;
+		x1 = MAX (icon1->x, icon2->x) + MAX_FUZZY_SELECT_OFFSET;
+		y0 = MIN (icon1->y, icon2->y) - MAX_FUZZY_SELECT_OFFSET;
+		y1 = MAX (icon1->y, icon2->y) + MAX_FUZZY_SELECT_OFFSET;
+
+		for (p = container->details->icons; p != NULL; p = p->next) {
+			icon = p->data;
 
-		if (unmatched_icon != NULL && icon == unmatched_icon) {
-			select = FALSE;
+			if (icon->x >= x0 && icon->x <= x1 &&
+			    icon->y >= y0 && icon->y <= y1) {
+				select = TRUE;
+			} else {
+				select = FALSE;
+			}
+			
+			selection_changed |= icon_set_selected
+				(container, icon, select);
 		}
-		
+
 	}
 	
 	if (selection_changed && icon2 != NULL) {

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]