diff --git a/apps/Makefile b/apps/Makefile index cc93bc87a..cd7dd50b4 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -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 diff --git a/apps/settings/Makefile b/apps/settings/Makefile new file mode 100644 index 000000000..c2f0111c7 --- /dev/null +++ b/apps/settings/Makefile @@ -0,0 +1,7 @@ +app_objs += $(addprefix apps/settings/,\ + app.o\ + preference.o\ + main_controller.o\ +) + +app_images += apps/settings/settings_icon.png diff --git a/apps/settings/app.cpp b/apps/settings/app.cpp new file mode 100644 index 000000000..52feb0ebe --- /dev/null +++ b/apps/settings/app.cpp @@ -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)) +{ +} + +} diff --git a/apps/settings/app.h b/apps/settings/app.h new file mode 100644 index 000000000..60c9143f9 --- /dev/null +++ b/apps/settings/app.h @@ -0,0 +1,21 @@ +#ifndef SETTINGS_APP_H +#define SETTINGS_APP_H + +#include +#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 diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp new file mode 100644 index 000000000..c4227bd4e --- /dev/null +++ b/apps/settings/main_controller.cpp @@ -0,0 +1,52 @@ +#include "main_controller.h" +#include + +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; +} + +} diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h new file mode 100644 index 000000000..644142a2c --- /dev/null +++ b/apps/settings/main_controller.h @@ -0,0 +1,28 @@ +#ifndef SETTINGS_MAIN_CONTROLLER_H +#define SETTINGS_MAIN_CONTROLLER_H + +#include + +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 diff --git a/apps/settings/preference.cpp b/apps/settings/preference.cpp new file mode 100644 index 000000000..807d4ca8a --- /dev/null +++ b/apps/settings/preference.cpp @@ -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; + } +} + +} diff --git a/apps/settings/preference.h b/apps/settings/preference.h new file mode 100644 index 000000000..b1bf43f1a --- /dev/null +++ b/apps/settings/preference.h @@ -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 diff --git a/apps/settings/settings_icon.png b/apps/settings/settings_icon.png new file mode 100644 index 000000000..b7cf4f93d Binary files /dev/null and b/apps/settings/settings_icon.png differ