aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-29 23:41:44 +0800
committercrupest <crupest@outlook.com>2020-03-29 23:41:44 +0800
commit7dd9494e957af8280f7221395333f886c500edf5 (patch)
tree8912fe7d3be5e4479bc801c8c524bae0a97b98fe /include
parent725d296ff1d58451010295b2dff1a95a18623c44 (diff)
downloadcru-7dd9494e957af8280f7221395333f886c500edf5.tar.gz
cru-7dd9494e957af8280f7221395333f886c500edf5.tar.bz2
cru-7dd9494e957af8280f7221395333f886c500edf5.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/common/bitmask.hpp6
-rw-r--r--include/cru/ui/ui_event.hpp31
-rw-r--r--include/cru/ui/window.hpp5
3 files changed, 29 insertions, 13 deletions
diff --git a/include/cru/common/bitmask.hpp b/include/cru/common/bitmask.hpp
index 6dfb651c..95edee13 100644
--- a/include/cru/common/bitmask.hpp
+++ b/include/cru/common/bitmask.hpp
@@ -19,15 +19,15 @@ struct Bitmask final {
Bitmask operator^(Bitmask rhs) const { return Bitmask(value ^ rhs.value); }
Bitmask operator~() const { return Bitmask(~value); }
Bitmask& operator|=(Bitmask rhs) {
- value |= rhs;
+ value |= rhs.value;
return *this;
}
Bitmask& operator&=(Bitmask rhs) {
- value &= rhs;
+ value &= rhs.value;
return *this;
}
Bitmask& operator^=(Bitmask rhs) {
- value ^= rhs;
+ value ^= rhs.value;
return *this;
}
diff --git a/include/cru/ui/ui_event.hpp b/include/cru/ui/ui_event.hpp
index d7ab4543..a9d6028a 100644
--- a/include/cru/ui/ui_event.hpp
+++ b/include/cru/ui/ui_event.hpp
@@ -2,6 +2,7 @@
#include "base.hpp"
#include "cru/common/event.hpp"
+#include "cru/platform/native/keyboard.hpp"
#include <memory>
#include <optional>
@@ -93,11 +94,17 @@ class MouseEventArgs : public UiEventArgs {
class MouseButtonEventArgs : public MouseEventArgs {
public:
MouseButtonEventArgs(Object* sender, Object* original_sender,
- const Point& point, const MouseButton button)
- : MouseEventArgs(sender, original_sender, point), button_(button) {}
+ const Point& point, const MouseButton button,
+ platform::native::KeyModifier key_modifier)
+ : MouseEventArgs(sender, original_sender, point),
+ button_(button),
+ key_modifier_(key_modifier) {}
MouseButtonEventArgs(Object* sender, Object* original_sender,
- const MouseButton button)
- : MouseEventArgs(sender, original_sender), button_(button) {}
+ const MouseButton button,
+ platform::native::KeyModifier key_modifier)
+ : MouseEventArgs(sender, original_sender),
+ button_(button),
+ key_modifier_(key_modifier) {}
MouseButtonEventArgs(const MouseButtonEventArgs& other) = default;
MouseButtonEventArgs(MouseButtonEventArgs&& other) = default;
MouseButtonEventArgs& operator=(const MouseButtonEventArgs& other) = default;
@@ -105,9 +112,11 @@ class MouseButtonEventArgs : public MouseEventArgs {
~MouseButtonEventArgs() override = default;
MouseButton GetButton() const { return button_; }
+ platform::native::KeyModifier GetKeyModifier() const { return key_modifier_; }
private:
MouseButton button_;
+ platform::native::KeyModifier key_modifier_;
};
class MouseWheelEventArgs : public MouseEventArgs {
@@ -182,18 +191,24 @@ class ToggleEventArgs : public UiEventArgs {
class KeyEventArgs : public UiEventArgs {
public:
- KeyEventArgs(Object* sender, Object* original_sender, int virtual_code)
- : UiEventArgs(sender, original_sender), virtual_code_(virtual_code) {}
+ KeyEventArgs(Object* sender, Object* original_sender,
+ platform::native::KeyCode key_code,
+ platform::native::KeyModifier key_modifier)
+ : UiEventArgs(sender, original_sender),
+ key_code_(key_code),
+ key_modifier_(key_modifier) {}
KeyEventArgs(const KeyEventArgs& other) = default;
KeyEventArgs(KeyEventArgs&& other) = default;
KeyEventArgs& operator=(const KeyEventArgs& other) = default;
KeyEventArgs& operator=(KeyEventArgs&& other) = default;
~KeyEventArgs() override = default;
- int GetVirtualCode() const { return virtual_code_; }
+ platform::native::KeyCode GetKeyCode() const { return key_code_; }
+ platform::native::KeyModifier GetKeyModifier() const { return key_modifier_; }
private:
- int virtual_code_;
+ platform::native::KeyCode key_code_;
+ platform::native::KeyModifier key_modifier_;
};
class CharEventArgs : public UiEventArgs {
diff --git a/include/cru/ui/window.hpp b/include/cru/ui/window.hpp
index ae54d006..86112189 100644
--- a/include/cru/ui/window.hpp
+++ b/include/cru/ui/window.hpp
@@ -94,8 +94,9 @@ class Window final : public ContentControl, public SelfResolvable<Window> {
const platform::native::NativeMouseButtonEventArgs& args);
void OnNativeKeyDown(platform::native::INativeWindow* window,
- int virtual_code);
- void OnNativeKeyUp(platform::native::INativeWindow* window, int virtual_code);
+ const platform::native::NativeKeyEventArgs& args);
+ void OnNativeKeyUp(platform::native::INativeWindow* window,
+ const platform::native::NativeKeyEventArgs& args);
void OnNativeChar(platform::native::INativeWindow* window, std::string c);
//*************** region: event dispatcher helper ***************