[gtk+/wip/css-icons: 5/6] css: Add -gtk-icon-transform property
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css-icons: 5/6] css: Add -gtk-icon-transform property
- Date: Mon, 5 May 2014 14:31:59 +0000 (UTC)
commit bd52d78e8f4a5f8f927cb7c26931621513329b85
Author: Benjamin Otte <otte redhat com>
Date: Mon May 5 15:28:18 2014 +0200
css: Add -gtk-icon-transform property
This property allows transforming icons and is mainly intended to be
used for spinner animations.
gtk/gtkcssstylepropertyimpl.c | 20 ++++++++++++++++++--
gtk/gtkcsstypesprivate.h | 1 +
gtk/gtkthemingengine.c | 10 +++++++++-
3 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 882f5a6..0195e44 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -57,6 +57,7 @@
#include "gtkcssrgbavalueprivate.h"
#include "gtkcssshadowsvalueprivate.h"
#include "gtkcssstringvalueprivate.h"
+#include "gtkcsstransformvalueprivate.h"
#include "gtkthemingengine.h"
#include "gtktypebuiltins.h"
#include "gtkwin32themeprivate.h"
@@ -577,6 +578,13 @@ shadow_value_parse (GtkCssStyleProperty *property,
}
static GtkCssValue *
+transform_value_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser)
+{
+ return _gtk_css_transform_value_parse (parser);
+}
+
+static GtkCssValue *
border_corner_radius_value_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
@@ -962,8 +970,8 @@ _gtk_css_style_property_init_properties (void)
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
css_image_value_parse,
- css_image_value_query,
- css_image_value_assign,
+ NULL,
+ NULL,
_gtk_css_image_value_new (NULL));
gtk_css_style_property_register ("icon-shadow",
GTK_CSS_PROPERTY_ICON_SHADOW,
@@ -973,6 +981,14 @@ _gtk_css_style_property_init_properties (void)
NULL,
NULL,
_gtk_css_shadows_value_new_none ());
+ gtk_css_style_property_register ("-gtk-icon-transform",
+ GTK_CSS_PROPERTY_ICON_TRANSFORM,
+ G_TYPE_NONE,
+ GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
+ transform_value_parse,
+ NULL,
+ NULL,
+ _gtk_css_transform_value_new_none ());
gtk_css_style_property_register ("box-shadow",
GTK_CSS_PROPERTY_BOX_SHADOW,
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 53e24c8..7a4de90 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -82,6 +82,7 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_TEXT_SHADOW,
GTK_CSS_PROPERTY_ICON_SOURCE,
GTK_CSS_PROPERTY_ICON_SHADOW,
+ GTK_CSS_PROPERTY_ICON_TRANSFORM,
GTK_CSS_PROPERTY_BOX_SHADOW,
GTK_CSS_PROPERTY_MARGIN_TOP,
GTK_CSS_PROPERTY_MARGIN_LEFT,
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index b009c75..57b9eb2 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -35,6 +35,7 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkcssshadowsvalueprivate.h"
+#include "gtkcsstransformvalueprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkhslaprivate.h"
#include "gtkthemingengineprivate.h"
@@ -2158,7 +2159,14 @@ render_icon_image (GtkThemingEngine *engine,
return FALSE;
cairo_translate (cr, x, y);
- _gtk_css_image_draw (image, cr, width, height);
+ cairo_translate (cr, width / 2, height / 2);
+
+ if (_gtk_css_transform_value_apply (_gtk_theming_engine_peek_property (engine,
GTK_CSS_PROPERTY_ICON_TRANSFORM), cr))
+ {
+ cairo_translate (cr, -width / 2, -height / 2);
+
+ _gtk_css_image_draw (image, cr, width, height);
+ }
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]