diff --git a/apps/code/console_controller.cpp b/apps/code/console_controller.cpp index c3e0a0cb1..9cd6b1f86 100644 --- a/apps/code/console_controller.cpp +++ b/apps/code/console_controller.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "../apps_container.h" extern "C" { @@ -27,7 +28,7 @@ ConsoleController::ConsoleController(Responder * parentResponder, App * pythonDe TextFieldDelegate(), MicroPython::ExecutionEnvironment(), m_pythonDelegate(pythonDelegate), - m_rowHeight(k_font->glyphSize().height()), + m_rowHeight(Poincare::Preferences::sharedPreferences()->KDPythonFont()->glyphSize().height()), m_importScriptsWhenViewAppears(false), m_selectableTableView(this, this, this, this), m_editCell(this, pythonDelegate, this), diff --git a/apps/code/console_controller.h b/apps/code/console_controller.h index 1c32f4f04..5775744c3 100644 --- a/apps/code/console_controller.h +++ b/apps/code/console_controller.h @@ -3,6 +3,7 @@ #include #include +#include #include "console_edit_cell.h" #include "console_line_cell.h" @@ -16,7 +17,6 @@ class App; class ConsoleController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource, public SelectableTableViewDelegate, public TextFieldDelegate, public MicroPython::ExecutionEnvironment { public: - static constexpr const KDFont * k_font = KDFont::LargeFont; ConsoleController(Responder * parentResponder, App * pythonDelegate, ScriptStore * scriptStore #if EPSILON_GETOPT diff --git a/apps/code/console_edit_cell.cpp b/apps/code/console_edit_cell.cpp index e2472d8fe..9eb431206 100644 --- a/apps/code/console_edit_cell.cpp +++ b/apps/code/console_edit_cell.cpp @@ -9,8 +9,8 @@ namespace Code { ConsoleEditCell::ConsoleEditCell(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, TextFieldDelegate * delegate) : HighlightCell(), Responder(parentResponder), - m_promptView(ConsoleController::k_font, nullptr, 0, 0.5), - m_textField(this, nullptr, TextField::maxBufferSize(), TextField::maxBufferSize(), inputEventHandlerDelegate, delegate, ConsoleController::k_font) + m_promptView(Poincare::Preferences::sharedPreferences()->KDPythonFont(), nullptr, 0, 0.5), + m_textField(this, nullptr, TextField::maxBufferSize(), TextField::maxBufferSize(), inputEventHandlerDelegate, delegate, Poincare::Preferences::sharedPreferences()->KDPythonFont()) { } diff --git a/apps/code/console_edit_cell.h b/apps/code/console_edit_cell.h index e98cfba46..378beb8c4 100644 --- a/apps/code/console_edit_cell.h +++ b/apps/code/console_edit_cell.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace Code { diff --git a/apps/code/console_line_cell.cpp b/apps/code/console_line_cell.cpp index 2d9ada321..e24a550c9 100644 --- a/apps/code/console_line_cell.cpp +++ b/apps/code/console_line_cell.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace Code { @@ -18,11 +19,11 @@ void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::setLine(Consol void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), Palette::CodeBackground); - ctx->drawString(m_line->text(), KDPointZero, ConsoleController::k_font, textColor(m_line), isHighlighted()? Palette::CodeBackgroundSelected : Palette::CodeBackground); + ctx->drawString(m_line->text(), KDPointZero, Poincare::Preferences::sharedPreferences()->KDPythonFont(), textColor(m_line), isHighlighted()? Palette::CodeBackgroundSelected : Palette::CodeBackground); } KDSize ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::minimalSizeForOptimalDisplay() const { - return ConsoleController::k_font->stringSize(m_line->text()); + return Poincare::Preferences::sharedPreferences()->KDPythonFont()->stringSize(m_line->text()); } ConsoleLineCell::ScrollableConsoleLineView::ScrollableConsoleLineView(Responder * parentResponder) : @@ -34,7 +35,7 @@ ConsoleLineCell::ScrollableConsoleLineView::ScrollableConsoleLineView(Responder ConsoleLineCell::ConsoleLineCell(Responder * parentResponder) : HighlightCell(), Responder(parentResponder), - m_promptView(ConsoleController::k_font, I18n::Message::ConsolePrompt, 0, 0.5), + m_promptView(Poincare::Preferences::sharedPreferences()->KDPythonFont(), I18n::Message::ConsolePrompt, 0, 0.5), m_scrollableView(this), m_line() { @@ -79,7 +80,7 @@ View * ConsoleLineCell::subviewAtIndex(int index) { void ConsoleLineCell::layoutSubviews() { if (m_line.isCommand()) { - KDSize promptSize = ConsoleController::k_font->stringSize(I18n::translate(I18n::Message::ConsolePrompt)); + KDSize promptSize = Poincare::Preferences::sharedPreferences()->KDPythonFont()->stringSize(I18n::translate(I18n::Message::ConsolePrompt)); m_promptView.setFrame(KDRect(KDPointZero, promptSize.width(), bounds().height())); m_scrollableView.setFrame(KDRect(KDPoint(promptSize.width(), 0), bounds().width() - promptSize.width(), bounds().height())); return; diff --git a/apps/code/editor_view.cpp b/apps/code/editor_view.cpp index 4138b5221..199a66845 100644 --- a/apps/code/editor_view.cpp +++ b/apps/code/editor_view.cpp @@ -1,18 +1,17 @@ #include "editor_view.h" #include #include +#include namespace Code { /* EditorView */ -static constexpr const KDFont * editorFont = KDFont::LargeFont; - EditorView::EditorView(Responder * parentResponder, App * pythonDelegate) : Responder(parentResponder), View(), - m_textArea(parentResponder, pythonDelegate, editorFont), - m_gutterView(editorFont) + m_textArea(parentResponder, pythonDelegate, Poincare::Preferences::sharedPreferences()->KDPythonFont()), + m_gutterView(Poincare::Preferences::sharedPreferences()->KDPythonFont()) { m_textArea.setScrollViewDelegate(this); } @@ -51,7 +50,6 @@ void EditorView::layoutSubviews() { EditorView::GutterView::GutterView(const KDFont * font) : View(), - m_font(font), m_offset(0) { } @@ -62,7 +60,7 @@ void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(rect, backgroundColor); - KDSize glyphSize = m_font->glyphSize(); + KDSize glyphSize = Poincare::Preferences::sharedPreferences()->KDPythonFont()->glyphSize(); KDCoordinate firstLine = m_offset / glyphSize.height(); KDCoordinate firstLinePixelOffset = m_offset - firstLine * glyphSize.height(); @@ -76,7 +74,7 @@ void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const { ctx->drawString( lineNumber, KDPoint(k_margin + leftPadding, i*glyphSize.height() - firstLinePixelOffset), - m_font, + Poincare::Preferences::sharedPreferences()->KDPythonFont(), textColor, backgroundColor ); @@ -94,7 +92,7 @@ void EditorView::GutterView::setOffset(KDCoordinate offset) { KDSize EditorView::GutterView::minimalSizeForOptimalDisplay() const { int numberOfChars = 2; // TODO: Could be computed - return KDSize(2 * k_margin + numberOfChars * m_font->glyphSize().width(), 0); + return KDSize(2 * k_margin + numberOfChars * Poincare::Preferences::sharedPreferences()->KDPythonFont()->glyphSize().width(), 0); } } diff --git a/apps/code/editor_view.h b/apps/code/editor_view.h index 7e4d85ece..9fb759fca 100644 --- a/apps/code/editor_view.h +++ b/apps/code/editor_view.h @@ -36,7 +36,6 @@ private: KDSize minimalSizeForOptimalDisplay() const override; private: static constexpr KDCoordinate k_margin = 2; - const KDFont * m_font; KDCoordinate m_offset; }; diff --git a/apps/settings/base.de.i18n b/apps/settings/base.de.i18n index cf1e413b8..27a080176 100644 --- a/apps/settings/base.de.i18n +++ b/apps/settings/base.de.i18n @@ -50,4 +50,7 @@ SymbolMultiplication = "Multiplikation" SymbolMultiplicationCross = "Kreuz " SymbolMultiplicationMiddleDot = "Mittelpunkt " SymbolMultiplicationStar = "Stern " -SymbolMultiplicationAutoSymbol = "automatisch " \ No newline at end of file +SymbolMultiplicationAutoSymbol = "automatisch " +PythonFont = "Python schriftart" +Large = "Groß " +Small = "Klein " diff --git a/apps/settings/base.en.i18n b/apps/settings/base.en.i18n index 811b3acf2..8285415da 100644 --- a/apps/settings/base.en.i18n +++ b/apps/settings/base.en.i18n @@ -50,4 +50,7 @@ SymbolMultiplication = "Multiply" SymbolMultiplicationCross = "Cross " SymbolMultiplicationMiddleDot = "Dot " SymbolMultiplicationStar = "Star " -SymbolMultiplicationAutoSymbol = "Auto " \ No newline at end of file +SymbolMultiplicationAutoSymbol = "Auto " +PythonFont = "Python Font" +Large = "Large " +Small = "Small " diff --git a/apps/settings/base.es.i18n b/apps/settings/base.es.i18n index 4ecd529aa..bfe7bfa31 100644 --- a/apps/settings/base.es.i18n +++ b/apps/settings/base.es.i18n @@ -50,4 +50,7 @@ SymbolMultiplication = "Multiplicación" SymbolMultiplicationCross = "Contrariar " SymbolMultiplicationMiddleDot = "Punto " SymbolMultiplicationStar = "Estrella " -SymbolMultiplicationAutoSymbol = "Auto " \ No newline at end of file +SymbolMultiplicationAutoSymbol = "Auto " +PythonFont = "Fuente Python" +Large = "Grande " +Small = "Pequeña " diff --git a/apps/settings/base.fr.i18n b/apps/settings/base.fr.i18n index f2c8b0a39..cfff730ca 100644 --- a/apps/settings/base.fr.i18n +++ b/apps/settings/base.fr.i18n @@ -50,4 +50,7 @@ SymbolMultiplication = "Multiplication" SymbolMultiplicationCross = "Croix " SymbolMultiplicationMiddleDot = "Point " SymbolMultiplicationStar = "Etoile " -SymbolMultiplicationAutoSymbol = "Automatique " \ No newline at end of file +SymbolMultiplicationAutoSymbol = "Automatique " +PythonFont = "Police Python" +Large = "Grand " +Small = "Petit " diff --git a/apps/settings/base.pt.i18n b/apps/settings/base.pt.i18n index 8194baeff..de1fe5a55 100644 --- a/apps/settings/base.pt.i18n +++ b/apps/settings/base.pt.i18n @@ -50,4 +50,7 @@ SymbolMultiplication = "Multiplicação" SymbolMultiplicationCross = "crómio " SymbolMultiplicationMiddleDot = "ponto médio " SymbolMultiplicationStar = "estrela " -SymbolMultiplicationAutoSymbol = "automático " \ No newline at end of file +SymbolMultiplicationAutoSymbol = "automático " +PythonFont = "Fonte Python" +Large = "Ampla " +Small = "Pequeno " diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index 12419bc55..248a59a1b 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -17,7 +17,8 @@ MainController::MainController(Responder * parentResponder, InputEventHandlerDel m_languageController(this, 13), m_accessibilityController(this), m_examModeController(this), - m_aboutController(this) + m_aboutController(this), + m_preferencesController(this) { for (int i = 0; i < k_numberOfSimpleChevronCells; i++) { m_cells[i].setMessageFont(KDFont::LargeFont); @@ -83,6 +84,8 @@ bool MainController::handleEvent(Ion::Events::Event event) { subController = &m_accessibilityController; } else if (model()->children(selectedRow())->label() == I18n::Message::MathOptions) { subController = &m_mathOptionsController; + } else { + subController = &m_preferencesController; } subController->setMessageTreeModel(model()->children(selectedRow())); StackViewController * stack = stackController(); @@ -141,6 +144,7 @@ int MainController::typeAtLocation(int i, int j) { void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { GlobalPreferences * globalPreferences = GlobalPreferences::sharedGlobalPreferences(); + Preferences * preferences = Preferences::sharedPreferences(); MessageTableCell * myCell = (MessageTableCell *)cell; I18n::Message thisLabel = model()->children(index)->label(); myCell->setMessage(thisLabel); @@ -157,12 +161,18 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { static_cast(cell)->setSubtitle(I18n::LanguageNames[index]); return; } + if (thisLabel == I18n::Message::PythonFont) { + int childIndex = (int)preferences->pythonFont(); + static_cast(cell)->setSubtitle(model()->children(index)->children(childIndex)->label()); + return; + } if (hasPrompt() && (thisLabel == I18n::Message::UpdatePopUp || thisLabel == I18n::Message::BetaPopUp)) { MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell; SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); mySwitch->setState(globalPreferences->showPopUp()); return; } + static_cast(cell)->setSubtitle(I18n::Message::Default); } void MainController::viewWillAppear() { diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h index bfa85be37..f19bf4314 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -8,6 +8,7 @@ #include "sub_menu/exam_mode_controller.h" #include "sub_menu/language_controller.h" #include "sub_menu/math_options_controller.h" +#include "sub_menu/preferences_controller.h" namespace Settings { @@ -31,7 +32,7 @@ private: StackViewController * stackController() const; I18n::Message promptMessage() const; bool hasPrompt() const { return promptMessage() != I18n::Message::Default; } - constexpr static int k_numberOfSimpleChevronCells = 5; + constexpr static int k_numberOfSimpleChevronCells = 6; MessageTableCellWithChevronAndMessage m_cells[k_numberOfSimpleChevronCells]; MessageTableCellWithGauge m_brightnessCell; MessageTableCellWithSwitch m_popUpCell; @@ -41,6 +42,7 @@ private: AccessibilityController m_accessibilityController; ExamModeController m_examModeController; AboutController m_aboutController; + PreferencesController m_preferencesController; }; } diff --git a/apps/settings/main_controller_prompt_beta.cpp b/apps/settings/main_controller_prompt_beta.cpp index 12d153c33..0464d09f0 100644 --- a/apps/settings/main_controller_prompt_beta.cpp +++ b/apps/settings/main_controller_prompt_beta.cpp @@ -16,6 +16,7 @@ constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::M //sub-menus constexpr SettingsMessageTree s_modelMathOptionsChildren[5] = {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 3), SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren, 4), SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren, 2), SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren, 3), SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren, 4)}; constexpr SettingsMessageTree s_modelExamChildren[3] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::ExamModeMode, s_examModeMode, 3), SettingsMessageTree(I18n::Message::ActivateExamMode)}; +constexpr SettingsMessageTree s_pythonFont[2] = {SettingsMessageTree(I18n::Message::Large), SettingsMessageTree(I18n::Message::Small)}; constexpr SettingsMessageTree s_accessibilityChildren[6] = {SettingsMessageTree(I18n::Message::AccessibilityInvertColors), SettingsMessageTree(I18n::Message::AccessibilityMagnify),SettingsMessageTree(I18n::Message::AccessibilityGamma),SettingsMessageTree(I18n::Message::AccessibilityGammaRed),SettingsMessageTree(I18n::Message::AccessibilityGammaGreen),SettingsMessageTree(I18n::Message::AccessibilityGammaBlue)}; #ifdef USERNAME constexpr SettingsMessageTree s_modelAboutChildren[7] = {SettingsMessageTree(I18n::Message::Username), SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::CustomSoftwareVersion), SettingsMessageTree(I18n::Message::MicroPythonVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId), SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 7)}; @@ -27,7 +28,8 @@ constexpr SettingsMessageTree s_modelMenu[] = {SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 5), SettingsMessageTree(I18n::Message::Brightness), SettingsMessageTree(I18n::Message::Language), - SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 4), + SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 3), + SettingsMessageTree(I18n::Message::PythonFont, s_pythonFont, 2), SettingsMessageTree(I18n::Message::BetaPopUp), SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren, 6), #ifdef USERNAME @@ -36,7 +38,7 @@ constexpr SettingsMessageTree s_modelMenu[] = SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 6)}; #endif -constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 7); +constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 8); I18n::Message MainController::promptMessage() const { return I18n::Message::BetaPopUp; diff --git a/apps/settings/main_controller_prompt_none.cpp b/apps/settings/main_controller_prompt_none.cpp index faf94a896..4b313c325 100644 --- a/apps/settings/main_controller_prompt_none.cpp +++ b/apps/settings/main_controller_prompt_none.cpp @@ -17,6 +17,7 @@ constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::M //sub-menus constexpr SettingsMessageTree s_modelMathOptionsChildren[5] = {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 3), SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren, 4), SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren, 2), SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren, 3), SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren, 4)}; constexpr SettingsMessageTree s_modelExamChildren[3] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::ExamModeMode, s_examModeMode, 3), SettingsMessageTree(I18n::Message::ActivateExamMode)}; +constexpr SettingsMessageTree s_pythonFont[2] = {SettingsMessageTree(I18n::Message::Large), SettingsMessageTree(I18n::Message::Small)}; constexpr SettingsMessageTree s_accessibilityChildren[6] = {SettingsMessageTree(I18n::Message::AccessibilityInvertColors), SettingsMessageTree(I18n::Message::AccessibilityMagnify),SettingsMessageTree(I18n::Message::AccessibilityGamma),SettingsMessageTree(I18n::Message::AccessibilityGammaRed),SettingsMessageTree(I18n::Message::AccessibilityGammaGreen),SettingsMessageTree(I18n::Message::AccessibilityGammaBlue)}; #ifdef USERNAME constexpr SettingsMessageTree s_modelAboutChildren[7] = {SettingsMessageTree(I18n::Message::Username), SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::CustomSoftwareVersion), SettingsMessageTree(I18n::Message::MicroPythonVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId), SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 7)}; @@ -29,6 +30,7 @@ constexpr SettingsMessageTree s_modelMenu[] = SettingsMessageTree(I18n::Message::Brightness), SettingsMessageTree(I18n::Message::Language), SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 3), + SettingsMessageTree(I18n::Message::PythonFont, s_pythonFont, 2), SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren, 6), #ifdef USERNAME SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 7)}; @@ -36,7 +38,7 @@ constexpr SettingsMessageTree s_modelMenu[] = SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 6)}; #endif -constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 6); +constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 7); I18n::Message MainController::promptMessage() const { return I18n::Message::Default; diff --git a/apps/settings/main_controller_prompt_update.cpp b/apps/settings/main_controller_prompt_update.cpp index 7b68df1a4..e014785af 100644 --- a/apps/settings/main_controller_prompt_update.cpp +++ b/apps/settings/main_controller_prompt_update.cpp @@ -16,6 +16,7 @@ constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::M //sub-menus constexpr SettingsMessageTree s_modelMathOptionsChildren[5] = {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 3), SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren, 4), SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren, 2), SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren, 3), SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren, 4)}; constexpr SettingsMessageTree s_modelExamChildren[3] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::ExamModeMode, s_examModeMode, 3), SettingsMessageTree(I18n::Message::ActivateExamMode)}; +constexpr SettingsMessageTree s_pythonFont[2] = {SettingsMessageTree(I18n::Message::Large), SettingsMessageTree(I18n::Message::Small)}; constexpr SettingsMessageTree s_accessibilityChildren[6] = {SettingsMessageTree(I18n::Message::AccessibilityInvertColors), SettingsMessageTree(I18n::Message::AccessibilityMagnify),SettingsMessageTree(I18n::Message::AccessibilityGamma),SettingsMessageTree(I18n::Message::AccessibilityGammaRed),SettingsMessageTree(I18n::Message::AccessibilityGammaGreen),SettingsMessageTree(I18n::Message::AccessibilityGammaBlue)}; #ifdef USERNAME constexpr SettingsMessageTree s_modelAboutChildren[7] = {SettingsMessageTree(I18n::Message::Username), SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::CustomSoftwareVersion), SettingsMessageTree(I18n::Message::MicroPythonVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId), SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 7)}; @@ -27,7 +28,8 @@ constexpr SettingsMessageTree s_modelMenu[] = {SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 5), SettingsMessageTree(I18n::Message::Brightness), SettingsMessageTree(I18n::Message::Language), - SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 4), + SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 3), + SettingsMessageTree(I18n::Message::PythonFont, s_pythonFont, 2), SettingsMessageTree(I18n::Message::UpdatePopUp), SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren, 6), #ifdef USERNAME @@ -36,7 +38,7 @@ constexpr SettingsMessageTree s_modelMenu[] = SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 6)}; #endif -constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 7); +constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 8); I18n::Message MainController::promptMessage() const { return I18n::Message::UpdatePopUp; diff --git a/apps/settings/sub_menu/preferences_controller.cpp b/apps/settings/sub_menu/preferences_controller.cpp index 62921e49a..1a85983b0 100644 --- a/apps/settings/sub_menu/preferences_controller.cpp +++ b/apps/settings/sub_menu/preferences_controller.cpp @@ -128,7 +128,7 @@ Layout PreferencesController::layoutForPreferences(I18n::Message message) { const char * text = " "; return LayoutHelper::String(text, strlen(text), k_layoutFont); } - + // Exam mode modes case I18n::Message::ExamModeModeStandard: { @@ -145,7 +145,7 @@ Layout PreferencesController::layoutForPreferences(I18n::Message message) { const char * text = " "; 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..? @@ -163,6 +163,12 @@ Layout PreferencesController::layoutForPreferences(I18n::Message message) { case I18n::Message::SymbolMultiplicationAutoSymbol: return CodePointLayout::Builder(' ', k_layoutFont); + // Font size + case I18n::Message::Large: + return LayoutHelper::String("000", 3, KDFont::LargeFont); + case I18n::Message::Small: + return LayoutHelper::String("000", 3, KDFont::SmallFont); + default: assert(false); return Layout(); @@ -204,6 +210,8 @@ void PreferencesController::setPreferenceWithValueIndex(I18n::Message message, i GlobalPreferences::sharedGlobalPreferences()->setTempExamMode((GlobalPreferences::ExamMode)((uint8_t)valueIndex + 1)); } else if (message == I18n::Message::SymbolMultiplication) { preferences->setSymbolMultiplication((Preferences::SymbolMultiplication)valueIndex); + } else if (message == I18n::Message::PythonFont) { + preferences->setPythonFont((Preferences::PythonFont)valueIndex); } } @@ -227,6 +235,9 @@ int PreferencesController::valueIndexForPreference(I18n::Message message) const if (message == I18n::Message::SymbolMultiplication) { return (int)preferences->symbolofMultiplication(); } + if (message == I18n::Message::PythonFont) { + return (int)preferences->pythonFont(); + } return 0; } diff --git a/poincare/include/poincare/preferences.h b/poincare/include/poincare/preferences.h index 95505cf55..6a563a31d 100644 --- a/poincare/include/poincare/preferences.h +++ b/poincare/include/poincare/preferences.h @@ -2,6 +2,7 @@ #define POINCARE_PREFERENCES_H #include +#include namespace Poincare { @@ -48,6 +49,10 @@ public: Star = 2, Auto = 3 }; + enum class PythonFont : uint8_t { + Large = 0, + Small = 1 + }; Preferences(); static Preferences * sharedPreferences(); AngleUnit angleUnit() const { return m_angleUnit; } @@ -62,8 +67,11 @@ public: void setNumberOfSignificantDigits(uint8_t numberOfSignificantDigits) { m_numberOfSignificantDigits = numberOfSignificantDigits; } LEDColor colorOfLED() const { return m_colorOfLED; } void setColorOfLED(LEDColor color) { m_colorOfLED = color; } - SymbolMultiplication symbolofMultiplication() const {return m_symbolMultiplication;} - void setSymbolMultiplication(SymbolMultiplication symbolofMultiplication) {m_symbolMultiplication = symbolofMultiplication;} + SymbolMultiplication symbolofMultiplication() const { return m_symbolMultiplication; } + void setSymbolMultiplication(SymbolMultiplication symbolofMultiplication) { m_symbolMultiplication = symbolofMultiplication; } + PythonFont pythonFont() const { return m_pythonFont; } + void setPythonFont(PythonFont pythonFont) { m_pythonFont = pythonFont; } + const KDFont * KDPythonFont() const { return (m_pythonFont == PythonFont::Small) ? KDFont::SmallFont : KDFont::LargeFont; } private: AngleUnit m_angleUnit; PrintFloatMode m_displayMode; @@ -72,6 +80,7 @@ private: uint8_t m_numberOfSignificantDigits; LEDColor m_colorOfLED; SymbolMultiplication m_symbolMultiplication; + PythonFont m_pythonFont; }; } diff --git a/poincare/src/preferences.cpp b/poincare/src/preferences.cpp index 4cdb0613f..8115a5475 100644 --- a/poincare/src/preferences.cpp +++ b/poincare/src/preferences.cpp @@ -14,7 +14,8 @@ Preferences::Preferences() : m_complexFormat(Preferences::ComplexFormat::Real), m_numberOfSignificantDigits(PrintFloat::k_numberOfPrintedSignificantDigits), m_colorOfLED(Preferences::LEDColor::White), - m_symbolMultiplication(Preferences::SymbolMultiplication::Auto) + m_symbolMultiplication(Preferences::SymbolMultiplication::Auto), + m_pythonFont(Preferences::PythonFont::Large) {} Preferences * Preferences::sharedPreferences() {