From 55074c2312411a16f670738635a48af5ceb726b5 Mon Sep 17 00:00:00 2001 From: Pepe Rivera Date: Thu, 3 Oct 2019 15:56:44 -0700 Subject: [PATCH] Update Calculator keyboard for greater consistency and extensibility (#688) --- .../Common/CalculatorButtonUser.h | 27 +- .../Common/LocalizationService.cpp | 35 +- src/CalcViewModel/Common/NavCategory.cpp | 6 +- .../StandardCalculatorViewModel.cpp | 1 - .../StandardCalculatorViewModel.h | 18 - src/Calculator/App.xaml | 471 ++++- src/Calculator/Assets/CalcMDL2.ttf | Bin 24040 -> 24028 bytes src/Calculator/Calculator.vcxproj | 6 + src/Calculator/Calculator.vcxproj.filters | 18 + .../Controls/OperatorPanelButton.cpp | 44 + src/Calculator/Controls/OperatorPanelButton.h | 36 + .../Controls/OperatorPanelListView.cpp | 147 ++ .../Controls/OperatorPanelListView.h | 43 + src/Calculator/Resources/en-US/Resources.resw | 430 ++++- src/Calculator/Views/Calculator.xaml.h | 3 + .../CalculatorProgrammerRadixOperators.xaml | 656 +++++-- ...alculatorProgrammerRadixOperators.xaml.cpp | 84 +- .../CalculatorProgrammerRadixOperators.xaml.h | 6 +- .../CalculatorScientificAngleButtons.xaml | 16 +- .../CalculatorScientificAngleButtons.xaml.cpp | 4 - .../CalculatorScientificAngleButtons.xaml.h | 3 +- .../Views/CalculatorScientificOperators.xaml | 1559 +++++++++++------ .../CalculatorScientificOperators.xaml.cpp | 90 +- .../CalculatorScientificOperators.xaml.h | 16 +- .../Views/CalculatorStandardOperators.xaml | 442 ++--- .../CalculatorStandardOperators.xaml.cpp | 1 + src/Calculator/Views/NumberPad.xaml | 3 +- src/Calculator/Views/OperatorsPanel.xaml | 20 +- src/Calculator/Views/OperatorsPanel.xaml.cpp | 7 +- .../StateTriggers/ControlSizeTrigger.cpp | 80 + .../Views/StateTriggers/ControlSizeTrigger.h | 37 + src/Calculator/Views/UnitConverter.xaml | 5 +- .../StandardModeFunctionalTests.cs | 15 - src/Settings.XamlStyler | 3 +- 34 files changed, 3151 insertions(+), 1181 deletions(-) create mode 100644 src/Calculator/Controls/OperatorPanelButton.cpp create mode 100644 src/Calculator/Controls/OperatorPanelButton.h create mode 100644 src/Calculator/Controls/OperatorPanelListView.cpp create mode 100644 src/Calculator/Controls/OperatorPanelListView.h create mode 100644 src/Calculator/Views/StateTriggers/ControlSizeTrigger.cpp create mode 100644 src/Calculator/Views/StateTriggers/ControlSizeTrigger.h diff --git a/src/CalcViewModel/Common/CalculatorButtonUser.h b/src/CalcViewModel/Common/CalculatorButtonUser.h index b9ce332..113d34d 100644 --- a/src/CalcViewModel/Common/CalculatorButtonUser.h +++ b/src/CalcViewModel/Common/CalculatorButtonUser.h @@ -94,6 +94,32 @@ public Byte = (int)CM::Command::CommandByte, Cube = (int)CM::Command::CommandCUB, DMS = (int)CM::Command::CommandDMS, + Hyp = (int) CM::Command::CommandHYP, + Sec = (int) CM::Command::CommandSEC, + Csc = (int) CM::Command::CommandCSC, + Cot = (int) CM::Command::CommandCOT, + InvSec = (int) CM::Command::CommandASEC, + InvCsc = (int) CM::Command::CommandACSC, + InvCot = (int) CM::Command::CommandACOT, + Sech = (int) CM::Command::CommandSECH, + Csch = (int) CM::Command::CommandCSCH, + Coth = (int) CM::Command::CommandCOTH, + InvSech = (int) CM::Command::CommandASECH, + InvCsch = (int) CM::Command::CommandACSCH, + InvCoth = (int) CM::Command::CommandACOTH, + CubeRoot = (int) CM::Command::CommandCUBEROOT, + TwoPowerX = (int) CM::Command::CommandPOW2, + LogBaseX = (int) CM::Command::CommandLogBaseX, + Nand = (int) CM::Command::CommandNand, + Nor = (int) CM::Command::CommandNor, + Abs = (int) CM::Command::CommandAbs, + Floor = (int) CM::Command::CommandFloor, + Ceil = (int) CM::Command::CommandCeil, + Rand = (int) CM::Command::CommandRand, + Euler = (int) CM::Command::CommandEuler, + RshL = (int)CM::Command::CommandRSHFL, + RolC = (int)CM::Command::CommandROLC, + RorC = (int)CM::Command::CommandRORC, BINSTART = (int)CM::Command::CommandBINEDITSTART, BINPOS0 = (int)CM::Command::CommandBINPOS0, @@ -161,7 +187,6 @@ public BINPOS62 = (int)CM::Command::CommandBINPOS62, BINPOS63 = (int)CM::Command::CommandBINPOS63, BINEND = (int)CM::Command::CommandBINEDITEND, - Hyp = (int)CM::Command::CommandHYP, // Enum values below are used for Tracelogging and do not map to the Calculator engine MemoryAdd = (int)CM::Command::CommandMPLUS, diff --git a/src/CalcViewModel/Common/LocalizationService.cpp b/src/CalcViewModel/Common/LocalizationService.cpp index eacc04d..f314336 100644 --- a/src/CalcViewModel/Common/LocalizationService.cpp +++ b/src/CalcViewModel/Common/LocalizationService.cpp @@ -503,16 +503,49 @@ unordered_map LocalizationService::GetTokenToReadableNameMap() make_pair(L"27", L"HyperbolicTangent"), make_pair(L"87", L"InverseHyperbolicTangent"), + // Secant permutations + make_pair(L"SecDeg", L"SecantDegrees"), + make_pair(L"SecRad", L"SecantRadians"), + make_pair(L"SecGrad", L"SecantGradians"), + make_pair(L"InverseSecDeg", L"InverseSecantDegrees"), + make_pair(L"InverseSecRad", L"InverseSecantRadians"), + make_pair(L"InverseSecGrad", L"InverseSecantGradians"), + make_pair(L"Sech", L"HyperbolicSecant"), + make_pair(L"InverseSech", L"InverseHyperbolicSecant"), + + // Cosecant permutations + make_pair(L"CscDeg", L"CosecantDegrees"), + make_pair(L"CscRad", L"CosecantRadians"), + make_pair(L"CscGrad", L"CosecantGradians"), + make_pair(L"InverseCscDeg", L"InverseCosecantDegrees"), + make_pair(L"InverseCscRad", L"InverseCosecantRadians"), + make_pair(L"InverseCscGrad", L"InverseCosecantGradians"), + make_pair(L"Csch", L"HyperbolicCosecant"), + make_pair(L"InverseCsch", L"InverseHyperbolicCosecant"), + + // Cotangent permutations + make_pair(L"CotDeg", L"CotangentDegrees"), + make_pair(L"CotRad", L"CotangentRadians"), + make_pair(L"CotGrad", L"CotangentGradians"), + make_pair(L"InverseCotDeg", L"InverseCotangentDegrees"), + make_pair(L"InverseCotRad", L"InverseCotangentRadians"), + make_pair(L"InverseCotGrad", L"InverseCotangentGradians"), + make_pair(L"Coth", L"HyperbolicCotangent"), + make_pair(L"InverseCoth", L"InverseHyperbolicCotangent"), + // Miscellaneous Scientific functions make_pair(L"94", L"Factorial"), make_pair(L"35", L"DegreeMinuteSecond"), make_pair(L"28", L"NaturalLog"), - make_pair(L"91", L"Square") + make_pair(L"91", L"Square"), + make_pair(L"CubeRoot", L"CubeRoot"), + make_pair(L"Abs", L"AbsoluteValue") }; static vector> s_noParenEngineKeyResourceMap = { // Programmer mode functions make_pair(L"9", L"LeftShift"), make_pair(L"10", L"RightShift"), + make_pair(L"LogBaseX", L"Logx"), // Y Root scientific function make_pair(L"16", L"YRoot") diff --git a/src/CalcViewModel/Common/NavCategory.cpp b/src/CalcViewModel/Common/NavCategory.cpp index 9dfd905..8bffc79 100644 --- a/src/CalcViewModel/Common/NavCategory.cpp +++ b/src/CalcViewModel/Common/NavCategory.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "pch.h" @@ -160,7 +160,7 @@ static constexpr array s_categoryManifest = { L"\uE945", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY }, + SUPPORTS_NEGATIVE }, NavCategoryInitializer{ ViewMode::Data, DATA_ID, L"Data", @@ -184,7 +184,7 @@ static constexpr array s_categoryManifest = { L"\uF515", CategoryGroupType::Converter, MyVirtualKey::None, - POSITIVE_ONLY } }; + SUPPORTS_NEGATIVE } }; // This function should only be used when storing the mode to app data. int NavCategory::Serialize(ViewMode mode) diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index 04f5726..c842d20 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -73,7 +73,6 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() , m_MemorizedNumbers(ref new Vector()) , m_IsMemoryEmpty(true) , m_IsFToEChecked(false) - , m_isShiftChecked(false) , m_IsShiftProgrammerChecked(false) , m_valueBitLength(BitLength::BitLengthQWord) , m_isBitFlipChecked(false) diff --git a/src/CalcViewModel/StandardCalculatorViewModel.h b/src/CalcViewModel/StandardCalculatorViewModel.h index d003708..744fe9f 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.h +++ b/src/CalcViewModel/StandardCalculatorViewModel.h @@ -66,7 +66,6 @@ namespace CalculatorApp OBSERVABLE_NAMED_PROPERTY_RW(bool, IsMemoryEmpty); OBSERVABLE_PROPERTY_RW(bool, IsFToEChecked); OBSERVABLE_PROPERTY_RW(bool, IsFToEEnabled); - OBSERVABLE_PROPERTY_RW(bool, IsHyperbolicChecked); OBSERVABLE_PROPERTY_RW(bool, AreHEXButtonsEnabled); OBSERVABLE_PROPERTY_RW(Platform::String ^, CalculationResultAutomationName); OBSERVABLE_PROPERTY_RW(Platform::String ^, CalculationExpressionAutomationName); @@ -90,22 +89,6 @@ namespace CalculatorApp event HideMemoryClickedHandler ^ HideMemoryClicked; - property bool IsShiftChecked - { - bool get() - { - return m_isShiftChecked; - } - void set(bool value) - { - if (m_isShiftChecked != value) - { - m_isShiftChecked = value; - RaisePropertyChanged(L"IsShiftChecked"); - } - } - } - property bool IsBitFlipChecked { bool get() @@ -435,7 +418,6 @@ namespace CalculatorApp bool m_isAlwaysOnTop; bool m_isBinaryBitFlippingEnabled; bool m_isBitFlipChecked; - bool m_isShiftChecked; bool m_isRtlLanguage; int m_tokenPosition; bool m_keyPressed; diff --git a/src/Calculator/App.xaml b/src/Calculator/App.xaml index d9b2d7b..a08fb6d 100644 --- a/src/Calculator/App.xaml +++ b/src/Calculator/App.xaml @@ -17,17 +17,33 @@ 0 #FF000000 #FF2B2B2B + #FF858585 + + + + + + + + 0,0,0,0 0 #FFF2F2F2 #FFE0E0E0 + #FF858585 + + + + + + + + 0,1,0,0 @@ -91,17 +129,23 @@ + - + + + + + + @@ -116,6 +160,21 @@ 15 SemiBold + 64 + 24 + 24 + 16 + + 64 + 16 + 20 + 10 + + 38 + 12 + 16 + 8 + 12 15 24 @@ -125,13 +184,17 @@ 40 34 + 38 + 48 24 20 + 22 15 12 - 15 + 14 + 16 + + + + + - + + + + @@ -457,6 +562,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +