]> git.sesse.net Git - nageru/blobdiff - futatabi/mainwindow.cpp
In Futatabi, make it possible to set custom source labels.
[nageru] / futatabi / mainwindow.cpp
index 9bea809b8c63dc2ebe0ac840e9900a313402cd09..49581e53caeb134d180b1bba5546a8083fec05fa 100644 (file)
@@ -289,7 +289,7 @@ MainWindow::MainWindow()
                if (!load_midi_mapping_from_file(global_flags.midi_mapping_filename, &midi_mapping)) {
                        fprintf(stderr, "Couldn't load MIDI mapping '%s'; exiting.\n",
                                global_flags.midi_mapping_filename.c_str());
-                       exit(1);
+                       abort();
                }
                midi_mapper.set_midi_mapping(midi_mapping);
        }
@@ -324,7 +324,11 @@ void MainWindow::change_num_cameras()
                display->setAutoFillBackground(true);
                layout->addWidget(display);
 
-               display->set_overlay(to_string(i + 1));
+               if (global_flags.source_labels.count(i + 1)) {
+                       display->set_overlay(global_flags.source_labels[i + 1]);
+               } else {
+                       display->set_overlay(to_string(i + 1));
+               }
 
                QPushButton *preview_btn = new QPushButton(this);
                preview_btn->setMaximumSize(20, 17);
@@ -388,6 +392,10 @@ void MainWindow::cue_in_clicked()
                playlist_selection_changed();
        }
 
+       // Show the clip in the preview.
+       unsigned stream_idx = ui->preview_display->get_stream_idx();
+       preview_single_frame(cliplist_clips->mutable_back()->pts_in, stream_idx, FIRST_AT_OR_AFTER);
+
        // Select the item so that we can jog it.
        ui->clip_list->setFocus();
        QModelIndex index = cliplist_clips->index(cliplist_clips->size() - 1, int(ClipList::Column::IN));
@@ -404,6 +412,10 @@ void MainWindow::cue_out_clicked()
 
        cliplist_clips->mutable_back()->pts_out = current_pts + lrint(global_flags.cue_out_point_padding_seconds * TIMEBASE);
 
+       // Show the clip in the preview. (TODO: This won't take padding into account.)
+       unsigned stream_idx = ui->preview_display->get_stream_idx();
+       preview_single_frame(cliplist_clips->mutable_back()->pts_out, stream_idx, LAST_BEFORE);
+
        // Select the item so that we can jog it.
        ui->clip_list->setFocus();
        QModelIndex index = cliplist_clips->index(cliplist_clips->size() - 1, int(ClipList::Column::OUT));
@@ -621,10 +633,7 @@ void MainWindow::defer_timer_expired()
 void MainWindow::content_changed()
 {
        // If we are playing, update the part of the playlist that's not playing yet.
-       vector<ClipWithID> clips;
-       for (unsigned row = 0; row < playlist_clips->size(); ++row) {
-               clips.emplace_back(*playlist_clips->clip_with_id(row));
-       }
+       vector<ClipWithID> clips = get_playlist(0, playlist_clips->size());
        live_player->splice_play(clips);
 
        // Serialize the state.
@@ -685,14 +694,7 @@ void MainWindow::play_clicked()
        }
        unsigned start_row = selected->selectedRows(0)[0].row();
 
-       vector<ClipWithID> clips;
-       for (unsigned row = start_row; row < playlist_clips->size(); ++row) {
-               ClipWithID clip = *playlist_clips->clip_with_id(row);
-               if (clip.clip.pts_out == -1) {
-                       clip.clip.pts_out = clip.clip.pts_in + int64_t(TIMEBASE) * 86400 * 7;  // One week; effectively infinite, but without overflow issues.
-               }
-               clips.emplace_back(clip);
-       }
+       vector<ClipWithID> clips = get_playlist(start_row, playlist_clips->size());
        live_player->play(clips);
        playlist_clips->set_progress({ { start_row, 0.0f } });
        ui->playlist->selectionModel()->clear();
@@ -844,6 +846,11 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
                if (mouse->modifiers() & Qt::KeyboardModifier::ShiftModifier) {
                        scrub_sensitivity *= 10;
                        wheel_sensitivity *= 10;
+                       if (mouse->modifiers() & Qt::KeyboardModifier::ControlModifier) {
+                               // Ctrl+Shift is a super-modifier, meant only for things like “go back two hours”.
+                               scrub_sensitivity *= 100;
+                               wheel_sensitivity *= 100;
+                       }
                }
                if (mouse->modifiers() & Qt::KeyboardModifier::AltModifier) {  // Note: Shift + Alt cancel each other out.
                        scrub_sensitivity /= 10;
@@ -899,6 +906,11 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
                if (wheel->modifiers() & Qt::KeyboardModifier::ShiftModifier) {
                        scrub_sensitivity *= 10;
                        wheel_sensitivity *= 10;
+                       if (wheel->modifiers() & Qt::KeyboardModifier::ControlModifier) {
+                               // Ctrl+Shift is a super-modifier, meant only for things like “go back two hours”.
+                               scrub_sensitivity *= 100;
+                               wheel_sensitivity *= 100;
+                       }
                }
                if (wheel->modifiers() & Qt::KeyboardModifier::AltModifier) {  // Note: Shift + Alt cancel each other out.
                        scrub_sensitivity /= 10;
@@ -1036,6 +1048,19 @@ void MainWindow::clip_list_selection_changed(const QModelIndex &current, const Q
        enable_or_disable_queue_button();
 }
 
+vector<ClipWithID> MainWindow::get_playlist(size_t start_row, size_t end_row)
+{
+       vector<ClipWithID> clips;
+       for (unsigned row = start_row; row < end_row; ++row) {
+               ClipWithID clip = *playlist_clips->clip_with_id(row);
+               if (clip.clip.pts_out == -1) {
+                       clip.clip.pts_out = clip.clip.pts_in + int64_t(TIMEBASE) * 86400 * 7;  // One week; effectively infinite, but without overflow issues.
+               }
+               clips.emplace_back(clip);
+       }
+       return clips;
+}
+
 void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_left)
 {
        char time_str[256];