mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/probability] Add editable text subviews to the calculation
controller Change-Id: I47833fbecd6eccc2b8dc8be816321846843b385f
This commit is contained in:
@@ -10,20 +10,54 @@ CalculationController::ContentView::ContentView(Responder * parentResponder, Law
|
||||
}
|
||||
|
||||
int CalculationController::ContentView::numberOfSubviews() const {
|
||||
return 2;
|
||||
return 6;
|
||||
}
|
||||
|
||||
View * CalculationController::ContentView::subviewAtIndex(int index) {
|
||||
assert(index >= 0 && index < 2);
|
||||
assert(index >= 0 && index < 6);
|
||||
if (index == 0) {
|
||||
return &m_lawCurveView;
|
||||
}
|
||||
return &m_imageTableView;
|
||||
if (index == 1) {
|
||||
return &m_imageTableView;
|
||||
}
|
||||
if (index == 2) {
|
||||
m_text[0].setAlignment(0.5f, 0.5f);
|
||||
m_text[0].setText("P(X <=");
|
||||
return &m_text[0];
|
||||
}
|
||||
if (index == 3) {
|
||||
m_calculationCell[0].setText("test");
|
||||
return &m_calculationCell[0];
|
||||
}
|
||||
if (index == 4) {
|
||||
m_text[1].setAlignment(0.5f, 0.5f);
|
||||
m_text[1].setText(") = ");
|
||||
return &m_text[1];
|
||||
}
|
||||
if (index == 5) {
|
||||
m_calculationCell[1].setText("test2");
|
||||
return &m_calculationCell[1];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CalculationController::ContentView::layoutSubviews() {
|
||||
KDCoordinate xCoordinate = 0;
|
||||
m_lawCurveView.setFrame(KDRect(0, ImageTableView::k_imageHeight, bounds().width(), bounds().height() - ImageTableView::k_imageHeight));
|
||||
m_imageTableView.setFrame(KDRect(0, 0, ImageTableView::k_imageWidth, 3*ImageTableView::k_imageHeight));
|
||||
m_imageTableView.setFrame(KDRect(xCoordinate, 0, ImageTableView::k_imageWidth, 3*ImageTableView::k_imageHeight));
|
||||
xCoordinate += ImageTableView::k_imageWidth + k_textMargin;
|
||||
m_text[0].setFrame(KDRect(xCoordinate, 0, 7*k_charWidth, ImageTableView::k_imageHeight));
|
||||
xCoordinate += 7*k_charWidth + k_textMargin;
|
||||
m_calculationCell[0].setFrame(KDRect(xCoordinate, 0, k_textFieldWidth, ImageTableView::k_imageHeight));
|
||||
xCoordinate += k_textFieldWidth + k_textMargin;
|
||||
m_text[1].setFrame(KDRect(xCoordinate, 0, 7*k_charWidth, ImageTableView::k_imageHeight));
|
||||
xCoordinate += 7*k_charWidth + k_textMargin;
|
||||
m_calculationCell[1].setFrame(KDRect(xCoordinate, 0, k_textFieldWidth, ImageTableView::k_imageHeight));
|
||||
}
|
||||
|
||||
void CalculationController::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), KDColorWhite);
|
||||
}
|
||||
|
||||
LawCurveView * CalculationController::ContentView::lawCurveView() {
|
||||
|
||||
@@ -20,13 +20,19 @@ private:
|
||||
public:
|
||||
ContentView(Responder * parentResponder, Law * law);
|
||||
void layoutSubviews() override;
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
LawCurveView * lawCurveView();
|
||||
ImageTableView * imageTableView();
|
||||
private:
|
||||
constexpr static KDCoordinate k_textFieldWidth = 50;
|
||||
constexpr static KDCoordinate k_charWidth = 7;
|
||||
constexpr static KDCoordinate k_textMargin = 5;
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
LawCurveView m_lawCurveView;
|
||||
ImageTableView m_imageTableView;
|
||||
PointerTextView m_text[3];
|
||||
EditableTextCell m_calculationCell[3];
|
||||
};
|
||||
ContentView m_contentView;
|
||||
Law * m_law;
|
||||
|
||||
Reference in New Issue
Block a user