[gtk/wip/baedert/css-values: 1/20] cssshadowvalue: Only create 2 shadows values for transitions
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/css-values: 1/20] cssshadowvalue: Only create 2 shadows values for transitions
- Date: Thu, 16 Jan 2020 13:50:34 +0000 (UTC)
commit 43e8721d2f9a467c8e30ef4e20177d00b9349095
Author: Timm Bäder <mail baedert org>
Date: Mon Jan 13 08:37:52 2020 +0100
cssshadowvalue: Only create 2 shadows values for transitions
This is for cases where we want to transition from "no shadow" to
"shadow", which we need quite a lot.
gtk/gtkcssshadowvalue.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index cc123dc8cc..e0213de8be 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -192,17 +192,29 @@ gtk_css_shadow_value_new (GtkCssValue *hoffset,
return retval;
}
+
+static GtkCssValue transition_inset_singleton = { >K_CSS_VALUE_SHADOW, 1, TRUE, .inset = TRUE };
+static GtkCssValue transition_outset_singleton = { >K_CSS_VALUE_SHADOW, 1, TRUE, .inset = FALSE };
+
GtkCssValue *
_gtk_css_shadow_value_new_for_transition (GtkCssValue *target)
{
+ GtkCssValue *result;
+
g_return_val_if_fail (target->class == >K_CSS_VALUE_SHADOW, NULL);
- return gtk_css_shadow_value_new (_gtk_css_number_value_new (0, GTK_CSS_PX),
- _gtk_css_number_value_new (0, GTK_CSS_PX),
- _gtk_css_number_value_new (0, GTK_CSS_PX),
- _gtk_css_number_value_new (0, GTK_CSS_PX),
- target->inset,
- gtk_css_color_value_new_transparent ());
+ if (target->inset)
+ result = &transition_inset_singleton;
+ else
+ result = &transition_outset_singleton;
+
+ if (G_UNLIKELY (!result->hoffset))
+ {
+ result->hoffset = result->voffset = result->spread = result->radius = _gtk_css_number_value_new (0,
GTK_CSS_PX);
+ result->color = gtk_css_color_value_new_transparent ();
+ }
+
+ return _gtk_css_value_ref (result);
}
enum {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]