[apps/solver/solutions_controller] Code cleaning

This commit is contained in:
Léa Saviot
2020-01-27 11:36:22 +01:00
parent 0e64e89496
commit 7e7a37bf8e
2 changed files with 59 additions and 45 deletions

View File

@@ -15,7 +15,7 @@ public:
bool shouldReplaceFuncionsButNotSymbols() const { return m_shouldReplaceFuncionsButNotSymbols; }
/* ViewController */
const char * title() override;
View * view() override;
View * view() override { return &m_contentView; }
void viewWillAppear() override;
void didEnterResponderChain(Responder * previousFirstResponder) override;
/* AlternateEmptyViewDefaultDelegate */
@@ -24,7 +24,7 @@ public:
virtual Responder * defaultController() override;
/* TableViewDataSource */
int numberOfRows() const override;
int numberOfColumns() const override;
int numberOfColumns() const override { return 2; }
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
KDCoordinate columnWidth(int i) override;
KDCoordinate rowHeight(int j) override;
@@ -39,6 +39,7 @@ public:
private:
class ContentView : public View {
public:
constexpr static KDCoordinate k_topMargin = 50;
ContentView(SolutionsController * controller);
void drawRect(KDContext * ctx, KDRect rect) const override;
void setWarning(bool warning);
@@ -47,7 +48,7 @@ private:
return &m_selectableTableView;
}
private:
constexpr static KDCoordinate k_topMargin = 50;
constexpr static KDCoordinate k_middleMargin = 50;
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews(bool force = false) override;
@@ -56,15 +57,31 @@ private:
SelectableTableView m_selectableTableView;
bool m_displayWarningMoreSolutions;
};
// Cell types
constexpr static int k_symbolCellType = 0;
constexpr static int k_deltaCellType = 1;
constexpr static int k_exactValueCellType = 2;
constexpr static int k_approximateValueCellType = 3;
// Heights and widths
constexpr static KDCoordinate k_defaultCellHeight = 20;
constexpr static int k_symbolCellWidth = 90;
constexpr static int k_valueCellWidth = 190;
constexpr static KDCoordinate k_defaultCellHeight = 20;
// Number of cells
constexpr static int k_maxNumberOfVisibleCells = (Ion::Display::Height - 3 * Meric::TitleBarHeight - ContentView::k_topMargin) / k_defaultCellHeight + 1;
static_assert(k_maxNumberOfVisibleCells <= EquationStore::k_maxNumberOfSolutions + Poincare::Expression::k_maxNumberOfVariables, "We can reduce the number of cells in Solver:SolutionsController.");
constexpr static int k_numberOfSymbolCells = k_maxNumberOfVisibleCells < EquationStore::k_maxNumberOfSolutions ? k_maxNumberOfVisibleCells : EquationStore::k_maxNumberOfSolutions;
constexpr static int k_numberOfExactValueCells = k_maxNumberOfVisibleCells < EquationStore::k_maxNumberOfExactSolutions ? k_maxNumberOfVisibleCells : EquationStore::k_maxNumberOfExactSolutions;
constexpr static int k_numberOfApproximateValueCells = k_maxNumberOfVisibleCells < EquationStore::k_maxNumberOfApproximateSolutions ? k_maxNumberOfVisibleCells : EquationStore::k_maxNumberOfApproximateSolutions;
EquationStore * m_equationStore;
EvenOddBufferTextCell m_symbolCells[EquationStore::k_maxNumberOfSolutions];
EvenOddBufferTextCell m_symbolCells[k_numberOfSymbolCells];
EvenOddExpressionCell m_deltaCell;
Poincare::Layout m_delta2Layout;
Shared::ScrollableTwoExpressionsCell m_exactValueCells[EquationStore::k_maxNumberOfExactSolutions];
EvenOddBufferTextCell m_approximateValueCells[EquationStore::k_maxNumberOfApproximateSolutions];
Shared::ScrollableTwoExpressionsCell m_exactValueCells[k_numberOfExactValueCells];
EvenOddBufferTextCell m_approximateValueCells[k_numberOfApproximateValueCells];
ContentView m_contentView;
bool m_shouldReplaceFuncionsButNotSymbols;
};