css: Add -gtk-icon-transform property

This property allows transforming icons and is mainly intended to be
used for spinner animations.
This commit is contained in:
Benjamin Otte 2014-05-05 15:28:18 +02:00
parent 965cd4a9c0
commit f56ba8378b
3 changed files with 28 additions and 3 deletions

View File

@ -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"
@ -576,6 +577,13 @@ shadow_value_parse (GtkCssStyleProperty *property,
return _gtk_css_shadows_value_parse (parser);
}
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,

View File

@ -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,

View File

@ -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;
}