[gtk+/rendering-cleanup: 57/124] style: Replace draw_diamond vfunc with Cairo calls
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 57/124] style: Replace draw_diamond vfunc with Cairo calls
- Date: Thu, 22 Jul 2010 02:03:27 +0000 (UTC)
commit aa6e523a4b11703b4f143c9909ae39f5a61e01ad
Author: Benjamin Otte <otte redhat com>
Date: Thu Jul 15 00:35:15 2010 +0200
style: Replace draw_diamond vfunc with Cairo calls
gtk/gtkstyle.c | 168 +++++++++++++++++++++++++++-----------------------------
1 files changed, 81 insertions(+), 87 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 8e7c290..2e4f823 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -2483,68 +2483,61 @@ gtk_default_draw_diamond (GtkStyle *style,
{
gint half_width;
gint half_height;
- GdkGC *outer_nw = NULL;
- GdkGC *outer_ne = NULL;
- GdkGC *outer_sw = NULL;
- GdkGC *outer_se = NULL;
- GdkGC *middle_nw = NULL;
- GdkGC *middle_ne = NULL;
- GdkGC *middle_sw = NULL;
- GdkGC *middle_se = NULL;
- GdkGC *inner_nw = NULL;
- GdkGC *inner_ne = NULL;
- GdkGC *inner_sw = NULL;
- GdkGC *inner_se = NULL;
+ GdkColor *outer_nw = NULL;
+ GdkColor *outer_ne = NULL;
+ GdkColor *outer_sw = NULL;
+ GdkColor *outer_se = NULL;
+ GdkColor *middle_nw = NULL;
+ GdkColor *middle_ne = NULL;
+ GdkColor *middle_sw = NULL;
+ GdkColor *middle_se = NULL;
+ GdkColor *inner_nw = NULL;
+ GdkColor *inner_ne = NULL;
+ GdkColor *inner_sw = NULL;
+ GdkColor *inner_se = NULL;
+ cairo_t *cr;
sanitize_size (window, &width, &height);
half_width = width / 2;
half_height = height / 2;
- if (area)
- {
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
- gdk_gc_set_clip_rectangle (style->black_gc, area);
- }
-
switch (shadow_type)
{
case GTK_SHADOW_IN:
- inner_sw = inner_se = style->bg_gc[state_type];
- middle_sw = middle_se = style->light_gc[state_type];
- outer_sw = outer_se = style->light_gc[state_type];
- inner_nw = inner_ne = style->black_gc;
- middle_nw = middle_ne = style->dark_gc[state_type];
- outer_nw = outer_ne = style->dark_gc[state_type];
+ inner_sw = inner_se = &style->bg[state_type];
+ middle_sw = middle_se = &style->light[state_type];
+ outer_sw = outer_se = &style->light[state_type];
+ inner_nw = inner_ne = &style->black;
+ middle_nw = middle_ne = &style->dark[state_type];
+ outer_nw = outer_ne = &style->dark[state_type];
break;
case GTK_SHADOW_OUT:
- inner_sw = inner_se = style->dark_gc[state_type];
- middle_sw = middle_se = style->dark_gc[state_type];
- outer_sw = outer_se = style->black_gc;
- inner_nw = inner_ne = style->bg_gc[state_type];
- middle_nw = middle_ne = style->light_gc[state_type];
- outer_nw = outer_ne = style->light_gc[state_type];
+ inner_sw = inner_se = &style->dark[state_type];
+ middle_sw = middle_se = &style->dark[state_type];
+ outer_sw = outer_se = &style->black;
+ inner_nw = inner_ne = &style->bg[state_type];
+ middle_nw = middle_ne = &style->light[state_type];
+ outer_nw = outer_ne = &style->light[state_type];
break;
case GTK_SHADOW_ETCHED_IN:
- inner_sw = inner_se = style->bg_gc[state_type];
- middle_sw = middle_se = style->dark_gc[state_type];
- outer_sw = outer_se = style->light_gc[state_type];
- inner_nw = inner_ne = style->bg_gc[state_type];
- middle_nw = middle_ne = style->light_gc[state_type];
- outer_nw = outer_ne = style->dark_gc[state_type];
+ inner_sw = inner_se = &style->bg[state_type];
+ middle_sw = middle_se = &style->dark[state_type];
+ outer_sw = outer_se = &style->light[state_type];
+ inner_nw = inner_ne = &style->bg[state_type];
+ middle_nw = middle_ne = &style->light[state_type];
+ outer_nw = outer_ne = &style->dark[state_type];
break;
case GTK_SHADOW_ETCHED_OUT:
- inner_sw = inner_se = style->bg_gc[state_type];
- middle_sw = middle_se = style->light_gc[state_type];
- outer_sw = outer_se = style->dark_gc[state_type];
- inner_nw = inner_ne = style->bg_gc[state_type];
- middle_nw = middle_ne = style->dark_gc[state_type];
- outer_nw = outer_ne = style->light_gc[state_type];
+ inner_sw = inner_se = &style->bg[state_type];
+ middle_sw = middle_se = &style->light[state_type];
+ outer_sw = outer_se = &style->dark[state_type];
+ inner_nw = inner_ne = &style->bg[state_type];
+ middle_nw = middle_ne = &style->dark[state_type];
+ outer_nw = outer_ne = &style->light[state_type];
break;
default:
@@ -2552,54 +2545,55 @@ gtk_default_draw_diamond (GtkStyle *style,
break;
}
- if (inner_sw)
+ cr = gdk_cairo_create (window);
+ if (area)
{
- gdk_draw_line (window, inner_sw,
- x + 2, y + half_height,
- x + half_width, y + height - 2);
- gdk_draw_line (window, inner_se,
- x + half_width, y + height - 2,
- x + width - 2, y + half_height);
- gdk_draw_line (window, middle_sw,
- x + 1, y + half_height,
- x + half_width, y + height - 1);
- gdk_draw_line (window, middle_se,
- x + half_width, y + height - 1,
- x + width - 1, y + half_height);
- gdk_draw_line (window, outer_sw,
- x, y + half_height,
- x + half_width, y + height);
- gdk_draw_line (window, outer_se,
- x + half_width, y + height,
- x + width, y + half_height);
-
- gdk_draw_line (window, inner_nw,
- x + 2, y + half_height,
- x + half_width, y + 2);
- gdk_draw_line (window, inner_ne,
- x + half_width, y + 2,
- x + width - 2, y + half_height);
- gdk_draw_line (window, middle_nw,
- x + 1, y + half_height,
- x + half_width, y + 1);
- gdk_draw_line (window, middle_ne,
- x + half_width, y + 1,
- x + width - 1, y + half_height);
- gdk_draw_line (window, outer_nw,
- x, y + half_height,
- x + half_width, y);
- gdk_draw_line (window, outer_ne,
- x + half_width, y,
- x + width, y + half_height);
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
}
- if (area)
+ if (inner_sw)
{
- gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
- gdk_gc_set_clip_rectangle (style->black_gc, NULL);
+ _cairo_draw_line (cr, inner_sw,
+ x + 2, y + half_height,
+ x + half_width, y + height - 2);
+ _cairo_draw_line (cr, inner_se,
+ x + half_width, y + height - 2,
+ x + width - 2, y + half_height);
+ _cairo_draw_line (cr, middle_sw,
+ x + 1, y + half_height,
+ x + half_width, y + height - 1);
+ _cairo_draw_line (cr, middle_se,
+ x + half_width, y + height - 1,
+ x + width - 1, y + half_height);
+ _cairo_draw_line (cr, outer_sw,
+ x, y + half_height,
+ x + half_width, y + height);
+ _cairo_draw_line (cr, outer_se,
+ x + half_width, y + height,
+ x + width, y + half_height);
+
+ _cairo_draw_line (cr, inner_nw,
+ x + 2, y + half_height,
+ x + half_width, y + 2);
+ _cairo_draw_line (cr, inner_ne,
+ x + half_width, y + 2,
+ x + width - 2, y + half_height);
+ _cairo_draw_line (cr, middle_nw,
+ x + 1, y + half_height,
+ x + half_width, y + 1);
+ _cairo_draw_line (cr, middle_ne,
+ x + half_width, y + 1,
+ x + width - 1, y + half_height);
+ _cairo_draw_line (cr, outer_nw,
+ x, y + half_height,
+ x + half_width, y);
+ _cairo_draw_line (cr, outer_ne,
+ x + half_width, y,
+ x + width, y + half_height);
}
+
+ cairo_destroy (cr);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]