mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Added submenu in settings for changing the symbol of multiplication
This commit is contained in:
@@ -14,6 +14,7 @@ app_settings_src = $(addprefix apps/settings/,\
|
||||
sub_menu/message_table_cell_with_editable_text_with_separator.cpp \
|
||||
sub_menu/preferences_controller.cpp \
|
||||
sub_menu/contributors_controller.cpp \
|
||||
sub_menu/symbol_controller.cpp \
|
||||
)
|
||||
|
||||
app_src += $(app_settings_src)
|
||||
|
||||
@@ -40,3 +40,8 @@ AccessibilityGamma = "Gammakorrektur"
|
||||
AccessibilityGammaRed = "Rotes Gamma"
|
||||
AccessibilityGammaGreen = "Grünes Gamma"
|
||||
AccessibilityGammaBlue = "Blaues Gamma"
|
||||
SymbolMultiplication = "Multiplikationszeichen"
|
||||
SymbolMultiplicationCross = "Kreuz"
|
||||
SymbolMultiplicationMiddleDot = "Mittelpunkt"
|
||||
SymbolMultiplicationStar = "Stern"
|
||||
SymbolMultiplicationAutoSymbol = "Immer vereinfachen"
|
||||
|
||||
@@ -40,3 +40,8 @@ AccessibilityGamma = "Gamma correction"
|
||||
AccessibilityGammaRed = "Red gamma"
|
||||
AccessibilityGammaGreen = "Green gamma"
|
||||
AccessibilityGammaBlue = "Blue gamma"
|
||||
SymbolMultiplication = "Symbol of multiplication"
|
||||
SymbolMultiplicationCross = "Cross"
|
||||
SymbolMultiplicationMiddleDot = "Middle dot"
|
||||
SymbolMultiplicationStar = "Star"
|
||||
SymbolMultiplicationAutoSymbol = "Always simplify"
|
||||
|
||||
@@ -40,3 +40,8 @@ AccessibilityGamma = "Corrección gamma"
|
||||
AccessibilityGammaRed = "Gamma roja"
|
||||
AccessibilityGammaGreen = "Gamma verde"
|
||||
AccessibilityGammaBlue = "Gamma azul"
|
||||
SymbolMultiplication = "signo de multiplicación"
|
||||
SymbolMultiplicationCross = "contrariar"
|
||||
SymbolMultiplicationMiddleDot = "punto medio"
|
||||
SymbolMultiplicationStar = "estrella"
|
||||
SymbolMultiplicationAutoSymbol = "siempre simplifique"
|
||||
|
||||
@@ -40,3 +40,8 @@ AccessibilityGamma = "Correction gamma"
|
||||
AccessibilityGammaRed = "Gamma rouge"
|
||||
AccessibilityGammaGreen = "Gamma vert"
|
||||
AccessibilityGammaBlue = "Gamma bleu"
|
||||
SymbolMultiplication = "Signe de multiplication"
|
||||
SymbolMultiplicationCross = "Croix"
|
||||
SymbolMultiplicationMiddleDot = "Point"
|
||||
SymbolMultiplicationStar = "Etoile"
|
||||
SymbolMultiplicationAutoSymbol = "Toujours simplifier"
|
||||
|
||||
@@ -40,3 +40,8 @@ AccessibilityGamma = "Correção gama"
|
||||
AccessibilityGammaRed = "Gama vermelha"
|
||||
AccessibilityGammaGreen = "Gama verde"
|
||||
AccessibilityGammaBlue = "Gama azul"
|
||||
SymbolMultiplication = "Sinal de multiplicação"
|
||||
SymbolMultiplicationCross = "crómio"
|
||||
SymbolMultiplicationMiddleDot = "ponto médio"
|
||||
SymbolMultiplicationStar = "estrela"
|
||||
SymbolMultiplicationAutoSymbol = "Sempre simplificar"
|
||||
|
||||
@@ -18,7 +18,8 @@ MainController::MainController(Responder * parentResponder, InputEventHandlerDel
|
||||
m_accessibilityController(this),
|
||||
m_examModeController(this),
|
||||
m_aboutController(this),
|
||||
m_contributorsController(this)
|
||||
m_contributorsController(this),
|
||||
m_symbolController(this)
|
||||
{
|
||||
for (int i = 0; i < k_numberOfSimpleChevronCells; i++) {
|
||||
m_cells[i].setMessageFont(KDFont::LargeFont);
|
||||
@@ -80,6 +81,8 @@ bool MainController::handleEvent(Ion::Events::Event event) {
|
||||
subController = &m_accessibilityController;
|
||||
} else if (rowIndex == 10 + hasPrompt()) {
|
||||
subController = &m_contributorsController;
|
||||
} else if (rowIndex == 11 + hasPrompt()){
|
||||
subController = &m_symbolController;
|
||||
} else {
|
||||
subController = &m_preferencesController;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "sub_menu/language_controller.h"
|
||||
#include "sub_menu/preferences_controller.h"
|
||||
#include "sub_menu/contributors_controller.h"
|
||||
#include "sub_menu/symbol_controller.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
@@ -45,6 +46,7 @@ private:
|
||||
ExamModeController m_examModeController;
|
||||
AboutController m_aboutController;
|
||||
ContributorsController m_contributorsController;
|
||||
SymbolController m_symbolController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ constexpr SettingsMessageTree s_modelAboutChildren[4] = {SettingsMessageTree(I18
|
||||
constexpr SettingsMessageTree s_ledColorChildren[4] = {SettingsMessageTree(I18n::Message::ColorWhite), SettingsMessageTree(I18n::Message::ColorGreen), SettingsMessageTree(I18n::Message::ColorBlue), SettingsMessageTree(I18n::Message::ColorYellow)};
|
||||
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)};
|
||||
constexpr SettingsMessageTree s_contributorsChildren[5] = {SettingsMessageTree(I18n::Message::QuentinGuidee), SettingsMessageTree(I18n::Message::DannySimmons), SettingsMessageTree(I18n::Message::JoachimLeFournis), SettingsMessageTree(I18n::Message::JeanBaptisteBoric), SettingsMessageTree(I18n::Message::MaximeFriess)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 3),
|
||||
@@ -33,9 +34,10 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren, 6),
|
||||
SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 5)};
|
||||
SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 5),
|
||||
SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren, 4)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 12);
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 13);
|
||||
|
||||
I18n::Message MainController::promptMessage() const {
|
||||
return I18n::Message::BetaPopUp;
|
||||
|
||||
@@ -17,6 +17,7 @@ constexpr SettingsMessageTree s_modelAboutChildren[4] = {SettingsMessageTree(I18
|
||||
constexpr SettingsMessageTree s_ledColorChildren[4] = {SettingsMessageTree(I18n::Message::ColorWhite), SettingsMessageTree(I18n::Message::ColorGreen), SettingsMessageTree(I18n::Message::ColorBlue), SettingsMessageTree(I18n::Message::ColorYellow)};
|
||||
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)};
|
||||
constexpr SettingsMessageTree s_contributorsChildren[5] = {SettingsMessageTree(I18n::Message::QuentinGuidee), SettingsMessageTree(I18n::Message::DannySimmons), SettingsMessageTree(I18n::Message::JoachimLeFournis), SettingsMessageTree(I18n::Message::JeanBaptisteBoric), SettingsMessageTree(I18n::Message::MaximeFriess)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 3),
|
||||
@@ -33,9 +34,10 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren, 6),
|
||||
SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 5)};
|
||||
SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 5),
|
||||
SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren, 4)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 11);
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 12);
|
||||
|
||||
I18n::Message MainController::promptMessage() const {
|
||||
return I18n::Message::Default;
|
||||
|
||||
@@ -16,6 +16,7 @@ constexpr SettingsMessageTree s_modelAboutChildren[4] = {SettingsMessageTree(I18
|
||||
constexpr SettingsMessageTree s_ledColorChildren[4] = {SettingsMessageTree(I18n::Message::ColorWhite), SettingsMessageTree(I18n::Message::ColorGreen), SettingsMessageTree(I18n::Message::ColorBlue), SettingsMessageTree(I18n::Message::ColorYellow)};
|
||||
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)};
|
||||
constexpr SettingsMessageTree s_contributorsChildren[5] = {SettingsMessageTree(I18n::Message::QuentinGuidee), SettingsMessageTree(I18n::Message::DannySimmons), SettingsMessageTree(I18n::Message::JoachimLeFournis), SettingsMessageTree(I18n::Message::JeanBaptisteBoric), SettingsMessageTree(I18n::Message::MaximeFriess)};
|
||||
constexpr SettingsMessageTree s_symbolChildren[4] = {SettingsMessageTree(I18n::Message::SymbolMultiplicationCross),SettingsMessageTree(I18n::Message::SymbolMultiplicationMiddleDot),SettingsMessageTree(I18n::Message::SymbolMultiplicationStar),SettingsMessageTree(I18n::Message::SymbolMultiplicationAutoSymbol)};
|
||||
|
||||
constexpr SettingsMessageTree s_modelMenu[] =
|
||||
{SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 3),
|
||||
@@ -33,9 +34,10 @@ constexpr SettingsMessageTree s_modelMenu[] =
|
||||
#endif
|
||||
SettingsMessageTree(I18n::Message::LEDColor, s_ledColorChildren, 4),
|
||||
SettingsMessageTree(I18n::Message::Accessibility, s_accessibilityChildren, 6),
|
||||
SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 5)};
|
||||
SettingsMessageTree(I18n::Message::Contributors, s_contributorsChildren, 5),
|
||||
SettingsMessageTree(I18n::Message::SymbolMultiplication, s_symbolChildren, 4)};
|
||||
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 12);
|
||||
constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 13);
|
||||
|
||||
I18n::Message MainController::promptMessage() const {
|
||||
return I18n::Message::UpdatePopUp;
|
||||
|
||||
132
apps/settings/sub_menu/symbol_controller.cpp
Normal file
132
apps/settings/sub_menu/symbol_controller.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
#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;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
symbolofMultiplication = Poincare::Preferences::SymbolMultiplication::MiddleDot;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
symbolofMultiplication = Poincare::Preferences::SymbolMultiplication::Star;
|
||||
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();
|
||||
} 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(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::Cross){
|
||||
mySwitch->setState(true);
|
||||
} else {
|
||||
mySwitch->setState(false);
|
||||
}
|
||||
//mySwitch->setState(KDIonContext::sharedContext()->invertEnabled);
|
||||
}
|
||||
else if (index == 1) {
|
||||
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
|
||||
if(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::MiddleDot){
|
||||
mySwitch->setState(true);
|
||||
} else {
|
||||
mySwitch->setState(false);
|
||||
}
|
||||
//mySwitch->setState(KDIonContext::sharedContext()->zoomEnabled);
|
||||
}
|
||||
else if (index == 2) {
|
||||
SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView();
|
||||
if(symbolofMultiplication == Poincare::Preferences::SymbolMultiplication::Star){
|
||||
mySwitch->setState(true);
|
||||
} else {
|
||||
mySwitch->setState(false);
|
||||
}
|
||||
//mySwitch->setState(KDIonContext::sharedContext()->gammaEnabled);
|
||||
}
|
||||
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