gtk-demo: Explicitly pass nuclear icon colors

This commit is contained in:
Benjamin Otte 2021-08-27 23:44:42 +02:00
parent 2808f9c75b
commit 1b390d3857
4 changed files with 24 additions and 17 deletions

View File

@ -45,26 +45,27 @@ struct _GtkNuclearIconClass
* so that it can be called from all the other demos, too. * so that it can be called from all the other demos, too.
*/ */
void void
gtk_nuclear_snapshot (GtkSnapshot *snapshot, gtk_nuclear_snapshot (GtkSnapshot *snapshot,
double width, const GdkRGBA *foreground,
double height, const GdkRGBA *background,
double rotation, double width,
gboolean draw_background) double height,
double rotation)
{ {
#define RADIUS 0.3 #define RADIUS 0.3
cairo_t *cr; cairo_t *cr;
double size; double size;
if (draw_background) gtk_snapshot_append_color (snapshot,
gtk_snapshot_append_color (snapshot, background,
&(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 }, &GRAPHENE_RECT_INIT (0, 0, width, height));
&GRAPHENE_RECT_INIT (0, 0, width, height));
size = MIN (width, height); size = MIN (width, height);
cr = gtk_snapshot_append_cairo (snapshot, cr = gtk_snapshot_append_cairo (snapshot,
&GRAPHENE_RECT_INIT ((width - size) / 2.0, &GRAPHENE_RECT_INIT ((width - size) / 2.0,
(height - size) / 2.0, (height - size) / 2.0,
size, size)); size, size));
gdk_cairo_set_source_rgba (cr, foreground);
cairo_translate (cr, width / 2.0, height / 2.0); cairo_translate (cr, width / 2.0, height / 2.0);
cairo_scale (cr, size, size); cairo_scale (cr, size, size);
cairo_rotate (cr, rotation); cairo_rotate (cr, rotation);
@ -94,9 +95,10 @@ gtk_nuclear_icon_snapshot (GdkPaintable *paintable,
*/ */
gtk_nuclear_snapshot (snapshot, gtk_nuclear_snapshot (snapshot,
&(GdkRGBA) { 0, 0, 0, 1 }, /* black */
&(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 }, /* yellow */
width, height, width, height,
nuclear->rotation, nuclear->rotation);
TRUE);
} }
static GdkPaintableFlags static GdkPaintableFlags

View File

@ -4,10 +4,11 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
void gtk_nuclear_snapshot (GtkSnapshot *snapshot, void gtk_nuclear_snapshot (GtkSnapshot *snapshot,
const GdkRGBA *foreground,
const GdkRGBA *background,
double width, double width,
double height, double height,
double rotation, double rotation);
gboolean draw_background);
GdkPaintable * gtk_nuclear_icon_new (double rotation); GdkPaintable * gtk_nuclear_icon_new (double rotation);
GdkPaintable * gtk_nuclear_animation_new (gboolean draw_background); GdkPaintable * gtk_nuclear_animation_new (gboolean draw_background);

View File

@ -65,9 +65,12 @@ gtk_nuclear_animation_snapshot (GdkPaintable *paintable,
/* We call the function from the previous example here. */ /* We call the function from the previous example here. */
gtk_nuclear_snapshot (snapshot, 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, width, height,
2 * G_PI * nuclear->progress / MAX_PROGRESS, 2 * G_PI * nuclear->progress / MAX_PROGRESS);
nuclear->draw_background);
} }
static GdkPaintable * static GdkPaintable *

View File

@ -73,9 +73,10 @@ gtk_nuclear_media_stream_snapshot (GdkPaintable *paintable,
/* We call the function from the previous example here. */ /* We call the function from the previous example here. */
gtk_nuclear_snapshot (snapshot, gtk_nuclear_snapshot (snapshot,
&(GdkRGBA) { 0, 0, 0, 1 }, /* black */
&(GdkRGBA) { 0.9, 0.75, 0.15, 1.0 }, /* yellow */
width, height, width, height,
2 * G_PI * nuclear->progress / DURATION, 2 * G_PI * nuclear->progress / DURATION);
TRUE);
} }
static GdkPaintable * static GdkPaintable *