[apps/shared] Change Zoom API

Moved some code around to decrease redundancy and put more of the logic
into Poincare::Zoom

Change-Id: I4804cf39493ac7f2f0b3c4eb554e5c15c3cef1c9
This commit is contained in:
Gabriel Ozouf
2020-10-13 12:19:26 +02:00
committed by Émilie Feral
parent 8572f4953c
commit 6be5e7d62c
11 changed files with 93 additions and 128 deletions

View File

@@ -9,6 +9,7 @@
#include <poincare/integer.h>
#include <poincare/rational.h>
#include <poincare/addition.h>
#include <poincare/zoom.h>
#include "../shared/poincare_helpers.h"
#include <string.h>
#include <apps/i18n.h>
@@ -310,6 +311,15 @@ Expression Sequence::sumBetweenBounds(double start, double end, Poincare::Contex
return Float<double>::Builder(result);
}
void Sequence::rangeForDisplay(float * xMin, float * xMax, float * yMin, float * yMax, Poincare::Context * context) const {
Poincare::Zoom::ValueAtAbscissa evaluation = [](float x, Poincare::Context * context, const void * auxiliary) {
return static_cast<float>(static_cast<const Shared::Sequence *>(auxiliary)->initialRank());
};
Poincare::Zoom::FullRange(evaluation, 0, 1, 1, xMin, xMax, context, this);
*xMax += Poincare::Zoom::k_defaultHalfRange;
protectedFullRangeForDisplay(*xMin, *xMax, 1.f, yMin, yMax, context, false);
}
Sequence::RecordDataBuffer * Sequence::recordData() const {
assert(!isNull());
Ion::Storage::Record::Data d = value();