timebasedwidget: re-implemented toggle show all function

This commit is contained in:
itsmattkc
2020-04-15 15:31:54 +10:00
parent 2610d58ae3
commit 9cc4349054
7 changed files with 53 additions and 2 deletions
+2
View File
@@ -144,6 +144,8 @@ public:
virtual void PasteInsert(){}
virtual void ToggleShowAll(){}
protected:
/**
* @brief paintEvent
+30 -1
View File
@@ -35,7 +35,8 @@ TimeBasedWidget::TimeBasedWidget(bool ruler_text_visible, bool ruler_cache_statu
TimelineScaledWidget(parent),
viewer_node_(nullptr),
auto_max_scrollbar_(false),
points_(nullptr)
points_(nullptr),
toggle_show_all_(false)
{
ruler_ = new TimeRuler(ruler_text_visible, ruler_cache_status_visible, this);
connect(ruler_, &TimeRuler::TimeChanged, this, &TimeBasedWidget::SetTimeAndSignal);
@@ -164,6 +165,8 @@ void TimeBasedWidget::ScaleChangedEvent(const double &scale)
ruler_->SetScale(scale);
UpdateMaximumScroll();
toggle_show_all_ = false;
}
void TimeBasedWidget::SetAutoMaxScrollBar(bool e)
@@ -433,4 +436,30 @@ void TimeBasedWidget::SetMarker()
}
}
void TimeBasedWidget::ToggleShowAll()
{
if (!GetConnectedNode()) {
return;
}
if (toggle_show_all_) {
SetScale(toggle_show_all_old_scale_);
toggle_show_all_ = false;
} else {
int w;
if (timeline_views_.isEmpty()) {
w = width();
} else {
w = timeline_views_.first()->width();
}
w = w / 10 * 9;
toggle_show_all_old_scale_ = GetScale();
SetScale(w / GetConnectedNode()->Length().toDouble());
toggle_show_all_ = true;
}
}
OLIVE_NAMESPACE_EXIT
+6
View File
@@ -84,6 +84,8 @@ public slots:
void SetMarker();
void ToggleShowAll();
TimeRuler* ruler() const;
protected slots:
@@ -158,6 +160,10 @@ private:
QList<TimelineViewBase*> timeline_views_;
bool toggle_show_all_;
double toggle_show_all_old_scale_;
private slots:
void UpdateMaximumScroll();