[apps/sequence] Make controllers inherit from StorageFunction controllers when required

This commit is contained in:
Émilie Feral
2019-02-28 14:51:22 +01:00
parent 184d2f0802
commit 2bc2506b60
29 changed files with 270 additions and 285 deletions

View File

@@ -1,6 +1,5 @@
#include "term_sum_controller.h"
#include "../../shared/text_field_delegate.h"
#include "../app.h"
#include <poincare/code_point_layout.h>
#include <poincare/horizontal_layout.h>
#include <poincare/vertical_offset_layout.h>
@@ -18,7 +17,7 @@ using namespace Poincare;
namespace Sequence {
TermSumController::TermSumController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, GraphView * graphView, CurveViewRange * graphRange, CurveViewCursor * cursor) :
SumGraphController(parentResponder, inputEventHandlerDelegate, graphView, graphRange, cursor, UCodePointNArySummation)
StorageSumGraphController(parentResponder, inputEventHandlerDelegate, graphView, graphRange, cursor, UCodePointNArySummation)
{
}
@@ -30,7 +29,7 @@ bool TermSumController::moveCursorHorizontallyToPosition(double position) {
if (position < 0.0) {
return false;
}
return SumGraphController::moveCursorHorizontallyToPosition(std::round(position));
return StorageSumGraphController::moveCursorHorizontallyToPosition(std::round(position));
}
I18n::Message TermSumController::legendMessageAtStep(Step step) {
@@ -49,14 +48,9 @@ double TermSumController::cursorNextStep(double x, int direction) {
return std::round(m_cursor->x()+delta);
}
Layout TermSumController::createFunctionLayout(const char * functionName) {
return HorizontalLayout::Builder(
CodePointLayout::Builder(functionName[0], KDFont::SmallFont),
VerticalOffsetLayout::Builder(
CodePointLayout::Builder('n', KDFont::SmallFont),
VerticalOffsetLayoutNode::Type::Subscript
)
);
Layout TermSumController::createFunctionLayout(Shared::ExpiringPointer<Shared::StorageFunction> function) {
Shared::ExpiringPointer<Sequence> sequence = static_cast<Shared::ExpiringPointer<Sequence>>(function);
return sequence->nameLayout();
}
}