mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 18:20:14 +01:00
[apps/reg] Color the columns titles in Stats
This commit is contained in:
@@ -5,6 +5,7 @@ app_objs += $(addprefix apps/regression/,\
|
||||
app.o\
|
||||
banner_view.o\
|
||||
calculation_controller.o\
|
||||
column_title_cell.o\
|
||||
even_odd_buffer_text_cell_with_margin.o\
|
||||
even_odd_double_buffer_text_cell_with_separator.o\
|
||||
even_odd_expression_cell_with_margin.o\
|
||||
|
||||
@@ -145,11 +145,12 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
|
||||
// Coordinate and series title
|
||||
if (j == 0 && i > 0) {
|
||||
EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)cell;
|
||||
ColumnTitleCell * myCell = (ColumnTitleCell *)cell;
|
||||
char buffer[] = {'X', static_cast<char>('0' + seriesNumber), 0};
|
||||
myCell->setFirstText(buffer);
|
||||
buffer[0] = 'Y';
|
||||
myCell->setSecondText(buffer);
|
||||
myCell->setColor(Palette::DataColor[seriesNumber]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -259,7 +260,7 @@ View * CalculationController::loadView() {
|
||||
;
|
||||
m_r2TitleCell = new EvenOddExpressionCellWithMargin(1.0f, 0.5f);
|
||||
for (int i = 0; i < Store::k_numberOfSeries; i++) {
|
||||
m_columnTitleCells[i] = new EvenOddDoubleBufferTextCellWithSeparator(tableView);
|
||||
m_columnTitleCells[i] = new ColumnTitleCell(tableView);
|
||||
}
|
||||
for (int i = 0; i < k_maxNumberOfDisplayableRows; i++) {
|
||||
m_titleCells[i] = new MarginEvenOddMessageTextCell(KDText::FontSize::Small);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <escher.h>
|
||||
#include "store.h"
|
||||
#include "column_title_cell.h"
|
||||
#include "even_odd_double_buffer_text_cell_with_separator.h"
|
||||
#include "even_odd_expression_cell_with_margin.h"
|
||||
#include "../shared/margin_even_odd_message_text_cell.h"
|
||||
@@ -60,7 +61,7 @@ private:
|
||||
Shared::MarginEvenOddMessageTextCell * m_titleCells[k_maxNumberOfDisplayableRows];
|
||||
EvenOddExpressionCellWithMargin * m_r2TitleCell;
|
||||
Poincare::ExpressionLayout * m_r2Layout;
|
||||
EvenOddDoubleBufferTextCellWithSeparator * m_columnTitleCells[Store::k_numberOfSeries];
|
||||
ColumnTitleCell * m_columnTitleCells[Store::k_numberOfSeries];
|
||||
EvenOddDoubleBufferTextCellWithSeparator * m_doubleCalculationCells[k_numberOfDoubleCalculationCells];
|
||||
Shared::SeparatorEvenOddBufferTextCell * m_calculationCells[k_numberOfCalculationCells];
|
||||
Store * m_store;
|
||||
|
||||
24
apps/regression/column_title_cell.cpp
Normal file
24
apps/regression/column_title_cell.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "column_title_cell.h"
|
||||
|
||||
namespace Regression {
|
||||
|
||||
void ColumnTitleCell::setColor(KDColor color) {
|
||||
m_functionColor = color;
|
||||
m_firstBufferTextView.setTextColor(color);
|
||||
m_secondBufferTextView.setTextColor(color);
|
||||
reloadCell();
|
||||
}
|
||||
|
||||
void ColumnTitleCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
EvenOddDoubleBufferTextCellWithSeparator::drawRect(ctx, rect);
|
||||
ctx->fillRect(KDRect(Metric::TableSeparatorThickness, 0, bounds().width(), k_colorIndicatorThickness), m_functionColor);
|
||||
}
|
||||
|
||||
void ColumnTitleCell::layoutSubviews() {
|
||||
KDCoordinate width = bounds().width() - Metric::TableSeparatorThickness;
|
||||
KDCoordinate height = bounds().height();
|
||||
m_firstBufferTextView.setFrame(KDRect(Metric::TableSeparatorThickness, k_colorIndicatorThickness, width/2, height - k_colorIndicatorThickness));
|
||||
m_secondBufferTextView.setFrame(KDRect(Metric::TableSeparatorThickness + width/2, k_colorIndicatorThickness, width/2, height - k_colorIndicatorThickness));
|
||||
}
|
||||
|
||||
}
|
||||
25
apps/regression/column_title_cell.h
Normal file
25
apps/regression/column_title_cell.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef REGRESSION_COLUMN_TITLE_CELL_H
|
||||
#define REGRESSION_COLUMN_TITLE_CELL_H
|
||||
|
||||
#include "even_odd_double_buffer_text_cell_with_separator.h"
|
||||
|
||||
namespace Regression {
|
||||
|
||||
class ColumnTitleCell : public EvenOddDoubleBufferTextCellWithSeparator {
|
||||
public:
|
||||
ColumnTitleCell(Responder * parentResponder = nullptr) :
|
||||
EvenOddDoubleBufferTextCellWithSeparator(parentResponder, 0.5f, 0.5f),
|
||||
m_functionColor(Palette::Red)
|
||||
{
|
||||
}
|
||||
virtual void setColor(KDColor color);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void layoutSubviews() override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_colorIndicatorThickness = 2;
|
||||
KDColor m_functionColor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
namespace Regression {
|
||||
|
||||
EvenOddDoubleBufferTextCellWithSeparator::EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder) :
|
||||
EvenOddDoubleBufferTextCellWithSeparator::EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder, float horizontalAlignment, float verticalAlignment) :
|
||||
EvenOddCell(),
|
||||
Responder(parentResponder),
|
||||
m_firstTextSelected(true),
|
||||
m_firstBufferTextView(KDText::FontSize::Small),
|
||||
m_secondBufferTextView(KDText::FontSize::Small)
|
||||
m_firstBufferTextView(KDText::FontSize::Small, horizontalAlignment, verticalAlignment),
|
||||
m_secondBufferTextView(KDText::FontSize::Small, horizontalAlignment, verticalAlignment)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Regression {
|
||||
|
||||
class EvenOddDoubleBufferTextCellWithSeparator : public EvenOddCell, public Responder{
|
||||
public:
|
||||
EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder = nullptr);
|
||||
EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder = nullptr, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f);
|
||||
const char * firstText();
|
||||
const char * secondText();
|
||||
void reloadCell() override;
|
||||
|
||||
Reference in New Issue
Block a user