mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Work in progress: resolve conflicts + settings easier
This commit is contained in:
@@ -15,6 +15,7 @@ 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)
|
||||
|
||||
@@ -41,3 +41,8 @@ AccessibilityGammaRed = "Rotes Gamma"
|
||||
AccessibilityGammaGreen = "Grünes Gamma"
|
||||
AccessibilityGammaBlue = "Blaues Gamma"
|
||||
MathOptions = "Mathe-optionen"
|
||||
SymbolMultiplication = "Multiplikationszeichen"
|
||||
SymbolMultiplicationCross = "Kreuz"
|
||||
SymbolMultiplicationMiddleDot = "Mittelpunkt"
|
||||
SymbolMultiplicationStar = "Stern"
|
||||
SymbolMultiplicationAutoSymbol = "automatisch"
|
||||
|
||||
@@ -41,3 +41,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"
|
||||
|
||||
@@ -41,3 +41,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"
|
||||
|
||||
@@ -41,3 +41,8 @@ AccessibilityGammaRed = "Gamma rouge"
|
||||
AccessibilityGammaGreen = "Gamma vert"
|
||||
AccessibilityGammaBlue = "Gamma bleu"
|
||||
MathOptions = "Math"
|
||||
SymbolMultiplication = "Signe de multiplication"
|
||||
SymbolMultiplicationCross = "Croix"
|
||||
SymbolMultiplicationMiddleDot = "Point"
|
||||
SymbolMultiplicationStar = "Etoile"
|
||||
SymbolMultiplicationAutoSymbol = "Automatique"
|
||||
|
||||
@@ -41,3 +41,8 @@ AccessibilityGammaRed = "Gama vermelha"
|
||||
AccessibilityGammaGreen = "Gama verde"
|
||||
AccessibilityGammaBlue = "Gama azul"
|
||||
MathOptions = "Matemática"
|
||||
SymbolMultiplication = "Sinal de multiplicação"
|
||||
SymbolMultiplicationCross = "crómio"
|
||||
SymbolMultiplicationMiddleDot = "ponto médio"
|
||||
SymbolMultiplicationStar = "estrela"
|
||||
SymbolMultiplicationAutoSymbol = "automático"
|
||||
|
||||
@@ -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/symbol_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ constexpr SettingsMessageTree s_modelAngleChildren[3] = {SettingsMessageTree(I18
|
||||
constexpr SettingsMessageTree s_modelEditionModeChildren[2] = {SettingsMessageTree(I18n::Message::Edition2D), SettingsMessageTree(I18n::Message::EditionLinear)};
|
||||
constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[4] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::Engineering), SettingsMessageTree(I18n::Message::SignificantFigures)};
|
||||
constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
|
||||
//sub-menus
|
||||
constexpr SettingsMessageTree s_modelMathOptionsChildren[4] = {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)};
|
||||
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[2] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::ActivateExamMode)};
|
||||
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
|
||||
@@ -22,7 +23,7 @@ constexpr SettingsMessageTree s_modelAboutChildren[5] = {SettingsMessageTree(I18
|
||||
#endif
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 4),
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 5),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::Language),
|
||||
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 2),
|
||||
@@ -34,7 +35,7 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 5)};
|
||||
#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::BetaPopUp;
|
||||
|
||||
@@ -11,9 +11,10 @@ constexpr SettingsMessageTree s_modelAngleChildren[3] = {SettingsMessageTree(I18
|
||||
constexpr SettingsMessageTree s_modelEditionModeChildren[2] = {SettingsMessageTree(I18n::Message::Edition2D), SettingsMessageTree(I18n::Message::EditionLinear)};
|
||||
constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[4] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::Engineering), SettingsMessageTree(I18n::Message::SignificantFigures)};
|
||||
constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
|
||||
//sub-menus
|
||||
constexpr SettingsMessageTree s_modelMathOptionsChildren[4] = {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)};
|
||||
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[2] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::ActivateExamMode)};
|
||||
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
|
||||
@@ -23,7 +24,7 @@ constexpr SettingsMessageTree s_modelAboutChildren[5] = {SettingsMessageTree(I18
|
||||
#endif
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 4),
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 5),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::Language),
|
||||
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 2),
|
||||
|
||||
@@ -10,9 +10,10 @@ constexpr SettingsMessageTree s_modelAngleChildren[3] = {SettingsMessageTree(I18
|
||||
constexpr SettingsMessageTree s_modelEditionModeChildren[2] = {SettingsMessageTree(I18n::Message::Edition2D), SettingsMessageTree(I18n::Message::EditionLinear)};
|
||||
constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[4] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::Engineering), SettingsMessageTree(I18n::Message::SignificantFigures)};
|
||||
constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
|
||||
//sub-menus
|
||||
constexpr SettingsMessageTree s_modelMathOptionsChildren[4] = {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)};
|
||||
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[2] = {SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4), SettingsMessageTree(I18n::Message::ActivateExamMode)};
|
||||
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
|
||||
@@ -22,7 +23,7 @@ constexpr SettingsMessageTree s_modelAboutChildren[5] = {SettingsMessageTree(I18
|
||||
#endif
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 4),
|
||||
{SettingsMessageTree(I18n::Message::MathOptions, s_modelMathOptionsChildren, 5),
|
||||
SettingsMessageTree(I18n::Message::Brightness),
|
||||
SettingsMessageTree(I18n::Message::Language),
|
||||
SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 2),
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace Settings {
|
||||
MathOptionsController::MathOptionsController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate) :
|
||||
GenericSubController(parentResponder),
|
||||
m_preferencesController(this),
|
||||
m_displayModeController(this, inputEventHandlerDelegate)
|
||||
m_displayModeController(this, inputEventHandlerDelegate),
|
||||
m_symbolController(this)
|
||||
{
|
||||
for (int i = 0; i < k_totalNumberOfCell; i++) {
|
||||
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||
@@ -21,6 +22,8 @@ bool MathOptionsController::handleEvent(Ion::Events::Event event) {
|
||||
GenericSubController * subController = nullptr;
|
||||
if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::DisplayMode)
|
||||
subController = &m_displayModeController;
|
||||
if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::SymbolMultiplication)
|
||||
subController = &m_symbolController;
|
||||
else
|
||||
subController = &m_preferencesController;
|
||||
subController->setMessageTreeModel(m_messageTreeModel->children(selectedRow()));
|
||||
@@ -63,6 +66,9 @@ void MathOptionsController::willDisplayCellForIndex(HighlightCell * cell, int in
|
||||
case I18n::Message::ComplexFormat:
|
||||
childIndex = (int)preferences->complexFormat();
|
||||
break;
|
||||
case I18n::Message::SymbolMultiplication:
|
||||
childIndex = (int)preferences->symbolofMultiplication();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "generic_sub_controller.h"
|
||||
#include <escher.h>
|
||||
#include "display_mode_controller.h"
|
||||
#include "symbol_controller.h"
|
||||
#include "preferences_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
@@ -16,10 +17,11 @@ public:
|
||||
int reusableCellCount(int type) override;
|
||||
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
|
||||
private:
|
||||
constexpr static int k_totalNumberOfCell = 4;
|
||||
constexpr static int k_totalNumberOfCell = 5;
|
||||
MessageTableCellWithChevronAndMessage m_cells[k_totalNumberOfCell];
|
||||
PreferencesController m_preferencesController;
|
||||
DisplayModeController m_displayModeController;
|
||||
SymbolController m_symbolController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
139
apps/settings/sub_menu/symbol_controller.cpp
Normal file
139
apps/settings/sub_menu/symbol_controller.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
#include "symbol_controller.h"
|
||||
#include <assert.h>
|
||||
#include <poincare/preferences.h>
|
||||
|
||||
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 symbolofMultiplication = preferences->symbolofMultiplication();
|
||||
bool autoSymbol = (int)preferences->autoSymbol();
|
||||
if (event == Ion::Events::OK || event == Ion::Events::EXE){
|
||||
switch(selectedRow()){
|
||||
case 0:
|
||||
{
|
||||
symbolofMultiplication = Poincare::Preferences::SymbolMultiplication::Cross;
|
||||
autoSymbol = false;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
symbolofMultiplication = Poincare::Preferences::SymbolMultiplication::MiddleDot;
|
||||
autoSymbol = false;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
symbolofMultiplication = Poincare::Preferences::SymbolMultiplication::Star;
|
||||
autoSymbol = false;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
autoSymbol = !autoSymbol;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
GenericSubController::handleEvent(event);
|
||||
}
|
||||
}
|
||||
preferences->setSymbolMultiplication(symbolofMultiplication);
|
||||
autoSymbol ? preferences->SetAutoSymbol(Poincare::Preferences::AutoSymbol::True) : preferences->SetAutoSymbol(Poincare::Preferences::AutoSymbol::False);
|
||||
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();
|
||||
bool autoSymbol = (int)preferences->autoSymbol();
|
||||
|
||||
if (index == 0) {
|
||||
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
|
||||
if(autoSymbol == true){
|
||||
mySwitch->setState(false);
|
||||
} else if(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::Cross){
|
||||
mySwitch->setState(true);
|
||||
} else {
|
||||
mySwitch->setState(false);
|
||||
}
|
||||
}
|
||||
else if (index == 1) {
|
||||
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
|
||||
if(autoSymbol == true){
|
||||
mySwitch->setState(false);
|
||||
} else if(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::MiddleDot){
|
||||
mySwitch->setState(true);
|
||||
} else {
|
||||
mySwitch->setState(false);
|
||||
}
|
||||
}
|
||||
else if (index == 2) {
|
||||
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
|
||||
if(autoSymbol == true){
|
||||
mySwitch->setState(false);
|
||||
} else if (symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::Star){
|
||||
mySwitch->setState(true);
|
||||
} else {
|
||||
mySwitch->setState(false);
|
||||
}
|
||||
}
|
||||
else if (index == 3){
|
||||
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
|
||||
if(autoSymbol == true){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
23
apps/settings/sub_menu/symbol_controller.h
Normal file
23
apps/settings/sub_menu/symbol_controller.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#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
|
||||
@@ -139,6 +139,8 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
|
||||
m_contentView.cursor()->addEmptyTenPowerLayout();
|
||||
} else if ((strcmp(text, "[") == 0) || (strcmp(text, "]") == 0)) {
|
||||
m_contentView.cursor()->addEmptyMatrixLayout();
|
||||
} else if((strcmp(text, Ion::Events::Multiplication.text())) == 0){
|
||||
m_contentView.cursor()->addMultiplicationPointLayout();
|
||||
} else {
|
||||
Expression resultExpression = Expression::Parse(text);
|
||||
if (resultExpression.isUninitialized()) {
|
||||
|
||||
@@ -31,6 +31,7 @@ static constexpr CodePoint UCodePointRightSystemParenthesis = 0x13; // Used fo
|
||||
|
||||
static constexpr CodePoint UCodePointMiddleDot = 0xb7; // ·
|
||||
static constexpr CodePoint UCodePointMultiplicationSign = 0xd7; // ×
|
||||
static constexpr CodePoint UCodePointStar = 0x2a; // *
|
||||
static constexpr CodePoint UCodePointGreekSmallLetterTheta = 0x3b8; // θ
|
||||
static constexpr CodePoint UCodePointGreekSmallLetterPi = 0x3c0; // π
|
||||
static constexpr CodePoint UCodePointLatinLetterSmallCapitalE = 0x1d07; // ᴇ
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
void addEmptyTenPowerLayout();
|
||||
void addFractionLayoutAndCollapseSiblings();
|
||||
void addXNTCodePointLayout();
|
||||
void addMultiplicationPointLayout();
|
||||
void insertText(const char * text);
|
||||
void addLayoutAndMoveCursor(Layout l);
|
||||
bool showEmptyLayoutIfNeeded() { return privateShowHideEmptyLayoutIfNeeded(true); }
|
||||
|
||||
@@ -42,6 +42,15 @@ public:
|
||||
Blue = 2,
|
||||
Yellow = 3
|
||||
};
|
||||
enum class SymbolMultiplication {
|
||||
Cross = 0,
|
||||
MiddleDot = 1,
|
||||
Star = 2
|
||||
};
|
||||
enum class AutoSymbol{
|
||||
False = 0,
|
||||
True = 1
|
||||
};
|
||||
Preferences();
|
||||
static Preferences * sharedPreferences();
|
||||
AngleUnit angleUnit() const { return m_angleUnit; }
|
||||
@@ -56,6 +65,10 @@ 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;}
|
||||
AutoSymbol autoSymbol() const {return m_autoSymbol;}
|
||||
void SetAutoSymbol(AutoSymbol autoSymbol) {m_autoSymbol = autoSymbol;}
|
||||
private:
|
||||
AngleUnit m_angleUnit;
|
||||
PrintFloatMode m_displayMode;
|
||||
@@ -63,6 +76,8 @@ private:
|
||||
ComplexFormat m_complexFormat;
|
||||
uint8_t m_numberOfSignificantDigits;
|
||||
LEDColor m_colorOfLED;
|
||||
SymbolMultiplication m_symbolMultiplication;
|
||||
AutoSymbol m_autoSymbol;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <poincare/vertical_offset_layout.h>
|
||||
#include <ion/unicode/utf8_decoder.h>
|
||||
#include <stdio.h>
|
||||
#include <poincare/preferences.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -139,6 +140,21 @@ void LayoutCursor::addXNTCodePointLayout() {
|
||||
m_layout.addSibling(this, CodePointLayout::Builder(m_layout.XNTCodePoint()), true);
|
||||
}
|
||||
|
||||
void LayoutCursor::addMultiplicationPointLayout(){
|
||||
Preferences * preferences = Preferences::sharedPreferences();
|
||||
switch((int)preferences->symbolofMultiplication()){
|
||||
case 1:
|
||||
addLayoutAndMoveCursor(HorizontalLayout::Builder(CodePointLayout::Builder(UCodePointMiddleDot)));
|
||||
break;
|
||||
case 2:
|
||||
addLayoutAndMoveCursor(HorizontalLayout::Builder(CodePointLayout::Builder(UCodePointStar)));
|
||||
break;
|
||||
default:
|
||||
addLayoutAndMoveCursor(HorizontalLayout::Builder(CodePointLayout::Builder(UCodePointMultiplicationSign)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutCursor::insertText(const char * text) {
|
||||
Layout newChild;
|
||||
Layout pointedChild;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <assert.h>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include <poincare/preferences.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -159,20 +160,38 @@ static int operatorSymbolBetween(ExpressionNode::LayoutShape left, ExpressionNod
|
||||
}
|
||||
|
||||
CodePoint MultiplicationNode::operatorSymbol() const {
|
||||
Preferences * preferences = Preferences::sharedPreferences();
|
||||
/* ø --> 0
|
||||
* · --> 1
|
||||
* × --> 2 */
|
||||
* × --> 2
|
||||
* * --> 3 */
|
||||
int sign = -1;
|
||||
for (int i = 0; i < numberOfChildren() - 1; i++) {
|
||||
/* The operator symbol must be the same for all operands of the multiplication.
|
||||
* If one operator has to be '×', they will all be '×'. Idem for '·'. */
|
||||
sign = maxInt(sign, operatorSymbolBetween(childAtIndex(i)->rightLayoutShape(), childAtIndex(i+1)->leftLayoutShape()));
|
||||
if(preferences->autoSymbol() == Poincare::Preferences::AutoSymbol::True){
|
||||
for (int i = 0; i < numberOfChildren() - 1; i++) {
|
||||
/* The operator symbol must be the same for all operands of the multiplication.
|
||||
* If one operator has to be '×', they will all be '×'. Idem for '·'. */
|
||||
sign = maxInt(sign, operatorSymbolBetween(childAtIndex(i)->rightLayoutShape(), childAtIndex(i+1)->leftLayoutShape()));
|
||||
}
|
||||
} else {
|
||||
switch(preferences->symbolofMultiplication()){
|
||||
case Poincare::Preferences::SymbolMultiplication::MiddleDot :
|
||||
sign = 1; // · --> · (1)
|
||||
break;
|
||||
case Poincare::Preferences::SymbolMultiplication::Star :
|
||||
sign = 3; // * --> * (3)
|
||||
break;
|
||||
default:
|
||||
sign = 2; // × --> × (2)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (sign) {
|
||||
case 0:
|
||||
return UCodePointNull;
|
||||
case 1:
|
||||
return UCodePointMiddleDot;
|
||||
case 3:
|
||||
return UCodePointStar;
|
||||
default:
|
||||
return UCodePointMultiplicationSign;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ Preferences::Preferences() :
|
||||
m_editionMode(EditionMode::Edition2D),
|
||||
m_complexFormat(Preferences::ComplexFormat::Real),
|
||||
m_numberOfSignificantDigits(PrintFloat::k_numberOfPrintedSignificantDigits),
|
||||
m_colorOfLED(Preferences::LEDColor::White)
|
||||
m_colorOfLED(Preferences::LEDColor::White),
|
||||
m_symbolMultiplication(Preferences::SymbolMultiplication::Cross),
|
||||
m_autoSymbol(Preferences::AutoSymbol::True)
|
||||
{}
|
||||
|
||||
Preferences * Preferences::sharedPreferences() {
|
||||
|
||||
Reference in New Issue
Block a user