From: Steinar H. Gunderson Date: Mon, 4 Apr 2016 21:46:11 +0000 (+0200) Subject: Add red and green borders around channels to mark them as used for live and preview. X-Git-Tag: 1.2.0~6 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=f006b5b162841dbc764fb620025b87a3272ac79a Add red and green borders around channels to mark them as used for live and preview. --- diff --git a/glwidget.cpp b/glwidget.cpp index bf3ac13..f8e76c7 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -60,6 +60,7 @@ void GLWidget::initializeGL() QMetaObject::invokeMethod(this, "update", Qt::AutoConnection); emit transition_names_updated(global_mixer->get_transition_names()); emit resolution_updated(output); + emit color_updated(output); }); if (output >= Mixer::OUTPUT_INPUT0) { diff --git a/glwidget.h b/glwidget.h index b0dc79e..a4b54ad 100644 --- a/glwidget.h +++ b/glwidget.h @@ -47,6 +47,7 @@ signals: void clicked(); void transition_names_updated(std::vector transition_names); void resolution_updated(Mixer::Output output); + void color_updated(Mixer::Output output); private slots: void show_context_menu(unsigned signal_num, const QPoint &pos); diff --git a/mainwindow.cpp b/mainwindow.cpp index 5cd698e..60f2c85 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -90,8 +90,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. + // Let the theme update the text whenever the resolution or color changed. connect(ui_display->display, &GLWidget::resolution_updated, this, &MainWindow::update_channel_name); + connect(ui_display->display, &GLWidget::color_updated, this, &MainWindow::update_channel_color); // Hook up the keyboard key. QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this); @@ -329,6 +330,15 @@ void MainWindow::update_channel_name(Mixer::Output output) } } +void MainWindow::update_channel_color(Mixer::Output output) +{ + if (output >= Mixer::OUTPUT_INPUT0) { + unsigned channel = output - Mixer::OUTPUT_INPUT0; + string color = global_mixer->get_channel_color(output); + previews[channel]->frame->setStyleSheet(QString::fromStdString("background-color:" + color)); + } +} + void MainWindow::transition_clicked(int transition_number) { global_mixer->transition_clicked(transition_number); diff --git a/mainwindow.h b/mainwindow.h index 8ca728a..be80bc8 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -40,6 +40,7 @@ public slots: void wb_button_clicked(int channel_number); void set_transition_names(std::vector transition_names); void update_channel_name(Mixer::Output output); + void update_channel_color(Mixer::Output output); void gain_staging_knob_changed(int value); void final_makeup_gain_knob_changed(int value); void cutoff_knob_changed(int value); diff --git a/mixer.h b/mixer.h index ee701e5..6f04c67 100644 --- a/mixer.h +++ b/mixer.h @@ -171,6 +171,11 @@ public: return theme->get_channel_name(channel); } + std::string get_channel_color(unsigned channel) const + { + return theme->get_channel_color(channel); + } + int get_channel_signal(unsigned channel) const { return theme->get_channel_signal(channel); diff --git a/simple.lua b/simple.lua index 1e895d5..451146d 100644 --- a/simple.lua +++ b/simple.lua @@ -77,6 +77,15 @@ function channel_signal(channel) end end +-- API ENTRY POINT +-- Called every frame. Returns the color (if any) to paint around the given +-- channel. Returns a CSS color (typically to mark live and preview signals); +-- "transparent" is allowed. +-- Will never be called for live (0) or preview (1). +function channel_color(channel) + return "transparent" +end + -- API ENTRY POINT -- Returns if a given channel supports setting white balance (starting from 2). -- Called only once for each channel, at the start of the program. diff --git a/theme.cpp b/theme.cpp index 35b777e..aefc081 100644 --- a/theme.cpp +++ b/theme.cpp @@ -810,6 +810,22 @@ int Theme::get_channel_signal(unsigned channel) return ret; } +std::string Theme::get_channel_color(unsigned channel) +{ + unique_lock lock(m); + lua_getglobal(L, "channel_color"); + lua_pushnumber(L, channel); + if (lua_pcall(L, 1, 1, 0) != 0) { + fprintf(stderr, "error running function `channel_color': %s\n", lua_tostring(L, -1)); + exit(1); + } + + std::string ret = checkstdstring(L, -1); + lua_pop(L, 1); + assert(lua_gettop(L) == 0); + return ret; +} + bool Theme::get_supports_set_wb(unsigned channel) { unique_lock lock(m); diff --git a/theme.h b/theme.h index 20d7367..264b5ac 100644 --- a/theme.h +++ b/theme.h @@ -58,6 +58,7 @@ public: int get_channel_signal(unsigned channel); bool get_supports_set_wb(unsigned channel); void set_wb(unsigned channel, double r, double g, double b); + std::string get_channel_color(unsigned channel); std::vector get_transition_names(float t); diff --git a/theme.lua b/theme.lua index d7c281d..bbc086a 100644 --- a/theme.lua +++ b/theme.lua @@ -333,6 +333,41 @@ function channel_signal(channel) end end +-- API ENTRY POINT +-- Called every frame. Returns the color (if any) to paint around the given +-- channel. Returns a CSS color (typically to mark live and preview signals); +-- "transparent" is allowed. +-- Will never be called for live (0) or preview (1). +function channel_color(channel) + if channel_involved_in(channel, live_signal_num) then + return "#f00" + end + if channel_involved_in(channel, preview_signal_num) then + return "#0f0" + end + return "transparent" +end + +function channel_involved_in(channel, signal_num) + if signal_num == INPUT0_SIGNAL_NUM then + return channel == 2 + end + if signal_num == INPUT1_SIGNAL_NUM then + return channel == 3 + end + if signal_num == SBS_SIGNAL_NUM then + return (channel == 2 or channel == 3) + end + if signal_num == STATIC_SIGNAL_NUM then + return (channel == 5) + end + if signal_num == FADE_SIGNAL_NUM then + return (channel_involved_in(channel, fade_src_signal) or + channel_involved_in(channel, fade_dst_signal)) + end + return false +end + -- API ENTRY POINT -- Returns if a given channel supports setting white balance (starting from 2). -- Called only once for each channel, at the start of the program. diff --git a/ui_display.ui b/ui_display.ui index 79be4c2..51022fe 100644 --- a/ui_display.ui +++ b/ui_display.ui @@ -27,13 +27,49 @@ 0 - + 0 1 + + true + + + QFrame::Box + + + QFrame::Plain + + + 0 + + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + 0 + 0 + + + + +