top 10 vertical scrolling of all time

This commit is contained in:
itsmattkc
2018-10-11 10:42:40 +11:00
parent 7612a7646e
commit 407865348a
5 changed files with 145 additions and 131 deletions
+4 -6
View File
@@ -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();
+82 -106
View File
@@ -377,7 +377,7 @@
</item>
<item>
<widget class="QWidget" name="editAreas" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
@@ -398,107 +398,89 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="ScrollArea" name="videoScrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>807</width>
<height>217</height>
</rect>
<widget class="QWidget" name="videoContainer" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="TimelineWidget" name="video_area" native="true">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="TimelineWidget" name="video_area" native="true">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QScrollBar" name="videoScrollbar">
<property name="maximum">
<number>0</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="pageStep">
<number>1826</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="ScrollArea" name="audioScrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>807</width>
<height>270</height>
</rect>
<widget class="QWidget" name="audioContainer" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="TimelineWidget" name="audio_area" native="true">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="TimelineWidget" name="audio_area" native="true">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QScrollBar" name="audioScrollbar">
<property name="maximum">
<number>0</number>
</property>
<property name="singleStep">
<number>20</number>
</property>
<property name="pageStep">
<number>1826</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
@@ -508,7 +490,7 @@
<item>
<widget class="QScrollBar" name="horizontalScrollBar">
<property name="maximum">
<number>2</number>
<number>0</number>
</property>
<property name="singleStep">
<number>20</number>
@@ -556,12 +538,6 @@
<header>ui/audiomonitor.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ScrollArea</class>
<extends>QScrollArea</extends>
<header>ui/scrollarea.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../icons/icons.qrc"/>
+1
View File
@@ -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
+48 -15
View File
@@ -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;i<sequence->clips.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();
}
+10 -4
View File
@@ -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<QTreeWidgetItem*> file_import_items;
QVector<Media*> file_import_media;*/
signals:
public slots:
void setScroll(int);
private slots:
void right_click_ripple();