X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=futatabi%2Fmainwindow.cpp;h=7455cacb31233bbe81b0bcfed50967092e23f5d0;hb=03be4eea8fe0f2a72ee848595fdd37036574cbcb;hp=54efa1c1de221c107f3b57cbcc15a74418096fd5;hpb=eaba7288c4fb39ca195c9355970293bcaf088dbc;p=nageru diff --git a/futatabi/mainwindow.cpp b/futatabi/mainwindow.cpp index 54efa1c..7455cac 100644 --- a/futatabi/mainwindow.cpp +++ b/futatabi/mainwindow.cpp @@ -418,25 +418,11 @@ void MainWindow::live_player_clip_progress(const map &progress) { playlist_clips->set_progress(progress); - // Look at the last clip and then start counting from there. - assert(!progress.empty()); - auto last_it = progress.end(); - --last_it; - double remaining = 0.0; - double last_fade_time_seconds = 0.0; - for (size_t row = last_it->first; row < playlist_clips->size(); ++row) { - const Clip clip = *playlist_clips->clip(row); - double clip_length = double(clip.pts_out - clip.pts_in) / TIMEBASE / 0.5; // FIXME: stop hardcoding speed. - if (row == last_it->first) { - // A clip we're playing: Subtract the part we've already played. - remaining = clip_length * (1.0 - last_it->second); - } else { - // A clip we haven't played yet: Subtract the part that's overlapping - // with a previous clip (due to fade). - remaining += max(clip_length - last_fade_time_seconds, 0.0); - } - last_fade_time_seconds = min(clip_length, clip.fade_time_seconds); + vector clips; + for (size_t row = 0; row < playlist_clips->size(); ++row) { + clips.push_back(*playlist_clips->clip(row)); } + double remaining = compute_time_left(clips, progress); set_output_status(format_duration(remaining) + " left"); } @@ -469,9 +455,9 @@ void set_pts_in(int64_t pts, int64_t current_pts, ClipProxy &clip) bool MainWindow::eventFilter(QObject *watched, QEvent *event) { constexpr int dead_zone_pixels = 3; // To avoid that simple clicks get misinterpreted. - constexpr int scrub_sensitivity = 100; // pts units per pixel. - constexpr int wheel_sensitivity = 100; // pts units per degree. constexpr int camera_degrees_per_pixel = 15; // One click of most mice. + int scrub_sensitivity = 100; // pts units per pixel. + int wheel_sensitivity = 100; // pts units per degree. unsigned stream_idx = ui->preview_display->get_stream_idx(); @@ -534,8 +520,16 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) scrub_x_origin = mouse->x(); scrub_type = type; } else if (event->type() == QEvent::MouseMove) { + QMouseEvent *mouse = (QMouseEvent *)event; + if (mouse->modifiers() & Qt::KeyboardModifier::ShiftModifier) { + scrub_sensitivity *= 10; + wheel_sensitivity *= 10; + } + if (mouse->modifiers() & Qt::KeyboardModifier::AltModifier) { // Note: Shift + Alt cancel each other out. + scrub_sensitivity /= 10; + wheel_sensitivity /= 10; + } if (scrubbing) { - QMouseEvent *mouse = (QMouseEvent *)event; int offset = mouse->x() - scrub_x_origin; int adjusted_offset; if (offset >= dead_zone_pixels) { @@ -581,6 +575,16 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) } } else if (event->type() == QEvent::Wheel) { QWheelEvent *wheel = (QWheelEvent *)event; + int angle_delta = wheel->angleDelta().y(); + if (wheel->modifiers() & Qt::KeyboardModifier::ShiftModifier) { + scrub_sensitivity *= 10; + wheel_sensitivity *= 10; + } + if (wheel->modifiers() & Qt::KeyboardModifier::AltModifier) { // Note: Shift + Alt cancel each other out. + scrub_sensitivity /= 10; + wheel_sensitivity /= 10; + angle_delta = wheel->angleDelta().x(); // Qt ickiness. + } QTableView *destination; int in_column, out_column, camera_column; @@ -623,19 +627,19 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) } if (column == in_column) { current_change_id += "in:" + to_string(row); - int64_t pts = clip->pts_in + wheel->angleDelta().y() * wheel_sensitivity; + int64_t pts = clip->pts_in + angle_delta * wheel_sensitivity; set_pts_in(pts, current_pts, clip); preview_single_frame(pts, stream_idx, FIRST_AT_OR_AFTER); } else if (column == out_column) { current_change_id += "out:" + to_string(row); - int64_t pts = clip->pts_out + wheel->angleDelta().y() * wheel_sensitivity; + int64_t pts = clip->pts_out + angle_delta * wheel_sensitivity; pts = std::max(pts, clip->pts_in); pts = std::min(pts, current_pts); clip->pts_out = pts; preview_single_frame(pts, stream_idx, LAST_BEFORE); } else if (column == camera_column) { current_change_id += "camera:" + to_string(row); - int angle_degrees = wheel->angleDelta().y(); + int angle_degrees = angle_delta; if (last_mousewheel_camera_row == row) { angle_degrees += leftover_angle_degrees; }