From dc0aff0c0e2408495b53151e482b471837491572 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 20 May 2003 17:52:48 +0000 Subject: [PATCH] app/display/gimpdisplayshell.[ch] removed padding_gc from the 2003-05-20 Sven Neumann * app/display/gimpdisplayshell.[ch] * app/display/gimpdisplayshell-callbacks.c: removed padding_gc from the GimpDisplayShell struct. Don't draw the padding color manually. * app/display/gimpdisplayshell-appearance.c (gimp_display_shell_set_padding): set the canvas background color using gdk_window_set_background(). --- ChangeLog | 10 ++++ app/display/gimpdisplayshell-appearance.c | 32 ++++++----- app/display/gimpdisplayshell-callbacks.c | 4 -- app/display/gimpdisplayshell-draw.c | 68 ++--------------------- app/display/gimpdisplayshell-draw.h | 1 - app/display/gimpdisplayshell.c | 68 ++--------------------- app/display/gimpdisplayshell.h | 1 - 7 files changed, 37 insertions(+), 147 deletions(-) diff --git a/ChangeLog b/ChangeLog index 576dfa2821..f07de809c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-05-20 Sven Neumann + + * app/display/gimpdisplayshell.[ch] + * app/display/gimpdisplayshell-callbacks.c: removed padding_gc from + the GimpDisplayShell struct. Don't draw the padding color manually. + + * app/display/gimpdisplayshell-appearance.c + (gimp_display_shell_set_padding): set the canvas background color + using gdk_window_set_background(). + 2003-05-20 Sven Neumann * app/core/gimpimage-rotate.c (gimp_image_rotate): fixed a harmless diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c index c1bde685cf..6b1bdcfb26 100644 --- a/app/display/gimpdisplayshell-appearance.c +++ b/app/display/gimpdisplayshell-appearance.c @@ -47,6 +47,8 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell, GimpDisplayPaddingMode padding_mode, GimpRGB *padding_color) { + guchar r, g, b; + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); g_return_if_fail (padding_color != NULL); @@ -55,20 +57,16 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell, switch (shell->padding_mode) { case GIMP_DISPLAY_PADDING_MODE_DEFAULT: - if (shell->padding_gc) + if (shell->canvas) { - guchar r, g, b; - + gtk_widget_ensure_style (shell->canvas); + r = shell->canvas->style->bg[GTK_STATE_NORMAL].red >> 8; g = shell->canvas->style->bg[GTK_STATE_NORMAL].green >> 8; b = shell->canvas->style->bg[GTK_STATE_NORMAL].blue >> 8; - + gimp_rgb_set_uchar (&shell->padding_color, r, g, b); } - else - { - shell->padding_color = *padding_color; - } break; case GIMP_DISPLAY_PADDING_MODE_LIGHT_CHECK: @@ -90,18 +88,22 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell, break; } - if (shell->padding_gc) + if (GTK_WIDGET_REALIZED (shell->canvas)) { - GdkColor gdk_color; - guchar r, g, b; + GdkColormap *colormap; + GdkColor color; gimp_rgb_get_uchar (&shell->padding_color, &r, &g, &b); - gdk_color.red = r + r * 256; - gdk_color.green = g + g * 256; - gdk_color.blue = b + b * 256; + color.red = r + r * 256; + color.green = g + g * 256; + color.blue = b + b * 256; - gdk_gc_set_rgb_fg_color (shell->padding_gc, &gdk_color); + colormap = gdk_drawable_get_colormap (shell->canvas->window); + g_return_if_fail (colormap != NULL); + gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE); + + gdk_window_set_background (shell->canvas->window, &color); } if (shell->padding_button) diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index d78e5f9b76..2ec9c189ae 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -252,14 +252,10 @@ gimp_display_shell_canvas_realize (GtkWidget *canvas, gtk_widget_grab_focus (shell->canvas); - shell->padding_gc = gdk_gc_new (canvas->window); - gimp_display_shell_set_padding (shell, shell->padding_mode, &shell->padding_color); - gdk_window_set_back_pixmap (shell->canvas->window, NULL, FALSE); - gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar)); gimp_display_shell_update_title (shell); diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index 58ae63807f..59d08941e1 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -245,7 +245,6 @@ gimp_display_shell_init (GimpDisplayShell *shell) shell->padding_mode = GIMP_DISPLAY_PADDING_MODE_DEFAULT; shell->padding_mode_set = FALSE; gimp_rgba_set (&shell->padding_color, 1.0, 1.0, 1.0, 1.0); - shell->padding_gc = NULL; shell->warning_dialog = NULL; shell->info_dialog = NULL; @@ -375,12 +374,6 @@ gimp_display_shell_destroy (GtkObject *object) shell->render_gc = NULL; } - if (shell->padding_gc) - { - g_object_unref (shell->padding_gc); - shell->padding_gc = NULL; - } - if (shell->title_idle_id) { g_source_remove (shell->title_idle_id); @@ -1322,67 +1315,16 @@ gimp_display_shell_draw_area (GimpDisplayShell *shell, sx = SCALEX (shell, shell->gdisp->gimage->width); sy = SCALEY (shell, shell->gdisp->gimage->height); - /* Bounds check */ + /* Bounds checks */ x1 = CLAMP (x, 0, shell->disp_width); y1 = CLAMP (y, 0, shell->disp_height); x2 = CLAMP (x + w, 0, shell->disp_width); y2 = CLAMP (y + h, 0, shell->disp_height); - if (y1 < shell->disp_yoffset) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - x, y, - w, shell->disp_yoffset - y); - /* X X X - . # . - . . . */ - - y1 = shell->disp_yoffset; - } - - if (x1 < shell->disp_xoffset) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - x, y1, - shell->disp_xoffset - x, h); - /* . . . - X # . - X . . */ - - x1 = shell->disp_xoffset; - } - - if (x2 > (shell->disp_xoffset + sx)) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - shell->disp_xoffset + sx, y1, - x2 - (shell->disp_xoffset + sx), h - (y1 - y)); - /* . . . - . # X - . . X */ - - x2 = shell->disp_xoffset + sx; - } - - if (y2 > (shell->disp_yoffset + sy)) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - x1, shell->disp_yoffset + sy, - x2 - x1, y2 - (shell->disp_yoffset + sy)); - /* . . . - . # . - . X . */ - - y2 = shell->disp_yoffset + sy; - } + x1 = MAX (x1, shell->disp_xoffset); + y1 = MAX (y1, shell->disp_yoffset); + x2 = MIN (x2, shell->disp_xoffset + sx); + y2 = MIN (y2, shell->disp_yoffset + sy); /* display the image in RENDER_BUF_WIDTH x RENDER_BUF_HEIGHT sized chunks */ for (i = y1; i < y2; i += GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT) diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h index 35daa96219..99aa213a3d 100644 --- a/app/display/gimpdisplayshell-draw.h +++ b/app/display/gimpdisplayshell-draw.h @@ -148,7 +148,6 @@ struct _GimpDisplayShell GimpDisplayPaddingMode padding_mode; gboolean padding_mode_set; GimpRGB padding_color; /* color of the empty around the image */ - GdkGC *padding_gc; /* GC with padding_color as BG */ GtkWidget *nav_ebox; /* GtkEventBox on the SE corner */ diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 58ae63807f..59d08941e1 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -245,7 +245,6 @@ gimp_display_shell_init (GimpDisplayShell *shell) shell->padding_mode = GIMP_DISPLAY_PADDING_MODE_DEFAULT; shell->padding_mode_set = FALSE; gimp_rgba_set (&shell->padding_color, 1.0, 1.0, 1.0, 1.0); - shell->padding_gc = NULL; shell->warning_dialog = NULL; shell->info_dialog = NULL; @@ -375,12 +374,6 @@ gimp_display_shell_destroy (GtkObject *object) shell->render_gc = NULL; } - if (shell->padding_gc) - { - g_object_unref (shell->padding_gc); - shell->padding_gc = NULL; - } - if (shell->title_idle_id) { g_source_remove (shell->title_idle_id); @@ -1322,67 +1315,16 @@ gimp_display_shell_draw_area (GimpDisplayShell *shell, sx = SCALEX (shell, shell->gdisp->gimage->width); sy = SCALEY (shell, shell->gdisp->gimage->height); - /* Bounds check */ + /* Bounds checks */ x1 = CLAMP (x, 0, shell->disp_width); y1 = CLAMP (y, 0, shell->disp_height); x2 = CLAMP (x + w, 0, shell->disp_width); y2 = CLAMP (y + h, 0, shell->disp_height); - if (y1 < shell->disp_yoffset) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - x, y, - w, shell->disp_yoffset - y); - /* X X X - . # . - . . . */ - - y1 = shell->disp_yoffset; - } - - if (x1 < shell->disp_xoffset) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - x, y1, - shell->disp_xoffset - x, h); - /* . . . - X # . - X . . */ - - x1 = shell->disp_xoffset; - } - - if (x2 > (shell->disp_xoffset + sx)) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - shell->disp_xoffset + sx, y1, - x2 - (shell->disp_xoffset + sx), h - (y1 - y)); - /* . . . - . # X - . . X */ - - x2 = shell->disp_xoffset + sx; - } - - if (y2 > (shell->disp_yoffset + sy)) - { - gdk_draw_rectangle (shell->canvas->window, - shell->padding_gc, - TRUE, - x1, shell->disp_yoffset + sy, - x2 - x1, y2 - (shell->disp_yoffset + sy)); - /* . . . - . # . - . X . */ - - y2 = shell->disp_yoffset + sy; - } + x1 = MAX (x1, shell->disp_xoffset); + y1 = MAX (y1, shell->disp_yoffset); + x2 = MIN (x2, shell->disp_xoffset + sx); + y2 = MIN (y2, shell->disp_yoffset + sy); /* display the image in RENDER_BUF_WIDTH x RENDER_BUF_HEIGHT sized chunks */ for (i = y1; i < y2; i += GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT) diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index 35daa96219..99aa213a3d 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -148,7 +148,6 @@ struct _GimpDisplayShell GimpDisplayPaddingMode padding_mode; gboolean padding_mode_set; GimpRGB padding_color; /* color of the empty around the image */ - GdkGC *padding_gc; /* GC with padding_color as BG */ GtkWidget *nav_ebox; /* GtkEventBox on the SE corner */