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
*/
......@@ -77,8 +77,7 @@ rugby_possibility_widget_set_property (GObject *object,
}
static void
render_bar (GtkWidget *widget,
GtkSnapshot *snapshot,
render_bar (GtkSnapshot *snapshot,
float x,
float w,
float h,
......@@ -97,20 +96,20 @@ render_bar (GtkWidget *widget,
&area);
gtk_snapshot_pop (snapshot);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
GdkRGBA border_colour;
GtkStyleContext *ctx = gtk_widget_get_style_context (widget);
gtk_style_context_lookup_color (ctx, "card_fg_color", &border_colour);
G_GNUC_END_IGNORE_DEPRECATIONS
GdkRGBA border;
AdwStyleManager *manager = adw_style_manager_get_default ();
if (adw_style_manager_get_dark (manager))
gdk_rgba_parse (&border, "white");
else
gdk_rgba_parse (&border, "black");
gtk_snapshot_append_border (snapshot,
&rounded,
(float[]) { 2.0, 2.0, 2.0, 2.0 },
(GdkRGBA[]) { border_colour,
border_colour,
border_colour,
border_colour });
(GdkRGBA[]) { border,
border,
border,
border });
}
static void
......@@ -135,16 +134,14 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
NULL);
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;
// Tries
float w = width / (score / (float) try_points);
for (int i = 0; i < tries; i++)
{
gtk_style_context_lookup_color (ctx, "green_3", &rgba);
render_bar (widget, snapshot, x, w, height, rgba);
gdk_rgba_parse (&rgba, "#33d17a"); // Green 3
render_bar (snapshot, x, w, height, rgba);
x += w;
}
......@@ -152,8 +149,8 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
w = width / (score / (float) utry_points);
for (int i = 0; i < utries; i++)
{
gtk_style_context_lookup_color (ctx, "red_3", &rgba);
render_bar (widget, snapshot, x, w, height, rgba);
gdk_rgba_parse (&rgba, "#e01b24"); // Red 3
render_bar (snapshot, x, w, height, rgba);
x += w;
}
......@@ -161,11 +158,10 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
w = width / (score / (float) kick_points);
for (int i = 0; i < kicks; i++)
{
gtk_style_context_lookup_color (ctx, "yellow_3", &rgba);
render_bar (widget, snapshot, x, w, height, rgba);
gdk_rgba_parse (&rgba, "#f6d32d"); // Yellow 3
render_bar (snapshot, x, w, height, rgba);
x += w;
}
G_GNUC_END_IGNORE_DEPRECATIONS
}
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