diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/platform/native/native_window.hpp | 6 | ||||
-rw-r--r-- | include/cru/ui/window.hpp | 11 | ||||
-rw-r--r-- | include/cru/win/native/native_window.hpp | 5 |
3 files changed, 22 insertions, 0 deletions
diff --git a/include/cru/platform/native/native_window.hpp b/include/cru/platform/native/native_window.hpp index 22a2dce0..b557a0dd 100644 --- a/include/cru/platform/native/native_window.hpp +++ b/include/cru/platform/native/native_window.hpp @@ -56,6 +56,12 @@ class NativeWindow : public NativeResource { // The lefttop of the rect is relative to screen lefttop. virtual void SetWindowRect(const Rect& rect) = 0; + // Relative to client lefttop. + virtual Point GetMousePosition() = 0; + + virtual bool CaptureMouse() = 0; + virtual bool ReleaseMouse() = 0; + virtual graph::Painter* BeginPaint() = 0; virtual IEvent<std::nullptr_t>* DestroyEvent() = 0; diff --git a/include/cru/ui/window.hpp b/include/cru/ui/window.hpp index 197198d2..ee6d2176 100644 --- a/include/cru/ui/window.hpp +++ b/include/cru/ui/window.hpp @@ -60,6 +60,14 @@ class Window final : public ContentControl, public SelfResolvable<Window> { // Get the control that has focus. Control* GetFocusControl(); + //*************** region: focus *************** + + // Pass nullptr to release capture. + bool CaptureMouseFor(Control* control); + + // Return null if not captured. + Control* GetMouseCaptureControl(); + protected: void OnChildChanged(Control* old_child, Control* new_child) override; @@ -86,6 +94,7 @@ class Window final : public ContentControl, public SelfResolvable<Window> { //*************** region: event dispatcher helper *************** + // dispatch enter is useful when mouse is captured. void DispatchMouseHoverControlChangeEvent(Control* old_control, Control* new_control, const Point& point); @@ -100,6 +109,8 @@ class Window final : public ContentControl, public SelfResolvable<Window> { Control* focus_control_; // "focus_control_" can't be nullptr + Control* mouse_captured_control_; + bool need_layout_ = false; }; } // namespace cru::ui diff --git a/include/cru/win/native/native_window.hpp b/include/cru/win/native/native_window.hpp index ed678591..b044aef8 100644 --- a/include/cru/win/native/native_window.hpp +++ b/include/cru/win/native/native_window.hpp @@ -48,6 +48,11 @@ class WinNativeWindow : public NativeWindow { // The lefttop of the rect is relative to screen lefttop. void SetWindowRect(const Rect& rect) override; + Point GetMousePosition() override; + + bool CaptureMouse() override; + bool ReleaseMouse() override; + graph::Painter* BeginPaint() override; IEvent<std::nullptr_t>* DestroyEvent() override { return &destroy_event_; } |