From 390521f709026cb1acdbde84ef77d1490da1ffa2 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 2 Nov 2015 21:58:58 +0100 Subject: [PATCH] Make some labels and a white balance button per preview (the latter is not hooked up yet, though). --- .gitignore | 1 + Makefile | 4 +-- main.cpp | 2 +- mainwindow.cpp | 22 ++++++++----- mainwindow.h | 3 +- mixer.h | 10 ++++++ theme.cpp | 32 +++++++++++++++++++ theme.h | 2 ++ theme.lua | 18 +++++++++++ ui_display.ui | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 166 insertions(+), 11 deletions(-) create mode 100644 ui_display.ui diff --git a/.gitignore b/.gitignore index 8db8f47..1e9c626 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.d *.o *.moc.cpp +ui_display.h ui_mainwindow.h nageru diff --git a/Makefile b/Makefile index 65cf5a6..657f7e7 100644 --- 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 diff --git a/main.cpp b/main.cpp index fd41e0b..3969634 100644 --- 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(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 430ec0f..eacda1c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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(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? diff --git a/mainwindow.h b/mainwindow.h index 8d80aaf..6a8e9db 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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 previews; + std::vector previews; }; extern MainWindow *global_mainwindow; diff --git a/mixer.h b/mixer.h index 7a2d45c..b02b997 100644 --- 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, diff --git a/theme.cpp b/theme.cpp index 61ead92..f8e0d8e 100644 --- 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 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 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 Theme::get_transition_names(float t) { unique_lock lock(m); diff --git a/theme.h b/theme.h index f9a3d2d..5752590 100644 --- 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 get_transition_names(float t); diff --git a/theme.lua b/theme.lua index 543857f..b91e0fa 100644 --- 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 index 0000000..40c6e43 --- /dev/null +++ b/ui_display.ui @@ -0,0 +1,83 @@ + + + Display + + + + 0 + 0 + 606 + 433 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 1 + + + + + + + + + + + 1 + 0 + + + + + 0 + 24 + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Set WB + + + + + + + + + + GLWidget + QWidget +
glwidget.h
+
+
+ + +
-- 2.39.2