[gnome-games/wip/exalm/gameapd: 8/14] gamepad-view: Draw each button only once
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/gameapd: 8/14] gamepad-view: Draw each button only once
- Date: Wed, 4 Mar 2020 16:51:10 +0000 (UTC)
commit c59ea58dab0d4af230a00b0b77c9722a5c5cdf12
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Mar 4 20:00:29 2020 +0500
gamepad-view: Draw each button only once
Instead of drawing the whole gamepad at the beginning, and then hovered
elements above it, draw each element only once with its designated color.
This temporarily breaks analog sticks display, it will be fixed in the
following commits.
src/ui/gamepad-view.vala | 32 +++++++++++---------------------
1 file changed, 11 insertions(+), 21 deletions(-)
---
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index 43595ac6..aeb662ae 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -99,38 +99,28 @@ private class Games.GamepadView : Gtk.DrawingArea {
context.translate (x, y);
context.scale (scale, scale);
- color_gamepad (context);
- highlight_gamepad (context);
+ input_state.for_each ((path, state) => {
+ var color_name = state.highlight ? "theme_selected_bg_color" : "theme_fg_color";
+
+ Gdk.RGBA color;
+ get_style_context ().lookup_color (color_name, out color);
+
+ draw_path (context, path, color);
+ });
return false;
}
- private void color_gamepad (Cairo.Context context) {
+ private void draw_path (Cairo.Context context, string path, Gdk.RGBA color) {
context.push_group ();
- handle.render_cairo (context);
+
+ handle.render_cairo_sub (context, @"#$path");
var group = context.pop_group ();
- Gdk.RGBA color;
- get_style_context ().lookup_color ("theme_fg_color", out color);
context.set_source_rgba (color.red, color.green, color.blue, color.alpha);
context.mask (group);
}
- private void highlight_gamepad (Cairo.Context context) {
- input_state.for_each ((path, state) => {
- if (state.highlight) {
- context.push_group ();
- handle.render_cairo_sub (context, @"#$path");
- var group = context.pop_group ();
-
- Gdk.RGBA color;
- get_style_context ().lookup_color ("theme_selected_bg_color", out color);
- context.set_source_rgba (color.red, color.green, color.blue, color.alpha);
- context.mask (group);
- }
- });
- }
-
private void calculate_image_dimensions (out double x, out double y, out double scale) {
double width = get_allocated_width ();
double height = get_allocated_height ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]