[apps/shared] EditableCellTableViewController: function and sequence

values table cells were to narrow to display
LargeNumberOfSignificantDigits (~16 digits). We adjust the number of
digits authorized before switching to scientific mode to the cell width
This commit is contained in:
Émilie Feral
2019-08-05 13:49:46 +02:00
parent c2720109fc
commit 79d7e58ec8
3 changed files with 7 additions and 2 deletions

View File

@@ -78,7 +78,7 @@ void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(H
}
if (!myEditableValueCell->editableTextCell()->textField()->isEditing()) {
myCell->setEven(j%2 == 0);
PrintFloat::convertFloatToText<double>(dataAtLocation(i, j), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, floatDisplayMode);
PrintFloat::convertFloatToText<double>(dataAtLocation(i, j), buffer, cellBufferSize(i), Constant::LargeNumberOfSignificantDigits, floatDisplayMode);
myEditableValueCell->editableTextCell()->textField()->setText(buffer);
}
return;

View File

@@ -22,6 +22,11 @@ public:
void didBecomeFirstResponder() override;
protected:
static constexpr KDCoordinate k_cellHeight = 20;
/* Editable cell might be not wide enough to display
* LargeNumberOfSignificantDigits, we update the buffer to the column width. */
size_t cellBufferSize(int i) {
return columnWidth(i)/KDFont::SmallFont->glyphSize().width()+1;
}
private:
virtual bool cellAtLocationIsEditable(int columnIndex, int rowIndex) = 0;
virtual bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) = 0;

View File

@@ -171,7 +171,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
// The cell is a value cell
EvenOddBufferTextCell * myValueCell = (EvenOddBufferTextCell *)cell;
double x = m_interval->element(j-1);
PoincareHelpers::ConvertFloatToText<double>(evaluationOfAbscissaAtColumn(x, i), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
PoincareHelpers::ConvertFloatToText<double>(evaluationOfAbscissaAtColumn(x, i), buffer, cellBufferSize(i), Constant::LargeNumberOfSignificantDigits);
myValueCell->setText(buffer);
}
}