2020-03-23 10:44:02 -07:00
# pragma once
2020-07-13 11:49:09 -07:00
# include "keyboardmanager/common/Shortcut.h"
2020-07-23 16:43:49 -07:00
# include <variant>
2020-07-13 11:49:09 -07:00
class KeyboardManagerState ;
class KeyDropDownControl ;
namespace winrt : : Windows : : UI : : Xaml
{
struct XamlRoot ;
namespace Controls
{
struct StackPanel ;
struct Grid ;
struct TextBox ;
}
}
2020-03-23 10:44:02 -07:00
class ShortcutControl
{
private :
2020-04-18 16:12:26 -07:00
// Stack panel for the drop downs to display the selected shortcut
2020-07-13 11:49:09 -07:00
winrt : : Windows : : Foundation : : IInspectable shortcutDropDownStackPanel ;
2020-04-18 16:12:26 -07:00
2020-03-23 10:44:02 -07:00
// Button to type the shortcut
2020-07-13 11:49:09 -07:00
winrt : : Windows : : Foundation : : IInspectable typeShortcut ;
2020-03-23 10:44:02 -07:00
// StackPanel to parent the above controls
2020-07-13 11:49:09 -07:00
winrt : : Windows : : Foundation : : IInspectable shortcutControlLayout ;
2020-03-23 10:44:02 -07:00
public :
// Handle to the current Edit Shortcuts Window
static HWND EditShortcutsWindowHandle ;
// Pointer to the keyboard manager state
static KeyboardManagerState * keyboardManagerState ;
2020-04-09 09:20:19 -07:00
// Stores the current list of remappings
2020-08-13 16:32:15 -07:00
static RemapBuffer shortcutRemapBuffer ;
2020-04-18 16:12:26 -07:00
// Vector to store dynamically allocated KeyDropDownControl objects to avoid early destruction
std : : vector < std : : unique_ptr < KeyDropDownControl > > keyDropDownControlObjects ;
2020-03-23 10:44:02 -07:00
2020-07-13 11:49:09 -07:00
// constructor
ShortcutControl ( Grid table , const int colIndex , TextBox targetApp ) ;
2020-03-23 10:44:02 -07:00
// Function to add a new row to the shortcut table. If the originalKeys and newKeys args are provided, then the displayed shortcuts are set to those values.
2020-07-23 16:43:49 -07:00
static void AddNewShortcutControlRow ( Grid & parent , std : : vector < std : : vector < std : : unique_ptr < ShortcutControl > > > & keyboardRemapControlObjects , const Shortcut & originalKeys = Shortcut ( ) , const std : : variant < DWORD , Shortcut > & newKeys = Shortcut ( ) , const std : : wstring & targetAppName = L " " ) ;
2020-03-23 10:44:02 -07:00
// Function to return the stack panel element of the ShortcutControl. This is the externally visible UI element which can be used to add it to other layouts
StackPanel getShortcutControl ( ) ;
// Function to create the detect shortcut UI window
2020-08-13 16:32:15 -07:00
static void createDetectShortcutWindow ( winrt : : Windows : : Foundation : : IInspectable const & sender , XamlRoot xamlRoot , KeyboardManagerState & keyboardManagerState , const int colIndex , Grid table , std : : vector < std : : unique_ptr < KeyDropDownControl > > & keyDropDownControlObjects , StackPanel controlLayout , TextBox targetApp , bool isHybridControl , bool isSingleKeyWindow , HWND parentWindow , RemapBuffer & remapBuffer ) ;
2020-03-23 10:44:02 -07:00
} ;