]> git.sesse.net Git - nageru/commitdiff
Hook up some timers for the Lua theme, and make a more beautiful transition experience.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 8 Oct 2015 00:07:19 +0000 (02:07 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 8 Oct 2015 00:07:19 +0000 (02:07 +0200)
mainwindow.cpp
mixer.cpp
mixer.h
theme.lua

index f3c674d269b4b3611e98799f999b2c5a09a48a28..4ac21bfe99d5f220c42eb4b5c17305511f900cb0 100644 (file)
@@ -23,5 +23,5 @@ MainWindow::MainWindow()
 
 void MainWindow::cut()
 {
-       global_mixer->transition_clicked(0, 0.0f);  // FIXME: real values
+       global_mixer->transition_clicked(0);  // FIXME: real value
 }
index 053ad793e884b7e632bdd7ee4840d1c216484f27..4d69e5c732266a2dae67e9a794c9dca49b1f9ada 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -408,9 +408,9 @@ void Mixer::quit()
        mixer_thread.join();
 }
 
-void Mixer::transition_clicked(int transition_num, float t)
+void Mixer::transition_clicked(int transition_num)
 {
-       theme->transition_clicked(transition_num, t);
+       theme->transition_clicked(transition_num, frame / 60.0);
 }
 
 void Mixer::OutputChannel::output_frame(DisplayFrame frame)
diff --git a/mixer.h b/mixer.h
index b4eaad9b0d2a1338d9c099fe5302edeb6f2c4e48..97bae3057e87e60151f4ba87f96d57ab4d66e107 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -32,7 +32,7 @@ public:
        void start();
        void quit();
 
-       void transition_clicked(int transition_num, float t);
+       void transition_clicked(int transition_num);
 
        enum Output {
                OUTPUT_LIVE = 0,
index 662c1059e8af0372de28280b061358e7011a7a87..a8f9cda00bc85e86bd5777e8659b488ab1710fea 100644 (file)
--- a/theme.lua
+++ b/theme.lua
@@ -8,6 +8,11 @@
 -- C++ side and you generally just build chains.
 io.write("hello from lua\n");
 
+local zoom_start = -2.0;
+local zoom_end = -1.0;
+local zoom_src = 0.0;
+local zoom_dst = 1.0;
+
 local live_signal_num = 0;
 local preview_signal_num = 1;
 
@@ -49,10 +54,16 @@ function get_transitions()
 end
 
 function transition_clicked(num, t)
-       -- Only a cut for now.
-       local temp = live_signal_num;
-       live_signal_num = preview_signal_num;
-       preview_signal_num = temp;
+       -- local temp = live_signal_num;
+       -- live_signal_num = preview_signal_num;
+       -- preview_signal_num = temp;
+
+       zoom_start = t;
+       zoom_end = t + 1.0;
+
+       local temp = zoom_src;
+       zoom_src = zoom_dst;
+       zoom_dst = temp;
 end
 
 function channel_clicked(num, t)
@@ -81,7 +92,16 @@ end
 function get_chain(num, t, width, height)
        if num == 0 then  -- Live.
                prepare = function()
-                       prepare_sbs_chain(t, width, height);
+                       if (t < zoom_start) then
+                               prepare_sbs_chain(zoom_src, width, height);
+                       elseif (t > zoom_end) then
+                               prepare_sbs_chain(zoom_dst, width, height);
+                       else
+                               local tt = (t - zoom_start) / (zoom_end - zoom_start);
+                               -- Smooth it a bit.
+                               tt = math.sin(tt * 3.14159265358 * 0.5)
+                               prepare_sbs_chain(zoom_src + (zoom_dst - zoom_src) * tt, width, height);
+                       end
                end
                return main_chain, prepare;
        end
@@ -194,10 +214,9 @@ function prepare_sbs_chain(t, screen_width, screen_height)
        local left1 = right1 - width1;
 
        -- Interpolate between the fullscreen and side-by-side views.
-       local sub_t = 0.5 + 0.5 * math.cos(t * 1.0);
-       local scale0 = 1.0 + sub_t * (1280.0 / 848.0 - 1.0);
-       local tx0 = 0.0 + sub_t * (-left0 * scale0);
-       local ty0 = 0.0 + sub_t * (-top0 * scale0);
+       local scale0 = 1.0 + t * (1280.0 / 848.0 - 1.0);
+       local tx0 = 0.0 + t * (-left0 * scale0);
+       local ty0 = 0.0 + t * (-top0 * scale0);
 
        top0 = top0 * scale0 + ty0;
        bottom0 = bottom0 * scale0 + ty0;