summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2021-08-27 23:44:42 +0200
committerBenjamin Otte <otte@redhat.com>2021-08-29 04:29:53 +0200
commit1b390d3857f4777448e3c9baa41c4c248d79fe78 (patch)
treed52d0565196bf74486cb68fe05ea45f6de932e06
parent2808f9c75b79025cefdd70170e5bc05a76e8ca2a (diff)
downloadgtk+-1b390d3857f4777448e3c9baa41c4c248d79fe78.tar.gz
gtk-demo: Explicitly pass nuclear icon colors
-rw-r--r--demos/gtk-demo/paintable.c24
-rw-r--r--demos/gtk-demo/paintable.h5
-rw-r--r--demos/gtk-demo/paintable_animated.c7
-rw-r--r--demos/gtk-demo/paintable_mediastream.c5
4 files changed, 24 insertions, 17 deletions
diff --git a/demos/gtk-demo/paintable.c b/demos/gtk-demo/paintable.c
index 8ed5e51dde..ef0480db62 100644
--- a/demos/gtk-demo/paintable.c
+++ b/demos/gtk-demo/paintable.c
@@ -45,26 +45,27 @@ struct _GtkNuclearIconClass
* so that it can be called from all the other demos, too.
*/
void
-gtk_nuclear_snapshot (GtkSnapshot *snapshot,
- double width,
- double height,
- double rotation,
- gboolean draw_background)
+gtk_nuclear_snapshot (GtkSnapshot *snapshot,
+ const GdkRGBA *foreground,
+ const GdkRGBA *background,
+ double width,
+ double height,
+ double rotation)
{
#define RADIUS 0.3
cairo_t *cr;
double size;
- if (draw_background)
- gtk_snapshot_append_color (snapshot,
- &(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 },
- &GRAPHENE_RECT_INIT (0, 0, width, height));
+ gtk_snapshot_append_color (snapshot,
+ background,
+ &GRAPHENE_RECT_INIT (0, 0, width, height));
size = MIN (width, height);
cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT ((width - size) / 2.0,
(height - size) / 2.0,
size, size));
+ gdk_cairo_set_source_rgba (cr, foreground);
cairo_translate (cr, width / 2.0, height / 2.0);
cairo_scale (cr, size, size);
cairo_rotate (cr, rotation);
@@ -94,9 +95,10 @@ gtk_nuclear_icon_snapshot (GdkPaintable *paintable,
*/
gtk_nuclear_snapshot (snapshot,
+ &(GdkRGBA) { 0, 0, 0, 1 }, /* black */
+ &(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 }, /* yellow */
width, height,
- nuclear->rotation,
- TRUE);
+ nuclear->rotation);
}
static GdkPaintableFlags
diff --git a/demos/gtk-demo/paintable.h b/demos/gtk-demo/paintable.h
index a89713f9b1..b8d78160bb 100644
--- a/demos/gtk-demo/paintable.h
+++ b/demos/gtk-demo/paintable.h
@@ -4,10 +4,11 @@
#include <gtk/gtk.h>
void gtk_nuclear_snapshot (GtkSnapshot *snapshot,
+ const GdkRGBA *foreground,
+ const GdkRGBA *background,
double width,
double height,
- double rotation,
- gboolean draw_background);
+ double rotation);
GdkPaintable * gtk_nuclear_icon_new (double rotation);
GdkPaintable * gtk_nuclear_animation_new (gboolean draw_background);
diff --git a/demos/gtk-demo/paintable_animated.c b/demos/gtk-demo/paintable_animated.c
index 5d72483c96..f60f287e8d 100644
--- a/demos/gtk-demo/paintable_animated.c
+++ b/demos/gtk-demo/paintable_animated.c
@@ -65,9 +65,12 @@ gtk_nuclear_animation_snapshot (GdkPaintable *paintable,
/* We call the function from the previous example here. */
gtk_nuclear_snapshot (snapshot,
+ &(GdkRGBA) { 0, 0, 0, 1 }, /* black */
+ nuclear->draw_background
+ ? &(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 } /* yellow */
+ : &(GdkRGBA) { 0, 0, 0, 0 }, /* transparent */
width, height,
- 2 * G_PI * nuclear->progress / MAX_PROGRESS,
- nuclear->draw_background);
+ 2 * G_PI * nuclear->progress / MAX_PROGRESS);
}
static GdkPaintable *
diff --git a/demos/gtk-demo/paintable_mediastream.c b/demos/gtk-demo/paintable_mediastream.c
index 54d805c206..0228c75803 100644
--- a/demos/gtk-demo/paintable_mediastream.c
+++ b/demos/gtk-demo/paintable_mediastream.c
@@ -73,9 +73,10 @@ gtk_nuclear_media_stream_snapshot (GdkPaintable *paintable,
/* We call the function from the previous example here. */
gtk_nuclear_snapshot (snapshot,
+ &(GdkRGBA) { 0, 0, 0, 1 }, /* black */
+ &(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 }, /* yellow */
width, height,
- 2 * G_PI * nuclear->progress / DURATION,
- TRUE);
+ 2 * G_PI * nuclear->progress / DURATION);
}
static GdkPaintable *