summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-canvas-item.c
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-02-22 00:38:41 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-02-24 11:15:02 +0100
commitc3f111a9db0194db06cea26a93a228e2f0a440b4 (patch)
tree1bd14becd6d3b80f811a09733d4a3c67f1f0da47 /libnautilus-private/nautilus-canvas-item.c
parent955b99ab995c0cea02475ed9e28d67508946d5e3 (diff)
downloadnautilus-c3f111a9db0194db06cea26a93a228e2f0a440b4.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.
Diffstat (limited to 'libnautilus-private/nautilus-canvas-item.c')
-rw-r--r--libnautilus-private/nautilus-canvas-item.c32
1 files changed, 28 insertions, 4 deletions
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