[apps/graph] Margins in values title cells

This commit is contained in:
Léa Saviot
2019-09-04 11:29:10 +02:00
parent 30fee1fffe
commit f4bbab76ed
5 changed files with 60 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ app_graph_src = $(addprefix apps/graph/,\
list/text_field_function_title_cell.cpp \
list/type_helper.cpp \
list/type_parameter_controller.cpp \
values/abscissa_title_cell.cpp \
values/derivative_parameter_controller.cpp \
values/function_parameter_controller.cpp \
values/interval_parameter_selector_controller.cpp \

View File

@@ -0,0 +1,26 @@
#include "abscissa_title_cell.h"
#include <apps/shared/hideable_even_odd_editable_text_cell.h>
#include "escher/metric.h"
namespace Graph {
void AbscissaTitleCell::setSeparatorLeft(bool separator) {
if (m_separatorLeft != separator) {
m_separatorLeft = separator;
reloadCell();
}
}
void AbscissaTitleCell::drawRect(KDContext * ctx, KDRect rect) const {
EvenOddMessageTextCell::drawRect(ctx, rect);
// Draw the separator
KDRect separatorRect(0, 0, Metric::TableSeparatorThickness, bounds().height());
ctx->fillRect(separatorRect, m_separatorLeft ? Shared::HideableEvenOddEditableTextCell::hideColor() : backgroundColor());
}
void AbscissaTitleCell::layoutSubviews() {
KDRect rect = bounds();
m_messageTextView.setFrame(KDRect(rect.left() + (m_separatorLeft ? Metric::TableSeparatorThickness : 0), rect.top(), rect.width() - (m_separatorLeft ? Metric::TableSeparatorThickness : 0), rect.height()));
}
}

View File

@@ -0,0 +1,25 @@
#ifndef GRAPH_ABSCISSA_TITLE_CELL_H
#define GRAPH_ABSCISSA_TITLE_CELL_H
#include <escher/even_odd_message_text_cell.h>
namespace Graph {
// TODO LEA copied from Shared::StoreTitleCell -> refactor?
class AbscissaTitleCell : public EvenOddMessageTextCell {
public:
AbscissaTitleCell() :
EvenOddMessageTextCell(),
m_separatorLeft(false)
{}
void setSeparatorLeft(bool separator);
void drawRect(KDContext * ctx, KDRect rect) const override;
void layoutSubviews() override;
private:
bool m_separatorLeft;
};
}
#endif

View File

@@ -12,6 +12,8 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle
Shared::ValuesController(parentResponder, header, interval),
m_functionTitleCells{},
m_floatCells{},
m_abscissaTitleCells{},
m_abscissaCells{},
m_functionParameterController(this),
m_intervalParameterController(this, inputEventHandlerDelegate, m_interval),
m_derivativeParameterController(this),
@@ -33,10 +35,11 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
int typeAtLoc = typeAtLocation(i,j);
if (typeAtLoc == k_abscissaTitleCellType) {
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
AbscissaTitleCell * myTitleCell = (AbscissaTitleCell *)cell;
Ion::Storage::Record record = recordAtColumn(i+1);
Shared::ExpiringPointer<CartesianFunction> function = functionStore()->modelForRecord(record);
mytitleCell->setMessage(function->parameterMessageName());
myTitleCell->setMessage(function->parameterMessageName());
myTitleCell->setSeparatorLeft(i > 0);
return;
}
if (typeAtLoc == k_functionTitleCellType) {

View File

@@ -6,6 +6,7 @@
#include "../../shared/values_controller.h"
#include "../../shared/interval_parameter_controller.h"
#include "../../shared/store_cell.h"
#include "abscissa_title_cell.h"
#include "interval_parameter_selector_controller.h"
#include "derivative_parameter_controller.h"
#include "function_parameter_controller.h"
@@ -45,14 +46,14 @@ private:
int abscissaCellsCount() const override { return k_maxNumberOfAbscissaCells; }
EvenOddEditableTextCell * abscissaCells(int j) override { assert (j >= 0 && j < k_maxNumberOfAbscissaCells); return &m_abscissaCells[j]; }
int abscissaTitleCellsCount() const override { return Shared::CartesianFunction::k_numberOfPlotTypes; }
EvenOddMessageTextCell * abscissaTitleCells(int j) override { assert (j >= 0 && j < abscissaTitleCellsCount()); return &m_abscissaTitleCell[j]; }
EvenOddMessageTextCell * abscissaTitleCells(int j) override { assert (j >= 0 && j < abscissaTitleCellsCount()); return &m_abscissaTitleCells[j]; }
ViewController * functionParameterController() override;
I18n::Message valuesParameterControllerPageTitle() const override;
int m_numberOfColumnsForType[Shared::CartesianFunction::k_numberOfPlotTypes];
Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfFunctions];
EvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
EvenOddMessageTextCell m_abscissaTitleCell[Shared::CartesianFunction::k_numberOfPlotTypes];
AbscissaTitleCell m_abscissaTitleCells[Shared::CartesianFunction::k_numberOfPlotTypes];
Shared::StoreCell m_abscissaCells[k_maxNumberOfAbscissaCells];
FunctionParameterController m_functionParameterController;
Shared::IntervalParameterController m_intervalParameterController;