From 8cbf100e6126c1550a6436970d777a652ac1182e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 8 Oct 2015 21:35:02 +0200 Subject: [PATCH] Hook up the channel click events. --- glwidget.cpp | 5 +++++ glwidget.h | 4 ++++ mainwindow.cpp | 15 +++++++++++++++ mainwindow.h | 1 + mixer.cpp | 5 +++++ mixer.h | 1 + theme.cpp | 12 ++++++++++++ theme.h | 1 + theme.lua | 10 +++------- 9 files changed, 47 insertions(+), 7 deletions(-) diff --git a/glwidget.cpp b/glwidget.cpp index 9725210..1e34a1c 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -72,3 +72,8 @@ void GLWidget::paintGL() frame.chain->render_to_screen(); check_error(); } + +void GLWidget::mousePressEvent(QMouseEvent *event) +{ + emit clicked(); +} diff --git a/glwidget.h b/glwidget.h index 045ba55..d397273 100644 --- a/glwidget.h +++ b/glwidget.h @@ -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; diff --git a/mainwindow.cpp b/mainwindow.cpp index bac1f31..99b7974 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "window.h" #include +#include #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); +} diff --git a/mainwindow.h b/mainwindow.h index 3f3d8b6..edea126 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -12,6 +12,7 @@ public: public slots: void cut(); + void channel_clicked(int id); }; #endif diff --git a/mixer.cpp b/mixer.cpp index e861613..fd3cbae 100644 --- 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 3411a50..c6366fd 100644 --- 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, diff --git a/theme.cpp b/theme.cpp index d75ac86..5a42dff 100644 --- 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 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 6701ece..f35c6d5 100644 --- 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; diff --git a/theme.lua b/theme.lua index 3a59040..7a5ff80 100644 --- 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 , @@ -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() -- 2.39.2