[apps] Color Series names if not empty in Statistics

This commit is contained in:
Léa Saviot
2018-05-22 11:42:08 +02:00
parent 54ca272eb1
commit b1e732e135
10 changed files with 38 additions and 37 deletions

View File

@@ -5,7 +5,6 @@ app_objs += $(addprefix apps/graph/,\
app.o\
cartesian_function.o\
cartesian_function_store.o\
function_title_cell.o\
graph/banner_view.o\
graph/calculation_graph_controller.o\
graph/calculation_parameter_controller.o\

View File

@@ -79,7 +79,7 @@ HighlightCell * ListController::expressionCells(int index) {
void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) {
FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell;
Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell;
CartesianFunction * function = ((CartesianFunctionStore *)m_functionStore)->functionAtIndex(j);
char bufferName[5] = {*function->name(),'(', m_functionStore->symbol(),')', 0};
myFunctionCell->setText(bufferName);
@@ -106,7 +106,7 @@ bool ListController::removeFunctionRow(Function * function) {
View * ListController::loadView() {
for (int i = 0; i < k_maxNumberOfRows; i++) {
m_functionTitleCells[i] = new FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator);
m_functionTitleCells[i] = new Shared::BufferFunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator);
m_expressionCells[i] = new FunctionExpressionCell();
}
return Shared::ListController::loadView();

View File

@@ -2,9 +2,9 @@
#define GRAPH_LIST_CONTROLLER_H
#include <escher.h>
#include "../function_title_cell.h"
#include "../../shared/function_expression_cell.h"
#include "../cartesian_function_store.h"
#include "../../shared/buffer_function_title_cell.h"
#include "../../shared/function_expression_cell.h"
#include "../../shared/new_function_cell.h"
#include "../../shared/list_controller.h"
#include "../../shared/list_parameter_controller.h"
@@ -29,7 +29,7 @@ private:
View * loadView() override;
void unloadView(View * view) override;
constexpr static int k_maxNumberOfRows = 5;
FunctionTitleCell * m_functionTitleCells[k_maxNumberOfRows];
Shared::BufferFunctionTitleCell * m_functionTitleCells[k_maxNumberOfRows];
Shared::FunctionExpressionCell * m_expressionCells[k_maxNumberOfRows];
Shared::ListParameterController m_parameterController;
};

View File

@@ -37,7 +37,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
}
// The cell is a function title cell:
if (j == 0 && i > 0) {
FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell;
Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell;
CartesianFunction * function = functionAtColumn(i);
char bufferName[6] = {0, 0, '(', 'x', ')', 0};
const char * name = nullptr;
@@ -122,7 +122,7 @@ int ValuesController::maxNumberOfFunctions() {
return k_maxNumberOfFunctions;
}
FunctionTitleCell * ValuesController::functionTitleCells(int j) {
Shared::BufferFunctionTitleCell * ValuesController::functionTitleCells(int j) {
assert(j >= 0 && j < k_maxNumberOfFunctions);
return m_functionTitleCells[j];
}
@@ -151,7 +151,7 @@ double ValuesController::evaluationOfAbscissaAtColumn(double abscissa, int colum
View * ValuesController::loadView() {
for (int i = 0; i < k_maxNumberOfFunctions; i++) {
m_functionTitleCells[i] = new FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small);
m_functionTitleCells[i] = new Shared::BufferFunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small);
}
for (int i = 0; i < k_maxNumberOfCells; i++) {
m_floatCells[i] = new EvenOddBufferTextCell();

View File

@@ -2,7 +2,7 @@
#define GRAPH_VALUES_CONTROLLER_H
#include "../cartesian_function_store.h"
#include "../function_title_cell.h"
#include "../../shared/buffer_function_title_cell.h"
#include "../../shared/values_controller.h"
#include "../../shared/interval_parameter_controller.h"
#include "derivative_parameter_controller.h"
@@ -27,8 +27,8 @@ private:
double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex) override;
constexpr static int k_maxNumberOfCells = 50;
constexpr static int k_maxNumberOfFunctions = 5;
FunctionTitleCell * m_functionTitleCells[k_maxNumberOfFunctions];
FunctionTitleCell * functionTitleCells(int j) override;
Shared::BufferFunctionTitleCell * m_functionTitleCells[k_maxNumberOfFunctions];
Shared::BufferFunctionTitleCell * functionTitleCells(int j) override;
EvenOddBufferTextCell * m_floatCells[k_maxNumberOfCells];
EvenOddBufferTextCell * floatCells(int j) override;
CartesianFunctionStore * m_functionStore;

View File

@@ -1,5 +1,6 @@
app_objs += $(addprefix apps/shared/,\
banner_view.o\
buffer_function_title_cell.o\
button_with_separator.o\
cursor_view.o\
curve_view.o\

View File

@@ -1,45 +1,43 @@
#include "function_title_cell.h"
#include "buffer_function_title_cell.h"
#include <assert.h>
using namespace Shared;
namespace Shared {
namespace Graph {
FunctionTitleCell::FunctionTitleCell(Orientation orientation, KDText::FontSize size) :
Shared::FunctionTitleCell(orientation),
BufferFunctionTitleCell::BufferFunctionTitleCell(Orientation orientation, KDText::FontSize size) :
FunctionTitleCell(orientation),
m_bufferTextView(size, 0.5f, 0.5f)
{
}
void FunctionTitleCell::setHighlighted(bool highlight) {
void BufferFunctionTitleCell::setHighlighted(bool highlight) {
EvenOddCell::setHighlighted(highlight);
m_bufferTextView.setHighlighted(highlight);
}
void FunctionTitleCell::setEven(bool even) {
void BufferFunctionTitleCell::setEven(bool even) {
EvenOddCell::setEven(even);
m_bufferTextView.setEven(even);
}
void FunctionTitleCell::setColor(KDColor color) {
Shared::FunctionTitleCell::setColor(color);
void BufferFunctionTitleCell::setColor(KDColor color) {
FunctionTitleCell::setColor(color);
m_bufferTextView.setTextColor(color);
}
void FunctionTitleCell::setText(const char * title) {
void BufferFunctionTitleCell::setText(const char * title) {
m_bufferTextView.setText(title);
}
int FunctionTitleCell::numberOfSubviews() const {
int BufferFunctionTitleCell::numberOfSubviews() const {
return 1;
}
View * FunctionTitleCell::subviewAtIndex(int index) {
View * BufferFunctionTitleCell::subviewAtIndex(int index) {
assert(index == 0);
return &m_bufferTextView;
}
void FunctionTitleCell::layoutSubviews() {
void BufferFunctionTitleCell::layoutSubviews() {
KDRect textFrame(0, k_colorIndicatorThickness, bounds().width(), bounds().height() - k_colorIndicatorThickness);
if (m_orientation == Orientation::VerticalIndicator){
textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness, bounds().height()-k_separatorThickness);

View File

@@ -1,13 +1,13 @@
#ifndef GRAPH_FUNCTION_TITLE_CELL_H
#define GRAPH_FUNCTION_TITLE_CELL_H
#ifndef SHARED_BUFFER_FUNCTION_TITLE_CELL_H
#define SHARED_BUFFER_FUNCTION_TITLE_CELL_H
#include "../shared/function_title_cell.h"
#include "function_title_cell.h"
namespace Graph {
namespace Shared {
class FunctionTitleCell : public Shared::FunctionTitleCell {
class BufferFunctionTitleCell : public FunctionTitleCell {
public:
FunctionTitleCell(Orientation orientation, KDText::FontSize size = KDText::FontSize::Large);
BufferFunctionTitleCell(Orientation orientation, KDText::FontSize size = KDText::FontSize::Large);
void setEven(bool even) override;
void setHighlighted(bool highlight) override;
void setColor(KDColor color) override;

View File

@@ -21,17 +21,19 @@ void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int
if (cellAtLocationIsEditable(i, j)) {
return;
}
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
Shared::BufferFunctionTitleCell * mytitleCell = (Shared::BufferFunctionTitleCell *)cell;
bool valuesColumn = i%k_numberOfColumnsPerSeries == 0;
int seriesIndex = i/k_numberOfColumnsPerSeries;
assert(seriesIndex >= 0 && seriesIndex < FloatPairStore::k_numberOfSeries);
if (valuesColumn) {
I18n::Message valuesMessages[] = {I18n::Message::Values1, I18n::Message::Values2, I18n::Message::Values3};
mytitleCell->setMessage(valuesMessages[seriesIndex]);
mytitleCell->setText(I18n::translate(valuesMessages[seriesIndex]));
} else {
I18n::Message sizesMessages[] = {I18n::Message::Sizes1, I18n::Message::Sizes2, I18n::Message::Sizes3};
mytitleCell->setMessage(sizesMessages[seriesIndex]);
mytitleCell->setText(I18n::translate(sizesMessages[seriesIndex]));
}
KDColor colors[] = {Palette::Red, Palette::Blue, Palette::Green};
mytitleCell->setColor(m_store->numberOfPairsOfSeries(seriesIndex) == 0 ? Palette::GreyDark : colors[seriesIndex]); // TODO Share GreyDark and other colors with graph/list_controller
}
HighlightCell * StoreController::titleCells(int index) {
@@ -53,7 +55,7 @@ bool StoreController::setDataAtLocation(double floatBody, int columnIndex, int r
View * StoreController::loadView() {
for (int i = 0; i < k_numberOfTitleCells; i++) {
m_titleCells[i] = new EvenOddMessageTextCell(KDText::FontSize::Small);
m_titleCells[i] = new Shared::BufferFunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small);
}
return Shared::StoreController::loadView();
}

View File

@@ -4,6 +4,7 @@
#include <escher.h>
#include "store.h"
#include "../shared/store_controller.h"
#include "../shared/buffer_function_title_cell.h"
namespace Statistics {
@@ -16,7 +17,7 @@ private:
HighlightCell * titleCells(int index) override;
View * loadView() override;
void unloadView(View * view) override;
EvenOddMessageTextCell * m_titleCells[k_numberOfTitleCells];
Shared::BufferFunctionTitleCell * m_titleCells[k_numberOfTitleCells];
};
}