[apps/shared][apps/graph][apps/sequence] Reorganise list controllers,

function title cells and function expression cells

Change-Id: Idbdae4975c8ed83a023c781dc14929b8c2053bb0
This commit is contained in:
Émilie Feral
2017-02-08 12:03:11 +01:00
parent e414f81d67
commit 0f4d7f0914
21 changed files with 306 additions and 136 deletions

View File

@@ -7,31 +7,81 @@ namespace Sequence {
ListController::ListController(Responder * parentResponder, SequenceStore * sequenceStore, HeaderViewController * header) :
Shared::ListController(parentResponder, sequenceStore, header),
m_parameterController(ListParameterController(this, sequenceStore))
m_functionTitleCells{SequenceTitleCell(&m_selectableTableView),SequenceTitleCell(&m_selectableTableView),SequenceTitleCell(&m_selectableTableView)},
m_expressionCells{SequenceExpressionCell(&m_selectableTableView),SequenceExpressionCell(&m_selectableTableView),SequenceExpressionCell(&m_selectableTableView)},
m_parameterController(ListParameterController(this, sequenceStore)),
m_typeParameterController(this)
{
m_selectableTableView.setDelegate(this);
}
const char * ListController::title() const {
return "Suites";
}
KDCoordinate ListController::rowHeight(int j) {
if (m_functionStore->numberOfFunctions() < m_functionStore->maxNumberOfFunctions() && j == numberOfRows() - 1) {
return k_emptyRowHeight;
}
Sequence * sequence = ((SequenceStore *)m_functionStore)->functionAtIndex(j);
KDCoordinate height = 0;
KDCoordinate defaultHeight = sequence->type() == Sequence::Type::Explicite ? k_emptyRowHeight : k_emptySubRowHeight;
if (sequence->layout() == nullptr) {
height += defaultHeight;
} else {
KDCoordinate size = sequence->layout()->size().height();
height += size + defaultHeight - KDText::stringSize(" ").height();
}
if ((int)sequence->type() > 0) {
if (sequence->firstInitialConditionLayout() == nullptr) {
height += defaultHeight;
} else {
KDCoordinate size = sequence->firstInitialConditionLayout()->size().height();
height += size + defaultHeight - KDText::stringSize(" ").height();
}
}
if ((int)sequence->type() > 1) {
if (sequence->secondInitialConditionLayout() == nullptr) {
height += defaultHeight;
} else {
KDCoordinate size = sequence->secondInitialConditionLayout()->size().height();
height += size + defaultHeight - KDText::stringSize(" ").height();
}
}
return height;
}
bool ListController::handleEvent(Ion::Events::Event event) {
if (Shared::ListController::handleEvent(event)) {
return true;
}
if (event == Ion::Events::OK && m_selectableTableView.selectedColumn() == 1
&& m_selectableTableView.selectedRow() == numberOfRows() - 1) {
return addFunction();
if (addFunction()){
m_selectableTableView.dataHasChanged(true);
m_typeParameterController.setSequence((Sequence *)m_functionStore->functionAtIndex(m_selectableTableView.selectedRow()));
StackViewController * stack = stackController();
stack->push(&m_typeParameterController);
return true;
}
return false;
}
return false;
}
void ListController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) {
if (t->selectedRow() < numberOfRows() - 1) {
Responder * myCell = (Responder *)t->cellAtLocation(t->selectedColumn(), t->selectedRow());
app()->setFirstResponder(myCell);
if (m_functionStore->numberOfFunctions() == m_functionStore->maxNumberOfFunctions() || t->selectedRow() < numberOfRows() - 1) {
if (t->selectedColumn() == 0) {
SequenceTitleCell * myCell = (SequenceTitleCell *)t->cellAtLocation(t->selectedColumn(), t->selectedRow());
app()->setFirstResponder(myCell);
} else {
SequenceExpressionCell * myCell = (SequenceExpressionCell *)t->cellAtLocation(t->selectedColumn(), t->selectedRow());
app()->setFirstResponder(myCell);
}
} else {
app()->setFirstResponder(t);
if (app()->firstResponder() != t) {
app()->setFirstResponder(t);
}
}
}
@@ -53,4 +103,27 @@ TableViewCell * ListController::expressionCells(int index) {
return &m_expressionCells[index];
}
void ListController::willDisplayTitleCellAtIndex(TableViewCell * cell, int j) {
SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
Sequence * sequence = ((SequenceStore *)m_functionStore)->functionAtIndex(j);
myCell->setNumberOfSubCells((int)sequence->type()+1);
char bufferName[5] = {*sequence->name(),'(',sequence->symbol(),')', 0};
myCell->setDefinitionText(bufferName);
if ((int)sequence->type() > 0) {
char bufferName[7] = {*sequence->name(),'(',sequence->symbol(),'+','1',')', 0};
myCell->setFirstInitialConditionText(bufferName);
}
if ((int)sequence->type() > 1) {
char bufferName[7] = {*sequence->name(),'(',sequence->symbol(),'+','2',')', 0};
myCell->setSecondInitialConditionText(bufferName);
}
KDColor functionNameColor = sequence->isActive() ? sequence->color() : Palette::GreyDark;
myCell->setColor(functionNameColor);
}
void ListController::willDisplayExpressionCellAtIndex(TableViewCell * cell, int j) {
SequenceExpressionCell * myCell = (SequenceExpressionCell *)cell;
myCell->setSequence(((SequenceStore *)m_functionStore)->functionAtIndex(j));
}
}