diff --git a/apps/shared/curve_view.cpp b/apps/shared/curve_view.cpp index 6e4c0f272..1890d2455 100644 --- a/apps/shared/curve_view.cpp +++ b/apps/shared/curve_view.cpp @@ -112,6 +112,10 @@ float CurveView::pixelHeight() const { return (m_curveViewRange->yMax() - m_curveViewRange->yMin()) / (m_frame.height() - 1); } +float CurveView::pixelLength(Axis axis) const { + return axis == Axis::Horizontal ? pixelWidth() : pixelHeight(); +} + float CurveView::pixelToFloat(Axis axis, KDCoordinate p) const { return (axis == Axis::Horizontal) ? m_curveViewRange->xMin() + p * pixelWidth() : @@ -140,8 +144,7 @@ float CurveView::floatToPixel(Axis axis, float f) const { } float CurveView::floatLengthToPixelLength(Axis axis, float f) const { - float pixelLength = axis == Axis::Horizontal ? pixelWidth() : pixelHeight(); - float dist = f / pixelLength; + float dist = f / pixelLength(axis); return clippedFloat(dist); } diff --git a/apps/shared/curve_view.h b/apps/shared/curve_view.h index 481429489..cc882b8f7 100644 --- a/apps/shared/curve_view.h +++ b/apps/shared/curve_view.h @@ -41,6 +41,7 @@ public: void setForceOkDisplay(bool force) { m_forceOkDisplay = force; } float pixelWidth() const; float pixelHeight() const; + float pixelLength(Axis axis) const; protected: CurveViewRange * curveViewRange() const { return m_curveViewRange; } void setCurveViewRange(CurveViewRange * curveViewRange);