[gnome-taquin] Allow to run on extra-flat screen.



commit d11e2422829cb98e8d47b6409e8044fa1c59ced3
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Jan 18 17:46:16 2019 +0100

    Allow to run on extra-flat screen.
    
    That is allowed by the use of BaseWindow.

 data/taquin.css          | 72 +++++++++++++++++++++++++++++++-----------------
 src/game-window.vala     |  5 ----
 src/new-game-screen.vala | 41 ++++++++++++++++++++-------
 3 files changed, 78 insertions(+), 40 deletions(-)
---
diff --git a/data/taquin.css b/data/taquin.css
index aa9b4d8..d15e271 100644
--- a/data/taquin.css
+++ b/data/taquin.css
@@ -17,13 +17,17 @@
 
 @import url("base-window.css");
 
-                   .new-game-screen         { padding:   0.5rem; }  /* for top    */
-      .flat-window button.start-game-button { margin-top:0.5rem; } /* for bottom */
 
-                   button.start-game-button { margin-top:2.0rem; margin-bottom:0.5rem; transition:margin-top 
0 ease; }
 
-.extra-thin-window label.section-header,
-.extra-thin-window button.start-game-button { margin-top:1.0rem; }
+                               .new-game-screen         {                          padding:0.5rem; }  /* for 
top    */
+                               button.start-game-button { margin-top:1.5rem; margin-bottom:0.5rem;
+                                               transition:margin-top 0 ease, margin-bottom 0 ease; }
+                  .flat-window button.start-game-button { margin-top:0.5rem;                       }
+.extra-flat-window.flat-window .new-game-screen         {                          padding:0.4rem; }
+.extra-flat-window.flat-window button.start-game-button { margin-top:  0rem; margin-bottom:0.4rem; }
+
+.extra-thin-window             label.section-header,
+.extra-thin-window             button.start-game-button { margin-top:1.0rem; }
 
 button.radio-like-toggle,
 button.menubutton-like-combo {
@@ -35,11 +39,11 @@ button.menubutton-like-combo {
 * * games buttons
 \*/
 
-                   button.radio-like-toggle#radio-fifteen { background-image: 
url("resource://org/gnome/Taquin/images/15-Puzzle.png"); }
-                   button.radio-like-toggle#radio-sixteen { background-image: 
url("resource://org/gnome/Taquin/images/16-Puzzle.png"); }
+button.radio-like-toggle#radio-fifteen { background-image: 
url("resource://org/gnome/Taquin/images/15-Puzzle.png"); }
+button.radio-like-toggle#radio-sixteen { background-image: 
url("resource://org/gnome/Taquin/images/16-Puzzle.png"); }
 
-                   button.radio-like-toggle:backdrop { color: @theme_unfocused_fg_color; }
-                   button.radio-like-toggle          { color: @theme_fg_color;
+                                                       button.radio-like-toggle:backdrop { color: 
@theme_unfocused_fg_color; }
+                                                       button.radio-like-toggle          { color: 
@theme_fg_color;
 
   background-repeat:no-repeat;
   background-color:transparent;
@@ -51,38 +55,56 @@ button.menubutton-like-combo {
   padding:0.5rem 1rem 1rem 1rem;
 }
 
-      window:not(.extra-thin-window) button.radio-like-toggle {
-  transition:background-size     0s ease 0.01s,
-             background-position 0s ease 0.01s,
-             min-height          0s ease 0.01s,
-             padding             0s ease 0.01s;
+                                   .extra-thin-window  button.radio-like-toggle {
+  background-size:5rem;
+  background-position:0.4rem center;
+  min-height:3rem;
+  padding:1.8rem 0.6rem 1rem 5rem;
 }
 
-.flat-window:not(.extra-thin-window) button.radio-like-toggle {
+                  .flat-window:not(.extra-thin-window) button.radio-like-toggle {
   background-size:8rem;
   min-height:9rem;
 }
 
-                 .extra-thin-window  button.radio-like-toggle {
-  background-size:5rem;
-  background-position:0.4rem center;
-  min-height:3rem;
-  padding:1.8rem 1rem 1rem 5rem;
+.extra-flat-window.flat-window                         button.radio-like-toggle {
+  background-size:3rem;
+  background-position:0.3rem center;
+  min-height:2rem;
+  padding:0.6rem 0.5rem 0.5rem 4rem;
 }
 
-                                     button.radio-like-toggle label { padding-bottom:10rem; }
-                 .extra-thin-window  button.radio-like-toggle label { padding-bottom: 1rem; }
-.flat-window:not(.extra-thin-window) button.radio-like-toggle label { padding-bottom: 6rem; }
+                                                       button.radio-like-toggle label { 
padding-bottom:10rem; }
+                                   .extra-thin-window  button.radio-like-toggle label { padding-bottom: 
1rem; }
+                  .flat-window:not(.extra-thin-window) button.radio-like-toggle label { padding-bottom: 
6rem; }
+.extra-flat-window.flat-window                         button.radio-like-toggle label { padding-bottom: 
0rem; }
+
+/* hack: help fixing the race between CSS and box orientation changes */
+                                                       button.radio-like-toggle,  /* for all, because there 
are others */
+                 .extra-flat-window.extra-thin-window  button.radio-like-toggle,  /* switch from phone_hztl 
window to phone_both window */
+                        window:not(.extra-thin-window) button.radio-like-toggle { /* switch from phone_vert 
window to usual size window */
+  transition:background-size     0s ease 0.01s,
+             background-position 0s ease 0.01s,
+             min-height          0s ease 0.01s,
+             padding             0s ease 0.01s;
+}
 
 /*\
 * * options buttons
 \*/
 
-button.start-game-button,
-button.menubutton-like-combo {
+.extra-flat-window button.start-game-button,
+.extra-flat-window button.menubutton-like-combo {
+  min-height:2rem;
+}
+                   button.start-game-button,
+                   button.menubutton-like-combo {
   min-height:3rem;
   min-width:11rem;
 }
+
+/* styling */
+
 button.menubutton-like-combo:checked,
 button.menubutton-like-combo:hover {
   color:#2e3436; /* gtk-contained.css’ theme_fg_color */
diff --git a/src/game-window.vala b/src/game-window.vala
index b8ba5cd..6cd2aaf 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -43,11 +43,6 @@ private class GameWindow : BaseWindow, AdaptativeWidget
     private GameView        game_view;
     private Box             new_game_screen;
 
-    construct
-    {
-        height_request = 400;    // FIXME remove limit
-    }
-
     public GameWindow (string? css_resource, string name, int width, int height, bool maximized, bool 
start_now, GameWindowFlags flags, Box _new_game_screen, Widget view_content, NightLightMonitor 
night_light_monitor)
     {
         GameHeaderBar _headerbar = new GameHeaderBar (name, flags, night_light_monitor);
diff --git a/src/new-game-screen.vala b/src/new-game-screen.vala
index 9f7a55c..ddb54f3 100644
--- a/src/new-game-screen.vala
+++ b/src/new-game-screen.vala
@@ -69,38 +69,59 @@ private class NewGameScreen : Box, AdaptativeWidget
 
     private bool phone_size = false;
     private bool extra_thin = false;
+    private bool extra_flat = false;
     private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
-        bool _extra_thin = new_size == AdaptativeWidget.WindowSize.EXTRA_THIN;
-        bool _phone_size = new_size == AdaptativeWidget.WindowSize.PHONE_BOTH
-                        || new_size == AdaptativeWidget.WindowSize.PHONE_VERT;
+        bool _extra_flat = AdaptativeWidget.WindowSize.is_extra_flat (new_size);
+        bool _extra_thin = (new_size == AdaptativeWidget.WindowSize.EXTRA_THIN);
+        bool _phone_size = (new_size == AdaptativeWidget.WindowSize.PHONE_BOTH)
+                        || (new_size == AdaptativeWidget.WindowSize.PHONE_VERT);
 
         if ((_extra_thin == extra_thin)
-         && (_phone_size == phone_size))
+         && (_phone_size == phone_size)
+         && (_extra_flat == extra_flat))
             return;
         extra_thin = _extra_thin;
         phone_size = _phone_size;
+        extra_flat = _extra_flat;
 
         if (!_extra_thin && !_phone_size)
         {
-            games_label.hide ();
-            options_label.hide ();
-            options_separator.hide ();
-            games_box.set_orientation (Orientation.HORIZONTAL);
-            options_box.set_orientation (Orientation.HORIZONTAL);
-            games_box.hide ();
+            if (extra_flat)
+            {
+                games_label.hide ();
+                options_label.hide ();
+                this.set_orientation (Orientation.HORIZONTAL);
+                games_box.set_orientation (Orientation.VERTICAL);
+                options_box.set_orientation (Orientation.VERTICAL);
+                options_separator.set_orientation (Orientation.VERTICAL);
+                options_separator.show ();
+            }
+            else
+            {
+                games_label.hide ();
+                options_label.hide ();
+                options_separator.hide ();
+                this.set_orientation (Orientation.VERTICAL);
+                games_box.set_orientation (Orientation.HORIZONTAL);
+                options_box.set_orientation (Orientation.HORIZONTAL);
+                games_box.hide ();
+            }
         }
         else if (_phone_size)
         {
             games_label.hide ();
             options_label.hide ();
+            this.set_orientation (Orientation.VERTICAL);
             games_box.set_orientation (Orientation.VERTICAL);
             options_box.set_orientation (Orientation.VERTICAL);
+            options_separator.set_orientation (Orientation.HORIZONTAL);
             options_separator.show ();
         }
         else
         {
             options_separator.hide ();
+            this.set_orientation (Orientation.VERTICAL);
             games_box.set_orientation (Orientation.VERTICAL);
             options_box.set_orientation (Orientation.VERTICAL);
             games_label.show ();


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