[gtk+] cssstyleproperty: Add transition properties
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssstyleproperty: Add transition properties
- Date: Tue, 17 Apr 2012 07:16:52 +0000 (UTC)
commit 41ce29767cf78fb1e04b30e7d0d0b1a3ceb43894
Author: Benjamin Otte <otte redhat com>
Date: Sun Apr 1 06:22:20 2012 +0200
cssstyleproperty: Add transition properties
gtk/gtkcssstylepropertyimpl.c | 135 +++++++++++++++++++++++++++++++++++++++++
gtk/gtkcsstypesprivate.h | 4 +
2 files changed, 139 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index b2ee619..9f4bbbd 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -41,6 +41,7 @@
#include "gtkanimationdescription.h"
#include "gtkbindings.h"
#include "gtkcssarrayvalueprivate.h"
+#include "gtkcsseasevalueprivate.h"
#include "gtkcssimagegradientprivate.h"
#include "gtkcssimageprivate.h"
#include "gtkcssimagevalueprivate.h"
@@ -729,6 +730,91 @@ border_image_width_parse (GtkCssStyleProperty *property,
}
static GtkCssValue *
+transition_property_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ GPtrArray *names;
+ GtkCssValue *result, *value;
+
+ if (_gtk_css_parser_try (parser, "none", TRUE))
+ return _gtk_css_array_value_new (NULL, 0);
+
+ names = g_ptr_array_new ();
+
+ do {
+ value = _gtk_css_ident_value_try_parse (parser);
+
+ if (value == NULL)
+ {
+ _gtk_css_parser_error (parser, "Expected an identifier");
+ g_ptr_array_free (names, TRUE);
+ return NULL;
+ }
+
+ g_ptr_array_add (names, value);
+ } while (_gtk_css_parser_try (parser, ",", TRUE));
+
+ result = _gtk_css_array_value_new ((GtkCssValue **) names->pdata, names->len);
+ g_ptr_array_free (names, TRUE);
+ return result;
+}
+
+static GtkCssValue *
+transition_time_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ GPtrArray *times;
+ GtkCssValue *result, *next;
+
+ times = g_ptr_array_new ();
+
+ do {
+ next = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);
+
+ if (next == NULL)
+ {
+ g_ptr_array_free (times, TRUE);
+ return NULL;
+ }
+
+ g_ptr_array_add (times, next);
+ } while (_gtk_css_parser_try (parser, ",", TRUE));
+
+ result = _gtk_css_array_value_new ((GtkCssValue **) times->pdata, times->len);
+ g_ptr_array_free (times, TRUE);
+ return result;
+}
+
+static GtkCssValue *
+transition_timing_function_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ GPtrArray *funcs;
+ GtkCssValue *result, *next;
+
+ funcs = g_ptr_array_new ();
+
+ do {
+ next = _gtk_css_ease_value_parse (parser);
+
+ if (next == NULL)
+ {
+ g_ptr_array_free (funcs, TRUE);
+ return NULL;
+ }
+
+ g_ptr_array_add (funcs, next);
+ } while (_gtk_css_parser_try (parser, ",", TRUE));
+
+ result = _gtk_css_array_value_new ((GtkCssValue **) funcs->pdata, funcs->len);
+ g_ptr_array_free (funcs, TRUE);
+ return result;
+}
+
+static GtkCssValue *
engine_parse (GtkCssStyleProperty *property,
GtkCssParser *parser,
GFile *base)
@@ -1763,6 +1849,55 @@ _gtk_css_style_property_init_properties (void)
assign_simple,
NULL,
_gtk_css_value_new_from_boxed (GTK_TYPE_BORDER, NULL));
+
+ value = _gtk_css_ident_value_new ("all");
+ gtk_css_style_property_register ("transition-property",
+ GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
+ G_TYPE_NONE,
+ 0,
+ transition_property_parse,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ _gtk_css_array_value_new (&value, 1));
+ value = _gtk_css_number_value_new (0, GTK_CSS_S);
+ gtk_css_style_property_register ("transition-duration",
+ GTK_CSS_PROPERTY_TRANSITION_DURATION,
+ G_TYPE_NONE,
+ 0,
+ transition_time_parse,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ _gtk_css_array_value_new (&value, 1));
+ value = _gtk_css_ease_value_new_cubic_bezier (0.25, 0.1, 0.25, 1.0);
+ gtk_css_style_property_register ("transition-timing-function",
+ GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
+ G_TYPE_NONE,
+ 0,
+ transition_timing_function_parse,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ _gtk_css_array_value_new (&value, 1));
+ gtk_css_style_property_register ("transition-delay",
+ GTK_CSS_PROPERTY_TRANSITION_DELAY,
+ G_TYPE_NONE,
+ 0,
+ transition_time_parse,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ _gtk_css_array_value_new (&value, 1));
+
gtk_css_style_property_register ("engine",
GTK_CSS_PROPERTY_ENGINE,
GTK_TYPE_THEMING_ENGINE,
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index e79605c..d70b855 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -103,6 +103,10 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH,
+ GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
+ GTK_CSS_PROPERTY_TRANSITION_DURATION,
+ GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
+ GTK_CSS_PROPERTY_TRANSITION_DELAY,
GTK_CSS_PROPERTY_ENGINE,
GTK_CSS_PROPERTY_TRANSITION,
GTK_CSS_PROPERTY_GTK_KEY_BINDINGS,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]