]> git.sesse.net Git - nageru/blobdiff - mainwindow.cpp
Add some pagination to the main window.
[nageru] / mainwindow.cpp
index c1a3836b2ff7a97b4e23c3b9acfd5c384a38cfcf..e0db1b6ac8e16b8f3bc5b90269820a0bdc784430 100644 (file)
@@ -133,6 +133,12 @@ MainWindow::MainWindow()
        connect(ui->me_live, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names);
        qRegisterMetaType<Mixer::Output>("Mixer::Output");
 
+       // Hook up the prev/next buttons on the audio views.
+       connect(ui->compact_prev_page, &QAbstractButton::clicked, bind(&QStackedWidget::setCurrentIndex, ui->audio_views, 1));
+       connect(ui->compact_next_page, &QAbstractButton::clicked, bind(&QStackedWidget::setCurrentIndex, ui->audio_views, 1));
+       connect(ui->full_prev_page, &QAbstractButton::clicked, bind(&QStackedWidget::setCurrentIndex, ui->audio_views, 0));
+       connect(ui->full_next_page, &QAbstractButton::clicked, bind(&QStackedWidget::setCurrentIndex, ui->audio_views, 0));
+
        last_audio_level_callback = steady_clock::now() - seconds(1);
 }
 
@@ -255,7 +261,7 @@ void MainWindow::setup_audio_miniview()
                // TODO: Set the fader position.
                ui->faders->addWidget(channel);
 
-               connect(ui_audio_miniview->fader, &QAbstractSlider::valueChanged,
+               connect(ui_audio_miniview->fader, &NonLinearFader::dbValueChanged,
                        bind(&MainWindow::mini_fader_changed, this, ui_audio_miniview, bus_index, _1));
        }
 }
@@ -381,13 +387,15 @@ void MainWindow::compressor_threshold_knob_changed(int value)
                QString::fromStdString(format_db(threshold_dbfs, DB_WITH_SIGN)));
 }
 
-void MainWindow::mini_fader_changed(Ui::AudioMiniView *ui, int channel, int value)
+void MainWindow::mini_fader_changed(Ui::AudioMiniView *ui, int channel, double volume_db)
 {
-       float volume_db = value * 0.1f;
-
        char buf[256];
-       snprintf(buf, sizeof(buf), "%+.1f dB", volume_db);
-       ui->fader_label->setText(buf);
+       if (isfinite(volume_db)) {
+               snprintf(buf, sizeof(buf), "%+.1f dB", volume_db);
+               ui->fader_label->setText(buf);
+       } else {
+               ui->fader_label->setText("-∞ dB");
+       }
 
        global_mixer->get_audio_mixer()->set_fader_volume(channel, volume_db);
 }
@@ -467,6 +475,11 @@ void MainWindow::relayout()
        // Space between the M/E displays and the audio strip.
        remaining_height -= ui->vertical_layout->spacing();
 
+       // The label above the audio strip.
+       double compact_label_height = ui->compact_label->geometry().height() +
+               ui->compact_audio_layout->spacing();
+       remaining_height -= compact_label_height;
+
        // The previews will be constrained by the remaining height, and the width.
        double preview_label_height = previews[0]->title_bar->geometry().height() +
                previews[0]->main_vertical_layout->spacing();
@@ -475,8 +488,14 @@ void MainWindow::relayout()
        remaining_height -= preview_height + preview_label_height + ui->vertical_layout->spacing();
 
        ui->vertical_layout->setStretch(0, lrintf(me_height));
-       ui->vertical_layout->setStretch(1, lrintf(remaining_height));  // Audio strip.
-       ui->vertical_layout->setStretch(2, lrintf(preview_height + preview_label_height));
+       ui->vertical_layout->setStretch(1,
+               lrintf(compact_label_height) +
+               lrintf(remaining_height) +
+               lrintf(preview_height + preview_label_height));  // Audio strip and previews together.
+
+       ui->compact_audio_layout->setStretch(0, lrintf(compact_label_height));
+       ui->compact_audio_layout->setStretch(1, lrintf(remaining_height));  // Audio strip.
+       ui->compact_audio_layout->setStretch(2, lrintf(preview_height + preview_label_height));
 
        // Set the widths for the previews.
        double preview_width = preview_height * 16.0 / 9.0;