[gnome-games/wip/exalm/gameapd: 5/10] gamepad-view: Support drawing background elements



commit eb8227e94c21335da7edc11681494abbe306c706
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Mar 4 20:04:32 2020 +0500

    gamepad-view: Support drawing background elements
    
    Since the last commit, we don't draw the whole gamepad anymore. This means
    that any elements that aren't buttons won't be drawn at all and must be
    drawn separately.

 src/ui/gamepad-view-configuration.vala | 2 ++
 src/ui/gamepad-view.vala               | 7 +++++++
 2 files changed, 9 insertions(+)
---
diff --git a/src/ui/gamepad-view-configuration.vala b/src/ui/gamepad-view-configuration.vala
index 46509da3..ba949df4 100644
--- a/src/ui/gamepad-view-configuration.vala
+++ b/src/ui/gamepad-view-configuration.vala
@@ -33,12 +33,14 @@ namespace Games {
        private struct GamepadViewConfiguration {
                string svg_path;
                GamepadInputPath[] input_paths;
+               string[] background_paths;
 
                public static GamepadViewConfiguration get_default () {
                        GamepadViewConfiguration conf = {};
 
                        conf.svg_path = "/org/gnome/Games/gamepads/standard-gamepad.svg";
                        conf.input_paths = STANDARD_GAMEPAD_INPUT_PATHS;
+                       conf.background_paths = {};
 
                        return conf;
                }
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index aeb662ae..db39846e 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -99,6 +99,13 @@ private class Games.GamepadView : Gtk.DrawingArea {
                context.translate (x, y);
                context.scale (scale, scale);
 
+               foreach (var path in configuration.background_paths) {
+                       Gdk.RGBA color;
+                       get_style_context ().lookup_color ("theme_fg_color", out color);
+
+                       draw_path (context, path, color);
+               }
+
                input_state.for_each ((path, state) => {
                        var color_name = state.highlight ? "theme_selected_bg_color" : "theme_fg_color";
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]