[gtk+/wip/css-icons] themingengine: Draw "icon-shadow" on icons



commit 3401462c9363ddb3e9549a7bd59898b7dafe9b54
Author: Benjamin Otte <otte redhat com>
Date:   Mon May 12 03:16:07 2014 +0200

    themingengine: Draw "icon-shadow" on icons

 gtk/gtkcssshadowsvalue.c        |    8 ++++++++
 gtk/gtkcssshadowsvalueprivate.h |    2 ++
 gtk/gtkthemingengine.c          |   11 +++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index eb32471..6ff7ef0 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -241,6 +241,14 @@ _gtk_css_shadows_value_parse (GtkCssParser *parser)
   return result;
 }
 
+gboolean
+_gtk_css_shadows_value_is_none (const GtkCssValue *shadows)
+{
+  g_return_val_if_fail (shadows->class == &GTK_CSS_VALUE_SHADOWS, TRUE);
+
+  return shadows->len == 0;
+}
+
 void
 _gtk_css_shadows_value_paint_layout (const GtkCssValue *shadows,
                                      cairo_t           *cr,
diff --git a/gtk/gtkcssshadowsvalueprivate.h b/gtk/gtkcssshadowsvalueprivate.h
index 2b227bd..5f2bdbb 100644
--- a/gtk/gtkcssshadowsvalueprivate.h
+++ b/gtk/gtkcssshadowsvalueprivate.h
@@ -33,6 +33,8 @@ G_BEGIN_DECLS
 GtkCssValue *   _gtk_css_shadows_value_new_none       (void);
 GtkCssValue *   _gtk_css_shadows_value_parse          (GtkCssParser             *parser);
 
+gboolean        _gtk_css_shadows_value_is_none        (const GtkCssValue        *shadows);
+
 void            _gtk_css_shadows_value_paint_layout   (const GtkCssValue        *shadows,
                                                        cairo_t                  *cr,
                                                        PangoLayout              *layout);
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 910d7b6..f85baba 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -1031,12 +1031,15 @@ render_icon_image (GtkThemingEngine *engine,
                    double            width,
                    double            height)
 {
+  const GtkCssValue *shadows;
   GtkCssImage *image;
 
   image = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, 
GTK_CSS_PROPERTY_ICON_SOURCE));
   if (image == NULL)
     return FALSE;
 
+  shadows = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW);
+
   cairo_translate (cr, x, y);
   cairo_translate (cr, width / 2, height / 2);
   
@@ -1044,6 +1047,14 @@ render_icon_image (GtkThemingEngine *engine,
     {
       cairo_translate (cr, -width / 2, -height / 2);
 
+      if (!_gtk_css_shadows_value_is_none (shadows))
+        {
+          cairo_push_group (cr);
+          _gtk_css_image_draw (image, cr, width, height);
+          cairo_pop_group_to_source (cr);
+          _gtk_css_shadows_value_paint_icon (shadows, cr);
+        }
+      
       _gtk_css_image_draw (image, cr, width, height);
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]