[gtk+/wip/cssvalue: 95/164] cssstyleproperty: Add transition properties
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssvalue: 95/164] cssstyleproperty: Add transition properties
- Date: Wed, 11 Apr 2012 14:47:54 +0000 (UTC)
commit 2ee6abd629bea07dd04086ef3a17b2ab346c0ed0
Author: Benjamin Otte <otte redhat com>
Date: Sun Apr 1 06:22:20 2012 +0200
cssstyleproperty: Add transition properties
gtk/gtkcssstylepropertyimpl.c | 137 +++++++++++++++++++++++++++++++++++++++++
gtk/gtkcsstypesprivate.h | 4 +
2 files changed, 141 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index b2ee619..3ad6ce5 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,92 @@ border_image_width_parse (GtkCssStyleProperty *property,
}
static GtkCssValue *
+transition_property_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser,
+ GFile *base)
+{
+ GPtrArray *names;
+ GtkCssValue *result;
+ char *name;
+
+ if (_gtk_css_parser_try (parser, "none", TRUE))
+ return _gtk_css_array_value_new (NULL, 0);
+
+ names = g_ptr_array_new ();
+
+ do {
+ name = _gtk_css_parser_try_ident (parser, TRUE);
+
+ if (!name)
+ {
+ _gtk_css_parser_error (parser, "Expected an identifier");
+ g_ptr_array_free (names, TRUE);
+ return NULL;
+ }
+
+ g_ptr_array_add (names, _gtk_css_string_value_new_take (name));
+ } 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 +1850,56 @@ _gtk_css_style_property_init_properties (void)
assign_simple,
NULL,
_gtk_css_value_new_from_boxed (GTK_TYPE_BORDER, NULL));
+
+ value = _gtk_css_string_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, 0.1);
+ 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));
+ value = _gtk_css_number_value_new (0, GTK_CSS_S);
+ 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]