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

Lookup colours from style context

parent c505883a
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,7 @@ render_bar (GtkSnapshot *snapshot,
float x,
float w,
float h,
const GdkRGBA color)
const GdkRGBA rgba)
{
graphene_rect_t area = GRAPHENE_RECT_INIT (x, 0.0, w, h);
......@@ -89,7 +89,7 @@ render_bar (GtkSnapshot *snapshot,
gtk_snapshot_push_rounded_clip (snapshot, &rounded);
gtk_snapshot_append_color (snapshot,
&color,
&rgba,
&area);
gtk_snapshot_pop (snapshot);
......@@ -122,13 +122,15 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
NULL);
int score = tries * try_points + utries * utry_points + kicks * kick_points;
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++)
{
// Green
render_bar (snapshot, x, w, height,
(GdkRGBA) { 0.20, 0.82, 0.48, 1.0 });
gtk_style_context_lookup_color (ctx, "green_3", &rgba);
render_bar (snapshot, x, w, height, rgba);
x += w;
}
......@@ -136,9 +138,8 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
w = width / (score / (float) utry_points);
for (int i = 0; i < utries; i++)
{
// Red
render_bar (snapshot, x, w, height,
(GdkRGBA) { 0.88, 0.11, 0.14, 1.0 });
gtk_style_context_lookup_color (ctx, "red_3", &rgba);
render_bar (snapshot, x, w, height, rgba);
x += w;
}
......@@ -146,9 +147,8 @@ rugby_possibility_widget_snapshot (GtkWidget *widget,
w = width / (score / (float) kick_points);
for (int i = 0; i < kicks; i++)
{
// Yellow
render_bar (snapshot, x, w, height,
(GdkRGBA) { 0.96, 0.83, 0.18, 1.0 });
gtk_style_context_lookup_color (ctx, "yellow_3", &rgba);
render_bar (snapshot, x, w, height, rgba);
x += w;
}
}
......
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