diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index 0d8a64aaf..5e48afb35 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -1,5 +1,4 @@ #include "calculation_controller.h" -#include "../constant.h" #include "../apps_container.h" #include "../shared/poincare_helpers.h" #include @@ -246,7 +245,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int KDCoordinate CalculationController::columnWidth(int i) { if (i == 0) { - return k_smallCalculationCellWidth; + return k_titleCalculationCellWidth; } Model::Type currentType = m_store->seriesRegressionType(m_store->indexOfKthNonEmptySeries(i-1)); if (currentType == Model::Type::Quartic) { @@ -255,7 +254,7 @@ KDCoordinate CalculationController::columnWidth(int i) { if (currentType == Model::Type::Cubic) { return k_cubicCalculationCellWidth; } - return k_smallCalculationCellWidth; + return k_minCalculationCellWidth; } KDCoordinate CalculationController::rowHeight(int j) { diff --git a/apps/regression/calculation_controller.h b/apps/regression/calculation_controller.h index 5d85a2ca6..d9bfc1290 100644 --- a/apps/regression/calculation_controller.h +++ b/apps/regression/calculation_controller.h @@ -10,9 +10,12 @@ #include "../shared/tab_table_controller.h" #include "../shared/separator_even_odd_buffer_text_cell.h" #include "../shared/store_cell.h" +#include "../constant.h" namespace Regression { +constexpr static size_t max(KDCoordinate a, KDCoordinate b) { return a > b ? a : b; } + class CalculationController : public Shared::TabTableController, public TableViewDataSource, public SelectableTableViewDelegate, public ButtonRowDelegate, public AlternateEmptyViewDefaultDelegate { public: @@ -59,9 +62,11 @@ private: static constexpr int k_regressionCellIndex = 9; static constexpr KDCoordinate k_cellHeight = 25; - static constexpr KDCoordinate k_smallCalculationCellWidth = Ion::Display::Width/2 - Metric::CommonRightMargin/2 - Metric::CommonLeftMargin/2; - static constexpr KDCoordinate k_cubicCalculationCellWidth = 150; - static constexpr KDCoordinate k_quarticCalculationCellWidth = 195; + static constexpr KDCoordinate k_titleCalculationCellWidth = Ion::Display::Width/2 - Metric::CommonRightMargin/2 - Metric::CommonLeftMargin/2; + // TODO: change 7 for KDFont::SmallFont->glyphSize().width() + static constexpr KDCoordinate k_minCalculationCellWidth = 7*2*(Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)); //Calculation width should at least be able to hold to numbers with LargeNumberOfSignificantDigits. + static constexpr KDCoordinate k_cubicCalculationCellWidth = max(150, k_minCalculationCellWidth); // Should hold aX^3+bX^2+cX+d + static constexpr KDCoordinate k_quarticCalculationCellWidth = max(195, k_minCalculationCellWidth ); // Should hold ? aX^4+bX^3+c*X^2+dX+e static constexpr KDCoordinate k_margin = 8; static constexpr KDCoordinate k_r2CellMargin = 2; static constexpr KDCoordinate k_scrollBarMargin = Metric::CommonRightMargin; diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index cd1108d99..4a8e78062 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -1,5 +1,4 @@ #include "calculation_controller.h" -#include "../constant.h" #include "../apps_container.h" #include "../shared/poincare_helpers.h" #include diff --git a/apps/statistics/calculation_controller.h b/apps/statistics/calculation_controller.h index 8a717b3a0..c5ef14621 100644 --- a/apps/statistics/calculation_controller.h +++ b/apps/statistics/calculation_controller.h @@ -2,6 +2,7 @@ #define STATISTICS_CALCULATION_CONTROLLER_H #include +#include #include "store.h" #include "calculation_selectable_table_view.h" #include "../shared/hideable_even_odd_cell.h" @@ -9,6 +10,7 @@ #include "../shared/separator_even_odd_buffer_text_cell.h" #include "../shared/store_title_cell.h" #include "../shared/tab_table_controller.h" +#include "../constant.h" namespace Statistics { @@ -53,7 +55,8 @@ private: static constexpr int k_hideableCellType = 3; static constexpr KDCoordinate k_cellHeight = 20; static constexpr KDCoordinate k_calculationTitleCellWidth = 175; - static constexpr KDCoordinate k_calculationCellWidth = 84; + // TODO: change 7 for KDFont::SmallFont->glyphSize().width() + static constexpr KDCoordinate k_calculationCellWidth = 7*(Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)); static constexpr KDCoordinate k_margin = 8; static constexpr KDCoordinate k_scrollBarMargin = Metric::CommonRightMargin;