[apps/settings] Implement structure of settings app

Change-Id: If42dc3fcb363e3ceac0dda9f89394f2535ab09be
This commit is contained in:
Émilie Feral
2017-01-27 17:52:33 +01:00
parent c4336c93b1
commit e1a77ce8aa
9 changed files with 236 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ include apps/graph/Makefile
include apps/home/Makefile
include apps/probability/Makefile
include apps/regression/Makefile
include apps/settings/Makefile
include apps/statistics/Makefile
#include apps/picview/Makefile

7
apps/settings/Makefile Normal file
View File

@@ -0,0 +1,7 @@
app_objs += $(addprefix apps/settings/,\
app.o\
preference.o\
main_controller.o\
)
app_images += apps/settings/settings_icon.png

14
apps/settings/app.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include "app.h"
#include "settings_icon.h"
namespace Settings {
App::App(Container * container) :
::App(container, &m_stackViewController, "Parametre", "PARAMETRE", ImageStore::SettingsIcon),
m_preference(),
m_mainController(MainController(nullptr)),
m_stackViewController(StackViewController(&m_modalViewController, &m_mainController))
{
}
}

21
apps/settings/app.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef SETTINGS_APP_H
#define SETTINGS_APP_H
#include <escher.h>
#include "main_controller.h"
#include "preference.h"
namespace Settings {
class App : public ::App {
public:
App(Container * container);
private:
Preference m_preference;
MainController m_mainController;
StackViewController m_stackViewController;
};
}
#endif

View File

@@ -0,0 +1,52 @@
#include "main_controller.h"
#include <assert.h>
namespace Settings {
MainController::MainController(Responder * parentResponder) :
ViewController(parentResponder),
m_cells{ChevronMenuListCell((char*)"Angles"), ChevronMenuListCell((char*)"Resultats"), ChevronMenuListCell((char*)"Forme nombre"),
ChevronMenuListCell((char*)"Forme complexe"), ChevronMenuListCell((char*)"Langue")},
m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin,
Metric::BottomMargin, Metric::LeftMargin))
{
}
const char * MainController::title() const {
return "Parametres";
}
View * MainController::view() {
return &m_selectableTableView;
}
void MainController::didBecomeFirstResponder() {
if (m_selectableTableView.selectedRow() < 0) {
m_selectableTableView.selectCellAtLocation(0, 0);
}
app()->setFirstResponder(&m_selectableTableView);
}
bool MainController::handleEvent(Ion::Events::Event event) {
return false;
}
int MainController::numberOfRows() {
return k_totalNumberOfCell;
};
TableViewCell * MainController::reusableCell(int index) {
assert(index >= 0);
assert(index < k_totalNumberOfCell);
return &m_cells[index];
}
int MainController::reusableCellCount() {
return k_totalNumberOfCell;
}
KDCoordinate MainController::cellHeight() {
return Metric::ParameterCellHeight;
}
}

View File

@@ -0,0 +1,28 @@
#ifndef SETTINGS_MAIN_CONTROLLER_H
#define SETTINGS_MAIN_CONTROLLER_H
#include <escher.h>
namespace Settings {
class MainController : public ViewController, public SimpleListViewDataSource {
public:
MainController(Responder * parentResponder);
View * view() override;
const char * title() const override;
bool handleEvent(Ion::Events::Event event) override;
void didBecomeFirstResponder() override;
int numberOfRows() override;
KDCoordinate cellHeight() override;
TableViewCell * reusableCell(int index) override;
int reusableCellCount() override;
private:
constexpr static int k_totalNumberOfCell = 5;
ChevronMenuListCell m_cells[k_totalNumberOfCell];
SelectableTableView m_selectableTableView;
};
}
#endif

View File

@@ -0,0 +1,64 @@
#include "preference.h"
namespace Settings {
Preference::Preference() :
m_angleUnit(AngleUnit::Degree),
m_displayMode(DisplayMode::Auto),
m_numberType(NumberType::Reel),
m_complexFormat(ComplexFormat::Cartesian),
m_language(Language::French)
{
}
Preference::AngleUnit Preference::angleUnit() const {
return m_angleUnit;
}
void Preference::setAngleUnit(AngleUnit angleUnit) {
if (angleUnit != m_angleUnit) {
m_angleUnit = angleUnit;
}
}
Preference::DisplayMode Preference::displayMode() const {
return m_displayMode;
}
void Preference::setDisplayMode(DisplayMode displayMode) {
if (displayMode != m_displayMode) {
m_displayMode = displayMode;
}
}
Preference::NumberType Preference::numberType() const {
return m_numberType;
}
void Preference::setNumberType(NumberType numberType) {
if (numberType != m_numberType) {
m_numberType = numberType;
}
}
Preference::ComplexFormat Preference::complexFormat() const {
return m_complexFormat;
}
void Preference::setComplexFormat(ComplexFormat complexFormat) {
if (complexFormat != m_complexFormat) {
m_complexFormat = complexFormat;
}
}
Preference::Language Preference::language() const {
return m_language;
}
void Preference::setLanguage(Language language) {
if (language != m_language) {
m_language = language;
}
}
}

View File

@@ -0,0 +1,49 @@
#ifndef SETTINGS_MODEL_H
#define SETTINGS_MODEL_H
namespace Settings {
class Preference {
public:
enum class AngleUnit {
Degree,
Radian
};
enum class DisplayMode {
Auto,
Scientific
};
enum class NumberType {
Reel,
Complex
};
enum class ComplexFormat {
Cartesian,
Polar
};
enum class Language {
French,
English
};
Preference();
AngleUnit angleUnit() const;
void setAngleUnit(AngleUnit angleUnit);
DisplayMode displayMode() const;
void setDisplayMode(DisplayMode displayMode);
NumberType numberType() const;
void setNumberType(NumberType numberType);
ComplexFormat complexFormat() const;
void setComplexFormat(ComplexFormat complexFormat);
Language language() const;
void setLanguage(Language language);
private:
AngleUnit m_angleUnit;
DisplayMode m_displayMode;
NumberType m_numberType;
ComplexFormat m_complexFormat;
Language m_language;
};
}
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB