Files
Upsilon/apps/sequence/values/values_controller.cpp
Léa Saviot ea586d1ac5 [apps/graph] Add margins in values
+ Fix parameter titles
2019-09-03 17:32:04 +02:00

75 lines
2.5 KiB
C++

#include "values_controller.h"
#include <assert.h>
#include <cmath>
using namespace Shared;
namespace Sequence {
ValuesController::ValuesController(Responder * parentResponder,InputEventHandlerDelegate * inputEventHandlerDelegate, Interval * interval, ButtonRowController * header) :
Shared::ValuesController(parentResponder, header, interval),
m_sequenceTitleCells{},
m_floatCells{},
m_abscissaTitleCell(),
m_abscissaCells{},
#if COPY_COLUMN
m_sequenceParameterController('n'),
#endif
m_intervalParameterController(this, inputEventHandlerDelegate, m_interval),
m_setIntervalButton(this, I18n::Message::IntervalSet, Invocation([](void * context, void * sender) {
ValuesController * valuesController = (ValuesController *) context;
StackViewController * stack = ((StackViewController *)valuesController->stackController());
stack->push(valuesController->intervalParameterController());
return true;
}, this), k_font)
{
for (int i = 0; i < k_maxNumberOfSequences; i++) {
m_sequenceTitleCells[i].setOrientation(FunctionTitleCell::Orientation::HorizontalIndicator);
}
setupAbscissaCellsAndTitleCells(inputEventHandlerDelegate);
}
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
if (typeAtLocation(i,j) == k_abscissaTitleCellType) {
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
mytitleCell->setMessage(I18n::Message::N);
return;
}
if (typeAtLocation(i,j) == k_functionTitleCellType) {
SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
Sequence * sequence = functionStore()->modelForRecord(recordAtColumn(i));
myCell->setLayout(sequence->nameLayout());
myCell->setColor(sequence->color());
}
}
I18n::Message ValuesController::emptyMessage() {
if (functionStore()->numberOfDefinedModels() == 0) {
return I18n::Message::NoSequence;
}
return I18n::Message::NoActivatedSequence;
}
bool ValuesController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) {
if (floatBody < 0) {
return false;
}
return Shared::ValuesController::setDataAtLocation(std::round(floatBody), columnIndex, rowIndex);
}
ViewController * ValuesController::functionParameterController() {
#if COPY_COLUMN
m_sequenceParameterController.setRecord(recordAtColumn(selectedColumn()));
return &m_sequenceParameterController;
#else
return nullptr;
#endif
}
I18n::Message ValuesController::valuesParameterControllerPageTitle() const {
return I18n::Message::NColumn;
}
}