[lightsoff/wip/gtkview] Implemented gtk view transitions



commit 2feb09271a86402d1ee88156622fe49351018e9c
Author: Robert Roth <robert roth off gmail com>
Date:   Sun Jul 15 03:31:15 2018 +0300

    Implemented gtk view transitions

 src/board-view-gtk.vala |  8 --------
 src/game-view-gtk.vala  | 24 +++++++++++++++++++++---
 2 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/src/board-view-gtk.vala b/src/board-view-gtk.vala
index f2f7437..c963066 100644
--- a/src/board-view-gtk.vala
+++ b/src/board-view-gtk.vala
@@ -46,14 +46,6 @@ public class BoardViewGtk : Gtk.Grid, BoardView
         _moves = 0;
     }
 
-    public void slide_in (int direction, int sign, Clutter.Timeline timeline)
-    {
-    }
-
-    public void slide_out (int direction, int sign, Clutter.Timeline timeline)
-    {
-    }
-
     public void light_toggled_cb (Gtk.ToggleButton source)
     {
         int xl, yl;
diff --git a/src/game-view-gtk.vala b/src/game-view-gtk.vala
index 755e404..ecf65ed 100644
--- a/src/game-view-gtk.vala
+++ b/src/game-view-gtk.vala
@@ -1,4 +1,4 @@
-public class GtkGameView : Gtk.Frame, GameView {
+public class GtkGameView : Gtk.Stack, GameView {
 
     private BoardViewGtk board_view;
     private BoardViewGtk? new_board_view = null;
@@ -17,8 +17,26 @@ public class GtkGameView : Gtk.Frame, GameView {
 
     public void replace_board (BoardView old_board, BoardView new_board, GameView.ReplaceStyle style, bool 
fast = true)
     {
-        remove (old_board as Gtk.Widget);
-        add (new_board as Gtk.Widget);
+        transition_duration = fast ? 1000 : 2000;
+        switch (style)
+        {
+            case REFRESH:
+                transition_type = Gtk.StackTransitionType.SLIDE_DOWN;
+                break;
+            case SLIDE_NEXT:
+            case SLIDE_FORWARD:
+                transition_type = Gtk.StackTransitionType.SLIDE_LEFT;
+                break;
+            case SLIDE_BACKWARD:
+                transition_type = Gtk.StackTransitionType.SLIDE_RIGHT;
+                break;
+        }
+
+        var new_level = "level %d".printf(current_level);
+        add_named (new_board as Gtk.Widget, new_level);
+        set_visible_child (new_board as Gtk.Widget);
+        notify["transition-running"].connect(() => remove (old_board as Gtk.Widget));
+        ;
     }
 
     public void hide_cursor ()


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