mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/solver] Display user variables in the solutions
This commit is contained in:
@@ -11,8 +11,8 @@ namespace Solver {
|
||||
class SolutionsController : public ViewController, public AlternateEmptyViewDefaultDelegate, public SelectableTableViewDataSource, public TableViewDataSource {
|
||||
public:
|
||||
SolutionsController(Responder * parentResponder, EquationStore * equationStore);
|
||||
void setShouldReplaceFuncionsButNotSymbols(bool shouldReplaceFuncionsButNotSymbols) { m_shouldReplaceFuncionsButNotSymbols = shouldReplaceFuncionsButNotSymbols; }
|
||||
bool shouldReplaceFuncionsButNotSymbols() const { return m_shouldReplaceFuncionsButNotSymbols; }
|
||||
void setShouldReplaceFuncionsButNotSymbols(bool shouldReplaceFuncionsButNotSymbols) { m_shouldReplaceFunctionsButNotSymbols = shouldReplaceFuncionsButNotSymbols; }
|
||||
bool shouldReplaceFuncionsButNotSymbols() const { return m_shouldReplaceFunctionsButNotSymbols; }
|
||||
/* ViewController */
|
||||
const char * title() override;
|
||||
View * view() override { return &m_contentView; }
|
||||
@@ -40,13 +40,12 @@ private:
|
||||
class ContentView : public View {
|
||||
public:
|
||||
constexpr static KDCoordinate k_topMargin = 50;
|
||||
constexpr static KDColor k_backgroundColor = Palette::WallScreenDark;
|
||||
ContentView(SolutionsController * controller);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void setWarning(bool warning);
|
||||
void setWarningMessages(I18n::Message message0, I18n::Message message1);
|
||||
SelectableTableView * selectableTableView() {
|
||||
return &m_selectableTableView;
|
||||
}
|
||||
SelectableTableView * selectableTableView() { return &m_selectableTableView; }
|
||||
private:
|
||||
constexpr static KDCoordinate k_middleMargin = 50;
|
||||
int numberOfSubviews() const override;
|
||||
@@ -58,11 +57,26 @@ private:
|
||||
bool m_displayWarningMoreSolutions;
|
||||
};
|
||||
|
||||
class MessageCell : public HighlightCell {
|
||||
public:
|
||||
MessageCell() : m_messageView(KDFont::SmallFont, (I18n::Message)0, 0.0f, k_verticalAlignment, KDColorBlack, SolutionsController::ContentView::k_backgroundColor) {}
|
||||
void setBackgroundColor(KDColor color) { m_messageView.setBackgroundColor(color); }
|
||||
void setHorizontalAlignment(float alignment) { m_messageView.setAlignment(alignment, k_verticalAlignment); }
|
||||
void setMessage(I18n::Message message) { m_messageView.setMessage(message); }
|
||||
private:
|
||||
constexpr static float k_verticalAlignment = 0.8f;
|
||||
int numberOfSubviews() const override { return 1; }
|
||||
View * subviewAtIndex(int index) override { assert(index == 0); return &m_messageView; }
|
||||
void layoutSubviews(bool force = false) override { m_messageView.setFrame(bounds(), force); }
|
||||
MessageTextView m_messageView;
|
||||
};
|
||||
|
||||
// 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;
|
||||
constexpr static int k_messageCellType = 4;
|
||||
|
||||
// Heights and widths
|
||||
constexpr static KDCoordinate k_defaultCellHeight = 20;
|
||||
@@ -70,11 +84,19 @@ private:
|
||||
constexpr static int k_valueCellWidth = 190;
|
||||
|
||||
// Number of cells
|
||||
constexpr static int k_maxNumberOfVisibleCells = (Ion::Display::Height - 3 * Meric::TitleBarHeight - ContentView::k_topMargin) / k_defaultCellHeight + 1;
|
||||
constexpr static int k_maxNumberOfVisibleCells = (Ion::Display::Height - 3 * Metric::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_maxNumberOfSymbols = EquationStore::k_maxNumberOfSolutions + Poincare::Expression::k_maxNumberOfVariables;
|
||||
constexpr static int k_numberOfSymbolCells = k_maxNumberOfVisibleCells < k_maxNumberOfSymbols ? k_maxNumberOfVisibleCells : k_maxNumberOfSymbols;
|
||||
constexpr static int k_maxNumberOfExactValues = EquationStore::k_maxNumberOfExactSolutions + Poincare::Expression::k_maxNumberOfVariables;
|
||||
constexpr static int k_numberOfExactValueCells = k_maxNumberOfVisibleCells < k_maxNumberOfExactValues ? k_maxNumberOfVisibleCells : k_maxNumberOfExactValues;
|
||||
constexpr static int k_numberOfApproximateValueCells = k_maxNumberOfVisibleCells < EquationStore::k_maxNumberOfApproximateSolutions ? k_maxNumberOfVisibleCells : EquationStore::k_maxNumberOfApproximateSolutions;
|
||||
constexpr static int k_numberOfMessageCells = 2;
|
||||
|
||||
bool usedUserVariables() const {
|
||||
return m_equationStore->userVariablesUsed();
|
||||
}
|
||||
int userVariablesMessageRow() const;
|
||||
|
||||
EquationStore * m_equationStore;
|
||||
EvenOddBufferTextCell m_symbolCells[k_numberOfSymbolCells];
|
||||
@@ -82,8 +104,9 @@ private:
|
||||
Poincare::Layout m_delta2Layout;
|
||||
Shared::ScrollableTwoExpressionsCell m_exactValueCells[k_numberOfExactValueCells];
|
||||
EvenOddBufferTextCell m_approximateValueCells[k_numberOfApproximateValueCells];
|
||||
MessageCell m_messageCells[k_numberOfMessageCells];
|
||||
ContentView m_contentView;
|
||||
bool m_shouldReplaceFuncionsButNotSymbols;
|
||||
bool m_shouldReplaceFunctionsButNotSymbols;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user