Skip to content

Commit

Permalink
[ui] Auto-scroll improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Feb 12, 2022
1 parent 962d0a2 commit 00c8b3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void PluginSettingsView::handleAddon(const QJsonObject& obj)
RemotePackagesModel* model
= static_cast<RemotePackagesModel*>(m_remoteAddons->model());

if (m_addonsToRetrieve == model->m_vec.size())
if (m_addonsToRetrieve == std::ssize(model->m_vec))
{
reset_progress();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ void IntervalDurations::setPlayPercentage(double arg)

auto old = m_playPercentage;

m_playPercentage = arg;

// Only used for DurationSectionWidget
if (m_defaultDuration * std::abs(arg - old)
> TimeVal{std::chrono::milliseconds(16)})
> TimeVal{std::chrono::milliseconds(32)})
{
m_playPercentage = arg;
playPercentageChanged(arg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ void ScenarioDocumentPresenter::on_executionTimer()
else if(auto i = std::get_if<CentralIntervalDisplay>(&this->m_centralDisplay))
{
if(m_autoScroll)
autoScroll();
autoScroll();
}
}

Expand All @@ -822,7 +822,18 @@ void ScenarioDocumentPresenter::autoScroll()

auto& dur = sel_itv->duration;
auto delta = Scenario::timeDelta(sel_itv, &root);
double exec_d = dur.playPercentage() * (delta + dur.defaultDuration()).toPixels(this->m_zoomRatio);
auto visible_play_percentage = [&] {
if(dur.isMaxInfinite())
{
return std::min(dur.playPercentage(), 1.);
}
else
{
return dur.playPercentage();
}
};

double exec_d = visible_play_percentage() * (delta + dur.defaultDuration()).toPixels(this->m_zoomRatio);
auto center = view().view().visibleRect().center();
view().view().ensureVisible({exec_d - 100, center.y() - 10, view().viewWidth() / 2., 20});
}
Expand Down

0 comments on commit 00c8b3e

Please sign in to comment.