summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2014-05-05 15:28:18 +0200
committerBenjamin Otte <otte@redhat.com>2014-05-14 04:28:33 +0200
commitf56ba8378bf867eed8ba01e120dcc2dde069127a (patch)
tree604ca44916ec2782028e53612e52b4dafa389873
parent965cd4a9c04719ad0bfe1ae6fd9b179bbba8d595 (diff)
downloadgtk+-f56ba8378bf867eed8ba01e120dcc2dde069127a.tar.gz
css: Add -gtk-icon-transform property
This property allows transforming icons and is mainly intended to be used for spinner animations.
-rw-r--r--gtk/gtkcssstylepropertyimpl.c20
-rw-r--r--gtk/gtkcsstypesprivate.h1
-rw-r--r--gtk/gtkthemingengine.c10
3 files changed, 28 insertions, 3 deletions
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 882f5a6f5a..0195e44944 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 53e24c8199..7a4de907d6 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 fa058323c1..6f428b1764 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"
@@ -1037,7 +1038,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;
}