[PATCH] Neaten up the layout for text beside icons



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
Index: nautilus-icon-canvas-item.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.c,v
retrieving revision 1.183
diff -u -p -r1.183 nautilus-icon-canvas-item.c
--- nautilus-icon-canvas-item.c	24 May 2004 17:46:05 -0000	1.183
+++ nautilus-icon-canvas-item.c	29 Sep 2004 23:23:32 -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.375
diff -u -p -r1.375 nautilus-icon-container.c
--- nautilus-icon-container.c	25 Jun 2004 19:22:29 -0000	1.375
+++ nautilus-icon-container.c	29 Sep 2004 23:23:34 -0000
@@ -900,6 +900,7 @@ get_grid_width (NautilusIconContainer *c
 
 typedef struct {
 	double width;
+	double height;
 	double x_offset;
 	double y_offset;
 } IconPositions;
@@ -909,11 +910,12 @@ 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;
 
@@ -926,11 +928,17 @@ lay_down_one_line (NautilusIconContainer
 		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 +982,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 +997,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);
@@ -1020,11 +1028,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 +1056,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 - (bounds.x1 - bounds.x0)) / 2 + ICON_PAD_LEFT;
 			position->y_offset = 0;
 		} else {
 			position->x_offset = (icon_width - (icon_bounds.x1 - icon_bounds.x0)) / 2;
@@ -1070,7 +1079,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]