mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
* Added combobox * Formatted and removed unused code * Added drop down support for Edit Keyboard window * Reordered the displayed key list * Add shortcut stack panels and drop downs linked to detect shortcut * Add more selected item logic * Added complete dropdown support for edit shortcuts window * Added Flyout warning for incorrect drop down input * Tweaked warnings * Removed MainWindow code * Changed SelectedValue toSelectedIndex * Removed unnecessary assignments * Added a warning for two dropdowns and the first one is changed to an action key * Added function comments in cpp file * Fixed some comments * Fixed all allocation and out of scope issues * Fix most issues except reloading shortcuts * Fixed issue while reloading shortcuts * Fixed type cast warnings * Changed delete to delete[] * tweaked
55 lines
2.9 KiB
C++
55 lines
2.9 KiB
C++
#pragma once
|
|
#include <keyboardmanager/common/KeyboardManagerState.h>
|
|
#include "KeyDropDownControl.h"
|
|
|
|
class SingleKeyRemapControl
|
|
{
|
|
private:
|
|
// Drop down to display the selected remap key
|
|
KeyDropDownControl singleKeyRemapDropDown;
|
|
|
|
// Button to type the remap key
|
|
Button typeKey;
|
|
|
|
// StackPanel to parent the above controls
|
|
StackPanel singleKeyRemapControlLayout;
|
|
|
|
public:
|
|
// Handle to the current Edit Keyboard Window
|
|
static HWND EditKeyboardWindowHandle;
|
|
// Pointer to the keyboard manager state
|
|
static KeyboardManagerState* keyboardManagerState;
|
|
// Stores the current list of remappings
|
|
static std::vector<std::vector<DWORD>> singleKeyRemapBuffer;
|
|
|
|
SingleKeyRemapControl(const size_t rowIndex, const size_t colIndex) :
|
|
singleKeyRemapDropDown(rowIndex, colIndex, singleKeyRemapBuffer)
|
|
{
|
|
typeKey.Content(winrt::box_value(winrt::to_hstring("Type Key")));
|
|
typeKey.Background(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::LightGray() });
|
|
typeKey.Foreground(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::Black() });
|
|
typeKey.Click([&, rowIndex, colIndex](IInspectable const& sender, RoutedEventArgs const&) {
|
|
keyboardManagerState->SetUIState(KeyboardManagerUIState::DetectSingleKeyRemapWindowActivated, EditKeyboardWindowHandle);
|
|
// Using the XamlRoot of the typeKey to get the root of the XAML host
|
|
createDetectKeyWindow(sender, sender.as<Button>().XamlRoot(), singleKeyRemapBuffer, *keyboardManagerState, rowIndex, colIndex);
|
|
});
|
|
|
|
singleKeyRemapControlLayout.Background(Windows::UI::Xaml::Media::SolidColorBrush{ Windows::UI::Colors::LightGray() });
|
|
singleKeyRemapControlLayout.Margin({ 0, 0, 0, 10 });
|
|
singleKeyRemapControlLayout.Spacing(10);
|
|
|
|
singleKeyRemapControlLayout.Children().Append(typeKey);
|
|
singleKeyRemapControlLayout.Children().Append(singleKeyRemapDropDown.GetComboBox());
|
|
singleKeyRemapControlLayout.UpdateLayout();
|
|
}
|
|
|
|
// 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.
|
|
static void AddNewControlKeyRemapRow(StackPanel& parent, std::vector<std::vector<std::unique_ptr<SingleKeyRemapControl>>>& keyboardRemapControlObjects, const DWORD originalKey = NULL, const DWORD newKey = NULL);
|
|
|
|
// 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
|
|
StackPanel getSingleKeyRemapControl();
|
|
|
|
// Function to create the detect remap keys UI window
|
|
void createDetectKeyWindow(IInspectable const& sender, XamlRoot xamlRoot, std::vector<std::vector<DWORD>>& singleKeyRemapBuffer, KeyboardManagerState& keyboardManagerState, const size_t rowIndex, const size_t colIndex);
|
|
};
|