]> git.sesse.net Git - nageru/commitdiff
Add red and green borders around channels to mark them as used for live and preview.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 4 Apr 2016 21:46:11 +0000 (23:46 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 4 Apr 2016 21:46:11 +0000 (23:46 +0200)
glwidget.cpp
glwidget.h
mainwindow.cpp
mainwindow.h
mixer.h
simple.lua
theme.cpp
theme.h
theme.lua
ui_display.ui

index bf3ac13a6a6cb53df3f332785af6e8c980f291b4..f8e76c771402e6688e9be75e601a3f08c8230894 100644 (file)
@@ -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) {
index b0dc79ed09e5e4ef49101e9f8f97761989548560..a4b54adffecb7374c7b7a36d12a0e63f100102f8 100644 (file)
@@ -47,6 +47,7 @@ signals:
        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);
index 5cd698e39cc65346ea06321da3ebe1cdfb56d827..60f2c85dfb6e8952e63b18399ed67217310c8a54 100644 (file)
@@ -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);
index 8ca728ae11196cc610c18d339db353314a931bf7..be80bc8a991abfa29161c1636a929a098aa0ab56 100644 (file)
@@ -40,6 +40,7 @@ public slots:
        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);
diff --git a/mixer.h b/mixer.h
index ee701e5b9815815f25da5db2d8e0817461ccf52f..6f04c67844113d53010fa3ca93a451c0f6fcb821 100644 (file)
--- 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);
index 1e895d5cb69f7a236b6932b5846b7f95e721104d..451146d1839638ae8a314bcc807497cca26200c0 100644 (file)
@@ -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.
index 35b777e76d79c6ea3afe309e57b0ae5333be9b2e..aefc081e97847d9349079fcc502d1e9161f1cd90 100644 (file)
--- 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<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);
diff --git a/theme.h b/theme.h
index 20d736738a89d94718c9344e624bdc253e4b3db6..264b5ac67f86086f35a5a1555a9f071356fecbf3 100644 (file)
--- 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<std::string> get_transition_names(float t);
 
index d7c281dd3faacb3b62312fe0273e8b8199dc1038..bbc086a4e86f478dde7c2b66eabe8f64e78a0aee 100644 (file)
--- 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.
index 79be4c241f808b05d46864c8a1d0c2f671c9fcf4..51022fec9c47d4729792b0fbde648ef1273cf79b 100644 (file)
     <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>