[gimp] app: fix drawing of the canvas padding color
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix drawing of the canvas padding color
- Date: Wed, 23 May 2018 20:51:16 +0000 (UTC)
commit b33c6bc0723ec217f409553eb90783840c15a930
Author: Michael Natterer <mitch gimp org>
Date: Wed May 23 22:46:54 2018 +0200
app: fix drawing of the canvas padding color
Remove all clipping hacks for drawing the canvas background, turns out
they never worked and we were relying on the pattern set on the
window, gah!
Also remove deprecated attempts to get a backgroud color and simply
don't show a color box in the menus for "from theme" cases.
app/actions/view-actions.c | 22 +++++-----------------
app/display/gimpcanvas.c | 21 ++++++++++-----------
app/display/gimpcanvas.h | 20 ++++++++++++--------
app/display/gimpdisplayshell-appearance.c | 23 +++++++++++------------
app/display/gimpdisplayshell-callbacks.c | 23 ++---------------------
app/display/gimpdisplayshell-draw.c | 13 +++++++------
6 files changed, 47 insertions(+), 75 deletions(-)
---
diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c
index d20ac33..5e0a8ff 100644
--- a/app/actions/view-actions.c
+++ b/app/actions/view-actions.c
@@ -21,7 +21,6 @@
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
-#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
@@ -1014,28 +1013,17 @@ view_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("view-snap-to-vectors", image);
SET_ACTIVE ("view-snap-to-vectors", display && options->snap_to_path);
+ if (display && options->padding_mode != GIMP_CANVAS_PADDING_MODE_DEFAULT)
+ SET_COLOR ("view-padding-color-menu", &options->padding_color);
+ else
+ SET_COLOR ("view-padding-color-menu", NULL);
+
SET_SENSITIVE ("view-padding-color-theme", image);
SET_SENSITIVE ("view-padding-color-light-check", image);
SET_SENSITIVE ("view-padding-color-dark-check", image);
SET_SENSITIVE ("view-padding-color-custom", image);
SET_SENSITIVE ("view-padding-color-prefs", image);
- if (display)
- {
- SET_COLOR ("view-padding-color-menu", &options->padding_color);
-
- if (shell->canvas)
- {
- GtkStyleContext *style = gtk_widget_get_style_context (shell->canvas);
- GdkRGBA color;
-
- gtk_style_context_get_background_color (style, 0, &color);
- gimp_rgb_set_alpha ((GimpRGB *) &color, GIMP_OPACITY_OPAQUE);
-
- SET_COLOR ("view-padding-color-theme", (GimpRGB *) &color);
- }
- }
-
SET_SENSITIVE ("view-show-menubar", image);
SET_ACTIVE ("view-show-menubar", display && options->show_menubar);
SET_SENSITIVE ("view-show-rulers", image);
diff --git a/app/display/gimpcanvas.c b/app/display/gimpcanvas.c
index 0ce3b93..fe49c2f 100644
--- a/app/display/gimpcanvas.c
+++ b/app/display/gimpcanvas.c
@@ -156,9 +156,9 @@ gimp_canvas_style_updated (GtkWidget *widget)
{
GimpCanvas *canvas = GIMP_CANVAS (widget);
- GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
-
g_clear_object (&canvas->layout);
+
+ GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
}
static gboolean
@@ -265,7 +265,7 @@ gimp_canvas_get_layout (GimpCanvas *canvas,
}
/**
- * gimp_canvas_set_bg_color:
+ * gimp_canvas_set_padding:
* @canvas: a #GimpCanvas widget
* @color: a color in #GimpRGB format
*
@@ -273,16 +273,15 @@ gimp_canvas_get_layout (GimpCanvas *canvas,
* is the color the canvas is set to if it is cleared.
**/
void
-gimp_canvas_set_bg_color (GimpCanvas *canvas,
- GimpRGB *color)
+gimp_canvas_set_padding (GimpCanvas *canvas,
+ GimpCanvasPaddingMode padding_mode,
+ const GimpRGB *padding_color)
{
- GtkWidget *widget = GTK_WIDGET (canvas);
-
- if (! gtk_widget_get_realized (widget))
- return;
+ g_return_if_fail (GIMP_IS_CANVAS (canvas));
+ g_return_if_fail (padding_color != NULL);
- gdk_window_set_background_rgba (gtk_widget_get_window (widget),
- (GdkRGBA *) color);
+ canvas->padding_mode = padding_mode;
+ canvas->padding_color = *padding_color;
gtk_widget_queue_draw (GTK_WIDGET (canvas));
}
diff --git a/app/display/gimpcanvas.h b/app/display/gimpcanvas.h
index e49bdfc..689e04c 100644
--- a/app/display/gimpcanvas.h
+++ b/app/display/gimpcanvas.h
@@ -49,10 +49,13 @@ typedef struct _GimpCanvasClass GimpCanvasClass;
struct _GimpCanvas
{
- GimpOverlayBox parent_instance;
+ GimpOverlayBox parent_instance;
- GimpDisplayConfig *config;
- PangoLayout *layout;
+ GimpDisplayConfig *config;
+ PangoLayout *layout;
+
+ GimpCanvasPaddingMode padding_mode;
+ GimpRGB padding_color;
};
struct _GimpCanvasClass
@@ -63,14 +66,15 @@ struct _GimpCanvasClass
GType gimp_canvas_get_type (void) G_GNUC_CONST;
-GtkWidget * gimp_canvas_new (GimpDisplayConfig *config);
+GtkWidget * gimp_canvas_new (GimpDisplayConfig *config);
-PangoLayout * gimp_canvas_get_layout (GimpCanvas *canvas,
- const gchar *format,
+PangoLayout * gimp_canvas_get_layout (GimpCanvas *canvas,
+ const gchar *format,
...) G_GNUC_PRINTF (2, 3);
-void gimp_canvas_set_bg_color (GimpCanvas *canvas,
- GimpRGB *color);
+void gimp_canvas_set_padding (GimpCanvas *canvas,
+ GimpCanvasPaddingMode padding_mode,
+ const GimpRGB *padding_color);
#endif /* __GIMP_CANVAS_H__ */
diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c
index 1109a6b..f0ba17d 100644
--- a/app/display/gimpdisplayshell-appearance.c
+++ b/app/display/gimpdisplayshell-appearance.c
@@ -432,12 +432,6 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell,
switch (padding_mode)
{
case GIMP_CANVAS_PADDING_MODE_DEFAULT:
- if (shell->canvas)
- {
- GtkStyleContext *style = gtk_widget_get_style_context (shell->canvas);
-
- gtk_style_context_get_background_color (style, 0, (GdkRGBA *) &color);
- }
break;
case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
@@ -458,16 +452,21 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell,
"padding-color", &color,
NULL);
- gimp_canvas_set_bg_color (GIMP_CANVAS (shell->canvas), &color);
+ gimp_canvas_set_padding (GIMP_CANVAS (shell->canvas),
+ padding_mode, &color);
- gimp_display_shell_set_action_color (shell, "view-padding-color-menu",
- &options->padding_color);
+ if (padding_mode != GIMP_CANVAS_PADDING_MODE_DEFAULT)
+ gimp_display_shell_set_action_color (shell, "view-padding-color-menu",
+ &options->padding_color);
+ else
+ gimp_display_shell_set_action_color (shell, "view-padding-color-menu",
+ NULL);
}
void
-gimp_display_shell_get_padding (GimpDisplayShell *shell,
- GimpCanvasPaddingMode *padding_mode,
- GimpRGB *padding_color)
+gimp_display_shell_get_padding (GimpDisplayShell *shell,
+ GimpCanvasPaddingMode *padding_mode,
+ GimpRGB *padding_color)
{
GimpDisplayOptions *options;
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 7a2afd1..d91e38f 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -423,29 +423,10 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
&image_rect.width,
&image_rect.height);
-
- /* first, clear the exposed part of the region that is outside the
- * image, which is the exposed region minus the image rectangle
+ /* first, draw the background
*/
- cairo_save (cr);
-
- if (shell->rotate_transform)
- cairo_transform (cr, shell->rotate_transform);
-
- cairo_rectangle (cr,
- image_rect.x,
- image_rect.y,
- image_rect.width,
- image_rect.height);
-
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip (cr);
-
- if (gdk_cairo_get_clip_rectangle (cr, NULL))
- gimp_display_shell_draw_background (shell, cr);
-
- cairo_restore (cr);
+ gimp_display_shell_draw_background (shell, cr);
/* then, draw the exposed part of the region that is inside the
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index 62955bf..dbe90b9 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -84,17 +84,18 @@ void
gimp_display_shell_draw_background (GimpDisplayShell *shell,
cairo_t *cr)
{
- GdkWindow *window;
- cairo_pattern_t *bg_pattern;
+ GimpCanvas *canvas;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
- window = gtk_widget_get_window (shell->canvas);
- bg_pattern = gdk_window_get_background_pattern (window);
+ canvas = GIMP_CANVAS (shell->canvas);
- cairo_set_source (cr, bg_pattern);
- cairo_paint (cr);
+ if (canvas->padding_mode != GIMP_CANVAS_PADDING_MODE_DEFAULT)
+ {
+ gimp_cairo_set_source_rgb (cr, &canvas->padding_color);
+ cairo_paint (cr);
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]