aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-05-12 08:57:45 +0800
committercrupest <crupest@outlook.com>2021-05-12 08:57:45 +0800
commit1497b881c6d13c5e037dcd57988029df0b0e50eb (patch)
tree5f89c071cdb7c891d5afb35c49e3a337418bf026 /include
parent02baef645090f0514fa14b43aecf954fd55257dc (diff)
downloadcru-1497b881c6d13c5e037dcd57988029df0b0e50eb.tar.gz
cru-1497b881c6d13c5e037dcd57988029df0b0e50eb.tar.bz2
cru-1497b881c6d13c5e037dcd57988029df0b0e50eb.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/platform/gui/Base.hpp7
-rw-r--r--include/cru/platform/gui/Window.hpp1
-rw-r--r--include/cru/ui/events/UiEvent.hpp10
-rw-r--r--include/cru/ui/host/WindowHost.hpp2
-rw-r--r--include/cru/win/gui/Window.hpp11
5 files changed, 25 insertions, 6 deletions
diff --git a/include/cru/platform/gui/Base.hpp b/include/cru/platform/gui/Base.hpp
index 7a9d1889..fd9d265c 100644
--- a/include/cru/platform/gui/Base.hpp
+++ b/include/cru/platform/gui/Base.hpp
@@ -31,6 +31,13 @@ struct NativeMouseButtonEventArgs {
KeyModifier modifier;
};
+struct NativeMouseWheelEventArgs {
+ // Positive means down. Negative means up.
+ float delta;
+ Point point;
+ KeyModifier modifier;
+};
+
struct NativeKeyEventArgs {
KeyCode key;
KeyModifier modifier;
diff --git a/include/cru/platform/gui/Window.hpp b/include/cru/platform/gui/Window.hpp
index 26d1a476..b2129322 100644
--- a/include/cru/platform/gui/Window.hpp
+++ b/include/cru/platform/gui/Window.hpp
@@ -49,6 +49,7 @@ struct INativeWindow : virtual INativeResource {
virtual IEvent<Point>* MouseMoveEvent() = 0;
virtual IEvent<NativeMouseButtonEventArgs>* MouseDownEvent() = 0;
virtual IEvent<NativeMouseButtonEventArgs>* MouseUpEvent() = 0;
+ virtual IEvent<NativeMouseWheelEventArgs>* MouseWheelEvent() = 0;
virtual IEvent<NativeKeyEventArgs>* KeyDownEvent() = 0;
virtual IEvent<NativeKeyEventArgs>* KeyUpEvent() = 0;
diff --git a/include/cru/ui/events/UiEvent.hpp b/include/cru/ui/events/UiEvent.hpp
index 22ad0150..33bc0a60 100644
--- a/include/cru/ui/events/UiEvent.hpp
+++ b/include/cru/ui/events/UiEvent.hpp
@@ -122,18 +122,24 @@ class MouseButtonEventArgs : public MouseEventArgs {
class MouseWheelEventArgs : public MouseEventArgs {
public:
MouseWheelEventArgs(Object* sender, Object* original_sender,
- const Point& point, const float delta)
- : MouseEventArgs(sender, original_sender, point), delta_(delta) {}
+ const Point& point, const float delta,
+ platform::gui::KeyModifier key_modifier)
+ : MouseEventArgs(sender, original_sender, point),
+ delta_(delta),
+ key_modifier_(key_modifier) {}
MouseWheelEventArgs(const MouseWheelEventArgs& other) = default;
MouseWheelEventArgs(MouseWheelEventArgs&& other) = default;
MouseWheelEventArgs& operator=(const MouseWheelEventArgs& other) = default;
MouseWheelEventArgs& operator=(MouseWheelEventArgs&& other) = default;
~MouseWheelEventArgs() override = default;
+ // Positive means down; Negative means up.
float GetDelta() const { return delta_; }
+ platform::gui::KeyModifier GetKeyModifier() const { return key_modifier_; }
private:
float delta_;
+ platform::gui::KeyModifier key_modifier_;
};
class PaintEventArgs : public UiEventArgs {
diff --git a/include/cru/ui/host/WindowHost.hpp b/include/cru/ui/host/WindowHost.hpp
index cd9093bc..258b0c4c 100644
--- a/include/cru/ui/host/WindowHost.hpp
+++ b/include/cru/ui/host/WindowHost.hpp
@@ -139,6 +139,8 @@ class WindowHost : public Object {
const platform::gui::NativeMouseButtonEventArgs& args);
void OnNativeMouseUp(platform::gui::INativeWindow* window,
const platform::gui::NativeMouseButtonEventArgs& args);
+ void OnNativeMouseWheel(platform::gui::INativeWindow* window,
+ const platform::gui::NativeMouseWheelEventArgs& args);
void OnNativeKeyDown(platform::gui::INativeWindow* window,
const platform::gui::NativeKeyEventArgs& args);
diff --git a/include/cru/win/gui/Window.hpp b/include/cru/win/gui/Window.hpp
index 3ba9ef68..97a74fa7 100644
--- a/include/cru/win/gui/Window.hpp
+++ b/include/cru/win/gui/Window.hpp
@@ -59,14 +59,16 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
return &mouse_enter_leave_event_;
}
IEvent<Point>* MouseMoveEvent() override { return &mouse_move_event_; }
- IEvent<platform::gui::NativeMouseButtonEventArgs>* MouseDownEvent()
- override {
+ IEvent<platform::gui::NativeMouseButtonEventArgs>* MouseDownEvent() override {
return &mouse_down_event_;
}
- IEvent<platform::gui::NativeMouseButtonEventArgs>* MouseUpEvent()
- override {
+ IEvent<platform::gui::NativeMouseButtonEventArgs>* MouseUpEvent() override {
return &mouse_up_event_;
}
+ IEvent<NativeMouseWheelEventArgs>* MouseWheelEvent() override {
+ return &mouse_wheel_event_;
+ }
+
IEvent<platform::gui::NativeKeyEventArgs>* KeyDownEvent() override {
return &key_down_event_;
}
@@ -170,6 +172,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow {
Event<Point> mouse_move_event_;
Event<platform::gui::NativeMouseButtonEventArgs> mouse_down_event_;
Event<platform::gui::NativeMouseButtonEventArgs> mouse_up_event_;
+ Event<platform::gui::NativeMouseWheelEventArgs> mouse_wheel_event_;
Event<platform::gui::NativeKeyEventArgs> key_down_event_;
Event<platform::gui::NativeKeyEventArgs> key_up_event_;