[sequence] Fix TypeParameterController with new Poincare API

This commit is contained in:
Émilie Feral
2018-09-06 15:32:35 +02:00
parent b6f977f894
commit e0d298789a
3 changed files with 9 additions and 30 deletions

View File

@@ -3,9 +3,6 @@
#include "../app.h"
#include <assert.h>
#include <poincare/layout_helper.h>
#include "../../../poincare/src/layout/char_layout.h"
#include "../../../poincare/src/layout/horizontal_layout.h"
#include "../../../poincare/src/layout/vertical_offset_layout.h"
using namespace Poincare;
@@ -17,7 +14,7 @@ TypeParameterController::TypeParameterController(Responder * parentResponder, Se
m_expliciteCell(I18n::Message::Explicit, cellLayout),
m_singleRecurrenceCell(I18n::Message::SingleRecurrence, cellLayout),
m_doubleRecurenceCell(I18n::Message::DoubleRecurrence, cellLayout),
m_expressionLayouts{},
m_layouts{},
m_selectableTableView(this),
m_sequenceStore(sequenceStore),
m_sequence(nullptr),
@@ -27,15 +24,6 @@ TypeParameterController::TypeParameterController(Responder * parentResponder, Se
m_selectableTableView.setShowsIndicators(false);
}
TypeParameterController::~TypeParameterController() {
for (int i = 0; i < k_totalNumberOfCell; i++) {
if (m_expressionLayouts[i]) {
delete m_expressionLayouts[i];
m_expressionLayouts[i] = nullptr;
}
}
}
const char * TypeParameterController::title() {
if (m_sequence) {
return I18n::translate(I18n::Message::SequenceType);
@@ -125,16 +113,12 @@ void TypeParameterController::willDisplayCellAtLocation(HighlightCell * cell, in
size = KDText::FontSize::Small;
}
const char * subscripts[3] = {"n", "n+1", "n+2"};
if (m_expressionLayouts[j]) {
delete m_expressionLayouts[j];
m_expressionLayouts[j] = nullptr;
}
m_expressionLayouts[j] = new HorizontalLayout(
new CharLayout(nextName[0], size),
new VerticalOffsetLayout(LayoutHelper::String(subscripts[j], strlen(subscripts[j]), size), VerticalOffsetLayout::Type::Subscript, false),
false);
m_layouts[j] = HorizontalLayoutRef(
CharLayoutRef(nextName[0], size),
VerticalOffsetLayoutRef(LayoutHelper::String(subscripts[j], strlen(subscripts[j]), size), VerticalOffsetLayoutNode::Type::Subscript)
);
ExpressionTableCellWithPointer * myCell = (ExpressionTableCellWithPointer *)cell;
myCell->setExpressionLayout(m_expressionLayouts[j]);
myCell->setLayoutRef(m_layouts[j]);
}
void TypeParameterController::setSequence(Sequence * sequence) {

View File

@@ -13,11 +13,6 @@ public:
TypeParameterController(Responder * parentResponder, SequenceStore * sequenceStore, ListController * list,
TableCell::Layout cellLayout, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0,
KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0);
~TypeParameterController();
TypeParameterController(const TypeParameterController& other) = delete;
TypeParameterController(TypeParameterController&& other) = delete;
TypeParameterController& operator=(const TypeParameterController& other) = delete;
TypeParameterController& operator=(TypeParameterController&& other) = delete;
const char * title() override;
View * view() override;
void viewWillAppear() override;
@@ -36,7 +31,7 @@ private:
ExpressionTableCellWithPointer m_expliciteCell;
ExpressionTableCellWithPointer m_singleRecurrenceCell;
ExpressionTableCellWithPointer m_doubleRecurenceCell;
Poincare::ExpressionLayout * m_expressionLayouts[k_totalNumberOfCell];
Poincare::LayoutReference m_layouts[k_totalNumberOfCell];
SelectableTableView m_selectableTableView;
SequenceStore * m_sequenceStore;
Sequence * m_sequence;

View File

@@ -12,8 +12,8 @@ public:
void setEven(bool even) override;
void setHighlighted(bool highlight) override;
void setColor(KDColor color) override;
Poincare::ExpressionLayout * expressionLayout() const override {
return m_titleTextView.expressionLayout();
Poincare::LayoutReference layoutRef() const override {
return m_titleTextView.layoutRef();
}
private:
int numberOfSubviews() const override;