[apps/values_controller] Cell types naming for typeAtLocation

This commit is contained in:
Léa Saviot
2019-09-03 15:31:06 +02:00
parent e7958b8287
commit a3b59a585c
4 changed files with 15 additions and 11 deletions

View File

@@ -31,13 +31,13 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
// The cell is the abscissa title cell:
if (typeAtLocation(i,j) == 0) {
if (typeAtLocation(i,j) == k_abscissaTitleCellType) {
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
mytitleCell->setMessage(I18n::Message::X);
return;
}
// The cell is a function title cell:
if (typeAtLocation(i,j) == 1) {
if (typeAtLocation(i,j) == k_functionTitleCellType) {
Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell;
const size_t bufferNameSize = Shared::Function::k_maxNameWithArgumentSize + 1;
char bufferName[bufferNameSize];
@@ -75,7 +75,7 @@ Ion::Storage::Record ValuesController::recordAtColumn(int i) {
}
Ion::Storage::Record ValuesController::recordAtColumn(int i, bool * isDerivative) {
assert(typeAtLocation(i, 0) == 1);
assert(typeAtLocation(i, 0) == k_functionTitleCellType);
int plotTypeIndex = 0;
while (plotTypeIndex < 3 && i >= m_numberOfColumnsForType[plotTypeIndex]) {
i -= m_numberOfColumnsForType[plotTypeIndex++];

View File

@@ -28,14 +28,12 @@ ValuesController::ValuesController(Responder * parentResponder,InputEventHandler
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
// The cell is the abscissa title cell:
if (typeAtLocation(i,j) == 0) {
if (typeAtLocation(i,j) == k_abscissaTitleCellType) {
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
mytitleCell->setMessage(I18n::Message::N);
return;
}
// The cell is a function title cell:
if (typeAtLocation(i,j) == 1) {
if (typeAtLocation(i,j) == k_functionTitleCellType) {
SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
Sequence * sequence = functionStore()->modelForRecord(recordAtColumn(i));
myCell->setLayout(sequence->nameLayout());

View File

@@ -77,7 +77,7 @@ bool ValuesController::handleEvent(Ion::Events::Event event) {
}
if ((event == Ion::Events::OK || event == Ion::Events::EXE) && selectedRow() == 0) {
ViewController * parameterController = nullptr;
if (typeAtLocation(selectedColumn(), 0) == 0) {
if (typeAtLocation(selectedColumn(), 0) == k_abscissaTitleCellType) {
m_abscissaParameterController.setPageTitle(valuesParameterControllerPageTitle());
parameterController = &m_abscissaParameterController;
} else {
@@ -119,7 +119,7 @@ int ValuesController::numberOfButtons(ButtonRowController::Position) const {
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
willDisplayCellAtLocationWithDisplayMode(cell, i, j, Preferences::sharedPreferences()->displayMode());
// The cell is not a title cell and not editable
if (typeAtLocation(i,j) == 3) {
if (typeAtLocation(i,j) == k_notEditableValueCellType) {
constexpr int precision = Preferences::LargeNumberOfSignificantDigits;
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(precision)];
// Special case: last row
@@ -216,7 +216,7 @@ void ValuesController::viewDidDisappear() {
}
Ion::Storage::Record ValuesController::recordAtColumn(int i) {
assert(typeAtLocation(i, 0) == 1);
assert(typeAtLocation(i, 0) == k_functionTitleCellType);
return functionStore()->activeRecordAtIndex(i-1);
}
@@ -229,7 +229,7 @@ StackViewController * ValuesController::stackController() const {
}
bool ValuesController::cellAtLocationIsEditable(int columnIndex, int rowIndex) {
return typeAtLocation(columnIndex, rowIndex) == 2;
return typeAtLocation(columnIndex, rowIndex) == k_editableValueCellType;
}
bool ValuesController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) {

View File

@@ -40,7 +40,13 @@ public:
static constexpr KDCoordinate k_rightMargin = 15;
static constexpr KDCoordinate k_abscissaCellWidth = 100;
static constexpr KDCoordinate k_ordinateCellWidth = 100;
protected:
static constexpr int k_abscissaTitleCellType = 0;
static constexpr int k_functionTitleCellType = 1;
static constexpr int k_editableValueCellType = 2;
static constexpr int k_notEditableValueCellType = 3;
static constexpr const KDFont * k_font = KDFont::SmallFont;
StackViewController * stackController() const;
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override;