[gimp] app: size the GimpFgBgEditor relatively to the toolbox icon size.



commit 00fbcbea0bcfa9e0d1305818e0a31fa4231165b4
Author: Jehan <jehan girinstud io>
Date:   Sat Aug 20 23:48:44 2022 +0200

    app: size the GimpFgBgEditor relatively to the toolbox icon size.
    
    Until now we were sizing the FG/BG area with hardcoded size ((40, 38)
    which I'm not sure where it came from!). Now this allocation size will
    depend on the toolbox icon size (I made so that the FG/BG area is more
    or less the same size as former hardcoded values with large toolbar
    icons).
    I had to tweak a bit the size of the default FG/BG icons and the swap
    icons, which were also hardcoded. They now also depend on the allocation
    size, hence the icons size.
    
    Note that this code still has a limitation: it won't resize when you
    switch from a theme with one size to another size of icons. A restart
    will be necessary. This is something we should improve.

 app/widgets/gimpfgbgeditor.c |  8 +++++---
 app/widgets/gimptoolbox.c    | 15 ++++++++++++---
 2 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/app/widgets/gimpfgbgeditor.c b/app/widgets/gimpfgbgeditor.c
index 62e454e45e..4cf08f21f3 100644
--- a/app/widgets/gimpfgbgeditor.c
+++ b/app/widgets/gimpfgbgeditor.c
@@ -234,7 +234,7 @@ gimp_fg_bg_editor_init (GimpFgBgEditor *editor)
                              G_CALLBACK (gimp_fg_bg_editor_destroy_transform),
                              NULL, NULL);
 
-  gtk_widget_set_size_request (GTK_WIDGET (editor), 32, 24);
+  gtk_widget_set_size_request (GTK_WIDGET (editor), 24, 24);
 }
 
 static void
@@ -357,7 +357,8 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
   /*  draw the default colors pixbuf  */
   if (! editor->default_icon)
     editor->default_icon = gimp_widget_load_icon (widget,
-                                                  GIMP_ICON_COLORS_DEFAULT, 12);
+                                                  GIMP_ICON_COLORS_DEFAULT,
+                                                  MAX (MIN (width * 0.3, 12), 6));
 
   default_w = gdk_pixbuf_get_width  (editor->default_icon) / scale_factor;
   default_h = gdk_pixbuf_get_height (editor->default_icon) / scale_factor;
@@ -383,7 +384,8 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
   /*  draw the swap colors pixbuf  */
   if (! editor->swap_icon)
     editor->swap_icon = gimp_widget_load_icon (widget,
-                                               GIMP_ICON_COLORS_SWAP, 12);
+                                               GIMP_ICON_COLORS_SWAP,
+                                               MAX (MIN (width * 0.3, 12), 6));
 
   swap_w = gdk_pixbuf_get_width  (editor->swap_icon) / scale_factor;
   swap_h = gdk_pixbuf_get_height (editor->swap_icon) / scale_factor;
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index d752a196e3..de82aabd58 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -593,9 +593,18 @@ static GtkWidget *
 toolbox_create_color_area (GimpToolbox *toolbox,
                            GimpContext *context)
 {
-  GtkWidget *col_area;
-
-  col_area = gimp_toolbox_color_area_create (toolbox, 40, 38);
+  GtkWidget   *col_area;
+  GtkIconSize  tool_icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
+  gint         icon_width     = 40;
+  gint         icon_height    = 38;
+
+  gtk_widget_style_get (GTK_WIDGET (toolbox->p->tool_palette),
+                        "tool-icon-size", &tool_icon_size,
+                        NULL);
+  gtk_icon_size_lookup (tool_icon_size, &icon_width, &icon_height);
+  col_area = gimp_toolbox_color_area_create (toolbox,
+                                             (gint) (icon_width * 1.75),
+                                             (gint) (icon_height * 1.75));
   g_object_set (col_area,
                 "halign",        GTK_ALIGN_CENTER,
                 "valign",        GTK_ALIGN_CENTER,


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