mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-18 05:46:11 +00:00
widgets, gui: Connect GimpToolBox to icon size changes
Inspired by Mark Sweeney's work. This patch allows the active image, brush, pattern, and gradient areas in the toolbox to scale based on user icon scale preferences. Note that if the pattern itself is smaller than the icon size, it currently won't scale larger. This is a separate issue in the renderer.
This commit is contained in:
parent
c1ec6a5c0b
commit
70ae12eb16
|
@ -478,6 +478,8 @@ themes_apply_theme (Gimp *gimp,
|
|||
"\n"
|
||||
"* { -GimpToolPalette-tool-icon-size: %s; }"
|
||||
"\n"
|
||||
"* { -GimpDock-tool-icon-size: %s; }"
|
||||
"\n"
|
||||
"* { -GimpDockbook-tab-icon-size: %s; }"
|
||||
"\n"
|
||||
"* { -GimpColorNotebook-tab-icon-size: %s; }"
|
||||
|
@ -493,9 +495,9 @@ themes_apply_theme (Gimp *gimp,
|
|||
"button, tab { padding: %dpx; }"
|
||||
"\n"
|
||||
"paned separator { padding: %dpx; }",
|
||||
tool_icon_size, tab_icon_size, tab_icon_size, button_icon_size,
|
||||
button_icon_size, tool_icon_size, pal_padding, tab_padding,
|
||||
sep_padding);
|
||||
tool_icon_size, tool_icon_size, tab_icon_size, tab_icon_size,
|
||||
button_icon_size, button_icon_size, tool_icon_size, pal_padding,
|
||||
tab_padding, sep_padding);
|
||||
}
|
||||
|
||||
if (! error && config->font_relative_size != 1.0)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
@ -138,6 +139,13 @@ gimp_dock_class_init (GimpDockClass *klass)
|
|||
klass->description_invalidated = NULL;
|
||||
klass->geometry_invalidated = NULL;
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_enum ("tool-icon-size",
|
||||
NULL, NULL,
|
||||
GTK_TYPE_ICON_SIZE,
|
||||
GTK_ICON_SIZE_SMALL_TOOLBAR,
|
||||
GIMP_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "GimpDock");
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ gimp_toolbox_image_area_create (GimpToolbox *toolbox,
|
|||
gimp_view_set_viewable (GIMP_VIEW (image_view),
|
||||
GIMP_VIEWABLE (gimp_context_get_image (context)));
|
||||
|
||||
gtk_widget_show (image_view);
|
||||
gtk_widget_set_visible (image_view, TRUE);
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
tooltip = g_strdup_printf ("%s\n%s",
|
||||
|
|
|
@ -44,10 +44,7 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define CELL_SIZE 24 /* The size of the previews */
|
||||
#define GRAD_CELL_WIDTH 52 /* The width of the gradient preview */
|
||||
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
|
||||
#define CELL_SPACING 2 /* How much between brush and pattern cells */
|
||||
#define CELL_SPACING 2 /* How much between brush and pattern cells */
|
||||
|
||||
|
||||
static void
|
||||
|
@ -139,6 +136,9 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
|
|||
GtkWidget *brush_view;
|
||||
GtkWidget *pattern_view;
|
||||
GtkWidget *gradient_view;
|
||||
GtkIconSize tool_icon_size;
|
||||
gint pixel_size;
|
||||
gint gradient_width;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
|
||||
|
||||
|
@ -150,17 +150,23 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
|
|||
|
||||
gimp_help_set_help_data (grid, NULL, GIMP_HELP_TOOLBOX_INDICATOR_AREA);
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (toolbox),
|
||||
"tool-icon-size", &tool_icon_size,
|
||||
NULL);
|
||||
gtk_icon_size_lookup (tool_icon_size, &pixel_size, NULL);
|
||||
gradient_width = pixel_size * (13/6.0f);
|
||||
|
||||
/* brush view */
|
||||
|
||||
brush_view =
|
||||
gimp_view_new_full_by_types (context,
|
||||
GIMP_TYPE_VIEW, GIMP_TYPE_BRUSH,
|
||||
CELL_SIZE, CELL_SIZE, 1,
|
||||
pixel_size, pixel_size, 1,
|
||||
FALSE, TRUE, TRUE);
|
||||
gimp_view_set_viewable (GIMP_VIEW (brush_view),
|
||||
GIMP_VIEWABLE (gimp_context_get_brush (context)));
|
||||
gtk_grid_attach (GTK_GRID (grid), brush_view, 0, 0, 1, 1);
|
||||
gtk_widget_show (brush_view);
|
||||
gtk_widget_set_visible (brush_view, TRUE);
|
||||
|
||||
gimp_help_set_help_data (brush_view,
|
||||
_("The active brush.\n"
|
||||
|
@ -185,13 +191,13 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
|
|||
pattern_view =
|
||||
gimp_view_new_full_by_types (context,
|
||||
GIMP_TYPE_VIEW, GIMP_TYPE_PATTERN,
|
||||
CELL_SIZE, CELL_SIZE, 1,
|
||||
pixel_size, pixel_size, 1,
|
||||
FALSE, TRUE, TRUE);
|
||||
gimp_view_set_viewable (GIMP_VIEW (pattern_view),
|
||||
GIMP_VIEWABLE (gimp_context_get_pattern (context)));
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), pattern_view, 1, 0, 1, 1);
|
||||
gtk_widget_show (pattern_view);
|
||||
gtk_widget_set_visible (pattern_view, TRUE);
|
||||
|
||||
gimp_help_set_help_data (pattern_view,
|
||||
_("The active pattern.\n"
|
||||
|
@ -216,13 +222,13 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
|
|||
gradient_view =
|
||||
gimp_view_new_full_by_types (context,
|
||||
GIMP_TYPE_VIEW, GIMP_TYPE_GRADIENT,
|
||||
GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, 1,
|
||||
gradient_width, (pixel_size / 2), 1,
|
||||
FALSE, TRUE, TRUE);
|
||||
gimp_view_set_viewable (GIMP_VIEW (gradient_view),
|
||||
GIMP_VIEWABLE (gimp_context_get_gradient (context)));
|
||||
|
||||
gtk_grid_attach (GTK_GRID (grid), gradient_view, 0, 1, 2, 1);
|
||||
gtk_widget_show (gradient_view);
|
||||
gtk_widget_set_visible (gradient_view, TRUE);
|
||||
|
||||
gimp_help_set_help_data (gradient_view,
|
||||
_("The active gradient.\n"
|
||||
|
@ -242,7 +248,7 @@ gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
|
|||
gradient_preview_drop_gradient,
|
||||
context);
|
||||
|
||||
gtk_widget_show (grid);
|
||||
gtk_widget_set_visible (grid, TRUE);
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "gimpdockwindow.h"
|
||||
#include "gimphelp-ids.h"
|
||||
#include "gimppanedbox.h"
|
||||
#include "gimpviewrenderer.h"
|
||||
#include "gimptoolbox.h"
|
||||
#include "gimptoolbox-color-area.h"
|
||||
#include "gimptoolbox-dnd.h"
|
||||
|
@ -48,6 +49,7 @@
|
|||
#include "gimptoolbox-indicator-area.h"
|
||||
#include "gimptoolpalette.h"
|
||||
#include "gimpuimanager.h"
|
||||
#include "gimpview.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
|
||||
#include "about.h"
|
||||
|
@ -95,6 +97,7 @@ static void gimp_toolbox_get_property (GObject *object,
|
|||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_toolbox_style_updated (GtkWidget *widget);
|
||||
static gboolean gimp_toolbox_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event);
|
||||
static void gimp_toolbox_drag_leave (GtkWidget *widget,
|
||||
|
@ -162,6 +165,7 @@ gimp_toolbox_class_init (GimpToolboxClass *klass)
|
|||
object_class->get_property = gimp_toolbox_get_property;
|
||||
|
||||
widget_class->button_press_event = gimp_toolbox_button_press_event;
|
||||
widget_class->style_updated = gimp_toolbox_style_updated;
|
||||
|
||||
dock_class->get_description = gimp_toolbox_get_description;
|
||||
dock_class->set_host_geometry_hints = gimp_toolbox_set_host_geometry_hints;
|
||||
|
@ -226,6 +230,19 @@ gimp_toolbox_constructed (GObject *object)
|
|||
G_CALLBACK (gimp_toolbox_drag_drop),
|
||||
toolbox);
|
||||
|
||||
g_signal_connect_object (config,
|
||||
"notify::theme",
|
||||
G_CALLBACK (gimp_toolbox_style_updated),
|
||||
toolbox, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (config,
|
||||
"notify::override-theme-icon-size",
|
||||
G_CALLBACK (gimp_toolbox_style_updated),
|
||||
toolbox, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (config,
|
||||
"notify::custom-icon-size",
|
||||
G_CALLBACK (gimp_toolbox_style_updated),
|
||||
toolbox, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
|
||||
event_box = gtk_event_box_new ();
|
||||
gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), event_box, FALSE, FALSE, 0);
|
||||
g_signal_connect_swapped (event_box, "button-press-event",
|
||||
|
@ -351,6 +368,45 @@ gimp_toolbox_get_property (GObject *object,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_toolbox_style_updated (GtkWidget *widget)
|
||||
{
|
||||
GimpToolbox *toolbox = GIMP_TOOLBOX (widget);
|
||||
GtkWidget *area;
|
||||
GtkIconSize tool_icon_size;
|
||||
gint pixel_size;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"tool-icon-size", &tool_icon_size,
|
||||
NULL);
|
||||
gtk_icon_size_lookup (tool_icon_size, &pixel_size, NULL);
|
||||
|
||||
width = pixel_size * (13/6.0f);
|
||||
height = pixel_size * 1.75f;
|
||||
|
||||
/* Image Area */
|
||||
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->image_area), 0, 0);
|
||||
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
||||
width, height, 0);
|
||||
|
||||
/* Brush Area */
|
||||
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->foo_area), 0, 0);
|
||||
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
||||
pixel_size, pixel_size, 0);
|
||||
|
||||
/* Pattern Area */
|
||||
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->foo_area), 1, 0);
|
||||
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
||||
pixel_size, pixel_size, 0);
|
||||
|
||||
/* Gradient Area */
|
||||
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->foo_area), 0, 1);
|
||||
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
||||
width, (pixel_size / 2), 0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_toolbox_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event)
|
||||
|
@ -692,10 +748,28 @@ static GtkWidget *
|
|||
toolbox_create_image_area (GimpToolbox *toolbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *image_area;
|
||||
GtkWidget *image_area;
|
||||
GtkWidget *grid;
|
||||
GtkIconSize tool_icon_size;
|
||||
gint width = 52;
|
||||
gint height = 42;
|
||||
|
||||
image_area = gimp_toolbox_image_area_create (toolbox, 52, 42);
|
||||
g_object_set (image_area,
|
||||
grid = gtk_grid_new ();
|
||||
gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (toolbox),
|
||||
"tool-icon-size", &tool_icon_size,
|
||||
NULL);
|
||||
gtk_icon_size_lookup (tool_icon_size, &width, &height);
|
||||
width *= (13/6.0f);
|
||||
height *= 1.75f;
|
||||
|
||||
image_area = gimp_toolbox_image_area_create (toolbox, width, height);
|
||||
gtk_grid_attach (GTK_GRID (grid), image_area, 0, 0, 1, 1);
|
||||
gtk_widget_set_visible (grid, TRUE);
|
||||
|
||||
g_object_set (grid,
|
||||
"halign", GTK_ALIGN_CENTER,
|
||||
"valign", GTK_ALIGN_CENTER,
|
||||
"margin-start", 2,
|
||||
|
@ -704,7 +778,7 @@ toolbox_create_image_area (GimpToolbox *toolbox,
|
|||
"margin-bottom", 2,
|
||||
NULL);
|
||||
|
||||
return image_area;
|
||||
return grid;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
-GimpDockWindow-menu-preview-size: button;
|
||||
-GimpToolPalette-tool-icon-size: large-toolbar;
|
||||
-GimpToolPalette-button-relief: none;
|
||||
-GimpDock-tool-icon-size: large-toolbar;
|
||||
-GimpDockbook-tab-icon-size: button;
|
||||
-GimpColorNotebook-tab-icon-size: button;
|
||||
-GimpDockable-content-border: 2;
|
||||
|
|
Loading…
Reference in a new issue