[apps] Factorize scrolling speed for long repetition

Change-Id: I5fcfaf04e418942664641c4b1cd044cda7f5aebb
This commit is contained in:
Hugo Saint-Vignes
2020-06-09 17:42:49 +02:00
committed by Émilie Feral
parent 241a217f58
commit b60c67ff88
16 changed files with 23 additions and 24 deletions

View File

@@ -79,13 +79,13 @@ bool GraphController::handleEnter() {
return FunctionGraphController::handleEnter();
}
bool GraphController::moveCursorHorizontally(int direction, bool fast) {
bool GraphController::moveCursorHorizontally(int direction, int scrollSpeed) {
double xCursorPosition = std::round(m_cursor->x());
if (direction < 0 && xCursorPosition <= 0) {
return false;
}
// The cursor moves by step that is larger than 1 and than a pixel's width.
const int step = std::ceil(m_view.pixelWidth()) * (fast ? 5 : 1);
const int step = std::ceil(m_view.pixelWidth()) * scrollSpeed;
double x = direction > 0 ? xCursorPosition + step:
xCursorPosition - step;
if (x < 0.0) {

View File

@@ -25,7 +25,7 @@ public:
private:
Shared::XYBannerView * bannerView() override { return &m_bannerView; }
bool handleEnter() override;
bool moveCursorHorizontally(int direction, bool fast = false) override;
bool moveCursorHorizontally(int direction, int scrollSpeed = 1) override;
double defaultCursorT(Ion::Storage::Record record) override;
CurveViewRange * interactiveCurveViewRange() override { return m_graphRange; }
SequenceStore * functionStore() const override { return static_cast<SequenceStore *>(Shared::FunctionGraphController::functionStore()); }