correct math in resizable scrollbars
This commit is contained in:
+10
-2
@@ -451,7 +451,7 @@ void Timeline::repaint_timeline() {
|
||||
if (sequence != NULL) {
|
||||
long sequenceEndFrame = sequence->getEndFrame();
|
||||
|
||||
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequenceEndFrame, ui->editAreas->width() - getScreenPointFromFrame(zoom, 200));
|
||||
set_sb_max();
|
||||
|
||||
if (last_frame != sequence->playhead) {
|
||||
ui->audio_monitor->update();
|
||||
@@ -475,7 +475,11 @@ void Timeline::select_all() {
|
||||
}
|
||||
}
|
||||
repaint_timeline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::resizeEvent(QResizeEvent *event) {
|
||||
if (sequence != NULL) set_sb_max();
|
||||
}
|
||||
|
||||
void Timeline::delete_in_out(bool ripple) {
|
||||
@@ -1580,6 +1584,10 @@ void Timeline::resize_move(double z) {
|
||||
set_zoom_value(zoom * z);
|
||||
}
|
||||
|
||||
void Timeline::set_sb_max() {
|
||||
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequence->getEndFrame(), ui->editAreas->width() - getScreenPointFromFrame(zoom, 200));
|
||||
}
|
||||
|
||||
void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int itrack, bool verify_transitions) {
|
||||
ca->append(new MoveClipAction(c, iin, iout, iclip_in, itrack));
|
||||
|
||||
|
||||
@@ -186,6 +186,8 @@ public:
|
||||
int transition_tool_side;
|
||||
|
||||
Ui::Timeline *ui;
|
||||
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
public slots:
|
||||
void repaint_timeline();
|
||||
|
||||
@@ -232,6 +234,7 @@ private:
|
||||
void set_tool(int tool);
|
||||
long last_frame;
|
||||
int scroll;
|
||||
void set_sb_max();
|
||||
|
||||
int default_track_height;
|
||||
};
|
||||
|
||||
+17
-4
@@ -380,7 +380,7 @@ void Viewer::update_header_zoom() {
|
||||
if (cached_end_frame != sequenceEndFrame) {
|
||||
minimum_zoom = (sequenceEndFrame > 0) ? ((double) ui->headers->width() / (double) sequenceEndFrame) : 1;
|
||||
ui->headers->update_zoom(qMax(ui->headers->get_zoom(), minimum_zoom));
|
||||
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, sequenceEndFrame, ui->headers->width());
|
||||
set_sb_max();
|
||||
viewer_widget->waveform_zoom = ui->headers->get_zoom();
|
||||
} else {
|
||||
ui->headers->update();
|
||||
@@ -393,7 +393,13 @@ void Viewer::update_parents() {
|
||||
update_ui(false);
|
||||
} else {
|
||||
update_viewer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::resizeEvent(QResizeEvent *event) {
|
||||
if (seq != NULL) {
|
||||
set_sb_max();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::update_viewer() {
|
||||
@@ -430,9 +436,15 @@ void Viewer::set_zoom_value(double d) {
|
||||
viewer_widget->waveform_zoom = d;
|
||||
viewer_widget->update();
|
||||
}
|
||||
if (seq != NULL) {
|
||||
set_sb_max();
|
||||
if (!ui->horizontalScrollBar->is_resizing())
|
||||
center_scroll_to_playhead(ui->horizontalScrollBar, ui->headers->get_zoom(), seq->playhead);
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::set_sb_max() {
|
||||
ui->headers->set_scrollbar_max(ui->horizontalScrollBar, seq->getEndFrame(), ui->headers->width());
|
||||
if (!ui->horizontalScrollBar->is_resizing())
|
||||
center_scroll_to_playhead(ui->horizontalScrollBar, ui->headers->get_zoom(), seq->playhead);
|
||||
}
|
||||
|
||||
void Viewer::set_media(Media* m) {
|
||||
@@ -575,6 +587,7 @@ void Viewer::zoom_update(int i) {
|
||||
}
|
||||
|
||||
void Viewer::resize_move(double d) {
|
||||
dout << "RM";
|
||||
set_zoom_value(ui->headers->get_zoom()*d);
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -71,6 +71,8 @@ public:
|
||||
|
||||
Ui::Viewer *ui;
|
||||
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
public slots:
|
||||
void play_wake();
|
||||
|
||||
@@ -94,9 +96,10 @@ private:
|
||||
QString panel_name;
|
||||
double minimum_zoom;
|
||||
void set_zoom_value(double d);
|
||||
void set_sb_max();
|
||||
|
||||
bool cue_recording_internal;
|
||||
QTimer recording_flasher;
|
||||
QTimer recording_flasher;
|
||||
};
|
||||
|
||||
#endif // VIEWER_H
|
||||
|
||||
@@ -20,6 +20,10 @@ bool ResizableScrollBar::is_resizing() {
|
||||
return resize_proc;
|
||||
}
|
||||
|
||||
void ResizableScrollBar::resizeEvent(QResizeEvent *event) {
|
||||
setPageStep(event->size().width());
|
||||
}
|
||||
|
||||
void ResizableScrollBar::mousePressEvent(QMouseEvent *e) {
|
||||
if (resize_init) {
|
||||
QStyleOptionSlider opt;
|
||||
@@ -30,6 +34,9 @@ void ResizableScrollBar::mousePressEvent(QMouseEvent *e) {
|
||||
|
||||
resize_proc = true;
|
||||
resize_start = e->pos().x();
|
||||
|
||||
resize_start_max = maximum();
|
||||
resize_start_width = sr.width();
|
||||
} else {
|
||||
QScrollBar::mousePressEvent(e);
|
||||
}
|
||||
@@ -54,8 +61,9 @@ void ResizableScrollBar::mouseMoveEvent(QMouseEvent *e) {
|
||||
|
||||
if (resize_top) {
|
||||
int slider_min = gr.x();
|
||||
int slider_max = gr.right() - (sr.width()+diff) + 1;
|
||||
int slider_max = gr.right() - (sr.width()+diff);
|
||||
int val = QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x() - slider_min, slider_max - slider_min, opt.upsideDown);
|
||||
|
||||
setValue(val);
|
||||
} else {
|
||||
setValue(qRound(value() * scale));
|
||||
|
||||
@@ -12,6 +12,7 @@ public:
|
||||
signals:
|
||||
void resize_move(double i);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseMoveEvent(QMouseEvent *) override;
|
||||
void mouseReleaseEvent(QMouseEvent *) override;
|
||||
@@ -20,6 +21,9 @@ private:
|
||||
bool resize_proc;
|
||||
int resize_start;
|
||||
bool resize_top;
|
||||
|
||||
int resize_start_max;
|
||||
int resize_start_width;
|
||||
};
|
||||
|
||||
#endif // RESIZABLESCROLLBAR_H
|
||||
|
||||
Reference in New Issue
Block a user