[gtk+] render: Remove spinner special-cases
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] render: Remove spinner special-cases
- Date: Tue, 20 Jan 2015 05:34:40 +0000 (UTC)
commit e697213b35e6fe2bf1bea6b6d51607c1a7241bc1
Author: Benjamin Otte <otte redhat com>
Date: Mon Jan 19 17:41:29 2015 +0100
render: Remove spinner special-cases
The spinner is a regular builtin image now. There is no need to go
through the shadows code manually anymore as regular items do get
shadows automatically.
This also allows simplifying the actual spinner drawing code so that it
actually works.
gtk/gtkcssimagebuiltin.c | 35 ++++++++++++++++++++++++---
gtk/gtkcssshadowsvalue.c | 16 ------------
gtk/gtkcssshadowsvalueprivate.h | 4 ---
gtk/gtkcssshadowvalue.c | 23 ------------------
gtk/gtkcssshadowvalueprivate.h | 4 ---
gtk/gtkrender.c | 50 ---------------------------------------
gtk/gtkrenderprivate.h | 3 --
7 files changed, 31 insertions(+), 104 deletions(-)
---
diff --git a/gtk/gtkcssimagebuiltin.c b/gtk/gtkcssimagebuiltin.c
index 6562931..d364496 100644
--- a/gtk/gtkcssimagebuiltin.c
+++ b/gtk/gtkcssimagebuiltin.c
@@ -732,17 +732,44 @@ gtk_css_image_builtin_draw_spinner (GtkCssImage *image,
double height)
{
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
+ guint num_steps;
gdouble radius;
+ gdouble half;
+ gint i;
radius = MIN (width / 2, height / 2);
- cairo_save (cr);
cairo_translate (cr, width / 2, height / 2);
- gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
- gtk_render_paint_spinner (cr, radius, -1);
+ num_steps = 12;
+
+ cairo_set_line_width (cr, 2.0);
- cairo_restore (cr);
+ half = num_steps / 2;
+
+ for (i = 0; i < num_steps; i++)
+ {
+ gint inset = 0.7 * radius;
+ /* transparency is a function of time and intial value */
+ gdouble t = 1.0 - (gdouble) i / num_steps;
+ gdouble xscale = - sin (i * G_PI / half);
+ gdouble yscale = - cos (i * G_PI / half);
+
+ cairo_move_to (cr,
+ (radius - inset) * xscale,
+ (radius - inset) * yscale);
+ cairo_line_to (cr,
+ radius * xscale,
+ radius * yscale);
+
+ cairo_set_source_rgba (cr,
+ builtin->fg_color.red,
+ builtin->fg_color.green,
+ builtin->fg_color.blue,
+ builtin->fg_color.alpha * t);
+
+ cairo_stroke (cr);
+ }
}
static void
diff --git a/gtk/gtkcssshadowsvalue.c b/gtk/gtkcssshadowsvalue.c
index 590fa24..f0bae5c 100644
--- a/gtk/gtkcssshadowsvalue.c
+++ b/gtk/gtkcssshadowsvalue.c
@@ -282,22 +282,6 @@ _gtk_css_shadows_value_paint_icon (const GtkCssValue *shadows,
}
void
-_gtk_css_shadows_value_paint_spinner (const GtkCssValue *shadows,
- cairo_t *cr,
- gdouble radius,
- gdouble progress)
-{
- guint i;
-
- g_return_if_fail (shadows->class == >K_CSS_VALUE_SHADOWS);
-
- for (i = 0; i < shadows->len; i++)
- {
- _gtk_css_shadow_value_paint_spinner (shadows->values[i], cr, radius, progress);
- }
-}
-
-void
_gtk_css_shadows_value_paint_box (const GtkCssValue *shadows,
cairo_t *cr,
const GtkRoundedBox *padding_box,
diff --git a/gtk/gtkcssshadowsvalueprivate.h b/gtk/gtkcssshadowsvalueprivate.h
index 4713b86..790e8ec 100644
--- a/gtk/gtkcssshadowsvalueprivate.h
+++ b/gtk/gtkcssshadowsvalueprivate.h
@@ -43,10 +43,6 @@ void _gtk_css_shadows_value_paint_layout (const GtkCssValue
void _gtk_css_shadows_value_paint_icon (const GtkCssValue *shadows,
cairo_t *cr);
-void _gtk_css_shadows_value_paint_spinner (const GtkCssValue *shadows,
- cairo_t *cr,
- gdouble radius,
- gdouble progress);
void _gtk_css_shadows_value_paint_box (const GtkCssValue *shadows,
cairo_t *cr,
const GtkRoundedBox *padding_box,
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index b5c4233..d7f3963 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -542,29 +542,6 @@ _gtk_css_shadow_value_paint_icon (const GtkCssValue *shadow,
cairo_pattern_destroy (pattern);
}
-void
-_gtk_css_shadow_value_paint_spinner (const GtkCssValue *shadow,
- cairo_t *cr,
- gdouble radius,
- gdouble progress)
-{
- g_return_if_fail (shadow->class == >K_CSS_VALUE_SHADOW);
-
- cairo_save (cr);
-
- gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color));
- cr = gtk_css_shadow_value_start_drawing (shadow, cr);
-
- cairo_translate (cr,
- _gtk_css_number_value_get (shadow->hoffset, 0),
- _gtk_css_number_value_get (shadow->voffset, 0));
- gtk_render_paint_spinner (cr, radius, progress);
-
- cr = gtk_css_shadow_value_finish_drawing (shadow, cr);
-
- cairo_restore (cr);
-}
-
gboolean
_gtk_css_shadow_value_get_inset (const GtkCssValue *shadow)
{
diff --git a/gtk/gtkcssshadowvalueprivate.h b/gtk/gtkcssshadowvalueprivate.h
index 1e5eb22..5fab1cc 100644
--- a/gtk/gtkcssshadowvalueprivate.h
+++ b/gtk/gtkcssshadowvalueprivate.h
@@ -50,10 +50,6 @@ void _gtk_css_shadow_value_paint_layout (const GtkCssValue
void _gtk_css_shadow_value_paint_icon (const GtkCssValue *shadow,
cairo_t *cr);
-void _gtk_css_shadow_value_paint_spinner (const GtkCssValue *shadow,
- cairo_t *cr,
- gdouble radius,
- gdouble progress);
void _gtk_css_shadow_value_paint_box (const GtkCssValue *shadow,
cairo_t *cr,
const GtkRoundedBox *padding_box);
diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c
index 133ba2f..d5d3ad1 100644
--- a/gtk/gtkrender.c
+++ b/gtk/gtkrender.c
@@ -1042,56 +1042,6 @@ gtk_render_handle (GtkStyleContext *context,
cairo_restore (cr);
}
-void
-gtk_render_paint_spinner (cairo_t *cr,
- gdouble radius,
- gdouble progress)
-{
- guint num_steps, step;
- gdouble half;
- gint i;
-
- num_steps = 12;
-
- if (progress >= 0)
- step = (guint) (progress * num_steps);
- else
- step = 0;
-
- cairo_save (cr);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_line_width (cr, 2.0);
-
- half = num_steps / 2;
-
- for (i = 0; i < num_steps; i++)
- {
- gint inset = 0.7 * radius;
-
- /* transparency is a function of time and intial value */
- gdouble t = 1.0 - (gdouble) ((i + step) % num_steps) / num_steps;
- gdouble xscale = - sin (i * G_PI / half);
- gdouble yscale = - cos (i * G_PI / half);
-
- cairo_push_group (cr);
-
- cairo_move_to (cr,
- (radius - inset) * xscale,
- (radius - inset) * yscale);
- cairo_line_to (cr,
- radius * xscale,
- radius * yscale);
-
- cairo_stroke (cr);
-
- cairo_pop_group_to_source (cr);
- cairo_paint_with_alpha (cr, t);
- }
-
- cairo_restore (cr);
-}
-
/**
* gtk_render_activity:
* @context: a #GtkStyleContext
diff --git a/gtk/gtkrenderprivate.h b/gtk/gtkrenderprivate.h
index 81c9d6c..3e98e81 100644
--- a/gtk/gtkrenderprivate.h
+++ b/gtk/gtkrenderprivate.h
@@ -28,8 +28,5 @@ void gtk_render_content_path (GtkStyleContext *context,
double y,
double width,
double height);
-void gtk_render_paint_spinner (cairo_t *cr,
- gdouble radius,
- gdouble progress);
#endif /* __GTK_RENDER_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]