From 79d7e58ec8e70935d7030ce8205d20beb6303ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 5 Aug 2019 13:49:46 +0200 Subject: [PATCH] [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 --- apps/shared/editable_cell_table_view_controller.cpp | 2 +- apps/shared/editable_cell_table_view_controller.h | 5 +++++ apps/shared/values_controller.cpp | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/shared/editable_cell_table_view_controller.cpp b/apps/shared/editable_cell_table_view_controller.cpp index 4e1ef615f..40b93f6ec 100644 --- a/apps/shared/editable_cell_table_view_controller.cpp +++ b/apps/shared/editable_cell_table_view_controller.cpp @@ -78,7 +78,7 @@ void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(H } if (!myEditableValueCell->editableTextCell()->textField()->isEditing()) { myCell->setEven(j%2 == 0); - PrintFloat::convertFloatToText(dataAtLocation(i, j), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, floatDisplayMode); + PrintFloat::convertFloatToText(dataAtLocation(i, j), buffer, cellBufferSize(i), Constant::LargeNumberOfSignificantDigits, floatDisplayMode); myEditableValueCell->editableTextCell()->textField()->setText(buffer); } return; diff --git a/apps/shared/editable_cell_table_view_controller.h b/apps/shared/editable_cell_table_view_controller.h index f7b5900ed..f6872f183 100644 --- a/apps/shared/editable_cell_table_view_controller.h +++ b/apps/shared/editable_cell_table_view_controller.h @@ -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; diff --git a/apps/shared/values_controller.cpp b/apps/shared/values_controller.cpp index a260eda64..a66ee1270 100644 --- a/apps/shared/values_controller.cpp +++ b/apps/shared/values_controller.cpp @@ -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(evaluationOfAbscissaAtColumn(x, i), buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); + PoincareHelpers::ConvertFloatToText(evaluationOfAbscissaAtColumn(x, i), buffer, cellBufferSize(i), Constant::LargeNumberOfSignificantDigits); myValueCell->setText(buffer); } }