68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "UIInputPath.h"
|
|
|
|
#include <XCEngine/UI/Types.h>
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace XCEngine {
|
|
namespace UI {
|
|
|
|
enum class UIShortcutScope : std::uint8_t {
|
|
Global = 0,
|
|
Window,
|
|
Panel,
|
|
Widget
|
|
};
|
|
|
|
struct UIShortcutChord {
|
|
std::int32_t keyCode = 0;
|
|
UIInputModifiers modifiers = {};
|
|
bool allowRepeat = false;
|
|
};
|
|
|
|
struct UIShortcutBinding {
|
|
std::uint64_t bindingId = 0;
|
|
UIShortcutScope scope = UIShortcutScope::Global;
|
|
UIElementId ownerId = 0;
|
|
UIInputEventType triggerEventType = UIInputEventType::KeyDown;
|
|
UIShortcutChord chord = {};
|
|
std::string commandId = {};
|
|
};
|
|
|
|
struct UIShortcutContext {
|
|
UIInputPath focusedPath = {};
|
|
UIInputPath activePath = {};
|
|
UIInputPath hoveredPath = {};
|
|
};
|
|
|
|
struct UIShortcutMatch {
|
|
bool matched = false;
|
|
UIShortcutBinding binding = {};
|
|
};
|
|
|
|
class UIShortcutRegistry {
|
|
public:
|
|
std::uint64_t RegisterBinding(const UIShortcutBinding& binding);
|
|
bool UnregisterBinding(std::uint64_t bindingId);
|
|
void Clear();
|
|
|
|
const std::vector<UIShortcutBinding>& GetBindings() const {
|
|
return m_bindings;
|
|
}
|
|
|
|
UIShortcutMatch Match(
|
|
const UIInputEvent& event,
|
|
const UIShortcutContext& context) const;
|
|
|
|
private:
|
|
std::vector<UIShortcutBinding> m_bindings = {};
|
|
std::uint64_t m_nextBindingId = 1;
|
|
};
|
|
|
|
} // namespace UI
|
|
} // namespace XCEngine
|