X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mainwindow.cpp;h=3f0098be7a07d385e3326f1de0dbc184cf0e4dc6;hb=d7bba4abb3d56893399578f0540b9ded0a28380f;hp=25d7a09645b02affc062186f61eeaf4298e7c9c5;hpb=393ff668fccf38b76e2468ae83163f3788e03978;p=nageru diff --git a/mainwindow.cpp b/mainwindow.cpp index 25d7a09..3f0098b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,24 +1,39 @@ #include "mainwindow.h" -#include "window.h" -#include -#include + +#include +#include +#include #include -#include +#include +#include +#include +#include #include +#include +#include #include +#include +#include +#include -#include "context.h" +#include "glwidget.h" +#include "lrameter.h" #include "mixer.h" - #include "ui_mainwindow.h" +#include "vumeter.h" + +class QResizeEvent; using namespace std; Q_DECLARE_METATYPE(std::vector); +MainWindow *global_mainwindow = nullptr; + MainWindow::MainWindow() : ui(new Ui::MainWindow) { + global_mainwindow = this; ui->setupUi(this); ui->me_live->set_output(Mixer::OUTPUT_LIVE); @@ -84,35 +99,59 @@ void MainWindow::resizeEvent(QResizeEvent* event) { QMainWindow::resizeEvent(event); + // Ask for a relayout, but only after the event loop is done doing relayout + // on everything else. + QMetaObject::invokeMethod(this, "relayout", Qt::QueuedConnection); +} + +void MainWindow::mixer_created(Mixer *mixer) +{ + mixer->set_audio_level_callback([this](float level_lufs, float peak_db, float global_level_lufs, float range_low_lufs, float range_high_lufs){ + ui->vu_meter->set_level(level_lufs); + ui->lra_meter->set_levels(global_level_lufs, range_low_lufs, range_high_lufs); + + char buf[256]; + snprintf(buf, sizeof(buf), "%.1f", peak_db); + ui->peak_display->setText(buf); + if (peak_db > -0.1f) { // -0.1 dBFS is EBU peak limit. + ui->peak_display->setStyleSheet("QLabel { background-color: red; color: white; }"); + } else { + ui->peak_display->setStyleSheet(""); + } + }); +} + +void MainWindow::relayout() +{ + int width = size().width(); + int height = size().height(); + // Allocate the height; the most important part is to keep the main displays // at 16:9 if at all possible. - double me_width = (width() - ui->transition_btn2->width()) / 2.0; + double me_width = ui->me_preview->width(); double me_height = me_width * 9.0 / 16.0 + ui->label_preview->height(); - double me_proportion = me_height / height(); // TODO: Scale the widths when we need to do this. - if (me_proportion > 0.8) { - me_proportion = 0.8; + if (me_height / double(height) > 0.8) { + me_height = height * 0.8; } // The previews will be constrained by the remaining height, and the width. - // FIXME: spacing= - double preview_height = std::min(height() - me_height, (width() / 4.0) * 9.0 / 16.0); - double preview_proportion = preview_height / height(); + // FIXME: spacing? + double preview_height = std::min(height - me_height, (width / 4.0) * 9.0 / 16.0); - ui->vertical_layout->setStretch(0, lrintf(1000 * me_proportion)); - ui->vertical_layout->setStretch(1, lrintf(1000 * (1.0 - me_proportion - preview_proportion))); - ui->vertical_layout->setStretch(2, lrintf(1000 * preview_proportion)); + 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)); // Set the widths for the previews. - double preview_width = preview_height * 16.0 / 9.0; - double preview_width_proportion = preview_width / width(); // FIXME: spacing? - - ui->preview_displays->setStretch(0, lrintf(1000 * preview_width_proportion)); - ui->preview_displays->setStretch(1, lrintf(1000 * preview_width_proportion)); - ui->preview_displays->setStretch(2, lrintf(1000 * preview_width_proportion)); - ui->preview_displays->setStretch(3, lrintf(1000 * preview_width_proportion)); - ui->preview_displays->setStretch(4, lrintf(1000 * (1.0 - 4.0 * preview_width_proportion))); + double preview_width = preview_height * 16.0 / 9.0; // FIXME: spacing? + + ui->preview_displays->setStretch(0, lrintf(preview_width)); + ui->preview_displays->setStretch(1, lrintf(preview_width)); + ui->preview_displays->setStretch(2, lrintf(preview_width)); + ui->preview_displays->setStretch(3, lrintf(preview_width)); + ui->preview_displays->setStretch(4, lrintf(width - 4.0 * preview_width)); } void MainWindow::set_transition_names(vector transition_names)