]> git.sesse.net Git - nageru/commitdiff
Make some labels and a white balance button per preview (the latter is not hooked...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 2 Nov 2015 20:58:58 +0000 (21:58 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 2 Nov 2015 21:03:46 +0000 (22:03 +0100)
.gitignore
Makefile
main.cpp
mainwindow.cpp
mainwindow.h
mixer.h
theme.cpp
theme.h
theme.lua
ui_display.ui [new file with mode: 0644]

index 8db8f4789f1e4acb6b2605a52bbb19e57c4e160c..1e9c62625f2b40fd4e76f4cecdacc203533d483d 100644 (file)
@@ -1,5 +1,6 @@
 *.d
 *.o
 *.moc.cpp
+ui_display.h
 ui_mainwindow.h
 nageru
index 65cf5a66691250fc0d212b580db0f0b07e44f736..657f7e7419f650683322aa20263d87fcba7047c8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,10 +26,10 @@ all: nageru
 nageru: $(OBJS)
        $(CXX) $(LDFLAGS) -o $@ $^
 
-mainwindow.o: mainwindow.cpp ui_mainwindow.h
+mainwindow.o: mainwindow.cpp ui_mainwindow.h ui_display.h
 
 DEPS=$(OBJS:.o=.d)
 -include $(DEPS)
 
 clean:
-       $(RM) $(OBJS) $(DEPS) nageru ui_mainwindow.h glwidget.moc.cpp mainwindow.moc.cpp window.moc.cpp chain-*.frag *.dot
+       $(RM) $(OBJS) $(DEPS) nageru ui_mainwindow.h ui_display.h glwidget.moc.cpp mainwindow.moc.cpp window.moc.cpp chain-*.frag *.dot
index fd41e0bd67bafdd710935d119a11a42b9d355e94..396963470c21ed4d6193f9eed204932ff44adec7 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
        global_share_widget = new QGLWidget();
 
        MainWindow mainWindow;
-       mainWindow.resize(QSize(1500, 606));
+       mainWindow.resize(QSize(1500, 685));
        mainWindow.show();
 
        int rc = app.exec();
index 430ec0f0a8b5af09231308451ec1e5a1f5b2eaf9..eacda1cf5f12b19fbda76546f5642a92a3abb682 100644 (file)
@@ -19,6 +19,7 @@
 #include "glwidget.h"
 #include "lrameter.h"
 #include "mixer.h"
+#include "ui_display.h"
 #include "ui_mainwindow.h"
 #include "vumeter.h"
 
@@ -77,14 +78,20 @@ void MainWindow::mixer_created(Mixer *mixer)
        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));
+               Mixer::Output output = Mixer::Output(Mixer::OUTPUT_INPUT0 + i);
+
+               QWidget *preview = new QWidget(this);
+               Ui::Display *ui_display = new Ui::Display;
+               ui_display->setupUi(preview);
+               ui_display->label->setText(mixer->get_channel_name(output).c_str());
+               ui_display->wb_button->setVisible(mixer->get_supports_set_wb(output));
+               ui_display->display->set_output(output);
                ui->preview_displays->insertWidget(previews.size(), preview, 1);
-               previews.push_back(preview);
+               previews.push_back(ui_display);
 
                // Hook up the click.
-               mapper->setMapping(preview, i);
-               connect(preview, SIGNAL(clicked()), mapper, SLOT(map()));
+               mapper->setMapping(ui_display->display, i);
+               connect(ui_display->display, SIGNAL(clicked()), mapper, SLOT(map()));
 
                // Hook up the keyboard key.
                QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this);
@@ -126,11 +133,12 @@ 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 / double(previews.size())) * 9.0 / 16.0);
+       double preview_label_height = previews[0]->label->height();
+       double preview_height = std::min(height - me_height - preview_label_height, (width / double(previews.size())) * 9.0 / 16.0);
 
        ui->vertical_layout->setStretch(0, lrintf(me_height));
        ui->vertical_layout->setStretch(1, std::max<int>(1, lrintf(height - me_height - preview_height)));
-       ui->vertical_layout->setStretch(2, lrintf(preview_height));
+       ui->vertical_layout->setStretch(2, lrintf(preview_height + preview_label_height));
 
        // Set the widths for the previews.
        double preview_width = preview_height * 16.0 / 9.0;  // FIXME: spacing?
index 8d80aafebac955e25f67565f957232739e642f26..6a8e9db4f8ce7b14948d5c0fb50238a4b6dd6494 100644 (file)
@@ -9,6 +9,7 @@ class GLWidget;
 class QResizeEvent;
 
 namespace Ui {
+class Display;
 class MainWindow;
 }  // namespace Ui
 
@@ -33,7 +34,7 @@ public slots:
 private:
        Ui::MainWindow *ui;
        QPushButton *transition_btn1, *transition_btn2, *transition_btn3;
-       std::vector<GLWidget *> previews;
+       std::vector<Ui::Display *> previews;
 };
 
 extern MainWindow *global_mainwindow;
diff --git a/mixer.h b/mixer.h
index 7a2d45cb4f96414ecb257f3cb07eece6db84eab7..b02b99742e6f4825f4589d417382ef0dc0875393 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -111,6 +111,16 @@ public:
                return theme->get_num_channels();
        }
 
+       std::string get_channel_name(unsigned channel) const
+       {
+               return theme->get_channel_name(channel);
+       }
+
+       bool get_supports_set_wb(unsigned channel) const
+       {
+               return theme->get_supports_set_wb(channel);
+       }
+
 private:
        void bm_frame(unsigned card_index, uint16_t timecode,
                FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format,
index 61ead92e98bc8503a8c137f135bf89aa18c2ba27..f8e0d8eff2801a5c91e220819779d652b821431a 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -469,6 +469,38 @@ Theme::get_chain(unsigned num, float t, unsigned width, unsigned height)
        });
 }
 
+std::string Theme::get_channel_name(unsigned channel)
+{
+       unique_lock<mutex> lock(m);
+       lua_getglobal(L, "channel_name");
+       lua_pushnumber(L, channel);
+       if (lua_pcall(L, 1, 1, 0) != 0) {
+               fprintf(stderr, "error running function `channel_nam': %s\n", lua_tostring(L, -1));
+               exit(1);
+       }
+
+       std::string ret = lua_tostring(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);
+       lua_getglobal(L, "supports_set_wb");
+       lua_pushnumber(L, channel);
+       if (lua_pcall(L, 1, 1, 0) != 0) {
+               fprintf(stderr, "error running function `supports_set_wb': %s\n", lua_tostring(L, -1));
+               exit(1);
+       }
+
+       bool ret = checkbool(L, -1);
+       lua_pop(L, 1);
+       assert(lua_gettop(L) == 0);
+       return ret;
+}
+
 std::vector<std::string> Theme::get_transition_names(float t)
 {
        unique_lock<mutex> lock(m);
diff --git a/theme.h b/theme.h
index f9a3d2d71a3bb5f88d4b48980effa6a408d27775..575259026e3157abda33a17c18f4d7cb0cfbedfc 100644 (file)
--- a/theme.h
+++ b/theme.h
@@ -46,6 +46,8 @@ public:
                input_textures[signal_num].tex_cbcr = tex_cbcr;
        }
        int get_num_channels() { return num_channels; }
+       std::string get_channel_name(unsigned channel);
+       bool get_supports_set_wb(unsigned channel);
 
        std::vector<std::string> get_transition_names(float t);
 
index 543857f4f79826160a3e8e19b23e45c5222640b3..b91e0fadfe8240c924d8f462380b0c053a206f20 100644 (file)
--- a/theme.lua
+++ b/theme.lua
@@ -100,6 +100,24 @@ function num_channels()
        return 3
 end
 
+-- Returns the name for each additional channel (starting from 2).
+-- Called only once for each channel, at the start of the program.
+function channel_name(channel)
+       if channel == 2 then
+               return "Input 1"
+       elseif channel == 3 then
+               return "Input 2"
+       else
+               return "Side-by-side"
+       end
+end
+
+-- Returns if a given channel supports setting white balance (starting from 2).
+-- Called only once for each channel, at the start of the program.
+function supports_set_wb(channel)
+       return channel == 2 or channel == 3
+end
+
 function finish_transitions(t)
        -- If live is 2 (SBS) but de-facto single, make it so.
        if live_signal_num == 2 and t >= transition_end and zoom_dst == 1.0 then
diff --git a/ui_display.ui b/ui_display.ui
new file mode 100644 (file)
index 0000000..40c6e43
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Display</class>
+ <widget class="QWidget" name="Display">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>606</width>
+    <height>433</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="GLWidget" name="display" native="true">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>1</verstretch>
+      </sizepolicy>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="title_bar">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+         <horstretch>1</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>24</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>TextLabel</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="wb_button">
+       <property name="text">
+        <string>Set WB</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>GLWidget</class>
+   <extends>QWidget</extends>
+   <header>glwidget.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>