[apps/probability] Improve the calculation selection button
Change-Id: Idddc06fd0158e357f82f43da27d3254fef25e211
@@ -74,24 +74,25 @@ void CalculationController::ContentView::layoutSubviews() {
|
||||
m_titleView.setFrame(KDRect(0, 0, bounds().width(), titleHeight));
|
||||
KDSize charSize = KDText::stringSize(" ");
|
||||
KDCoordinate xCoordinate = 0;
|
||||
m_lawCurveView.setFrame(KDRect(0, titleHeight+ImageTableView::k_imageCellHeight, bounds().width(), bounds().height() - ImageTableView::k_imageCellHeight-titleHeight));
|
||||
m_imageTableView.setFrame(KDRect(xCoordinate, titleHeight, ImageTableView::k_imageCellWidth, 3*ImageTableView::k_imageCellHeight));
|
||||
xCoordinate += ImageTableView::k_imageCellWidth + k_textWidthMargin;
|
||||
m_lawCurveView.setFrame(KDRect(0, titleHeight+ImageTableView::k_oneCellHeight, bounds().width(), bounds().height() - ImageTableView::k_oneCellHeight-titleHeight));
|
||||
KDSize tableSize = m_imageTableView.minimalSizeForOptimalDisplay();
|
||||
m_imageTableView.setFrame(KDRect(xCoordinate, titleHeight, tableSize));
|
||||
xCoordinate += tableSize.width() + k_textWidthMargin;
|
||||
KDCoordinate numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(0)));
|
||||
m_text[0].setFrame(KDRect(xCoordinate, titleHeight+ImageCell::k_imageMargin, numberOfCharacters*charSize.width(), ImageCell::k_imageHeight));
|
||||
m_text[0].setFrame(KDRect(xCoordinate, titleHeight+ImageTableView::k_totalMargin, numberOfCharacters*charSize.width(), ImageCell::k_height));
|
||||
xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin;
|
||||
m_calculationCell[0].setFrame(KDRect(xCoordinate, titleHeight+ImageCell::k_imageMargin, k_textFieldWidth, ImageCell::k_imageHeight));
|
||||
m_calculationCell[0].setFrame(KDRect(xCoordinate, titleHeight+ImageTableView::k_totalMargin, k_textFieldWidth, ImageCell::k_height));
|
||||
xCoordinate += k_textFieldWidth + k_textWidthMargin;
|
||||
numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(1)));
|
||||
m_text[1].setFrame(KDRect(xCoordinate, titleHeight+ImageCell::k_imageMargin, numberOfCharacters*charSize.width(), ImageCell::k_imageHeight));
|
||||
m_text[1].setFrame(KDRect(xCoordinate, titleHeight+ImageTableView::k_totalMargin, numberOfCharacters*charSize.width(), ImageCell::k_height));
|
||||
xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin;
|
||||
m_calculationCell[1].setFrame(KDRect(xCoordinate, titleHeight+ImageCell::k_imageMargin, k_textFieldWidth, ImageCell::k_imageHeight));
|
||||
m_calculationCell[1].setFrame(KDRect(xCoordinate, titleHeight+ImageTableView::k_totalMargin, k_textFieldWidth, ImageCell::k_height));
|
||||
xCoordinate += k_textFieldWidth + k_textWidthMargin;
|
||||
if (m_calculation->numberOfParameters() > 2) {
|
||||
numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(2)));;
|
||||
m_text[2].setFrame(KDRect(xCoordinate, titleHeight+ImageCell::k_imageMargin, numberOfCharacters*charSize.width(), ImageCell::k_imageHeight));
|
||||
m_text[2].setFrame(KDRect(xCoordinate, titleHeight+ImageTableView::k_totalMargin, numberOfCharacters*charSize.width(), ImageCell::k_height));
|
||||
xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin;
|
||||
m_calculationCell[2].setFrame(KDRect(xCoordinate, titleHeight+ImageCell::k_imageMargin, k_textFieldWidth, ImageCell::k_imageHeight));
|
||||
m_calculationCell[2].setFrame(KDRect(xCoordinate, titleHeight+ImageTableView::k_totalMargin, k_textFieldWidth, ImageCell::k_height));
|
||||
}
|
||||
for (int k = 0; k < m_calculation->numberOfParameters(); k++) {
|
||||
willDisplayEditableCellAtIndex(k);
|
||||
@@ -99,20 +100,20 @@ void CalculationController::ContentView::layoutSubviews() {
|
||||
}
|
||||
|
||||
void CalculationController::ContentView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), KDColorWhite);
|
||||
KDCoordinate titleHeight = KDText::stringSize("", KDText::FontSize::Small).height()+k_titleHeightMargin;
|
||||
ctx->fillRect(KDRect(0,titleHeight, bounds().width(), ImageTableView::k_oneCellWidth), KDColorWhite);
|
||||
KDSize charSize = KDText::stringSize(" ");
|
||||
KDCoordinate xCoordinate = ImageTableView::k_imageCellWidth + k_textWidthMargin;
|
||||
KDCoordinate xCoordinate = ImageTableView::k_oneCellWidth + k_textWidthMargin;
|
||||
KDCoordinate numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(0)));
|
||||
xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin;
|
||||
|
||||
ctx->drawRect(KDRect(xCoordinate-1, titleHeight+ImageCell::k_imageMargin-1, k_textFieldWidth+1, ImageCell::k_imageHeight+1), Palette::GreyMiddle);
|
||||
ctx->drawRect(KDRect(xCoordinate-ImageTableView::k_outline, titleHeight+ImageTableView::k_margin, k_textFieldWidth+ImageTableView::k_outline, ImageCell::k_height+ImageTableView::k_outline), Palette::GreyMiddle);
|
||||
|
||||
xCoordinate += k_textFieldWidth + k_textWidthMargin;
|
||||
numberOfCharacters = strlen(I18n::translate(m_calculation->legendForParameterAtIndex(1)));
|
||||
xCoordinate += numberOfCharacters*charSize.width() + k_textWidthMargin;
|
||||
|
||||
ctx->drawRect(KDRect(xCoordinate-1, titleHeight+ImageCell::k_imageMargin-1, k_textFieldWidth+1, ImageCell::k_imageHeight+1), Palette::GreyMiddle);
|
||||
ctx->drawRect(KDRect(xCoordinate-ImageTableView::k_outline, titleHeight+ImageTableView::k_margin, k_textFieldWidth+ImageTableView::k_outline, ImageCell::k_height+ImageTableView::k_outline), Palette::GreyMiddle);
|
||||
}
|
||||
|
||||
LawCurveView * CalculationController::ContentView::lawCurveView() {
|
||||
|
||||
@@ -15,15 +15,6 @@ ImageCell::ImageCell() :
|
||||
{
|
||||
}
|
||||
|
||||
void ImageCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
ctx->fillRect(KDRect(0,0, width, k_imageMargin), KDColorWhite);
|
||||
ctx->fillRect(KDRect(0,0, k_imageMargin, height), KDColorWhite);
|
||||
ctx->fillRect(KDRect(0,height-k_imageMargin, width, k_imageMargin), KDColorWhite);
|
||||
ctx->fillRect(KDRect(width-k_imageMargin,0, k_imageMargin, height), KDColorWhite);
|
||||
}
|
||||
|
||||
int ImageCell::numberOfSubviews() const {
|
||||
return 1;
|
||||
}
|
||||
@@ -34,9 +25,7 @@ View * ImageCell::subviewAtIndex(int index) {
|
||||
}
|
||||
|
||||
void ImageCell::layoutSubviews() {
|
||||
KDCoordinate width = bounds().width();
|
||||
KDCoordinate height = bounds().height();
|
||||
m_iconView.setFrame(KDRect(k_imageMargin, k_imageMargin, width - 2*k_imageMargin, height-2*k_imageMargin));
|
||||
m_iconView.setFrame(bounds());
|
||||
}
|
||||
|
||||
void ImageCell::reloadCell() {
|
||||
@@ -64,6 +53,14 @@ ImageTableView::ImageTableView(Responder * parentResponder, Calculation * calcul
|
||||
assert(m_calculation != nullptr);
|
||||
}
|
||||
|
||||
void ImageTableView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->drawRect(KDRect(k_margin, k_margin, ImageCell::k_width+k_outline, ImageCell::k_height+k_outline), Palette::GreyMiddle);
|
||||
}
|
||||
|
||||
KDSize ImageTableView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(2*k_totalMargin+ImageCell::k_width, k_totalMargin+3*ImageCell::k_height);
|
||||
}
|
||||
|
||||
void ImageTableView::didBecomeFirstResponder() {
|
||||
m_selectableTableView.reloadData();
|
||||
m_isSelected = true;
|
||||
@@ -141,7 +138,7 @@ void ImageTableView::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
}
|
||||
|
||||
KDCoordinate ImageTableView::cellHeight() {
|
||||
return k_imageCellHeight;
|
||||
return ImageCell::k_height;
|
||||
}
|
||||
|
||||
int ImageTableView::numberOfSubviews() const {
|
||||
@@ -154,7 +151,7 @@ View * ImageTableView::subviewAtIndex(int index) {
|
||||
}
|
||||
|
||||
void ImageTableView::layoutSubviews() {
|
||||
m_selectableTableView.setFrame(bounds());
|
||||
m_selectableTableView.setFrame(KDRect(k_totalMargin, k_totalMargin, bounds().width()-2*k_totalMargin, bounds().height()-k_totalMargin));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,10 @@ class CalculationController;
|
||||
class ImageCell : public HighlightCell {
|
||||
public:
|
||||
ImageCell();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void reloadCell() override;
|
||||
void setImage(const Image * image, const Image * focusedImage);
|
||||
constexpr static KDCoordinate k_imageMargin = 3;
|
||||
constexpr static KDCoordinate k_imageWidth = 35;
|
||||
constexpr static KDCoordinate k_imageHeight = 19;
|
||||
constexpr static KDCoordinate k_width = 39;
|
||||
constexpr static KDCoordinate k_height = 23;
|
||||
private:
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
@@ -27,9 +25,10 @@ private:
|
||||
};
|
||||
|
||||
class ImageTableView : public View, public Responder, public SimpleListViewDataSource, public SelectableTableViewDataSource {
|
||||
public:
|
||||
ImageTableView(Responder * parentResponder, Calculation * calculation, CalculationController * calculationController);
|
||||
void setCalculation(Calculation * calculation, int index);
|
||||
public:
|
||||
ImageTableView(Responder * parentResponder, Calculation * calculation, CalculationController * calculationController);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void didBecomeFirstResponder() override;
|
||||
void willExitResponderChain(Responder * nextFirstResponder) override;
|
||||
@@ -40,8 +39,11 @@ class ImageTableView : public View, public Responder, public SimpleListViewDataS
|
||||
KDCoordinate cellHeight() override;
|
||||
HighlightCell * reusableCell(int index) override;
|
||||
int reusableCellCount() override;
|
||||
constexpr static KDCoordinate k_imageCellWidth = 2*ImageCell::k_imageMargin+ImageCell::k_imageWidth;
|
||||
constexpr static KDCoordinate k_imageCellHeight = 2*ImageCell::k_imageMargin+ImageCell::k_imageHeight;
|
||||
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;
|
||||
private:
|
||||
int numberOfSubviews() const override;
|
||||
View * subviewAtIndex(int index) override;
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 55 KiB |