mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/graph/values] Create a parameter page to configure the abscissa
column Change-Id: I69bad8037ece0c421a96fe8b190146f23912ca90
This commit is contained in:
@@ -12,6 +12,7 @@ app_objs += $(addprefix apps/graph/,\
|
||||
list/function_name_view.o\
|
||||
list/list_controller.o\
|
||||
list/parameter_controller.o\
|
||||
values/abscissa_parameter_controller.o\
|
||||
values/function_title_cell.o\
|
||||
values/interval.o\
|
||||
values/title_cell.o\
|
||||
|
||||
76
apps/graph/values/abscissa_parameter_controller.cpp
Normal file
76
apps/graph/values/abscissa_parameter_controller.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
#include "abscissa_parameter_controller.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace Graph {
|
||||
|
||||
AbscissaParameterController::AbscissaParameterController(Responder * parentResponder) :
|
||||
ViewController(parentResponder),
|
||||
m_deleteColumn(ListViewCell((char*)"Effacer la colonne")),
|
||||
m_copyColumn(ListViewCell((char*)"Copier la colonne dans une liste")),
|
||||
m_setInterval(ListViewCell((char*)"Regler l'intervalle")),
|
||||
m_listView(ListView(this,Metric::TopMargin, Metric::RightMargin,
|
||||
Metric::BottomMargin, Metric::LeftMargin)),
|
||||
m_activeCell(0)
|
||||
{
|
||||
}
|
||||
|
||||
const char * AbscissaParameterController::title() const {
|
||||
return "Colonne x";
|
||||
}
|
||||
|
||||
View * AbscissaParameterController::view() {
|
||||
return &m_listView;
|
||||
}
|
||||
|
||||
void AbscissaParameterController::didBecomeFirstResponder() {
|
||||
setActiveCell(m_activeCell);
|
||||
}
|
||||
|
||||
void AbscissaParameterController::setActiveCell(int index) {
|
||||
if (index < 0 || index >= k_totalNumberOfCell) {
|
||||
return;
|
||||
}
|
||||
ListViewCell * previousCell = (ListViewCell *)(m_listView.cellAtIndex(m_activeCell));
|
||||
previousCell->setHighlighted(false);
|
||||
|
||||
m_activeCell = index;
|
||||
m_listView.scrollToRow(index);
|
||||
ListViewCell * cell = (ListViewCell *)(m_listView.cellAtIndex(index));
|
||||
cell->setHighlighted(true);
|
||||
}
|
||||
|
||||
bool AbscissaParameterController::handleEvent(Ion::Events::Event event) {
|
||||
switch (event) {
|
||||
case Ion::Events::Event::DOWN_ARROW:
|
||||
setActiveCell(m_activeCell+1);
|
||||
return true;
|
||||
case Ion::Events::Event::UP_ARROW:
|
||||
setActiveCell(m_activeCell-1);
|
||||
return true;
|
||||
case Ion::Events::Event::ENTER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int AbscissaParameterController::numberOfRows() {
|
||||
return k_totalNumberOfCell;
|
||||
};
|
||||
|
||||
View * AbscissaParameterController::reusableCell(int index) {
|
||||
assert(index >= 0);
|
||||
assert(index < k_totalNumberOfCell);
|
||||
View * cells[] = {&m_deleteColumn, &m_copyColumn, &m_setInterval};
|
||||
return cells[index];
|
||||
}
|
||||
|
||||
int AbscissaParameterController::reusableCellCount() {
|
||||
return k_totalNumberOfCell;
|
||||
}
|
||||
|
||||
KDCoordinate AbscissaParameterController::cellHeight() {
|
||||
return 35;
|
||||
}
|
||||
|
||||
}
|
||||
32
apps/graph/values/abscissa_parameter_controller.h
Normal file
32
apps/graph/values/abscissa_parameter_controller.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef GRAPH_ABSCISSA_PARAM_CONTROLLER_H
|
||||
#define GRAPH_ABSCISSA_PARAM_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
|
||||
namespace Graph {
|
||||
class AbscissaParameterController : public ViewController, public ListViewDataSource {
|
||||
public:
|
||||
AbscissaParameterController(Responder * parentResponder);
|
||||
|
||||
View * view() override;
|
||||
const char * title() const override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void didBecomeFirstResponder() override;
|
||||
|
||||
void setActiveCell(int index);
|
||||
int numberOfRows() override;
|
||||
KDCoordinate cellHeight() override;
|
||||
View * reusableCell(int index) override;
|
||||
int reusableCellCount() override;
|
||||
private:
|
||||
constexpr static int k_totalNumberOfCell = 3;
|
||||
ListViewCell m_deleteColumn;
|
||||
ListViewCell m_copyColumn;
|
||||
ListViewCell m_setInterval;
|
||||
ListView m_listView;
|
||||
int m_activeCell;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user