[gnome-games] display-box: Add a margin to the savestates list in fullscreen



commit 08a6444e7b100cc0009c65b528cf6f05e8a8c115
Author: Yetizone <andreii lisita gmail com>
Date:   Sat Aug 10 17:08:38 2019 +0300

    display-box: Add a margin to the savestates list in fullscreen
    
    The margin is added so the fullscreen header bar doesn't obstruct the
    savestates list

 src/ui/display-box.vala     | 19 ++++++++++++++++++-
 src/ui/savestates-list.vala |  6 ++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
---
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 4da9273f..b46b651a 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -4,7 +4,17 @@
 private class Games.DisplayBox : Gtk.Bin {
        public signal void back ();
 
-       public bool is_fullscreen { get; set; }
+       private bool _is_fullscreen;
+       public bool is_fullscreen {
+               get { return _is_fullscreen; }
+               set {
+                       _is_fullscreen = value;
+
+                       // A top margin is added to the savestates list in fullscreen mode such that
+                       // the fullscreen header bar doesn't cover the savestates menu
+                       savestates_list.set_margin (value ? fullscreen_header_bar_height : 0);
+               }
+       }
 
        public DisplayHeaderBar header_bar {
                get { return fullscreen_header_bar; }
@@ -56,6 +66,7 @@ private class Games.DisplayBox : Gtk.Bin {
        private SavestatesList savestates_list;
 
        private Binding fullscreen_binding;
+       private int fullscreen_header_bar_height;
        private long timeout_id;
 
        construct {
@@ -63,6 +74,8 @@ private class Games.DisplayBox : Gtk.Bin {
                                                    "is-fullscreen",
                                                    BindingFlags.BIDIRECTIONAL);
                timeout_id = -1;
+
+               fullscreen_header_bar.size_allocate.connect (on_fullscreen_header_bar_size_allocated);
        }
 
        public DisplayBox (SavestatesListState savestates_list_state) {
@@ -118,4 +131,8 @@ private class Games.DisplayBox : Gtk.Bin {
        public void on_savestates_list_revealed_changed () {
                fullscreen_box.autohide = !savestates_list.state.is_revealed;
        }
+
+       private void on_fullscreen_header_bar_size_allocated (Gtk.Allocation allocation) {
+               fullscreen_header_bar_height = allocation.height;
+       }
 }
diff --git a/src/ui/savestates-list.vala b/src/ui/savestates-list.vala
index d0626f04..8143be17 100644
--- a/src/ui/savestates-list.vala
+++ b/src/ui/savestates-list.vala
@@ -8,6 +8,8 @@ private class Games.SavestatesList : Gtk.Box {
        private Gtk.ListBox list_box;
        [GtkChild]
        private Gtk.ListBoxRow new_savestate_row;
+       [GtkChild]
+       private Gtk.ScrolledWindow scrolled_window;
 
        public bool is_revealed {
                get { return revealer.reveal_child; }
@@ -61,6 +63,10 @@ private class Games.SavestatesList : Gtk.Box {
                list_box.set_header_func (update_header);
        }
 
+       public void set_fullscreen_margin (int margin) {
+               scrolled_window.margin_top = margin;
+       }
+
        [GtkCallback]
        private void on_row_activated (Gtk.ListBoxRow activated_row) {
                if (activated_row == new_savestate_row) {


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