2021-04-27 03:01:38 +08:00
# pragma once
2021-05-07 16:16:31 +08:00
# include <keyboardmanager/common/Shortcut.h>
2021-04-27 03:01:38 +08:00
# include <KeyDropDownControl.h>
2021-05-07 16:16:31 +08:00
namespace KBMEditor
{
class KeyboardManagerState ;
}
2021-04-27 03:01:38 +08:00
namespace winrt : : Windows : : UI : : Xaml
{
struct XamlRoot ;
namespace Controls
{
struct StackPanel ;
struct Grid ;
struct Button ;
}
}
class SingleKeyRemapControl
{
private :
// Button to type the remap key
winrt : : Windows : : Foundation : : IInspectable typeKey ;
// StackPanel to parent the above controls
winrt : : Windows : : Foundation : : IInspectable singleKeyRemapControlLayout ;
// Stack panel for the drop downs to display the selected shortcut for the hybrid case
winrt : : Windows : : Foundation : : IInspectable hybridDropDownStackPanel ;
// Function to set the accessible names for all the controls in a row
static void UpdateAccessibleNames ( StackPanel sourceColumn , StackPanel mappedToColumn , Button deleteButton , int rowIndex ) ;
public :
// Vector to store dynamically allocated KeyDropDownControl objects to avoid early destruction
std : : vector < std : : unique_ptr < KeyDropDownControl > > keyDropDownControlObjects ;
// Handle to the current Edit Keyboard Window
static HWND EditKeyboardWindowHandle ;
// Pointer to the keyboard manager state
2021-05-07 16:16:31 +08:00
static KBMEditor : : KeyboardManagerState * keyboardManagerState ;
2021-04-27 03:01:38 +08:00
// Stores the current list of remappings
static RemapBuffer singleKeyRemapBuffer ;
// constructor
SingleKeyRemapControl ( StackPanel table , StackPanel row , const int colIndex ) ;
// Function to add a new row to the remap keys table. If the originalKey and newKey args are provided, then the displayed remap keys are set to those values.
2021-06-02 00:15:16 +08:00
static void AddNewControlKeyRemapRow ( StackPanel & parent , std : : vector < std : : vector < std : : unique_ptr < SingleKeyRemapControl > > > & keyboardRemapControlObjects , const DWORD originalKey = 0 , const KeyShortcutUnion newKey = ( DWORD ) 0 ) ;
2021-04-27 03:01:38 +08:00
// Function to return the stack panel element of the SingleKeyRemapControl. This is the externally visible UI element which can be used to add it to other layouts
winrt : : Windows : : UI : : Xaml : : Controls : : StackPanel getSingleKeyRemapControl ( ) ;
// Function to create the detect remap keys UI window
2021-05-07 16:16:31 +08:00
void createDetectKeyWindow ( winrt : : Windows : : Foundation : : IInspectable const & sender , XamlRoot xamlRoot , KBMEditor : : KeyboardManagerState & keyboardManagerState ) ;
2021-04-27 03:01:38 +08:00
} ;