[apps/graph] Round x before evaluating graph cursor on scroll

Change-Id: I13500669963eb8130e188a898bed0bf63655add6
This commit is contained in:
Hugo Saint-Vignes
2020-07-09 10:14:59 +02:00
committed by Émilie Feral
parent bd2609bcba
commit 9e12b61849
6 changed files with 50 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
#include "function_banner_delegate.h"
#include "interactive_curve_view_controller.h"
#include <cmath>
#include <float.h>
@@ -219,6 +220,10 @@ bool InteractiveCurveViewController::textFieldDidFinishEditing(TextField * textF
if (textFieldDelegateApp()->hasUndefinedValue(text, floatBody)) {
return false;
}
/* If possible, round floatBody so that we go to the evaluation of the
* displayed floatBody */
floatBody = FunctionBannerDelegate::getValueDisplayedOnBanner(floatBody, textFieldDelegateApp()->localContext(), curveView()->pixelWidth(), false);
Coordinate2D<double> xy = xyValues(selectedCurveIndex(), floatBody, textFieldDelegateApp()->localContext());
m_cursor->moveTo(floatBody, xy.x1(), xy.x2());
interactiveCurveViewRange()->panToMakePointVisible(m_cursor->x(), m_cursor->y(), cursorTopMarginRatio(), cursorRightMarginRatio(), cursorBottomMarginRatio(), cursorLeftMarginRatio(), curveView()->pixelWidth());