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) {
void clicked();
void transition_names_updated(std::vector<std::string> 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);
// 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);
}
}
+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);
void wb_button_clicked(int channel_number);
void set_transition_names(std::vector<std::string> 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);
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);
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.
return ret;
}
+std::string Theme::get_channel_color(unsigned channel)
+{
+ unique_lock<mutex> 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<mutex> lock(m);
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<std::string> get_transition_names(float t);
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.
<number>0</number>
</property>
<item>
- <widget class="GLWidget" name="display" native="true">
+ <widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="leftMargin">
+ <number>3</number>
+ </property>
+ <property name="topMargin">
+ <number>3</number>
+ </property>
+ <property name="rightMargin">
+ <number>3</number>
+ </property>
+ <property name="bottomMargin">
+ <number>3</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="GLWidget" name="display" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
<item>