diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 92ad9657f..d282e15bf 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -78,9 +78,8 @@ Timeline::Timeline(QWidget *parent) : /* --- */ ui->video_area->bottom_align = true; - - ui->video_area->container = ui->videoScrollArea; - ui->audio_area->container = ui->audioScrollArea; + ui->video_area->scrollBar = ui->videoScrollbar; + ui->audio_area->scrollBar = ui->audioScrollbar; tool_buttons.append(ui->toolArrowButton); tool_buttons.append(ui->toolEditButton); @@ -92,12 +91,11 @@ Timeline::Timeline(QWidget *parent) : ui->toolArrowButton->click(); - /*int timeline_area_height = (ui->timeline_area->height()>>1); - ui->videoScrollArea->resize(ui->videoScrollArea->width(), timeline_area_height); - ui->audioScrollArea->resize(ui->audioScrollArea->width(), timeline_area_height);*/ ui->headerScrollArea->setMaximumHeight(ui->headers->minimumHeight()); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(setScroll(int))); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), ui->headers, SLOT(set_scroll(int))); + connect(ui->videoScrollbar, SIGNAL(valueChanged(int)), ui->video_area, SLOT(setScroll(int))); + connect(ui->audioScrollbar, SIGNAL(valueChanged(int)), ui->audio_area, SLOT(setScroll(int))); update_sequence(); diff --git a/panels/timeline.ui b/panels/timeline.ui index bc7311dab..9cc1a8a01 100644 --- a/panels/timeline.ui +++ b/panels/timeline.ui @@ -377,7 +377,7 @@ - + 0 @@ -398,107 +398,89 @@ Qt::Vertical - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - true - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - 0 - 0 - 807 - 217 - + + + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::ClickFocus - - - - - + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::ClickFocus + + + + + + + 0 + + + 20 + + + 1826 + + + Qt::Vertical + + + + - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - true - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - 0 - 0 - 807 - 270 - + + + + 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::ClickFocus - - - - - + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::ClickFocus + + + + + + + 0 + + + 20 + + + 1826 + + + Qt::Vertical + + + + @@ -508,7 +490,7 @@ - 2 + 0 20 @@ -556,12 +538,6 @@
ui/audiomonitor.h
1 - - ScrollArea - QScrollArea -
ui/scrollarea.h
- 1 -
diff --git a/ui/timelinetools.h b/ui/timelinetools.h index d679fccb9..ba23ad621 100644 --- a/ui/timelinetools.h +++ b/ui/timelinetools.h @@ -11,5 +11,6 @@ #define TIMELINE_TOOL_HAND 7 #define TIMELINE_TOOL_ZOOM 8 #define TIMELINE_TOOL_MENU 9 +#define TIMELINE_TOOL_TRANSITION 10 #endif // TIMELINETOOLS_H diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 9bfdcc40c..f66e3cc78 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -36,6 +36,7 @@ TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) { selection_command = NULL; + scroll = 0; bottom_align = false; track_resizing = false; @@ -365,6 +366,18 @@ void TimelineWidget::dragMoveEvent(QDragMoveEvent *event) { } } +void TimelineWidget::wheelEvent(QWheelEvent *event) { + if (config.scroll_zooms) { + if (event->angleDelta().y() != 0) panel_timeline->set_zoom(event->angleDelta().y() > 0); + } else { + QScrollBar* bar = (event->modifiers() & Qt::ShiftModifier) ? scrollBar : panel_timeline->ui->horizontalScrollBar; + + int step = bar->singleStep(); + if (event->angleDelta().y() > 0) step = -step; + bar->setValue(bar->value() + step); + } +} + void TimelineWidget::dragLeaveEvent(QDragLeaveEvent*) { if (sequence != NULL && panel_timeline->importing) { panel_timeline->ghosts.clear(); @@ -1721,7 +1734,8 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { track_y += track_height; int y_test_value = (bottom_align) ? rect().bottom() - track_y : track_y; int test_range = 5; - if (pos.y() > y_test_value-test_range && pos.y() < y_test_value+test_range) { + int mouse_pos = pos.y() + scroll; + if (mouse_pos > y_test_value-test_range && mouse_pos < y_test_value+test_range) { // if track lines are hidden, only resize track if a clip is already there if (config.show_track_lines || cursor_contains_clip) { found = true; @@ -1773,7 +1787,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { } } - int panel_height = 100; + int panel_height = TRACK_DEFAULT_HEIGHT; if (bottom_align) { for (int i=-1;i>=video_track_limit;i--) { panel_height += panel_timeline->calculate_track_height(i, -1); @@ -1783,6 +1797,11 @@ void TimelineWidget::paintEvent(QPaintEvent*) { panel_height += panel_timeline->calculate_track_height(i, -1); } } + if (bottom_align) { + scrollBar->setMinimum(qMin(0, - panel_height + height())); + } else { + scrollBar->setMaximum(qMax(0, panel_height - height())); + } QColor transition_color(255, 0, 0, 16); for (int i=0;iclips.size();i++) { @@ -1790,10 +1809,12 @@ void TimelineWidget::paintEvent(QPaintEvent*) { if (clip != NULL && is_track_visible(clip->track)) { QRect clip_rect(panel_timeline->getTimelineScreenPointFromFrame(clip->timeline_in), getScreenPointFromTrack(clip->track), clip->getLength() * panel_timeline->zoom, panel_timeline->calculate_track_height(clip->track, -1)); QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - 1, clip_rect.height() - CLIP_TEXT_PADDING - 1); - if (clip_rect.left() < width() && clip_rect.right() >= 0) { + if (clip_rect.left() < width() && clip_rect.right() >= 0 && clip_rect.top() < height() && clip_rect.bottom() >= 0) { QRect actual_clip_rect = clip_rect; if (actual_clip_rect.x() < 0) actual_clip_rect.setX(0); - if (actual_clip_rect.right() >= width()) actual_clip_rect.setRight(width()); + if (actual_clip_rect.right() > width()) actual_clip_rect.setRight(width()); + if (actual_clip_rect.y() < 0) actual_clip_rect.setY(0); + if (actual_clip_rect.bottom() > height()) actual_clip_rect.setBottom(height()); p.fillRect(actual_clip_rect, (clip->enabled) ? QColor(clip->color_r, clip->color_g, clip->color_b) : QColor(96, 96, 96)); int thumb_x = clip_rect.x() + 1; @@ -1811,7 +1832,8 @@ void TimelineWidget::paintEvent(QPaintEvent*) { if (clip->track < 0) { // draw thumbnail - if (thumb_x < width()) { + int thumb_y = p.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING; + if (thumb_x < width() && thumb_y < height()) { int space_for_thumb = clip_rect.width(); if (clip->opening_transition != NULL) { int ot_width = getScreenPointFromFrame(panel_timeline->zoom, clip->opening_transition->length); @@ -1820,12 +1842,12 @@ void TimelineWidget::paintEvent(QPaintEvent*) { } if (clip->closing_transition != NULL) { space_for_thumb -= getScreenPointFromFrame(panel_timeline->zoom, clip->closing_transition->length); - } - int thumb_y = p.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING; + } int thumb_height = clip_rect.height()-thumb_y; int thumb_width = (thumb_height*((double)ms->video_preview.width()/(double)ms->video_preview.height())); if (thumb_x + thumb_width >= 0 && thumb_height > thumb_y + && thumb_y + thumb_height >= 0 && text_rect.width() + CLIP_TEXT_PADDING > thumb_width && space_for_thumb >= thumb_width) { // at small clip heights, don't even draw it QRect thumb_rect(thumb_x, clip_rect.y()+thumb_y, thumb_width, thumb_height); @@ -1885,8 +1907,13 @@ void TimelineWidget::paintEvent(QPaintEvent*) { if (draw_checkerboard) { checkerboard_rect.setLeft(qMax(checkerboard_rect.left(), 0)); checkerboard_rect.setRight(qMin(checkerboard_rect.right(), width())); + checkerboard_rect.setTop(qMax(checkerboard_rect.top(), 0)); + checkerboard_rect.setBottom(qMin(checkerboard_rect.bottom(), height())); - if (checkerboard_rect.left() < width() && checkerboard_rect.right() >= 0) { + if (checkerboard_rect.left() < width() + && checkerboard_rect.right() >= 0 + && checkerboard_rect.top() < height() + && checkerboard_rect.bottom() >= 0) { // draw "error lines" if media stream is missing p.setPen(QPen(QColor(64, 64, 64), 2)); int limit = checkerboard_rect.width(); @@ -1946,8 +1973,8 @@ void TimelineWidget::paintEvent(QPaintEvent*) { // top left bevel p.setPen(Qt::white); - if (clip_rect.x() >= 0) p.drawLine(clip_rect.bottomLeft(), clip_rect.topLeft()); - p.drawLine(QPoint(qMax(0, clip_rect.left()), qMax(0, clip_rect.top())), QPoint(qMin(width(), clip_rect.right()), qMax(0, clip_rect.top()))); + if (clip_rect.x() >= 0 && clip_rect.x() < width()) p.drawLine(clip_rect.bottomLeft(), clip_rect.topLeft()); + if (clip_rect.y() >= 0 && clip_rect.y() < height()) p.drawLine(QPoint(qMax(0, clip_rect.left()), clip_rect.top()), QPoint(qMin(width(), clip_rect.right()), clip_rect.top())); // draw text if (text_rect.width() > MAX_TEXT_WIDTH && text_rect.right() > 0 && text_rect.left() < width()) { @@ -1973,8 +2000,8 @@ void TimelineWidget::paintEvent(QPaintEvent*) { // bottom right gray p.setPen(QColor(0, 0, 0, 128)); - if (clip_rect.right() < width()) p.drawLine(clip_rect.bottomRight(), clip_rect.topRight()); - p.drawLine(QPoint(qMax(0, clip_rect.left()), qMin(height(), clip_rect.bottom())), QPoint(qMin(width(), clip_rect.right()), qMin(height(), clip_rect.bottom()))); + if (clip_rect.right() >= 0 && clip_rect.right() < width()) p.drawLine(clip_rect.bottomRight(), clip_rect.topRight()); + if (clip_rect.bottom() >= 0 && clip_rect.bottom() < height()) p.drawLine(QPoint(qMax(0, clip_rect.left()), clip_rect.bottom()), QPoint(qMin(width(), clip_rect.right()), clip_rect.bottom())); } } } @@ -2088,8 +2115,9 @@ bool TimelineWidget::is_track_visible(int track) { // ************************************** int TimelineWidget::getTrackFromScreenPoint(int y) { + y += scroll; if (bottom_align) { - y = -(y - rect().height()); + y = -(y - height()); } y--; int height_measure = 0; @@ -2109,7 +2137,7 @@ int TimelineWidget::getTrackFromScreenPoint(int y) { } int TimelineWidget::getScreenPointFromTrack(int track) { - int y = 0; + int y = 0; int counter = 0; while (counter != track) { if (bottom_align) counter--; @@ -2118,7 +2146,7 @@ int TimelineWidget::getScreenPointFromTrack(int track) { if (config.show_track_lines && counter != -1) y++; } y++; - return (bottom_align) ? rect().height() - y : y; + return (bottom_align) ? height() - y - scroll : y - scroll; } int TimelineWidget::getClipIndexFromCoords(long frame, int track) { @@ -2130,3 +2158,8 @@ int TimelineWidget::getClipIndexFromCoords(long frame, int track) { } return -1; } + +void TimelineWidget::setScroll(int s) { + scroll = s; + update(); +} diff --git a/ui/timelinewidget.h b/ui/timelinewidget.h index 4a7cdb361..c6283d320 100644 --- a/ui/timelinewidget.h +++ b/ui/timelinewidget.h @@ -15,7 +15,7 @@ struct Sequence; struct Clip; class Timeline; class TimelineAction; -class QScrollArea; +class QScrollBar; class SetSelectionsCommand; bool same_sign(int a, int b); @@ -24,10 +24,8 @@ class TimelineWidget : public QWidget { Q_OBJECT public: explicit TimelineWidget(QWidget *parent = 0); - + QScrollBar* scrollBar; bool bottom_align; - - QScrollArea* container; protected: void paintEvent(QPaintEvent*); @@ -41,6 +39,8 @@ protected: void dragLeaveEvent(QDragLeaveEvent *event); void dropEvent(QDropEvent* event); void dragMoveEvent(QDragMoveEvent *event); + + void wheelEvent(QWheelEvent *event); private: void init_ghosts(); void update_ghosts(QPoint& mouse_pos); @@ -70,10 +70,16 @@ private: QTimer tooltip_timer; int tooltip_clip; + int scroll; + SetSelectionsCommand* selection_command; + + /*QVector file_import_items; + QVector file_import_media;*/ signals: public slots: + void setScroll(int); private slots: void right_click_ripple();