[gnome-shell] Implement radial gradients for StWidget
- From: Florian Müllner <fmuellner src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] Implement radial gradients for StWidget
- Date: Tue, 12 Jan 2010 15:05:16 +0000 (UTC)
commit 59d6029f478aa5a12aded8a6ab69ad0d2c547dda
Author: Florian Müllner <fmuellner src gnome org>
Date: Sun Jan 10 02:17:01 2010 +0100
Implement radial gradients for StWidget
Some theme authors have stated interest in radial gradient backgrounds.
The w3c has some draft:
http://dev.w3.org/csswg/css3-images/#radial-gradients
As this is rather complex, we add only some very basic support, which
extends our syntax for linear gradients:
background-gradient-direction: [vertical|horizontal|radial]
Gradients are centered circles, whose size is determined by the closest
side.
https://bugzilla.gnome.org/show_bug.cgi?id=604945
src/st/st-theme-node.c | 4 ++++
src/st/st-theme-node.h | 3 ++-
src/st/st-widget.c | 10 +++++++++-
3 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index f8998e8..03d1543 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -1356,6 +1356,10 @@ ensure_background (StThemeNode *node)
{
node->background_gradient_type = ST_GRADIENT_HORIZONTAL;
}
+ else if (strcmp (term->content.str->stryng->str, "radial") == 0)
+ {
+ node->background_gradient_type = ST_GRADIENT_RADIAL;
+ }
else
{
g_warning ("Unrecognized background-gradient-direction \"%s\"",
diff --git a/src/st/st-theme-node.h b/src/st/st-theme-node.h
index 31fb08e..afb8f0f 100644
--- a/src/st/st-theme-node.h
+++ b/src/st/st-theme-node.h
@@ -61,7 +61,8 @@ typedef enum {
typedef enum {
ST_GRADIENT_NONE,
ST_GRADIENT_VERTICAL,
- ST_GRADIENT_HORIZONTAL
+ ST_GRADIENT_HORIZONTAL,
+ ST_GRADIENT_RADIAL
} StGradientType;
GType st_theme_node_get_type (void) G_GNUC_CONST;
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index e97d7cf..9759b72 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -632,8 +632,16 @@ st_widget_redraw_gradient (StWidget *widget)
if (priv->bg_gradient_type == ST_GRADIENT_VERTICAL)
pattern = cairo_pattern_create_linear (0, 0, 0, height);
- else
+ else if (priv->bg_gradient_type == ST_GRADIENT_HORIZONTAL)
pattern = cairo_pattern_create_linear (0, 0, width, 0);
+ else
+ {
+ gdouble cx, cy;
+
+ cx = width / 2.;
+ cy = height / 2.;
+ pattern = cairo_pattern_create_radial (cx, cy, 0, cx, cy, MIN (cx, cy));
+ }
cairo_pattern_add_color_stop_rgba (pattern, 0,
start->red / 255.,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]