From: Steinar H. Gunderson Date: Mon, 2 Nov 2015 00:40:58 +0000 (+0100) Subject: Create the previews dynamically, in a number determined by the theme. X-Git-Tag: 1.0.0~177 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=538aa2fb443b25f34feafb4a50bb52206f7fe79c;p=nageru Create the previews dynamically, in a number determined by the theme. --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 3f0098b..430ec0f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -39,40 +39,6 @@ MainWindow::MainWindow() ui->me_live->set_output(Mixer::OUTPUT_LIVE); ui->me_preview->set_output(Mixer::OUTPUT_PREVIEW); - // TODO: Ask for the real number. - ui->preview1->set_output(Mixer::OUTPUT_INPUT0); - ui->preview2->set_output(Mixer::OUTPUT_INPUT1); - ui->preview3->set_output(Mixer::OUTPUT_INPUT2); - - // Hook up the preview clicks. - { - 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))); - } - - // Hook up the preview keyboard keys. - { - QSignalMapper *mapper = new QSignalMapper(this); - QShortcut *shortcut1 = new QShortcut(QKeySequence(Qt::Key_1), this); - connect(shortcut1, SIGNAL(activated()), mapper, SLOT(map())); - QShortcut *shortcut2 = new QShortcut(QKeySequence(Qt::Key_2), this); - connect(shortcut2, SIGNAL(activated()), mapper, SLOT(map())); - QShortcut *shortcut3 = new QShortcut(QKeySequence(Qt::Key_3), this); - connect(shortcut3, SIGNAL(activated()), mapper, SLOT(map())); - mapper->setMapping(shortcut1, 0), - mapper->setMapping(shortcut2, 1); - mapper->setMapping(shortcut3, 2); - - connect(mapper, SIGNAL(mapped(int)), this, SLOT(channel_clicked(int))); - } - // Hook up the transition buttons. // TODO: Make them dynamic. { @@ -91,7 +57,7 @@ MainWindow::MainWindow() transition_btn2 = ui->transition_btn2; transition_btn3 = ui->transition_btn3; qRegisterMetaType>("std::vector"); - connect(ui->preview1, SIGNAL(transition_names_updated(std::vector)), + connect(ui->me_preview, SIGNAL(transition_names_updated(std::vector)), this, SLOT(set_transition_names(std::vector))); } @@ -106,6 +72,28 @@ void MainWindow::resizeEvent(QResizeEvent* event) void MainWindow::mixer_created(Mixer *mixer) { + // Make the previews. + unsigned num_previews = mixer->get_num_channels(); + QSignalMapper *mapper = new QSignalMapper(this); + + for (unsigned i = 0; i < num_previews; ++i) { + GLWidget *preview = new GLWidget(this); + preview->set_output(Mixer::Output(Mixer::OUTPUT_INPUT0 + i)); + ui->preview_displays->insertWidget(previews.size(), preview, 1); + previews.push_back(preview); + + // Hook up the click. + mapper->setMapping(preview, i); + connect(preview, SIGNAL(clicked()), mapper, SLOT(map())); + + // Hook up the keyboard key. + QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this); + mapper->setMapping(shortcut, i); + connect(shortcut, SIGNAL(activated()), mapper, SLOT(map())); + } + + connect(mapper, SIGNAL(mapped(int)), this, SLOT(channel_clicked(int))); + mixer->set_audio_level_callback([this](float level_lufs, float peak_db, float global_level_lufs, float range_low_lufs, float range_high_lufs){ ui->vu_meter->set_level(level_lufs); ui->lra_meter->set_levels(global_level_lufs, range_low_lufs, range_high_lufs); @@ -138,7 +126,7 @@ void MainWindow::relayout() // The previews will be constrained by the remaining height, and the width. // FIXME: spacing? - double preview_height = std::min(height - me_height, (width / 4.0) * 9.0 / 16.0); + double preview_height = std::min(height - me_height, (width / double(previews.size())) * 9.0 / 16.0); ui->vertical_layout->setStretch(0, lrintf(me_height)); ui->vertical_layout->setStretch(1, std::max(1, lrintf(height - me_height - preview_height))); @@ -147,11 +135,12 @@ void MainWindow::relayout() // Set the widths for the previews. double preview_width = preview_height * 16.0 / 9.0; // FIXME: spacing? - ui->preview_displays->setStretch(0, lrintf(preview_width)); - ui->preview_displays->setStretch(1, lrintf(preview_width)); - ui->preview_displays->setStretch(2, lrintf(preview_width)); - ui->preview_displays->setStretch(3, lrintf(preview_width)); - ui->preview_displays->setStretch(4, lrintf(width - 4.0 * preview_width)); + for (unsigned i = 0; i < previews.size(); ++i) { + ui->preview_displays->setStretch(i, lrintf(preview_width)); + } + + // The spacer. + ui->preview_displays->setStretch(previews.size(), lrintf(width - previews.size() * preview_width)); } void MainWindow::set_transition_names(vector transition_names) diff --git a/mainwindow.h b/mainwindow.h index ef0b04f..8d80aaf 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -5,6 +5,7 @@ #include #include +class GLWidget; class QResizeEvent; namespace Ui { @@ -32,6 +33,7 @@ public slots: private: Ui::MainWindow *ui; QPushButton *transition_btn1, *transition_btn2, *transition_btn3; + std::vector previews; }; extern MainWindow *global_mainwindow; diff --git a/mixer.h b/mixer.h index bf53c24..00c1e15 100644 --- a/mixer.h +++ b/mixer.h @@ -109,6 +109,11 @@ public: return theme->get_transition_names(pts()); } + unsigned get_num_channels() const + { + return theme->get_num_channels(); + } + private: void bm_frame(unsigned card_index, uint16_t timecode, FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format, diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index 6341867..ad5fb9e 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -43,6 +43,9 @@ + + + @@ -243,8 +246,6 @@ true - peak_display - peak_display @@ -387,6 +388,9 @@ Qt::Vertical + + QSizePolicy::Preferred + 20 @@ -396,59 +400,22 @@ - + 0 - - - - - 1 - 1 - - - - - - - - - 1 - 1 - - - - - - - - - 1 - 1 - - - - - - - - - 1 - 1 - - - - Qt::Horizontal + + QSizePolicy::Preferred + 0 - 0 + 40 @@ -489,11 +456,6 @@ QWidget
glwidget.h
- - QGLWidget - QWidget -
qglwidget.h
-
VUMeter QWidget