]> git.sesse.net Git - nageru/commitdiff
Hook up the channel click events.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 8 Oct 2015 19:35:02 +0000 (21:35 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 8 Oct 2015 19:35:02 +0000 (21:35 +0200)
glwidget.cpp
glwidget.h
mainwindow.cpp
mainwindow.h
mixer.cpp
mixer.h
theme.cpp
theme.h
theme.lua

index 9725210622ea04150b4b85386a7d55112abfbc72..1e34a1cb3290b6cd84099597a50ae53f8a4fa0bd 100644 (file)
@@ -72,3 +72,8 @@ void GLWidget::paintGL()
        frame.chain->render_to_screen();
        check_error();
 }
+
+void GLWidget::mousePressEvent(QMouseEvent *event)
+{
+       emit clicked();
+}
index 045ba5587204ea7ebb7351e2aad323dc79e0fb91..d3972739cff27de4550b462f5cc863617620ff49 100644 (file)
@@ -33,6 +33,10 @@ protected:
        void initializeGL() override;
        void resizeGL(int width, int height) override;
        void paintGL() override;
+       void mousePressEvent(QMouseEvent *event) override;
+
+signals:
+       void clicked();
 
 private:
        Mixer::Output output;
index bac1f3176189874f104424a38bebe6d4acf3c063..99b7974e4abcb07461460e5701a409e95e36354e 100644 (file)
@@ -1,6 +1,7 @@
 #include "mainwindow.h"
 #include "window.h"
 #include <thread>
+#include <QSignalMapper>
 
 #include "context.h"
 #include "mixer.h"
@@ -22,9 +23,23 @@ MainWindow::MainWindow()
        ui->preview1->set_output(Mixer::OUTPUT_INPUT0);
        ui->preview2->set_output(Mixer::OUTPUT_INPUT1);
        ui->preview3->set_output(Mixer::OUTPUT_INPUT2);
+
+       QSignalMapper *mapper = new QSignalMapper(this);
+       mapper->setMapping(ui->preview1, 0),
+       mapper->setMapping(ui->preview2, 1);
+       mapper->setMapping(ui->preview3, 2);
+       connect(ui->preview1, SIGNAL(clicked()), mapper, SLOT(map()));
+       connect(ui->preview2, SIGNAL(clicked()), mapper, SLOT(map()));
+       connect(ui->preview3, SIGNAL(clicked()), mapper, SLOT(map()));
+       connect(mapper, SIGNAL(mapped(int)), this, SLOT(channel_clicked(int)));
 }
 
 void MainWindow::cut()
 {
        global_mixer->transition_clicked(0);  // FIXME: real value
 }
+
+void MainWindow::channel_clicked(int channel_number)
+{
+       global_mixer->channel_clicked(channel_number);
+}
index 3f3d8b60b9ec75bf4895316b0e59f8a098d5b378..edea126568e133661c1d9ca7c58096e3674ed6d1 100644 (file)
@@ -12,6 +12,7 @@ public:
 
 public slots:
        void cut();
+       void channel_clicked(int id);
 };
 
 #endif
index e8616137afe169add9954a4508fc71a679e9568d..fd3cbae4a058f9506a3b3d46aebb61dee8c6d96e 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -415,6 +415,11 @@ void Mixer::transition_clicked(int transition_num)
        theme->transition_clicked(transition_num, frame / 60.0);
 }
 
+void Mixer::channel_clicked(int preview_num)
+{
+       theme->channel_clicked(preview_num);
+}
+
 Mixer::OutputChannel::~OutputChannel()
 {
        if (has_current_frame) {
diff --git a/mixer.h b/mixer.h
index 3411a50217d42d683671e596759acba8f7d8a909..c6366fdec1a65d5e8f7e909ed788e0c6119d8c73 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -33,6 +33,7 @@ public:
        void quit();
 
        void transition_clicked(int transition_num);
+       void channel_clicked(int preview_num);
 
        enum Output {
                OUTPUT_LIVE = 0,
index d75ac86e2c9a266a7231959b7db83b26a783fc70..5a42dff65e585e51e57d9083a8b3d52775d8a5d3 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -414,3 +414,15 @@ void Theme::transition_clicked(int transition_num, float t)
                exit(1);
        }
 }
+
+void Theme::channel_clicked(int preview_num)
+{
+       unique_lock<mutex> lock(m);
+       lua_getglobal(L, "channel_clicked");
+       lua_pushnumber(L, preview_num);
+
+       if (lua_pcall(L, 1, 0, 0) != 0) {
+               fprintf(stderr, "error running function `channel_clicked': %s\n", lua_tostring(L, -1));
+               exit(1);
+       }
+}
diff --git a/theme.h b/theme.h
index 6701ece87db2948487674eb267e233ebfd34e1b0..f35c6d5be472eddb3ad9b02b9864e2ab6687b963 100644 (file)
--- a/theme.h
+++ b/theme.h
@@ -28,6 +28,7 @@ public:
 
        void connect_signal(movit::YCbCrInput *input, int signal_num);
        void transition_clicked(int transition_num, float t);
+       void channel_clicked(int preview_num);
 
 private:
        std::mutex m;
index 3a59040b78624649b0df8b78548eb5fe0ccd86ba..7a5ff80e80b0d68e8b96541ac71155b4977a609a 100644 (file)
--- a/theme.lua
+++ b/theme.lua
@@ -107,9 +107,8 @@ function transition_clicked(num, t)
        zoom_dst = temp
 end
 
-function channel_clicked(num, t)
-       -- Presumably change the preview here.
-       io.write("STUB: channel_clicked\n")
+function channel_clicked(num)
+       preview_signal_num = num
 end
 
 -- Called every frame. Get the chain for displaying at input <num>,
@@ -154,10 +153,7 @@ function get_chain(num, t, width, height)
                return main_chain_hq.chain, prepare
        end
        if num == 1 then  -- Preview.
-               prepare = function()
-                       simple_chain_lq_input:connect_signal(preview_signal_num)
-               end
-               return simple_chain_lq, prepare
+               num = preview_signal_num + 2
        end
        if num == 2 then
                prepare = function()