Re: [PATCH] Neaten up the layout for text beside icons



Done...
iain

On Wed, 06 Oct 2004 18:22:47 -0400, Dave Camp <dave novell com> wrote:
> Yeah.  I think the code that's there does a baseline well assuming you
> don't have any stretched icons.  That's probably the best bet -
> stretched icons are a fairly rare corner case.
> 
> -dave
> 
> 
> 
> On Wed, 2004-10-06 at 23:05 +0100, Iain * wrote:
> > Actually, I've been thinking about this, and the current way that
> > nautilus lays out icons wouldn't (unless I'm mistaken) be able to do
> > this. Each row is laid out and drawn, and works down, which means that
> > the very first row that is laid out would be the baseline setter for
> > each column, and if an icon was bigger than this baseline, it would
> > push icons about all wrong.
> >
> > I'll think about this at more length...
> >
> > iain
> >
> >
> > On Wed, 06 Oct 2004 11:38:46 -0400, Dave Camp <dave novell com> wrote:
> > > Ideally we want a vertical baseline on the left hand side of the text,
> > > similar to the horizontal baseline above it in normal mode.
> > >
> > > -dave
> > >
> > >
> > >
> > >
> > > On Wed, 2004-10-06 at 16:29 +0100, Iain * wrote:
> > > > Hmm, yes...
> > > > Do we want the text labels aligned, or the icons aligned?
> > > >
> > > > iain
> > > >
> > > > On Wed, 6 Oct 2004 11:24:14 -0400, Vincent Noel <vincent noel gmail com> wrote:
> > > > > The patch improves a lot the display in text-besides-icon, but the
> > > > > icons are vertically misaligned. When there's only a single column of
> > > > > icons it's kind of obvious (see the attached screenshot). Is this on
> > > > > purpose ?
> > > > > Note that even with the misalignment it's still better than before.
> > > > >
> > > > >
> > > > >
> > > > > On Wed, 06 Oct 2004 11:07:14 -0400, Dave Camp <dave novell com> wrote:
> > > > > > Looks good, please commit.
> > > > > >
> > > > > > -dave
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Wed, 2004-10-06 at 10:38 +0100, Iain * wrote:
> > > > > > > With the recent comments on the text beside icons style I took a look
> > > > > > > at making it a bit neater. Attached is a patch that lines the icons
> > > > > > > and text along a centre line down the middle of the tallest icon.
> > > > > > >
> > > > > > > An also semi-related change is this
> > > > > > > -                       position->x_offset = (MAXIMUM_IMAGE_SIZE -
> > > > > > > (icon_bounds.x1 - icon_bounds.x0));
> > > > > > > +                       position->x_offset = (icon_width - (bounds.x1
> > > > > > > - bounds.x0)) / 2 + ICON_PAD_LEFT;
> > > > > > >
> > > > > > > It is possible to have an icon that is larger than MAXIMUM_IMAGE_SIZE
> > > > > > > if you are viewing the desktop folder as a normal folder and have
> > > > > > > stretched an icon. This change lines it up correctly. The
> > > > > > > ICON_PAD_LEFT is added because there was no padding for icons in this
> > > > > > > style.
> > > > > > >
> > > > > > > Enjoy, iain
> > > > > >
> > > > > > --
> > > > > > nautilus-list mailing list
> > > > > > nautilus-list gnome org
> > > > > > http://mail.gnome.org/mailman/listinfo/nautilus-list
> > > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> 
>
Index: nautilus-icon-canvas-item.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.c,v
retrieving revision 1.185
diff -u -p -r1.185 nautilus-icon-canvas-item.c
--- nautilus-icon-canvas-item.c	6 Oct 2004 15:21:13 -0000	1.185
+++ nautilus-icon-canvas-item.c	6 Oct 2004 23:29:50 -0000
@@ -640,7 +640,7 @@ compute_text_rectangle (const NautilusIc
 	if (NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
                 text_rectangle.x0 = icon_rectangle.x1;
                 text_rectangle.x1 = text_rectangle.x0 + text_width;
-                text_rectangle.y0 = icon_rectangle.y0;
+                text_rectangle.y0 = (icon_rectangle.y0 + icon_rectangle.y1) / 2- (int) text_height / 2;
                 text_rectangle.y1 = text_rectangle.y0 + text_height + LABEL_OFFSET / pixels_per_unit;
 	} else {
                 text_rectangle.x0 = (icon_rectangle.x0 + icon_rectangle.x1) / 2 - (int) text_width / 2;
Index: nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.376
diff -u -p -r1.376 nautilus-icon-container.c
--- nautilus-icon-container.c	6 Oct 2004 14:03:05 -0000	1.376
+++ nautilus-icon-container.c	6 Oct 2004 23:29:51 -0000
@@ -121,6 +121,9 @@
 #define MINIMUM_EMBEDDED_TEXT_RECT_WIDTH       20
 #define MINIMUM_EMBEDDED_TEXT_RECT_HEIGHT      20
 
+/* From nautilus-icon-canvas-item.c */
+#define MAX_TEXT_WIDTH_BESIDE 90
+
 #define SNAP_HORIZONTAL(func,x) ((func ((double)((x) - DESKTOP_PAD_HORIZONTAL) / SNAP_SIZE_X) * SNAP_SIZE_X) + DESKTOP_PAD_HORIZONTAL)
 #define SNAP_VERTICAL(func, y) ((func ((double)((y) - DESKTOP_PAD_VERTICAL) / SNAP_SIZE_Y) * SNAP_SIZE_Y) + DESKTOP_PAD_VERTICAL)
 
@@ -900,6 +903,7 @@ get_grid_width (NautilusIconContainer *c
 
 typedef struct {
 	double width;
+	double height;
 	double x_offset;
 	double y_offset;
 } IconPositions;
@@ -909,28 +913,35 @@ lay_down_one_line (NautilusIconContainer
 		   GList *line_start,
 		   GList *line_end,
 		   double y,
+		   double max_height,
 		   GArray *positions)
 {
 	GList *p;
 	NautilusIcon *icon;
-	double x;
+	double x, y_offset;
 	IconPositions *position;
 	int i;
 
 	/* FIXME: Should layout differently when in RTL base mode */
 
 	/* Lay out the icons along the baseline. */
-	x = 0;
+	x = ICON_PAD_LEFT;
 	i = 0;
 	for (p = line_start; p != line_end; p = p->next) {
 		icon = p->data;
 
 		position = &g_array_index (positions, IconPositions, i++);
+		
+		if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
+			y_offset = (max_height - position->height) / 2;
+		} else {
+			y_offset = position->y_offset;
+		}
 
 		icon_set_position
 			(icon,
 			 x + position->x_offset,
-			 y + position->y_offset);
+			 y + y_offset);
 
 		x += position->width;
 	}
@@ -974,7 +985,7 @@ lay_down_icons_horizontal (NautilusIconC
 
 	gridded_layout = !nautilus_icon_container_is_tighter_layout (container);
 	
-	line_width = 0;
+	line_width = container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE ? ICON_PAD_LEFT : 0;
 	line_start = icons;
 	y = start_y;
 	i = 0;
@@ -989,8 +1000,8 @@ lay_down_icons_horizontal (NautilusIconC
 		
 		/* Assume it's only one level hierarchy to avoid costly affine calculations */
 		eel_canvas_item_get_bounds (item,
-					      &bounds.x0, &bounds.y0,
-					      &bounds.x1, &bounds.y1);
+					    &bounds.x0, &bounds.y0,
+					    &bounds.x1, &bounds.y1);
 
 		icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
 		text_bounds = nautilus_icon_canvas_item_get_text_rectangle (icon->item);
@@ -1000,7 +1011,7 @@ lay_down_icons_horizontal (NautilusIconC
 
 
 		} else {
-			icon_width = ICON_PAD_LEFT + (bounds.x1 - bounds.x0) + ICON_PAD_RIGHT + 8; /* 8 pixels extra for fancy selection box */
+			icon_width = (bounds.x1 - bounds.x0) + ICON_PAD_RIGHT + 8; /* 8 pixels extra for fancy selection box */
 		}		
 
 		/* Calculate size above/below baseline */
@@ -1020,11 +1031,11 @@ lay_down_icons_horizontal (NautilusIconC
 				/* Advance to the baseline. */
 				y += ICON_PAD_TOP + max_height_above;
 			}
-			
-			lay_down_one_line (container, line_start, p, y, positions);
+
+			lay_down_one_line (container, line_start, p, y, max_height_above, positions);
 			
 			if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
-			y += max_height_above + max_height_below + ICON_PAD_BOTTOM;
+				y += max_height_above + max_height_below + ICON_PAD_BOTTOM;
 			} else {
 				/* Advance to next line. */
 				y += max_height_below + ICON_PAD_BOTTOM;
@@ -1048,9 +1059,10 @@ lay_down_icons_horizontal (NautilusIconC
 		g_array_set_size (positions, i + 1);
 		position = &g_array_index (positions, IconPositions, i++);
 		position->width = icon_width;
-		
+		position->height = icon_bounds.y1 - icon_bounds.y0;
+
 		if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
-			position->x_offset = (MAXIMUM_IMAGE_SIZE - (icon_bounds.x1 - icon_bounds.x0));
+			position->x_offset = icon_width - ((icon_bounds.x1 - icon_bounds.x0) + MAX_TEXT_WIDTH_BESIDE);
 			position->y_offset = 0;
 		} else {
 			position->x_offset = (icon_width - (icon_bounds.x1 - icon_bounds.x0)) / 2;
@@ -1070,7 +1082,7 @@ lay_down_icons_horizontal (NautilusIconC
 				y += ICON_PAD_TOP + max_height_above;
 			}
 		
-		lay_down_one_line (container, line_start, NULL, y, positions);
+		lay_down_one_line (container, line_start, NULL, y, max_height_above, positions);
 		
 		/* Advance to next line. */
 		y += max_height_below + ICON_PAD_BOTTOM;


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