summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-02-22 00:38:41 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-02-23 16:46:17 +0100
commita7cde3046b01b286a105b32185cc595a0cde6764 (patch)
tree8f105869770daeec063fde8acf2fcdc694016cd4
parent73d5a06850128063ffbf99f51144d4656387d5ad (diff)
downloadnautilus-a7cde3046b01b286a105b32185cc595a0cde6764.tar.gz
canvas-item: add dynamic label sizing for zoom levels
Last commit added dynamic grid size for canvas items. That gave me the idea to do the same for the label, allowing a mostly complete dynamic padding and label sizing for zoom levels. The calculations could be done by multiplying pixel_per_unit fore each padding level and then adjust, but in this way we have different padding per each level, giving more to smaller zooms than biggers ones.
-rw-r--r--libnautilus-private/nautilus-canvas-container.c9
-rw-r--r--libnautilus-private/nautilus-canvas-item.c32
2 files changed, 33 insertions, 8 deletions
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index b16452249..a562ac080 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -97,11 +97,12 @@
* So with an 80px grid unit, a 100px canvas item would take two grid units,
* where a 76px canvas item would only take one.
* Canvas items are then centered in the extra available space.
+ * Keep in sync with MAX_TEXT_WIDTH at nautilus-canvas-item.
*/
-#define SMALL_ICON_GRID_WIDTH 58
-#define STANDARD_ICON_GRID_WIDTH 56
-#define LARGE_ICON_GRID_WIDTH 56
-#define LARGER_ICON_GRID_WIDTH 64
+#define SMALL_ICON_GRID_WIDTH 124
+#define STANDARD_ICON_GRID_WIDTH 112
+#define LARGE_ICON_GRID_WIDTH 106
+#define LARGER_ICON_GRID_WIDTH 128
/* Desktop layout mode defines */
#define DESKTOP_PAD_HORIZONTAL 10
diff --git a/libnautilus-private/nautilus-canvas-item.c b/libnautilus-private/nautilus-canvas-item.c
index dbd6fe912..6eebea182 100644
--- a/libnautilus-private/nautilus-canvas-item.c
+++ b/libnautilus-private/nautilus-canvas-item.c
@@ -53,9 +53,11 @@
#define TEXT_BACK_PADDING_X 4
#define TEXT_BACK_PADDING_Y 1
-/* Width of the label with the standard icon size NAUTILUS_CANVAS_ICON_SIZE_STANDARD.
- * It will adapt to other sizes keeping the same space.*/
-#define MAX_TEXT_WIDTH_STANDARD 110
+/* Width of the label, keep in sync with ICON_GRID_WIDTH at nautilus-canvas-container.c */
+#define MAX_TEXT_WIDTH_SMALL 116
+#define MAX_TEXT_WIDTH_STANDARD 104
+#define MAX_TEXT_WIDTH_LARGE 98
+#define MAX_TEXT_WIDTH_LARGER 100
/* special text height handling
* each item has three text height variables:
@@ -676,10 +678,32 @@ static double
nautilus_canvas_item_get_max_text_width (NautilusCanvasItem *item)
{
EelCanvasItem *canvas_item;
+ NautilusCanvasContainer *container;
+ guint max_text_width;
+
canvas_item = EEL_CANVAS_ITEM (item);
+ container = canvas_item->canvas;
+
+ switch (nautilus_canvas_container_get_zoom_level (container)) {
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_SMALL:
+ max_text_width = MAX_TEXT_WIDTH_SMALL;
+ break;
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_STANDARD:
+ max_text_width = MAX_TEXT_WIDTH_STANDARD;
+ break;
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_LARGE:
+ max_text_width = MAX_TEXT_WIDTH_LARGE;
+ break;
+ case NAUTILUS_CANVAS_ZOOM_LEVEL_LARGER:
+ max_text_width = MAX_TEXT_WIDTH_LARGER;
+ break;
+ default:
+ g_warning ("Zoom level not valid. This may incur in missaligned grid");
+ max_text_width = MAX_TEXT_WIDTH_STANDARD;
+ }
- return MAX_TEXT_WIDTH_STANDARD * canvas_item->canvas->pixels_per_unit - 2 * TEXT_BACK_PADDING_X;
+ return max_text_width * canvas_item->canvas->pixels_per_unit - 2 * TEXT_BACK_PADDING_X;
}
static void