diff --git a/olive.pro b/olive.pro index 7cce76716..a2cb46ce7 100644 --- a/olive.pro +++ b/olive.pro @@ -8,7 +8,7 @@ QT += core gui multimedia opengl greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -TARGET = olive-qt +TARGET = olive TEMPLATE = app # The following define makes your compiler emit warnings if you use @@ -101,5 +101,4 @@ linux { } RESOURCES += \ - icons/icons.qrc \ - styles/styles.qrc + icons/icons.qrc diff --git a/olive.pro.user b/olive.pro.user index 9f1a191e9..f6349a675 100644 --- a/olive.pro.user +++ b/olive.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {89fae42a-e0bc-4377-8782-ec7014933bdd} + {3af06612-75ce-48d7-b444-7dc372f1566d} ProjectExplorer.Project.ActiveTarget @@ -54,9 +54,7 @@ ProjectExplorer.Project.PluginSettings - - - + ProjectExplorer.Project.Target.0 @@ -66,9 +64,9 @@ qt.qt5.5101.win64_msvc2017_64_kit 0 0 - 1 + 0 - E:/olive/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug + C:/Users/Matt/Documents/temp true @@ -122,7 +120,7 @@ true - E:/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Release + //neptune/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Release true @@ -176,7 +174,7 @@ true - E:/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Profile + //neptune/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Profile true @@ -245,61 +243,6 @@ 1 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - - E:/olive/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug/debug/olive-qt.exe - E:/olive/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug/debug/ - Run E:\olive\build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug\debug\olive-qt.exe - VC run - ProjectExplorer.CustomExecutableRunConfiguration - 3768 - false - true - false - false - true - - false false 1000 @@ -343,13 +286,13 @@ olive - Qt4ProjectManager.Qt4RunConfiguration:E:/olive/olive/olive.pro + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Matt/Desktop/olive/olive.pro true olive.pro false - E:/olive/build-olive-qt-Desktop_Qt_5_10_1_MSVC2017_64bit-Debug + C:/Users/Matt/Documents/temp 3768 false true @@ -357,7 +300,7 @@ false true - 2 + 1 diff --git a/panels/timeline.cpp b/panels/timeline.cpp index d585285cb..67c15e76b 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -18,8 +18,9 @@ Timeline::Timeline(QWidget *parent) : QDockWidget(parent), ui(new Ui::Timeline) { - selecting = moving_init = moving_proc = splitting = importing = playing = trim_in = false; - last_frame = playhead = 0; + selecting = moving_init = moving_proc = splitting = importing = playing = trim_in = snapped = false; + snapping = true; + last_frame = playhead = snap_point = 0; trim_target = -1; ui->setupUi(this); diff --git a/panels/timeline.h b/panels/timeline.h index a911f5bd6..dbe8ff40b 100644 --- a/panels/timeline.h +++ b/panels/timeline.h @@ -87,6 +87,11 @@ public: int drag_track_start; void redraw_all_clips(); + // snapping + bool snapping; + bool snapped; + long snap_point; + // selecting functions bool selecting; QVector selections; diff --git a/panels/timeline.ui b/panels/timeline.ui index 5fb2a3045..3739b8700 100644 --- a/panels/timeline.ui +++ b/panels/timeline.ui @@ -207,6 +207,12 @@ + + + 30 + 16777215 + + Slip Tool (Y) @@ -223,6 +229,25 @@ + + + + + 30 + 16777215 + + + + S + + + true + + + true + + + @@ -287,8 +312,8 @@ 0 0 - 789 - 494 + 796 + 506 diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 54e569bdd..6b0a820f9 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -254,6 +254,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { panel_timeline->moving_proc = false; panel_timeline->moving_init = false; panel_timeline->splitting = false; + panel_timeline->snapped = false; pre_clips.clear(); post_clips.clear(); @@ -307,6 +308,8 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { long frame_diff = getFrameFromScreenPoint(mouse_pos.x(), false) - panel_timeline->drag_frame_start; int track_diff = mouse_track - panel_timeline->drag_track_start; + int snap_range = 15; + long validator; if (panel_timeline->trim_target > -1) { // trim ops @@ -347,7 +350,7 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { } } } - } + } } else { // prevent clip length from being less than 1 frame long validator = g.ghost_length + frame_diff; @@ -418,6 +421,47 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { } } } + + // shitty hacky code but works wonders + panel_timeline->snapped = false; + if (panel_timeline->snapping) { + for (int j=0;jsequence->clip_count();j++) { + Clip& c = panel_timeline->sequence->get_clip(j); + + panel_timeline->snapped = false; + for (int k=0;k<4;k++) { + switch (k) { + case 0: + // snap in to timeline_in + validator = g.old_in + frame_diff - c.timeline_in; + panel_timeline->snap_point = c.timeline_in; + break; + case 1: + // snap in to timeline out + validator = g.old_in + frame_diff - c.timeline_out; + panel_timeline->snap_point = c.timeline_out; + break; + case 2: + // snap out to timeline_in + validator = g.old_out + frame_diff - c.timeline_in; + panel_timeline->snap_point = c.timeline_in; + break; + case 3: + // snap out to timeline_out + validator = g.old_out + frame_diff - c.timeline_out; + panel_timeline->snap_point = c.timeline_out; + break; + } + + if (validator > -snap_range && validator < snap_range) { + frame_diff -= validator; + panel_timeline->snapped = true; + break; + } + } + if (panel_timeline->snapped) break; + } + } } // move ghosts @@ -555,7 +599,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } // debug code - print the information we got - qDebug() << "found" << pre_clips.size() << "preceding clips and" << post_clips.size() << "following"; +// qDebug() << "found" << pre_clips.size() << "preceding clips and" << post_clips.size() << "following"; } init_ghosts(); @@ -712,6 +756,13 @@ void TimelineWidget::paintEvent(QPaintEvent*) { } } + // draw snap point + if (panel_timeline->snapping && panel_timeline->snapped) { + p.setPen(Qt::white); + int snap_x = getScreenPointFromFrame(panel_timeline->snap_point); + p.drawLine(snap_x, 0, snap_x, height()); + } + // Draw edit cursor if (panel_timeline->tool == TIMELINE_TOOL_EDIT || panel_timeline->tool == TIMELINE_TOOL_RAZOR) { QPoint mouse_pos = mapFromGlobal(QCursor::pos());