mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[graph] Change cursor initial position
The cursor now initially aligns with the grid, and tries to avoid points where the function is not defined. Change-Id: Ie3b304281f5848102c2f3c0aa5c031b351418186
This commit is contained in:
committed by
EmilieNumworks
parent
3ac3fba468
commit
5e679b7bc8
@@ -68,9 +68,21 @@ void FunctionGraphController::reloadBannerView() {
|
||||
reloadBannerViewForCursorOnFunction(m_cursor, record, functionStore(), AppsContainer::sharedAppsContainer()->globalContext());
|
||||
}
|
||||
|
||||
|
||||
double FunctionGraphController::defaultCursorT(Ion::Storage::Record record) {
|
||||
return (interactiveCurveViewRange()->xMin()+interactiveCurveViewRange()->xMax())/2.0f;
|
||||
Poincare::Context * context = textFieldDelegateApp()->localContext();
|
||||
ExpiringPointer<Function> function = functionStore()->modelForRecord(record);
|
||||
float gridUnit = 2 * interactiveCurveViewRange()->xGridUnit();
|
||||
|
||||
float yMin = interactiveCurveViewRange()->yMin(), yMax = interactiveCurveViewRange()->yMax();
|
||||
float middle = (interactiveCurveViewRange()->xMin()+interactiveCurveViewRange()->xMax())/2.0f;
|
||||
float resLeft = gridUnit * std::floor(middle / gridUnit);
|
||||
float yLeft = function->evaluateXYAtParameter(resLeft, context).x2();
|
||||
float resRight = resLeft + gridUnit;
|
||||
float yRight = function->evaluateXYAtParameter(resRight, context).x2();
|
||||
if ((yMin < yLeft && yLeft < yMax) || !(yMin < yRight && yRight < yMax)) {
|
||||
return resLeft;
|
||||
}
|
||||
return resRight;
|
||||
}
|
||||
|
||||
FunctionStore * FunctionGraphController::functionStore() const {
|
||||
|
||||
Reference in New Issue
Block a user