Commit a7ec3ba5 authored by Benjamin Otte's avatar Benjamin Otte

csscomputedvalues: Get rid of animated values

Merge the animated values code into the computed values code. This
should get rid of various bugs related to animated->computed updating.
parent 7248c190
......@@ -426,7 +426,6 @@ gtk_private_h_sources = \
gtkcolorscaleprivate.h \
gtkcolorchooserprivate.h \
gtkcontainerprivate.h \
gtkcssanimatedvaluesprivate.h \
gtkcssanimationprivate.h \
gtkcssarrayvalueprivate.h \
gtkcssbgsizevalueprivate.h \
......@@ -648,7 +647,6 @@ gtk_base_c_sources = \
gtkcombobox.c \
gtkcomboboxtext.c \
gtkcontainer.c \
gtkcssanimatedvalues.c \
gtkcssanimation.c \
gtkcssarrayvalue.c \
gtkcssbgsizevalue.c \
......
This diff is collapsed.
/*
* Copyright © 2012 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Benjamin Otte <otte@gnome.org>
*/
#ifndef __GTK_CSS_ANIMATED_VALUES_PRIVATE_H__
#define __GTK_CSS_ANIMATED_VALUES_PRIVATE_H__
#include "gtk/gtkcsscomputedvaluesprivate.h"
G_BEGIN_DECLS
#define GTK_TYPE_CSS_ANIMATED_VALUES (_gtk_css_animated_values_get_type ())
#define GTK_CSS_ANIMATED_VALUES(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_ANIMATED_VALUES, GtkCssAnimatedValues))
#define GTK_CSS_ANIMATED_VALUES_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_ANIMATED_VALUES, GtkCssAnimatedValuesClass))
#define GTK_IS_CSS_ANIMATED_VALUES(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_ANIMATED_VALUES))
#define GTK_IS_CSS_ANIMATED_VALUES_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_ANIMATED_VALUES))
#define GTK_CSS_ANIMATED_VALUES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_ANIMATED_VALUES, GtkCssAnimatedValuesClass))
typedef struct _GtkCssAnimatedValues GtkCssAnimatedValues;
typedef struct _GtkCssAnimatedValuesClass GtkCssAnimatedValuesClass;
struct _GtkCssAnimatedValues
{
GtkCssComputedValues parent;
gint64 current_time; /* the current time in our world */
GSList *animations; /* the running animations */
};
struct _GtkCssAnimatedValuesClass
{
GtkCssComputedValuesClass parent_class;
};
GType _gtk_css_animated_values_get_type (void) G_GNUC_CONST;
GtkCssComputedValues * _gtk_css_animated_values_new (GtkCssComputedValues *computed,
GtkCssComputedValues *source,
gint64 timestamp,
GtkStyleContext *context);
GtkBitmask * _gtk_css_animated_values_advance (GtkCssAnimatedValues *values,
gint64 timestamp) G_GNUC_WARN_UNUSED_RESULT;
gboolean _gtk_css_animated_values_is_finished (GtkCssAnimatedValues *values);
G_END_DECLS
#endif /* __GTK_CSS_ANIMATED_VALUES_PRIVATE_H__ */
This diff is collapsed.
......@@ -43,13 +43,17 @@ struct _GtkCssComputedValues
{
GObject parent;
GPtrArray *values;
GPtrArray *sections;
GPtrArray *animated_values;
GtkBitmask *depends_on_parent;
GtkBitmask *equals_parent;
GtkBitmask *depends_on_color;
GtkBitmask *depends_on_font_size;
GPtrArray *values; /* the unanimated (aka intrinsic) values */
GPtrArray *sections; /* sections the values are defined in */
GPtrArray *animated_values; /* NULL or array of animated values/NULL if not animated */
gint64 current_time; /* the current time in our world */
GSList *animations; /* the running animations, least important one first */
GtkBitmask *depends_on_parent; /* for intrinsic values */
GtkBitmask *equals_parent; /* dito */
GtkBitmask *depends_on_color; /* dito */
GtkBitmask *depends_on_font_size; /* dito */
};
struct _GtkCssComputedValuesClass
......@@ -84,6 +88,13 @@ GtkCssValue * _gtk_css_computed_values_get_intrinsic_value (GtkCssCom
GtkBitmask * _gtk_css_computed_values_get_difference (GtkCssComputedValues *values,
GtkCssComputedValues *other);
void _gtk_css_computed_values_start_animations (GtkCssComputedValues *values,
gint64 timestamp,
GtkCssComputedValues *source,
GtkStyleContext *context);
GtkBitmask * _gtk_css_computed_values_advance (GtkCssComputedValues *values,
gint64 timestamp);
gboolean _gtk_css_computed_values_is_static (GtkCssComputedValues *values);
G_END_DECLS
......
......@@ -24,7 +24,6 @@
#include "gtkstylecontextprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkcssanimatedvaluesprivate.h"
#include "gtkcssenginevalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
......@@ -526,7 +525,7 @@ style_data_unref (StyleData *data)
static gboolean
style_data_is_animating (StyleData *style_data)
{
return GTK_IS_CSS_ANIMATED_VALUES (style_data->store);
return !_gtk_css_computed_values_is_static (style_data->store);
}
static GtkStyleInfo *
......@@ -3011,10 +3010,10 @@ gtk_style_context_update_animations (GtkStyleContext *context,
style_data = style_data_lookup (context);
differences = _gtk_css_animated_values_advance (GTK_CSS_ANIMATED_VALUES (style_data->store),
differences = _gtk_css_computed_values_advance (style_data->store,
timestamp);
if (_gtk_css_animated_values_is_finished (GTK_CSS_ANIMATED_VALUES (style_data->store)))
if (_gtk_css_computed_values_is_static (style_data->store))
_gtk_style_context_stop_animations (context);
return differences;
......@@ -3043,32 +3042,27 @@ gtk_style_context_should_animate (GtkStyleContext *context)
static void
gtk_style_context_start_animations (GtkStyleContext *context,
GtkCssComputedValues *values,
GtkCssComputedValues *previous,
gint64 timestamp)
{
StyleData *animated;
if (!gtk_style_context_should_animate (context))
{
gtk_style_context_stop_animating (context);
return;
}
animated = style_data_new ();
animated->store = _gtk_css_animated_values_new (style_data_lookup (context)->store,
previous,
timestamp,
context);
_gtk_css_computed_values_start_animations (values,
timestamp,
previous,
context);
if (_gtk_css_animated_values_is_finished (GTK_CSS_ANIMATED_VALUES (animated->store)))
if (_gtk_css_computed_values_is_static (values))
{
style_data_unref (animated);
gtk_style_context_stop_animating (context);
return;
}
style_info_set_data (context->priv->info, animated);
style_data_unref (animated);
gtk_style_context_start_animating (context);
}
......@@ -3172,11 +3166,11 @@ _gtk_style_context_validate (GtkStyleContext *context,
{
StyleData *data;
gtk_style_context_start_animations (context, current->store, timestamp);
change &= ~GTK_CSS_CHANGE_ANIMATE;
data = style_data_lookup (context);
gtk_style_context_start_animations (context, data->store, current->store, timestamp);
change &= ~GTK_CSS_CHANGE_ANIMATE;
changes = _gtk_css_computed_values_get_difference (data->store, current->store);
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment