Improve warnings for KBM (dev/build-features) (#2386)

* Handled invalid input for single key remaps

* Added some functions

* Added better error message functions and finished warnings for edit keyboard

* Updated dropdown order of keys

* Added new warning template for shortcuts

* Added show warning on Apply code

* Removed old flyout code

* Fixed issue where tooltips were replaced on Apply

* Simplified == operator
This commit is contained in:
Arjun Balgovind
2020-04-26 15:09:40 -07:00
committed by GitHub
parent 7ec8d02c1f
commit 38ecc82e97
15 changed files with 439 additions and 125 deletions

View File

@@ -11,6 +11,10 @@ private:
HKL previousLayout = 0;
// Stores the key code list
std::vector<DWORD> keyCodeList;
// Stores the warning control
FontIcon warning;
// Stores the tooltip for the warning control
ToolTip toolTip;
// Function to set properties apart from the SelectionChanged event handler
void SetDefaultProperties(bool isShortcut);
@@ -22,17 +26,18 @@ public:
// Pointer to the keyboard manager state
static KeyboardManagerState* keyboardManagerState;
// Constructor for single key drop down
KeyDropDownControl(bool isShortcut)
// Constructor
KeyDropDownControl(bool isShortcut, FontIcon warning, ToolTip toolTip) :
warning(warning), toolTip(toolTip)
{
SetDefaultProperties(isShortcut);
}
// Function to set selection handler for single key remap drop down. Needs to be called after the constructor since the singleKeyControl StackPanel is null if called in the constructor
void SetSelectionHandler(Grid& table, StackPanel& singleKeyControl, size_t colIndex, std::vector<std::vector<DWORD>>& singleKeyRemapBuffer);
void SetSelectionHandler(Grid& table, StackPanel& singleKeyControl, int colIndex, std::vector<std::vector<DWORD>>& singleKeyRemapBuffer);
// Function to set selection handler for shortcut drop down. Needs to be called after the constructor since the shortcutControl StackPanel is null if called in the constructor
void SetSelectionHandler(Grid& table, StackPanel& shortcutControl, StackPanel parent, size_t colIndex, std::vector<std::vector<Shortcut>>& shortcutRemapBuffer, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects);
void SetSelectionHandler(Grid& table, StackPanel& shortcutControl, StackPanel parent, int colIndex, std::vector<std::vector<Shortcut>>& shortcutRemapBuffer, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects);
// Function to set the selected index of the drop down
void SetSelectedIndex(int32_t index);
@@ -41,7 +46,7 @@ public:
ComboBox GetComboBox();
// Function to add a drop down to the shortcut stack panel
static void AddDropDown(Grid table, StackPanel shortcutControl, StackPanel parent, const size_t colIndex, std::vector<std::vector<Shortcut>>& shortcutRemapBuffer, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects);
static void AddDropDown(Grid table, StackPanel shortcutControl, StackPanel parent, const int colIndex, std::vector<std::vector<Shortcut>>& shortcutRemapBuffer, std::vector<std::unique_ptr<KeyDropDownControl>>& keyDropDownControlObjects, FontIcon warning, ToolTip toolTip);
// Function to get the list of key codes from the shortcut combo box stack panel
std::vector<DWORD> GetKeysFromStackPanel(StackPanel parent);
@@ -49,6 +54,6 @@ public:
// Function to check if a modifier has been repeated in the previous drop downs
bool CheckRepeatedModifier(StackPanel parent, uint32_t dropDownIndex, int selectedKeyIndex, const std::vector<DWORD>& keyCodeList);
// Function to set the flyout warning message
void SetDropDownError(ComboBox dropDown, TextBlock messageBlock, hstring message);
// Function to set the warning message
void SetDropDownError(ComboBox currentDropDown, hstring message);
};