mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/stats] Draw table separators in Calculation
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#include "store_cell.h"
|
||||
#include "escher/metric.h"
|
||||
|
||||
namespace Shared {
|
||||
|
||||
void StoreCell::setSeparatorRight(bool separator) {
|
||||
if (separatorRight() != separator) {
|
||||
StoreSeparatorCell::setSeparatorRight(separator);
|
||||
void StoreCell::setSeparatorLeft(bool separator) {
|
||||
if (m_separatorLeft != separator) {
|
||||
m_separatorLeft = separator;
|
||||
reloadCell();
|
||||
}
|
||||
}
|
||||
@@ -12,14 +13,15 @@ void StoreCell::setSeparatorRight(bool separator) {
|
||||
void StoreCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
HideableEvenOddEditableTextCell::drawRect(ctx, rect);
|
||||
// Draw the separator
|
||||
if (separatorRight()) {
|
||||
ctx->fillRect(KDRect(bounds().width() - k_separatorThickness, 0, k_separatorThickness, bounds().height()), HideableEvenOddEditableTextCell::hideColor());
|
||||
KDRect separatorRect(0, 0, Metric::TableSeparatorThickness, bounds().height());
|
||||
if (m_separatorLeft) {
|
||||
ctx->fillRect(separatorRect, HideableEvenOddEditableTextCell::hideColor());
|
||||
}
|
||||
}
|
||||
|
||||
void StoreCell::layoutSubviews() {
|
||||
KDRect boundsThis = bounds();
|
||||
editableTextCell()->setFrame(KDRect(boundsThis.topLeft(), boundsThis.width() - k_separatorThickness, boundsThis.height()));
|
||||
editableTextCell()->setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness, boundsThis.height()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,19 +2,20 @@
|
||||
#define APPS_SHARED_STORE_CELL_H
|
||||
|
||||
#include "hideable_even_odd_editable_text_cell.h"
|
||||
#include "store_separator_cell.h"
|
||||
|
||||
namespace Shared {
|
||||
|
||||
class StoreCell : public HideableEvenOddEditableTextCell, public StoreSeparatorCell {
|
||||
class StoreCell : public HideableEvenOddEditableTextCell {
|
||||
public:
|
||||
StoreCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr) :
|
||||
HideableEvenOddEditableTextCell(parentResponder, delegate, draftTextBuffer),
|
||||
StoreSeparatorCell()
|
||||
m_separatorLeft(false)
|
||||
{}
|
||||
void setSeparatorRight(bool separator) override;
|
||||
void setSeparatorLeft(bool separator);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void layoutSubviews() override;
|
||||
private:
|
||||
bool m_separatorLeft;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ int StoreController::typeAtLocation(int i, int j) {
|
||||
void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||
// Handle the separator
|
||||
if (cellAtLocationIsEditable(i, j)) {
|
||||
bool shoudHaveRightSeparator = i % FloatPairStore::k_numberOfColumnsPerSeries == 1;
|
||||
static_cast<StoreCell *>(cell)->setSeparatorRight(shoudHaveRightSeparator);
|
||||
bool shouldHaveLeftSeparator = i % FloatPairStore::k_numberOfColumnsPerSeries == 0;
|
||||
static_cast<StoreCell *>(cell)->setSeparatorLeft(shouldHaveLeftSeparator);
|
||||
}
|
||||
// Handle empty cells
|
||||
if (j > 0 && j > m_store->numberOfPairsOfSeries(seriesAtColumn(i)) && j < numberOfRows()) {
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef APPS_SHARED_STORE_SEPARATOR_CELL_H
|
||||
#define APPS_SHARED_STORE_SEPARATOR_CELL_H
|
||||
|
||||
namespace Shared {
|
||||
|
||||
class StoreSeparatorCell {
|
||||
public:
|
||||
StoreSeparatorCell() :
|
||||
m_separatorRight(false)
|
||||
{}
|
||||
bool separatorRight() const { return m_separatorRight; }
|
||||
virtual void setSeparatorRight(bool separator) { m_separatorRight = separator; }
|
||||
protected:
|
||||
static constexpr KDCoordinate k_separatorThickness = 2;
|
||||
private:
|
||||
bool m_separatorRight;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,12 @@
|
||||
#include "store_title_cell.h"
|
||||
#include "hideable_even_odd_editable_text_cell.h"
|
||||
#include "escher/metric.h"
|
||||
|
||||
namespace Shared {
|
||||
|
||||
void StoreTitleCell::setSeparatorRight(bool separator) {
|
||||
if (separatorRight() != separator) {
|
||||
StoreSeparatorCell::setSeparatorRight(separator);
|
||||
void StoreTitleCell::setSeparatorLeft(bool separator) {
|
||||
if (m_separatorLeft != separator) {
|
||||
m_separatorLeft = separator;
|
||||
reloadCell();
|
||||
}
|
||||
}
|
||||
@@ -13,8 +14,8 @@ void StoreTitleCell::setSeparatorRight(bool separator) {
|
||||
void StoreTitleCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
BufferFunctionTitleCell::drawRect(ctx, rect);
|
||||
// Draw the separator
|
||||
KDRect separatorRect(bounds().width() - StoreSeparatorCell::k_separatorThickness, separatorRight() ? 0 : k_colorIndicatorThickness, StoreSeparatorCell::k_separatorThickness, bounds().height());
|
||||
if (separatorRight()) {
|
||||
KDRect separatorRect(0, m_separatorLeft ? 0 : k_colorIndicatorThickness, Metric::TableSeparatorThickness, bounds().height() - (m_separatorLeft ? 0 : k_colorIndicatorThickness));
|
||||
if (m_separatorLeft) {
|
||||
ctx->fillRect(separatorRect, HideableEvenOddEditableTextCell::hideColor());
|
||||
} else {
|
||||
ctx->fillRect(separatorRect, backgroundColor());
|
||||
@@ -23,7 +24,7 @@ void StoreTitleCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
|
||||
void StoreTitleCell::layoutSubviews() {
|
||||
KDRect textFrame = bufferTextViewFrame();
|
||||
bufferTextView()->setFrame(KDRect(textFrame.topLeft(), textFrame.width() - StoreSeparatorCell::k_separatorThickness, textFrame.height() ));
|
||||
bufferTextView()->setFrame(KDRect(textFrame.left() + Metric::TableSeparatorThickness, textFrame.top(), textFrame.width() - Metric::TableSeparatorThickness, textFrame.height()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,19 +2,20 @@
|
||||
#define SHARED_STORE_TITLE_CELL_H
|
||||
|
||||
#include "buffer_function_title_cell.h"
|
||||
#include "store_separator_cell.h"
|
||||
|
||||
namespace Shared {
|
||||
|
||||
class StoreTitleCell : public BufferFunctionTitleCell, public StoreSeparatorCell {
|
||||
class StoreTitleCell : public BufferFunctionTitleCell {
|
||||
public:
|
||||
StoreTitleCell(Orientation orientation, KDText::FontSize size = KDText::FontSize::Large) :
|
||||
BufferFunctionTitleCell(orientation, size),
|
||||
StoreSeparatorCell()
|
||||
m_separatorLeft(false)
|
||||
{}
|
||||
void setSeparatorRight(bool separator) override;
|
||||
void setSeparatorLeft(bool separator);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void layoutSubviews() override;
|
||||
private:
|
||||
bool m_separatorLeft;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ app_objs += $(addprefix apps/statistics/,\
|
||||
box_controller.o\
|
||||
box_range.o\
|
||||
box_view.o\
|
||||
calculation_cell.o\
|
||||
calculation_controller.o\
|
||||
histogram_banner_view.o\
|
||||
histogram_controller.o\
|
||||
|
||||
20
apps/statistics/calculation_cell.cpp
Normal file
20
apps/statistics/calculation_cell.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "calculation_cell.h"
|
||||
#include "../shared/hideable_even_odd_editable_text_cell.h"
|
||||
#include "escher/metric.h"
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
void CalculationCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
EvenOddBufferTextCell::drawRect(ctx, rect);
|
||||
// Draw the separator
|
||||
KDRect separatorRect(0, 0, Metric::TableSeparatorThickness, bounds().height());
|
||||
ctx->fillRect(separatorRect, Shared::HideableEvenOddEditableTextCell::hideColor());
|
||||
}
|
||||
|
||||
void CalculationCell::layoutSubviews() {
|
||||
KDRect boundsThis = bounds();
|
||||
m_bufferTextView.setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness, boundsThis.height()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
17
apps/statistics/calculation_cell.h
Normal file
17
apps/statistics/calculation_cell.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef APPS_STATISTICS_CALCULATION_CELL_H
|
||||
#define APPS_STATISTICS_CALCULATION_CELL_H
|
||||
|
||||
#include <escher/even_odd_buffer_text_cell.h>
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
class CalculationCell : public EvenOddBufferTextCell {
|
||||
public:
|
||||
using EvenOddBufferTextCell::EvenOddBufferTextCell;
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void layoutSubviews() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -200,14 +200,14 @@ Responder * CalculationController::tabController() const {
|
||||
View * CalculationController::loadView() {
|
||||
for (int i = 0; i < k_numberOfSeriesTitleCells; i++) {
|
||||
m_seriesTitleCells[i] = new StoreTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small);
|
||||
m_seriesTitleCells[i]->setSeparatorRight(true);
|
||||
m_seriesTitleCells[i]->setSeparatorLeft(true);
|
||||
}
|
||||
for (int i = 0; i < k_numberOfCalculationTitleCells; i++) {
|
||||
m_calculationTitleCells[i] = new EvenOddMessageTextCell(KDText::FontSize::Small);
|
||||
m_calculationTitleCells[i]->setAlignment(1.0f, 0.5f);
|
||||
}
|
||||
for (int i = 0; i < k_numberOfCalculationCells; i++) {
|
||||
m_calculationCells[i] = new EvenOddBufferTextCell(KDText::FontSize::Small);
|
||||
m_calculationCells[i] = new CalculationCell(KDText::FontSize::Small);
|
||||
m_calculationCells[i]->setTextColor(Palette::GreyDark);
|
||||
}
|
||||
m_hideableCell = new HideableEvenOddCell();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <escher.h>
|
||||
#include "store.h"
|
||||
#include "calculation_cell.h"
|
||||
#include "../shared/hideable_even_odd_cell.h"
|
||||
#include "../shared/store_title_cell.h"
|
||||
#include "../shared/tab_table_controller.h"
|
||||
@@ -60,7 +61,7 @@ private:
|
||||
|
||||
Shared::StoreTitleCell * m_seriesTitleCells[k_numberOfSeriesTitleCells];
|
||||
EvenOddMessageTextCell * m_calculationTitleCells[k_numberOfCalculationTitleCells];
|
||||
EvenOddBufferTextCell * m_calculationCells[k_numberOfCalculationCells];
|
||||
CalculationCell * m_calculationCells[k_numberOfCalculationCells];
|
||||
Shared::HideableEvenOddCell * m_hideableCell;
|
||||
Store * m_store;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int
|
||||
return;
|
||||
}
|
||||
Shared::StoreTitleCell * mytitleCell = static_cast<Shared::StoreTitleCell *>(cell);
|
||||
mytitleCell->setSeparatorRight(i % Store::k_numberOfColumnsPerSeries == 1);
|
||||
mytitleCell->setSeparatorLeft(i % Store::k_numberOfColumnsPerSeries == 0);
|
||||
int seriesIndex = i/Store::k_numberOfColumnsPerSeries;
|
||||
bool valuesColumn = i%Store::k_numberOfColumnsPerSeries == 0;
|
||||
assert(seriesIndex >= 0 && seriesIndex < FloatPairStore::k_numberOfSeries);
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
constexpr static KDCoordinate FractionAndConjugateHorizontalOverflow = 2;
|
||||
constexpr static KDCoordinate FractionAndConjugateHorizontalMargin = 2;
|
||||
constexpr static KDCoordinate MinimalBracketAndParenthesisHeight = 18;
|
||||
constexpr static KDCoordinate TableSeparatorThickness = 2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user