app/display/gimpdisplayshell.[ch] removed padding_gc from the

2003-05-20  Sven Neumann  <sven@gimp.org>

	* 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().
This commit is contained in:
Sven Neumann 2003-05-20 17:52:48 +00:00 committed by Sven Neumann
parent c90a88fd9d
commit dc0aff0c0e
7 changed files with 37 additions and 147 deletions

View File

@ -1,3 +1,13 @@
2003-05-20 Sven Neumann <sven@gimp.org>
* 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 <sven@gimp.org>
* app/core/gimpimage-rotate.c (gimp_image_rotate): fixed a harmless

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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 */

View File

@ -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)

View File

@ -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 */