[apps/stats] Fix margins and column widths

This commit is contained in:
Léa Saviot
2018-05-30 10:00:51 +02:00
parent cf03d7e7ac
commit 1e7069f00e
11 changed files with 49 additions and 12 deletions

View File

@@ -21,7 +21,7 @@ void StoreCell::drawRect(KDContext * ctx, KDRect rect) const {
void StoreCell::layoutSubviews() {
KDRect boundsThis = bounds();
editableTextCell()->setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness, boundsThis.height()));
editableTextCell()->setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness - k_rightMargin, boundsThis.height()));
}
}

View File

@@ -15,6 +15,7 @@ public:
void drawRect(KDContext * ctx, KDRect rect) const override;
void layoutSubviews() override;
private:
static constexpr KDCoordinate k_rightMargin = 2;
bool m_separatorLeft;
};

View File

@@ -34,11 +34,11 @@ public:
void didBecomeFirstResponder() override;
protected:
static constexpr KDCoordinate k_cellWidth = 80; //TODO
static constexpr KDCoordinate k_cellWidth = 116;
static constexpr KDCoordinate k_margin = 8;
static constexpr KDCoordinate k_scrollBarMargin = Metric::CommonRightMargin;
constexpr static int k_maxNumberOfEditableCells = 22 * FloatPairStore::k_numberOfSeries;
constexpr static int k_numberOfTitleCells = FloatPairStore::k_numberOfColumnsPerSeries * FloatPairStore::k_numberOfSeries; // TODO Put finer number of cells
constexpr static int k_numberOfTitleCells = 4;
static constexpr int k_titleCellType = 0;
static constexpr int k_editableCellType = 1;
Responder * tabController() const override;

View File

@@ -11,6 +11,7 @@ app_objs += $(addprefix apps/statistics/,\
calculation_cell.o\
calculation_controller.o\
calculation_selectable_table_view.o\
calculation_title_cell.o\
histogram_banner_view.o\
histogram_controller.o\
histogram_parameter_controller.o\

View File

@@ -40,7 +40,7 @@ void BoxController::reloadBannerView() {
// Set series name
char seriesChar = '0' + selectedSeries() + 1;
char bufferName[] = {'V', seriesChar, '/', 'N', seriesChar, 0};
char bufferName[] = {' ', 'V', seriesChar, '/', 'N', seriesChar, 0};
m_view.editableBannerView()->setLegendAtIndex(bufferName, 0);
@@ -49,11 +49,13 @@ void BoxController::reloadBannerView() {
m_view.editableBannerView()->setMessageAtIndex(calculationName[selectedQuantile], 1);
// Set calculation result
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits) + 1];
CalculPointer calculationMethods[5] = {&Store::minValue, &Store::firstQuartile, &Store::median, &Store::thirdQuartile,
&Store::maxValue};
double calculation = (m_store->*calculationMethods[selectedQuantile])(selectedSeries());
PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
int numberOfChar = PrintFloat::convertFloatToText<double>(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
buffer[numberOfChar++] = ' ';
buffer[numberOfChar] = 0;
m_view.editableBannerView()->setLegendAtIndex(buffer, 2);
}

View File

@@ -13,7 +13,7 @@ void CalculationCell::drawRect(KDContext * ctx, KDRect rect) const {
void CalculationCell::layoutSubviews() {
KDRect boundsThis = bounds();
m_bufferTextView.setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness, boundsThis.height()));
m_bufferTextView.setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness - k_rightMargin, boundsThis.height()));
}
}

View File

@@ -10,6 +10,8 @@ public:
using EvenOddBufferTextCell::EvenOddBufferTextCell;
void drawRect(KDContext * ctx, KDRect rect) const override;
void layoutSubviews() override;
private:
constexpr static KDCoordinate k_rightMargin = 2;
};
}

View File

@@ -75,8 +75,8 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
I18n::Message::Sum,
I18n::Message::SquareSum,
I18n::Message::SampleStandardDeviationS};
EvenOddMessageTextCell * evenOddMessageCell = static_cast<EvenOddMessageTextCell *>(cell);
evenOddMessageCell->setMessage(titles[j-1]);
CalculationTitleCell * calcTitleCell = static_cast<CalculationTitleCell *>(cell);
calcTitleCell->setMessage(titles[j-1]);
return;
}
// Display a calculation cell
@@ -205,7 +205,7 @@ View * CalculationController::loadView() {
m_seriesTitleCells[i]->setSeparatorLeft(true);
}
for (int i = 0; i < k_numberOfCalculationTitleCells; i++) {
m_calculationTitleCells[i] = new EvenOddMessageTextCell(KDText::FontSize::Small);
m_calculationTitleCells[i] = new CalculationTitleCell(KDText::FontSize::Small);
m_calculationTitleCells[i]->setAlignment(1.0f, 0.5f);
}
for (int i = 0; i < k_numberOfCalculationCells; i++) {

View File

@@ -4,6 +4,7 @@
#include <escher.h>
#include "store.h"
#include "calculation_cell.h"
#include "calculation_title_cell.h"
#include "../shared/hideable_even_odd_cell.h"
#include "../shared/store_title_cell.h"
#include "../shared/tab_table_controller.h"
@@ -53,7 +54,7 @@ private:
static constexpr int k_hideableCellType = 3;
static constexpr KDCoordinate k_cellHeight = 20;
static constexpr KDCoordinate k_calculationTitleCellWidth = 175;
static constexpr KDCoordinate k_calculationCellWidth = 70;
static constexpr KDCoordinate k_calculationCellWidth = 84;
static constexpr KDCoordinate k_margin = 8;
static constexpr KDCoordinate k_scrollBarMargin = Metric::CommonRightMargin;
@@ -62,7 +63,7 @@ private:
void unloadView(View * view) override;
Shared::StoreTitleCell * m_seriesTitleCells[k_numberOfSeriesTitleCells];
EvenOddMessageTextCell * m_calculationTitleCells[k_numberOfCalculationTitleCells];
CalculationTitleCell * m_calculationTitleCells[k_numberOfCalculationTitleCells];
CalculationCell * m_calculationCells[k_numberOfCalculationCells];
Shared::HideableEvenOddCell * m_hideableCell;
Store * m_store;

View File

@@ -0,0 +1,10 @@
#include "calculation_title_cell.h"
namespace Statistics {
void CalculationTitleCell::layoutSubviews() {
m_messageTextView.setFrame(KDRect(bounds().topLeft(), bounds().width() - k_rightMargin, bounds().height()));
}
}

View File

@@ -0,0 +1,20 @@
#ifndef APPS_STATISTICS_CALCULATION_TITLE_CELL_H
#define APPS_STATISTICS_CALCULATION_TITLE_CELL_H
#include <escher/even_odd_message_text_cell.h>
namespace Statistics {
class CalculationTitleCell : public EvenOddMessageTextCell {
public:
CalculationTitleCell(KDText::FontSize size = KDText::FontSize::Small) :
EvenOddMessageTextCell(size)
{}
void layoutSubviews() override;
private:
constexpr static KDCoordinate k_rightMargin = 2;
};
}
#endif