[california] Next/prev month animation should go up/down: Bug #732046



commit f906b7fbc71ccbf854116ee78ad6c8833c6d9eb1
Author: Jim Nelson <jim yorba org>
Date:   Wed Aug 20 17:22:23 2014 -0700

    Next/prev month animation should go up/down: Bug #732046
    
    Month view animation is now vertical, week view animation remains
    horizontal.  Crossfading is used to move between the views.

 src/Makefile.am                      |    1 +
 src/host/host-main-window-title.vala |   27 ++++++++++++++++++++++++---
 src/host/host-main-window.vala       |    4 +++-
 src/rc/main-window-title.ui          |    4 ++--
 src/view/month/month-controller.vala |    7 ++++++-
 src/view/view-chronology-motion.vala |   20 ++++++++++++++++++++
 src/view/view-controllable.vala      |    5 +++++
 src/view/week/week-controller.vala   |    5 +++++
 8 files changed, 66 insertions(+), 7 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index f11b6a9..11179c6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -159,6 +159,7 @@ california_VALASOURCES = \
        unit-test/unit-test-harness.vala \
        \
        view/view.vala \
+       view/view-chronology-motion.vala \
        view/view-container.vala \
        view/view-controllable.vala \
        view/view-palette.vala \
diff --git a/src/host/host-main-window-title.vala b/src/host/host-main-window-title.vala
index 01bd685..a0c8280 100644
--- a/src/host/host-main-window-title.vala
+++ b/src/host/host-main-window-title.vala
@@ -8,6 +8,10 @@ namespace California.Host {
 
 [GtkTemplate (ui = "/org/yorba/california/rc/main-window-title.ui")]
 internal class MainWindowTitle : Gtk.Grid {
+    public const string PROP_MOTION = "motion";
+    
+    public View.ChronologyMotion motion { get; set; default = View.ChronologyMotion.HORIZONTAL; }
+    
     [GtkChild]
     public Gtk.Button next_button;
     
@@ -24,9 +28,26 @@ internal class MainWindowTitle : Gtk.Grid {
     public Gtk.Label title_label;
     
     public MainWindowTitle() {
-        if (get_direction() == Gtk.TextDirection.RTL) {
-            prev_image.icon_name = "go-previous-rtl-symbolic";
-            next_image.icon_name = "go-next-rtl-symbolic";
+        notify[PROP_MOTION].connect(on_motion_changed);
+        on_motion_changed();
+    }
+    
+    private void on_motion_changed() {
+        switch (motion) {
+            case View.ChronologyMotion.HORIZONTAL:
+                bool rtl = (get_direction() == Gtk.TextDirection.RTL);
+                
+                prev_image.icon_name = rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic";
+                next_image.icon_name = rtl ? "go-next-rtl-symbolic" : "go-next-symbolic";
+            break;
+            
+            case View.ChronologyMotion.VERTICAL:
+                prev_image.icon_name = "go-up-symbolic";
+                next_image.icon_name = "go-down-symbolic";
+            break;
+            
+            default:
+                assert_not_reached();
         }
     }
 }
diff --git a/src/host/host-main-window.vala b/src/host/host-main-window.vala
index d8643b5..f487dc7 100644
--- a/src/host/host-main-window.vala
+++ b/src/host/host-main-window.vala
@@ -131,7 +131,7 @@ public class MainWindow : Gtk.ApplicationWindow {
         // view stack settings
         view_stack.homogeneous = true;
         view_stack.transition_duration = Toolkit.DEFAULT_STACK_TRANSITION_DURATION_MSEC;
-        view_stack.transition_type = Gtk.StackTransitionType.SLIDE_UP_DOWN;
+        view_stack.transition_type = Gtk.StackTransitionType.CROSSFADE;
         
         // subscribe before adding so first add to initialize UI
         view_stack.notify["visible-child"].connect(on_view_changed);
@@ -307,6 +307,8 @@ public class MainWindow : Gtk.ApplicationWindow {
             current_controller.request_create_all_day_event.connect(on_request_create_all_day_event);
             current_controller.request_display_event.connect(on_request_display_event);
             
+            custom_title.motion = current_controller.motion;
+            
             // bindings
             Binding binding = current_controller.bind_property(View.Controllable.PROP_CURRENT_LABEL,
                 custom_title.title_label, "label", BindingFlags.SYNC_CREATE);
diff --git a/src/rc/main-window-title.ui b/src/rc/main-window-title.ui
index 1820157..4b2ffa9 100644
--- a/src/rc/main-window-title.ui
+++ b/src/rc/main-window-title.ui
@@ -20,7 +20,7 @@
         <property name="vexpand">False</property>
         <property name="action_name">win.previous</property>
         <child>
-          <object class="GtkImage" id="next_image">
+          <object class="GtkImage" id="prev_image">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="icon_name">go-previous-symbolic</property>
@@ -46,7 +46,7 @@
         <property name="vexpand">False</property>
         <property name="action_name">win.next</property>
         <child>
-          <object class="GtkImage" id="prev_image">
+          <object class="GtkImage" id="next_image">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="icon_name">go-next-symbolic</property>
diff --git a/src/view/month/month-controller.vala b/src/view/month/month-controller.vala
index 12463e9..4e8df3c 100644
--- a/src/view/month/month-controller.vala
+++ b/src/view/month/month-controller.vala
@@ -63,6 +63,11 @@ public class Controller : BaseObject, View.Controllable {
     /**
      * @inheritDoc
      */
+    public ChronologyMotion motion { get { return ChronologyMotion.VERTICAL; } }
+    
+    /**
+     * @inheritDoc
+     */
     public Calendar.Date default_date { get; protected set; }
     
     /**
@@ -94,7 +99,7 @@ public class Controller : BaseObject, View.Controllable {
         stack.transition_duration = Toolkit.SLOW_STACK_TRANSITION_DURATION_MSEC;
         
         stack_model = new Toolkit.StackModel<Calendar.MonthOfYear>(stack,
-            Toolkit.StackModel.OrderedTransitionType.SLIDE_LEFT_RIGHT, model_presentation,
+            Toolkit.StackModel.OrderedTransitionType.SLIDE_UP_DOWN, model_presentation,
             trim_presentation_from_cache, ensure_presentation_in_cache);
         
         stack.bind_property("transition-running", this, PROP_IN_TRANSITION, BindingFlags.SYNC_CREATE);
diff --git a/src/view/view-chronology-motion.vala b/src/view/view-chronology-motion.vala
new file mode 100644
index 0000000..039f298
--- /dev/null
+++ b/src/view/view-chronology-motion.vala
@@ -0,0 +1,20 @@
+/* Copyright 2014 Yorba Foundation
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later).  See the COPYING file in this distribution.
+ */
+
+namespace California.View {
+
+/**
+ * Logical chronology motion.
+ *
+ * A description of spatial motion appropriate for a chronological shift in the { link View}.
+ */
+public enum ChronologyMotion {
+    HORIZONTAL,
+    VERTICAL
+}
+
+}
+
diff --git a/src/view/view-controllable.vala b/src/view/view-controllable.vala
index 299df7d..53ed7de 100644
--- a/src/view/view-controllable.vala
+++ b/src/view/view-controllable.vala
@@ -52,6 +52,11 @@ public interface Controllable : Object {
     public abstract bool is_viewing_today { get; protected set; }
     
     /**
+     * The "logical" chronology motion when moving between views of time.
+     */
+    public abstract ChronologyMotion motion { get; }
+    
+    /**
      * Indicates when a transition is running (such as when moving between dates).
      */
     public abstract bool in_transition { get; protected set; }
diff --git a/src/view/week/week-controller.vala b/src/view/week/week-controller.vala
index adbb00d..5f6de7f 100644
--- a/src/view/week/week-controller.vala
+++ b/src/view/week/week-controller.vala
@@ -54,6 +54,11 @@ public class Controller : BaseObject, View.Controllable {
     /**
      * @inheritDoc
      */
+    public ChronologyMotion motion { get { return ChronologyMotion.HORIZONTAL; } }
+    
+    /**
+     * @inheritDoc
+     */
     public bool in_transition { get; protected set; }
     
     /**


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