diff --git a/apps/sequence/graph/graph_controller.cpp b/apps/sequence/graph/graph_controller.cpp index a7ef02154..8579519a8 100644 --- a/apps/sequence/graph/graph_controller.cpp +++ b/apps/sequence/graph/graph_controller.cpp @@ -48,8 +48,13 @@ bool GraphController::moveCursorHorizontally(int direction) { if (direction < 0 && xCursorPosition <= 0) { return false; } - float x = direction > 0 ? xCursorPosition + 1.0f : - xCursorPosition - 1.0f; + float step = ceilf((interactiveCurveViewRange()->xMax()-interactiveCurveViewRange()->xMin())/GraphView::k_precision); + step = step < 1.0f ? 1.0f : step; + float x = direction > 0 ? xCursorPosition + step: + xCursorPosition - step; + if (x < 0.0f) { + return false; + } Sequence * s = m_sequenceStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); TextFieldDelegateApp * myApp = (TextFieldDelegateApp *)app(); float y = s->evaluateAtAbscissa(x, myApp->localContext()); diff --git a/apps/sequence/graph/graph_view.cpp b/apps/sequence/graph/graph_view.cpp index e3dcba188..e89e9e3df 100644 --- a/apps/sequence/graph/graph_view.cpp +++ b/apps/sequence/graph/graph_view.cpp @@ -22,7 +22,8 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const { Sequence * s = m_sequenceStore->activeFunctionAtIndex(i); float rectMin = pixelToFloat(Axis::Horizontal, rect.left() - k_externRectMargin); float rectMax = pixelToFloat(Axis::Horizontal, rect.right() + k_externRectMargin); - for (int x = rectMin; x < rectMax; x++) { + int step = ceilf((rectMax - rectMin)/k_precision); + for (int x = rectMin; x < rectMax; x += step) { float y = evaluateModelWithParameter(s, x); if (isnan(y)) { continue; diff --git a/apps/sequence/graph/graph_view.h b/apps/sequence/graph/graph_view.h index 90b1cc034..28ff71a65 100644 --- a/apps/sequence/graph/graph_view.h +++ b/apps/sequence/graph/graph_view.h @@ -16,6 +16,7 @@ public: void selectSequence(Sequence * sequence); void setHighlight(int start, int end); void setHighlightColor(bool highlightColor); + constexpr static float k_precision = 250.0f; private: float evaluateModelWithParameter(Model * expression, float abscissa) const override; KDSize cursorSize() override;