From 4d986f7fb0ea53bd11f41c389daf9ff8ffdbaa0d Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 1 Jun 2011 20:58:53 -0400 Subject: [PATCH] shadow: add _gtk_box_shadow_render() This supports only inset box-shadow elements for now. --- gtk/gtkshadow.c | 43 ++++++++++++++++++++++++++++++++++++++++++ gtk/gtkshadowprivate.h | 12 +++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/gtk/gtkshadow.c b/gtk/gtkshadow.c index 180c968171..ebb0df332b 100644 --- a/gtk/gtkshadow.c +++ b/gtk/gtkshadow.c @@ -23,6 +23,8 @@ #include "gtkshadowprivate.h" #include "gtkstylecontext.h" +#include "gtkthemingengineprivate.h" +#include "gtkthemingengine.h" #include "gtkpango.h" #include "gtkthemingengineprivate.h" @@ -323,3 +325,44 @@ _gtk_icon_shadow_paint_spinner (GtkShadow *shadow, cairo_restore (cr); } } + +void +_gtk_box_shadow_render (GtkShadow *shadow, + cairo_t *cr, + const GtkRoundedBox *padding_box) +{ + GtkShadowElement *element; + GtkRoundedBox box; + GList *l; + + cairo_save (cr); + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + + _gtk_rounded_box_path (padding_box, cr); + cairo_clip (cr); + + /* render shadows starting from the last one, + * and the others on top. + */ + for (l = g_list_last (shadow->elements); l != NULL; l = l->prev) + { + element = l->data; + + if (!element->inset) + continue; + + box = *padding_box; + _gtk_rounded_box_move (&box, element->hoffset, element->voffset); + _gtk_rounded_box_shrink (&box, + element->spread, element->spread, + element->spread, element->spread); + + _gtk_rounded_box_path (&box, cr); + _gtk_rounded_box_path (padding_box, cr); + + gdk_cairo_set_source_rgba (cr, &element->color); + cairo_fill (cr); + } + + cairo_restore (cr); +} diff --git a/gtk/gtkshadowprivate.h b/gtk/gtkshadowprivate.h index 08dd3b6df7..5b9bad5f0c 100644 --- a/gtk/gtkshadowprivate.h +++ b/gtk/gtkshadowprivate.h @@ -23,9 +23,12 @@ #define __GTK_SHADOW_H__ #include -#include -#include -#include + +#include "gtkstyleproperties.h" +#include "gtksymboliccolor.h" +#include "gtkicontheme.h" +#include "gtkcsstypesprivate.h" +#include "gtkroundedboxprivate.h" G_BEGIN_DECLS @@ -65,6 +68,9 @@ void _gtk_icon_shadow_paint_spinner (GtkShadow *shadow, cairo_t *cr, gdouble radius, gdouble progress); +void _gtk_box_shadow_render (GtkShadow *shadow, + cairo_t *cr, + const GtkRoundedBox *padding_box); G_END_DECLS