[gnome-mines] Fancy screen transitions added



commit c2902f998812f7976a1c25dd5e007b17408846fc
Author: Robert Roth <robert roth off gmail com>
Date:   Sat Oct 11 15:16:29 2014 +0300

    Fancy screen transitions added

 data/interface.ui    |  358 +++++++++++++++++++++++++-------------------------
 src/gnome-mines.vala |   30 ++---
 2 files changed, 189 insertions(+), 199 deletions(-)
---
diff --git a/data/interface.ui b/data/interface.ui
index 9539324..b2e6a45 100644
--- a/data/interface.ui
+++ b/data/interface.ui
@@ -24,186 +24,12 @@
         <property name="margin">12</property>
         <property name="spacing">12</property>
         <child>
-          <object class="GtkBox" id="view_box">
+          <object class="GtkStack" id="stack">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="hexpand">True</property>
             <property name="vexpand">True</property>
-            <property name="border_width">6</property>
-            <property name="orientation">vertical</property>
-            <child>
-              <object class="GtkBox" id="main_screen">
-                <property name="can_focus">False</property>
-                <property name="spacing">12</property>
-                <child>
-                  <object class="GtkAspectFrame" id="minefield_aspect">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="vexpand">True</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">none</property>
-                    <property name="obey_child">False</property>
-                    <child>
-                      <object class="GtkOverlay" id="minefield_overlay">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkBox" id="buttons_box">
-                    <property name="width_request">140</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="halign">start</property>
-                    <property name="margin_top">12</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">4</property>
-                    <child>
-                      <object class="GtkImage" id="flag_image">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="icon_name">flag-symbolic</property>
-                        <property name="pixel_size">32</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="flag_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="margin_bottom">12</property>
-                        <property name="label" translatable="no">5/10</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkImage" id="clock_image">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="icon_name">preferences-system-time-symbolic</property>
-                        <property name="pixel_size">32</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="clock_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="margin_bottom">12</property>
-                        <property name="label" translatable="no">0:00</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">3</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="play_pause_button">
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="action_name">app.pause</property>
-                        <property name="use_underline">True</property>
-                        <child>
-                          <object class="GtkLabel" id="play_pause_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="margin">12</property>
-                            <property name="label" translatable="yes">_Pause</property>
-                            <property name="use_underline">True</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">4</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="high_scores_button">
-                        <property name="label" translatable="yes">_Best Times</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="action_name">app.scores</property>
-                        <property name="use_underline">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">5</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="new_game_button">
-                        <property name="label" translatable="yes">Change _Difficulty</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="action_name">app.new-game</property>
-                        <property name="use_underline">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">6</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="replay_button">
-                        <property name="label" translatable="yes">_Play Again</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="action_name">app.repeat-size</property>
-                        <property name="use_underline">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="pack_type">end</property>
-                        <property name="position">7</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="pack_type">end</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
+            <property name="transition-type">slide-left-right</property>
             <child>
               <object class="GtkAspectFrame" id="new_game_screen">
                 <property name="visible">True</property>
@@ -267,9 +93,8 @@
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="name" translatable="no">new_game</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -408,8 +233,179 @@
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
+                <property name="name" translatable="no">custom_game</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkBox" id="main_screen">
+                <property name="can_focus">False</property>
+                <property name="spacing">12</property>
+                <child>
+                  <object class="GtkAspectFrame" id="minefield_aspect">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <property name="obey_child">False</property>
+                    <child>
+                      <object class="GtkOverlay" id="minefield_overlay">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkBox" id="buttons_box">
+                    <property name="width_request">150</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="halign">start</property>
+                    <property name="margin_top">12</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">4</property>
+                    <child>
+                      <object class="GtkImage" id="flag_image">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="icon_name">flag-symbolic</property>
+                        <property name="pixel_size">32</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="flag_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_bottom">12</property>
+                        <property name="label" translatable="no">5/10</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkImage" id="clock_image">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="icon_name">preferences-system-time-symbolic</property>
+                        <property name="pixel_size">32</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="clock_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="margin_bottom">12</property>
+                        <property name="label" translatable="no">0:00</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="play_pause_button">
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="action_name">app.pause</property>
+                        <property name="use_underline">True</property>
+                        <child>
+                          <object class="GtkLabel" id="play_pause_label">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="margin">12</property>
+                            <property name="label" translatable="yes">_Pause</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">4</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="high_scores_button">
+                        <property name="label" translatable="yes">_Best Times</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="action_name">app.scores</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="new_game_button">
+                        <property name="label" translatable="yes">Change _Difficulty</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="action_name">app.new-game</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">6</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="replay_button">
+                        <property name="label" translatable="yes">_Play Again</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="action_name">app.repeat-size</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">7</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="pack_type">end</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="name" translatable="no">game</property>
                 <property name="position">2</property>
               </packing>
             </child>
diff --git a/src/gnome-mines.vala b/src/gnome-mines.vala
index 7b645e3..e720007 100644
--- a/src/gnome-mines.vala
+++ b/src/gnome-mines.vala
@@ -39,6 +39,7 @@ public class Mines : Gtk.Application
     private Gtk.Overlay minefield_overlay;
     private Gtk.Box paused_box;
     private Gtk.ScrolledWindow scrolled;
+    private Gtk.Stack stack;
 
     private Gtk.Label clock_label;
 
@@ -74,7 +75,6 @@ public class Mines : Gtk.Application
     private SimpleAction pause_action;
     private Gtk.AspectFrame new_game_screen;
     private Gtk.AspectFrame custom_game_screen;
-    private bool is_new_game_screen;
 
     private const OptionEntry[] option_entries =
     {
@@ -217,6 +217,8 @@ public class Mines : Gtk.Application
         minefield_view = new MinefieldView (settings);
         minefield_view.show ();
 
+        stack = (Gtk.Stack) ui_builder.get_object ("stack");
+
         scrolled = new Gtk.ScrolledWindow (null, null);
         scrolled.show ();
         scrolled.add (minefield_view);
@@ -234,6 +236,7 @@ public class Mines : Gtk.Application
         minefield_overlay.add_overlay (paused_box);
 
         main_screen = (Gtk.Widget) ui_builder.get_object ("main_screen");
+        main_screen.show_all ();
 
         /* Initialize New Game Screen */
         startup_new_game_screen (ui_builder);
@@ -323,7 +326,6 @@ public class Mines : Gtk.Application
         button.clicked.connect (custom_size_clicked_cb);
 
         custom_game_screen.show_all ();
-        custom_game_screen.hide ();
     }
 
     private bool window_configure_event_cb (Gdk.EventConfigure event)
@@ -453,10 +455,7 @@ public class Mines : Gtk.Application
 
     private void show_custom_game_screen ()
     {
-        is_new_game_screen = false;
-        custom_game_screen.show ();
-        main_screen.hide ();
-        new_game_screen.hide ();
+        stack.visible_child_name = "custom_game";
     }
 
     private bool can_start_new_game ()
@@ -484,21 +483,17 @@ public class Mines : Gtk.Application
 
     private void show_new_game_screen ()
     {
-        if (is_new_game_screen)
+        if (stack.visible_child_name == "new_game")
             return;
 
         if (minefield != null)
         {
-            minefield.paused = false;
+            minefield.paused = true;
             pause_requested = false;
             SignalHandler.disconnect_by_func (minefield, null, this);
         }
         minefield = null;
 
-        is_new_game_screen = true;
-        custom_game_screen.hide ();
-        main_screen.hide ();
-        new_game_screen.show ();
         window.resize (window_width, window_height);
 
         new_game_button.show ();
@@ -506,22 +501,19 @@ public class Mines : Gtk.Application
         new_game_action.set_enabled (false);
         repeat_size_action.set_enabled (false);
         pause_action.set_enabled (false);
-        main_screen.hide ();
+
+        stack.visible_child_name = "new_game";
     }
 
     private void start_game ()
     {
-        is_new_game_screen = false;
-        custom_game_screen.hide ();
         window_skip_configure = true;
-        main_screen.show ();
         minefield_view.has_focus = true;
-        new_game_screen.hide ();
+
         play_pause_button.hide();
         replay_button.hide ();
         new_game_button.hide ();
         high_scores_button.hide ();
-        main_screen.show ();
 
         tick_cb ();
 
@@ -583,6 +575,8 @@ public class Mines : Gtk.Application
 
         minefield.paused = false;
         pause_requested = false;
+
+        stack.visible_child_name = "game";
     }
 
     private void new_game_cb ()


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