diff --git a/apps/settings/Makefile b/apps/settings/Makefile index bb3156a6d..1226acb40 100644 --- a/apps/settings/Makefile +++ b/apps/settings/Makefile @@ -15,7 +15,6 @@ app_settings_src = $(addprefix apps/settings/,\ sub_menu/preferences_controller.cpp \ sub_menu/contributors_controller.cpp \ sub_menu/math_options_controller.cpp \ - sub_menu/symbol_controller.cpp \ ) app_src += $(app_settings_src) diff --git a/apps/settings/base.en.i18n b/apps/settings/base.en.i18n index 0d62be4b8..26d80ae42 100644 --- a/apps/settings/base.en.i18n +++ b/apps/settings/base.en.i18n @@ -42,8 +42,8 @@ AccessibilityGammaRed = "Red gamma" AccessibilityGammaGreen = "Green gamma" AccessibilityGammaBlue = "Blue gamma" MathOptions = "Math options" -SymbolMultiplication = "Multiplication sign" -SymbolMultiplicationCross = "Cross" -SymbolMultiplicationMiddleDot = "Middle dot" -SymbolMultiplicationStar = "Star" -SymbolMultiplicationAutoSymbol = "Automatic" +SymbolMultiplication = "Multiply sign" +SymbolMultiplicationCross = "Cross " +SymbolMultiplicationMiddleDot = "Dot " +SymbolMultiplicationStar = "Star " +SymbolMultiplicationAutoSymbol = "Auto " diff --git a/apps/settings/base.es.i18n b/apps/settings/base.es.i18n index f4615de36..5554bb8b4 100644 --- a/apps/settings/base.es.i18n +++ b/apps/settings/base.es.i18n @@ -42,8 +42,8 @@ AccessibilityGammaRed = "Gamma roja" AccessibilityGammaGreen = "Gamma verde" AccessibilityGammaBlue = "Gamma azul" MathOptions = "Matemáticas" -SymbolMultiplication = "signo de multiplicación" -SymbolMultiplicationCross = "contrariar" -SymbolMultiplicationMiddleDot = "punto medio" -SymbolMultiplicationStar = "estrella" -SymbolMultiplicationAutoSymbol = "automático" +SymbolMultiplication = "Signo de multiplicación" +SymbolMultiplicationCross = "Contrariar " +SymbolMultiplicationMiddleDot = "Punto " +SymbolMultiplicationStar = "Estrella " +SymbolMultiplicationAutoSymbol = "Auto " diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h index 2a371b0c9..bfa85be37 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -8,7 +8,6 @@ #include "sub_menu/exam_mode_controller.h" #include "sub_menu/language_controller.h" #include "sub_menu/math_options_controller.h" -#include "sub_menu/symbol_controller.h" namespace Settings { diff --git a/apps/settings/sub_menu/math_options_controller.cpp b/apps/settings/sub_menu/math_options_controller.cpp index c4235fbc1..5b4b42b7b 100644 --- a/apps/settings/sub_menu/math_options_controller.cpp +++ b/apps/settings/sub_menu/math_options_controller.cpp @@ -9,8 +9,7 @@ namespace Settings { MathOptionsController::MathOptionsController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate) : GenericSubController(parentResponder), m_preferencesController(this), - m_displayModeController(this, inputEventHandlerDelegate), - m_symbolController(this) + m_displayModeController(this, inputEventHandlerDelegate) { for (int i = 0; i < k_totalNumberOfCell; i++) { m_cells[i].setMessageFont(KDFont::LargeFont); @@ -22,8 +21,6 @@ bool MathOptionsController::handleEvent(Ion::Events::Event event) { GenericSubController * subController = nullptr; if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::DisplayMode) subController = &m_displayModeController; - else if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::SymbolMultiplication) - subController = &m_symbolController; else subController = &m_preferencesController; subController->setMessageTreeModel(m_messageTreeModel->children(selectedRow())); diff --git a/apps/settings/sub_menu/math_options_controller.h b/apps/settings/sub_menu/math_options_controller.h index dcd073c10..1db4c3104 100644 --- a/apps/settings/sub_menu/math_options_controller.h +++ b/apps/settings/sub_menu/math_options_controller.h @@ -4,7 +4,6 @@ #include "generic_sub_controller.h" #include #include "display_mode_controller.h" -#include "symbol_controller.h" #include "preferences_controller.h" namespace Settings { @@ -21,7 +20,6 @@ private: MessageTableCellWithChevronAndMessage m_cells[k_totalNumberOfCell]; PreferencesController m_preferencesController; DisplayModeController m_displayModeController; - SymbolController m_symbolController; }; } diff --git a/apps/settings/sub_menu/preferences_controller.cpp b/apps/settings/sub_menu/preferences_controller.cpp index f335a2b32..1417a1c0a 100644 --- a/apps/settings/sub_menu/preferences_controller.cpp +++ b/apps/settings/sub_menu/preferences_controller.cpp @@ -130,6 +130,22 @@ Layout PreferencesController::layoutForPreferences(I18n::Message message) { return LayoutHelper::String(text, strlen(text), k_layoutFont); } + // Symbol controller + case I18n::Message::SymbolMultiplicationCross: // × and · aren't single characters, so they cannot be constructed into codepoints..? + { + const char * text = "×"; + return LayoutHelper::String(text, strlen(text), k_layoutFont); + } + case I18n::Message::SymbolMultiplicationMiddleDot: + { + const char * text = "·"; + return LayoutHelper::String(text, strlen(text), k_layoutFont); + } + case I18n::Message::SymbolMultiplicationStar: + return CodePointLayout::Builder('*', k_layoutFont); + case I18n::Message::SymbolMultiplicationAutoSymbol: + return CodePointLayout::Builder(' ', k_layoutFont); + default: assert(false); return Layout(); @@ -167,6 +183,8 @@ void PreferencesController::setPreferenceWithValueIndex(I18n::Message message, i preferences->setComplexFormat((Preferences::ComplexFormat)valueIndex); } else if (message == I18n::Message::LEDColor) { preferences->setColorOfLED((Preferences::LEDColor)valueIndex); + } else if (message == I18n::Message::SymbolMultiplication) { + preferences->setSymbolMultiplication((Preferences::SymbolMultiplication)valueIndex); } } @@ -187,6 +205,9 @@ int PreferencesController::valueIndexForPreference(I18n::Message message) { if (message == I18n::Message::LEDColor) { return (int)preferences->colorOfLED(); } + if (message == I18n::Message::SymbolMultiplication) { + return (int)preferences->symbolofMultiplication(); + } return 0; } diff --git a/apps/settings/sub_menu/symbol_controller.cpp b/apps/settings/sub_menu/symbol_controller.cpp deleted file mode 100644 index 33cebb801..000000000 --- a/apps/settings/sub_menu/symbol_controller.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "symbol_controller.h" -#include -#include - -using namespace Shared; -using namespace Poincare; - -namespace Settings { - -SymbolController::SymbolController(Responder * parentResponder) : - GenericSubController(parentResponder) -{ - for (int i = 0; i < k_totalNumberOfSwitchCells; i++) { - m_switchCells[i].setMessageFont(KDFont::LargeFont); - } -} - -bool SymbolController::handleEvent(Ion::Events::Event event) { - Preferences * preferences = Preferences::sharedPreferences(); - Poincare::Preferences::SymbolMultiplication oldSymbolOfMultiplication = preferences->symbolofMultiplication(); - Poincare::Preferences::SymbolMultiplication newSymbolOfMultiplication = preferences->symbolofMultiplication(); - if (event == Ion::Events::OK || event == Ion::Events::EXE){ - switch(selectedRow()){ - case 0: - { - newSymbolOfMultiplication = Poincare::Preferences::SymbolMultiplication::Cross; - break; - } - case 1: - { - newSymbolOfMultiplication = Poincare::Preferences::SymbolMultiplication::MiddleDot; - break; - } - case 2: - { - newSymbolOfMultiplication = Poincare::Preferences::SymbolMultiplication::Star; - break; - } - case 3: - { - newSymbolOfMultiplication = Poincare::Preferences::SymbolMultiplication::Auto; - break; - } - default: - { - GenericSubController::handleEvent(event); - } - } - if (oldSymbolOfMultiplication == newSymbolOfMultiplication) { - if (newSymbolOfMultiplication == Poincare::Preferences::SymbolMultiplication::Auto) { - preferences->setSymbolMultiplication(Poincare::Preferences::SymbolMultiplication::Cross); - } else { - preferences->setSymbolMultiplication(Poincare::Preferences::SymbolMultiplication::Auto); - } - } else { - preferences->setSymbolMultiplication(newSymbolOfMultiplication); - } - m_selectableTableView.reloadData(); - return true; - } else { - return GenericSubController::handleEvent(event); - } -} - -HighlightCell * SymbolController::reusableCell(int index, int type) { - assert(type == 1 || type == 2); - if (type == 2) { - assert(index >= 0 && index < k_totalNumberOfSwitchCells); - return &m_switchCells[index]; - } - return nullptr; -} - -int SymbolController::reusableCellCount(int type) { - assert(type == 1 || type == 2); - if (type == 2) { - return k_totalNumberOfSwitchCells; - } - return 0; -} - -void SymbolController::willDisplayCellForIndex(HighlightCell * cell, int index) { - GenericSubController::willDisplayCellForIndex(cell, index); - - MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell; - - Preferences * preferences = Preferences::sharedPreferences(); - Poincare::Preferences::SymbolMultiplication symbolofMultiplication = preferences->symbolofMultiplication(); - - if (index == 0) { - SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); - if(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::Cross){ - mySwitch->setState(true); - } else { - mySwitch->setState(false); - } - } - else if (index == 1) { - SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); - if(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::MiddleDot){ - mySwitch->setState(true); - } else { - mySwitch->setState(false); - } - } - else if (index == 2) { - SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); - if (symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::Star){ - mySwitch->setState(true); - } else { - mySwitch->setState(false); - } - } - else if (index == 3){ - SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); - if(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::Auto){ - mySwitch->setState(true); - } else { - mySwitch->setState(false); - } - } -} - -int SymbolController::typeAtLocation(int i, int j) { - switch (j) { - case 0: - case 1: - case 2: - case 3: - return 2; - default: - return 1; - } -} - -} diff --git a/apps/settings/sub_menu/symbol_controller.h b/apps/settings/sub_menu/symbol_controller.h deleted file mode 100644 index 2c01e1da2..000000000 --- a/apps/settings/sub_menu/symbol_controller.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SETTINGS_SYMBOLCONTROLLER_CONTROLLER_H -#define SETTINGS_SYMBOLCONTROLLER_CONTROLLER_H - -#include "generic_sub_controller.h" - -namespace Settings { - -class SymbolController : public GenericSubController { -public: - SymbolController(Responder * parentResponder); - bool handleEvent(Ion::Events::Event event) override; - HighlightCell * reusableCell(int index, int type) override; - int reusableCellCount(int type) override; - void willDisplayCellForIndex(HighlightCell * cell, int index) override; - int typeAtLocation(int i, int j) override; -private: - constexpr static int k_totalNumberOfSwitchCells = 4; - MessageTableCellWithSwitch m_switchCells[k_totalNumberOfSwitchCells]; -}; - -} - -#endif \ No newline at end of file diff --git a/poincare/include/poincare/preferences.h b/poincare/include/poincare/preferences.h index 569718aed..95505cf55 100644 --- a/poincare/include/poincare/preferences.h +++ b/poincare/include/poincare/preferences.h @@ -36,13 +36,13 @@ public: Radian = 1, Gradian = 2 }; - enum class LEDColor { + enum class LEDColor : uint8_t { White = 0, Green = 1, Blue = 2, Yellow = 3 }; - enum class SymbolMultiplication { + enum class SymbolMultiplication : uint8_t { Cross = 0, MiddleDot = 1, Star = 2, @@ -71,7 +71,7 @@ private: ComplexFormat m_complexFormat; uint8_t m_numberOfSignificantDigits; LEDColor m_colorOfLED; - SymbolMultiplication m_symbolMultiplication; + SymbolMultiplication m_symbolMultiplication; }; }