[apps] Probability: clean table margins (replace weird cell margins by

table margins)
This commit is contained in:
Émilie Feral
2017-12-22 14:16:49 +01:00
committed by EmilieNumworks
parent 30e6d0b3f0
commit fa127ced4e
4 changed files with 9 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ View * CalculationController::ContentView::subviewAtIndex(int index) {
void CalculationController::ContentView::layoutSubviews() {
KDCoordinate titleHeight = KDText::charSize(KDText::FontSize::Small).height()+k_titleHeightMargin;
m_titleView.setFrame(KDRect(0, 0, bounds().width(), titleHeight));
KDCoordinate calculationHeight = ResponderImageCell::k_oneCellHeight;
KDCoordinate calculationHeight = ResponderImageCell::k_oneCellHeight+2*k_tableMargin;
m_selectableTableView->setFrame(KDRect(0, titleHeight, bounds().width(), calculationHeight));
m_lawCurveView.setFrame(KDRect(0, titleHeight+calculationHeight, bounds().width(), bounds().height() - calculationHeight - titleHeight));
}
@@ -55,7 +55,7 @@ void CalculationController::ContentView::layoutSubviews() {
CalculationController::CalculationController(Responder * parentResponder, Law * law, Calculation * calculation) :
ViewController(parentResponder),
m_contentView(&m_selectableTableView, law, calculation),
m_selectableTableView(this, this, 0, 0, 0, 0, 0, 0, this, nullptr, false, true, KDColorWhite),
m_selectableTableView(this, this, 0, 0, k_tableMargin, k_tableMargin, k_tableMargin, k_tableMargin, this, nullptr, false, true, KDColorWhite),
m_imageCell(&m_selectableTableView, law, calculation, this),
m_draftTextBuffer{},
m_calculation(calculation),

View File

@@ -49,6 +49,7 @@ public:
void setCalculationAccordingToIndex(int index, bool forceReinitialisation = false);
private:
constexpr static int k_numberOfCalculationCells = 3;
constexpr static KDCoordinate k_tableMargin = 3;
Shared::TextFieldDelegateApp * textFieldDelegateApp() override;
void updateTitle();
class ContentView : public View {

View File

@@ -12,16 +12,16 @@ ResponderImageCell::ResponderImageCell(Responder * parentResponder, Law * law, C
void ResponderImageCell::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(bounds(), KDColorWhite);
ctx->strokeRect(KDRect(k_margin, k_margin, ImageCell::k_width+2*k_outline, ImageCell::k_height+2*k_outline), Palette::GreyMiddle);
ctx->strokeRect(KDRect(0, 0, ImageCell::k_width+2*k_outline, ImageCell::k_height+2*k_outline), Palette::GreyMiddle);
}
KDSize ResponderImageCell::minimalSizeForOptimalDisplay() const {
return KDSize(2*k_totalMargin+ImageCell::k_width, 2*k_totalMargin*ImageCell::k_height);
return KDSize(2*k_outline+ImageCell::k_width, 2*k_outline*ImageCell::k_height);
}
bool ResponderImageCell::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Down) {
KDPoint topLeftAngle = app()->modalView()->pointFromPointInView(this, KDPoint(k_totalMargin, k_totalMargin));
KDPoint topLeftAngle = app()->modalView()->pointFromPointInView(this, KDPoint(k_outline, k_outline));
app()->displayModalViewController(&m_calculationTypeController, 0.0f, 0.0f, topLeftAngle.y(), topLeftAngle.x());
return true;
}
@@ -47,7 +47,7 @@ View * ResponderImageCell::subviewAtIndex(int index) {
}
void ResponderImageCell::layoutSubviews() {
m_imageCell.setFrame(KDRect(k_totalMargin, k_totalMargin, bounds().width()-2*k_totalMargin, bounds().height()-2*k_totalMargin));
m_imageCell.setFrame(KDRect(k_outline, k_outline, bounds().width()-2*k_outline, bounds().height()-2*k_outline));
}
}

View File

@@ -20,10 +20,8 @@ public:
void setHighlighted(bool highlight) override;
void setImage(const Image * image, const Image * focusedImage);
constexpr static KDCoordinate k_outline = 1;
constexpr static KDCoordinate k_margin = 3;
constexpr static KDCoordinate k_totalMargin = k_outline+k_margin;
constexpr static KDCoordinate k_oneCellWidth = 2*k_totalMargin+ImageCell::k_width;
constexpr static KDCoordinate k_oneCellHeight = 2*k_totalMargin+ImageCell::k_height;
constexpr static KDCoordinate k_oneCellWidth = 2*k_outline+ImageCell::k_width;
constexpr static KDCoordinate k_oneCellHeight = 2*k_outline+ImageCell::k_height;
private:
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;