[sequence] Fix ListController with new Poincare API

This commit is contained in:
Émilie Feral
2018-09-07 10:17:52 +02:00
parent 82a0eea98f
commit b6b5821bb6
3 changed files with 12 additions and 12 deletions

View File

@@ -59,17 +59,17 @@ KDCoordinate ListController::expressionRowHeight(int j) {
}
Sequence * sequence = m_sequenceStore->modelAtIndex(modelIndexForRow(j));
KDCoordinate defaultHeight = 2*k_expressionCellVerticalMargin + (sequence->type() == Sequence::Type::Explicit ? Metric::StoreRowHeight : k_emptySubRowHeight);
ExpressionLayout * layout = sequence->layout();
LayoutReference layout = sequence->layoutRef();
if (sequenceDefinitionForRow(j) == 1) {
layout = sequence->firstInitialConditionLayout();
}
if (sequenceDefinitionForRow(j) == 2) {
layout = sequence->secondInitialConditionLayout();
}
if (layout == nullptr) {
if (layout.isUninitialized()) {
return defaultHeight;
}
KDCoordinate sequenceHeight = layout->size().height();
KDCoordinate sequenceHeight = layout.layoutSize().height();
return max(defaultHeight, sequenceHeight + 2*k_expressionCellVerticalMargin);
}
@@ -186,13 +186,13 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
Sequence * sequence = m_sequenceStore->modelAtIndex(modelIndexForRow(j));
if (sequenceDefinitionForRow(j) == 0) {
myCell->setExpressionLayout(sequence->definitionName());
myCell->setLayout(sequence->definitionName());
}
if (sequenceDefinitionForRow(j) == 1) {
myCell->setExpressionLayout(sequence->firstInitialConditionName());
myCell->setLayout(sequence->firstInitialConditionName());
}
if (sequenceDefinitionForRow(j) == 2) {
myCell->setExpressionLayout(sequence->secondInitialConditionName());
myCell->setLayout(sequence->secondInitialConditionName());
}
KDColor nameColor = sequence->isActive() ? sequence->color() : Palette::GreyDark;
myCell->setColor(nameColor);
@@ -202,13 +202,13 @@ void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int
FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell;
Sequence * sequence = m_sequenceStore->modelAtIndex(modelIndexForRow(j));
if (sequenceDefinitionForRow(j) == 0) {
myCell->setExpressionLayout(sequence->layout());
myCell->setLayoutRef(sequence->layoutRef());
}
if (sequenceDefinitionForRow(j) == 1) {
myCell->setExpressionLayout(sequence->firstInitialConditionLayout());
myCell->setLayoutRef(sequence->firstInitialConditionLayout());
}
if (sequenceDefinitionForRow(j) == 2) {
myCell->setExpressionLayout(sequence->secondInitialConditionLayout());
myCell->setLayoutRef(sequence->secondInitialConditionLayout());
}
bool active = sequence->isActive();
KDColor textColor = active ? KDColorBlack : Palette::GreyDark;

View File

@@ -12,8 +12,8 @@ SequenceTitleCell::SequenceTitleCell(Orientation orientation) :
{
}
void SequenceTitleCell::setExpressionLayout(Poincare::ExpressionLayout * expressionLayout) {
m_titleTextView.setExpressionLayout(expressionLayout);
void SequenceTitleCell::setLayout(Poincare::LayoutReference layout) {
m_titleTextView.setLayoutRef(layout);
}
void SequenceTitleCell::setHighlighted(bool highlight) {

View File

@@ -8,7 +8,7 @@ namespace Sequence {
class SequenceTitleCell : public Shared::FunctionTitleCell {
public:
SequenceTitleCell(Orientation orientation);
void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout);
void setLayout(Poincare::LayoutReference layout);
void setEven(bool even) override;
void setHighlighted(bool highlight) override;
void setColor(KDColor color) override;