Skip to content
Snippets Groups Projects
Verified Commit bf6024b8 authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Don't look up colours

parent fbcd26d6
No related branches found
No related tags found
No related merge requests found
/* /*
* SPDX-FileCopyrightText: 2018-2022 Bruce Cowan <bruce@bcowan.me.uk> * SPDX-FileCopyrightText: 2018-2024 Bruce Cowan <bruce@bcowan.me.uk>
* *
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
...@@ -77,8 +77,7 @@ rugby_possibility_widget_set_property (GObject *object, ...@@ -77,8 +77,7 @@ rugby_possibility_widget_set_property (GObject *object,
} }
static void static void
render_bar (GtkWidget *widget, render_bar (GtkSnapshot *snapshot,
GtkSnapshot *snapshot,
float x, float x,
float w, float w,
float h, float h,
...@@ -97,20 +96,20 @@ render_bar (GtkWidget *widget, ...@@ -97,20 +96,20 @@ render_bar (GtkWidget *widget,
&area); &area);
gtk_snapshot_pop (snapshot); gtk_snapshot_pop (snapshot);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS GdkRGBA border;
GdkRGBA border_colour; AdwStyleManager *manager = adw_style_manager_get_default ();
if (adw_style_manager_get_dark (manager))
GtkStyleContext *ctx = gtk_widget_get_style_context (widget); gdk_rgba_parse (&border, "white");
gtk_style_context_lookup_color (ctx, "card_fg_color", &border_colour); else
G_GNUC_END_IGNORE_DEPRECATIONS gdk_rgba_parse (&border, "black");
gtk_snapshot_append_border (snapshot, gtk_snapshot_append_border (snapshot,
&rounded, &rounded,
(float[]) { 2.0, 2.0, 2.0, 2.0 }, (float[]) { 2.0, 2.0, 2.0, 2.0 },
(GdkRGBA[]) { border_colour, (GdkRGBA[]) { border,
border_colour, border,
border_colour, border,
border_colour }); border });
} }
static void static void
...@@ -135,16 +134,14 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, ...@@ -135,16 +134,14 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
NULL); NULL);
int score = tries * try_points + utries * utry_points + kicks * kick_points; int score = tries * try_points + utries * utry_points + kicks * kick_points;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GtkStyleContext *ctx = gtk_widget_get_style_context (widget);
GdkRGBA rgba; GdkRGBA rgba;
// Tries // Tries
float w = width / (score / (float) try_points); float w = width / (score / (float) try_points);
for (int i = 0; i < tries; i++) for (int i = 0; i < tries; i++)
{ {
gtk_style_context_lookup_color (ctx, "green_3", &rgba); gdk_rgba_parse (&rgba, "#33d17a"); // Green 3
render_bar (widget, snapshot, x, w, height, rgba); render_bar (snapshot, x, w, height, rgba);
x += w; x += w;
} }
...@@ -152,8 +149,8 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, ...@@ -152,8 +149,8 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
w = width / (score / (float) utry_points); w = width / (score / (float) utry_points);
for (int i = 0; i < utries; i++) for (int i = 0; i < utries; i++)
{ {
gtk_style_context_lookup_color (ctx, "red_3", &rgba); gdk_rgba_parse (&rgba, "#e01b24"); // Red 3
render_bar (widget, snapshot, x, w, height, rgba); render_bar (snapshot, x, w, height, rgba);
x += w; x += w;
} }
...@@ -161,11 +158,10 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, ...@@ -161,11 +158,10 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
w = width / (score / (float) kick_points); w = width / (score / (float) kick_points);
for (int i = 0; i < kicks; i++) for (int i = 0; i < kicks; i++)
{ {
gtk_style_context_lookup_color (ctx, "yellow_3", &rgba); gdk_rgba_parse (&rgba, "#f6d32d"); // Yellow 3
render_bar (widget, snapshot, x, w, height, rgba); render_bar (snapshot, x, w, height, rgba);
x += w; x += w;
} }
G_GNUC_END_IGNORE_DEPRECATIONS
} }
static void static void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment