From 6b5c8411a2776e77d1bb7d66ee7ec255428f2a13 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 30 Dec 2015 13:48:10 +0100 Subject: [PATCH] Show the current resolution next to the inputs. --- glwidget.cpp | 1 + glwidget.h | 1 + mainwindow.cpp | 12 ++++++++++++ mainwindow.h | 4 +++- theme.lua | 34 +++++++++++++++++++++++++++++++--- 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/glwidget.cpp b/glwidget.cpp index e9b97d5..06675f3 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -51,6 +51,7 @@ void GLWidget::initializeGL() global_mixer->set_frame_ready_callback(output, [this]{ QMetaObject::invokeMethod(this, "update", Qt::AutoConnection); emit transition_names_updated(global_mixer->get_transition_names()); + emit resolution_updated(output); }); glDisable(GL_BLEND); diff --git a/glwidget.h b/glwidget.h index 2cf34eb..ae4902c 100644 --- a/glwidget.h +++ b/glwidget.h @@ -39,6 +39,7 @@ protected: signals: void clicked(); void transition_names_updated(std::vector transition_names); + void resolution_updated(Mixer::Output output); private: Mixer::Output output; diff --git a/mainwindow.cpp b/mainwindow.cpp index 8a91a3f..9f29334 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -53,6 +53,7 @@ MainWindow::MainWindow() transition_btn3 = ui->transition_btn3; qRegisterMetaType>("std::vector"); connect(ui->me_preview, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names); + qRegisterMetaType("Mixer::Output"); } void MainWindow::resizeEvent(QResizeEvent* event) @@ -83,6 +84,9 @@ void MainWindow::mixer_created(Mixer *mixer) // Hook up the click. connect(ui_display->display, &GLWidget::clicked, bind(&MainWindow::channel_clicked, this, i)); + // Let the theme update the text whenever the resolution changed. + connect(ui_display->display, &GLWidget::resolution_updated, this, &MainWindow::update_channel_name); + // Hook up the keyboard key. QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this); connect(shortcut, &QShortcut::activated, bind(&MainWindow::channel_clicked, this, i)); @@ -247,6 +251,14 @@ void MainWindow::set_transition_names(vector transition_names) } } +void MainWindow::update_channel_name(Mixer::Output output) +{ + if (output >= Mixer::OUTPUT_INPUT0) { + unsigned channel = output - Mixer::OUTPUT_INPUT0; + previews[channel]->label->setText(global_mixer->get_channel_name(output).c_str()); + } +} + void MainWindow::transition_clicked(int transition_number) { global_mixer->transition_clicked(transition_number); diff --git a/mainwindow.h b/mainwindow.h index 4c4c3f0..8faa812 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -6,6 +6,8 @@ #include #include +#include "mixer.h" + class GLWidget; class QResizeEvent; @@ -14,7 +16,6 @@ class Display; class MainWindow; } // namespace Ui -class Mixer; class QPushButton; class MainWindow : public QMainWindow @@ -31,6 +32,7 @@ public slots: void channel_clicked(int channel_number); void wb_button_clicked(int channel_number); void set_transition_names(std::vector transition_names); + void update_channel_name(Mixer::Output output); void cutoff_knob_changed(int value); void limiter_threshold_knob_changed(int value); void compressor_threshold_knob_changed(int value); diff --git a/theme.lua b/theme.lua index ee72838..1f00d52 100644 --- a/theme.lua +++ b/theme.lua @@ -31,6 +31,9 @@ local STATIC_SIGNAL_NUM = 3 -- to the next. local FADE_SIGNAL_NUM = 4 +-- Last width/height/resolution for each channel, if we have it. +local last_resolution = {} + -- Utility function to help creating many similar chains that can differ -- in a free set of chosen parameters. function make_cartesian_product(parms, callback) @@ -244,13 +247,30 @@ function num_channels() return 4 end +-- Helper function to write e.g. “720p”. +function get_channel_resolution(signal_num) + if last_resolution[signal_num] then + if last_resolution[signal_num].height == 0 or + last_resolution[signal_num].height == 525 then + return "no signal" + elseif last_resolution[signal_num].interlaced then + return (last_resolution[signal_num].height * 2) .. "i" + else + return last_resolution[signal_num].height .. "p" + end + else + return "no signal" + end +end + -- Returns the name for each additional channel (starting from 2). --- Called only once for each channel, at the start of the program. +-- Called at the start of the program, and then each frame for live +-- channels in case they change resolution. function channel_name(channel) if channel == 2 then - return "Input 1" + return "Input 1 (" .. get_channel_resolution(0) .. ")" elseif channel == 3 then - return "Input 2" + return "Input 2 (" .. get_channel_resolution(1) .. ")" elseif channel == 4 then return "Side-by-side" elseif channel == 5 then @@ -430,6 +450,14 @@ end -- NOTE: The chain returned must be finalized with the Y'CbCr flag -- if and only if num==0. function get_chain(num, t, width, height, signals) + for signal_num=0,1 do + last_resolution[signal_num] = { + width = signals:get_width(signal_num), + height = signals:get_height(signal_num), + interlaced = signals:get_interlaced(signal_num) + } + end + if num == 0 then -- Live. if live_signal_num == INPUT0_SIGNAL_NUM or live_signal_num == INPUT1_SIGNAL_NUM then -- Plain input. local input_type = get_input_type(signals, live_signal_num) -- 2.39.2