diff options
author | crupest <crupest@outlook.com> | 2020-03-19 19:45:26 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-19 19:45:26 +0800 |
commit | 507de8c6a931d0784c8f740d41db610d3ed8db68 (patch) | |
tree | 9f77d8e2b1b0955ff669677b4d5913a08075946a /include/cru/ui | |
parent | 5da4f511e85de9e79bee40e3c5e04f899a48723c (diff) | |
download | cru-507de8c6a931d0784c8f740d41db610d3ed8db68.tar.gz cru-507de8c6a931d0784c8f740d41db610d3ed8db68.tar.bz2 cru-507de8c6a931d0784c8f740d41db610d3ed8db68.zip |
...
Diffstat (limited to 'include/cru/ui')
-rw-r--r-- | include/cru/ui/control.hpp | 8 | ||||
-rw-r--r-- | include/cru/ui/controls/text_box.hpp | 6 | ||||
-rw-r--r-- | include/cru/ui/render/border_render_object.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/ui_event.hpp | 11 | ||||
-rw-r--r-- | include/cru/ui/window.hpp | 1 |
5 files changed, 18 insertions, 10 deletions
diff --git a/include/cru/ui/control.hpp b/include/cru/ui/control.hpp index 95e2cf52..f0475dea 100644 --- a/include/cru/ui/control.hpp +++ b/include/cru/ui/control.hpp @@ -111,9 +111,7 @@ class Control : public Object { event::RoutedEvent<event::KeyEventArgs>* KeyUpEvent() { return &key_up_event_; } - // event::RoutedEvent<event::CharEventArgs>* CharEvent() { - // return &char_event_; - // } + event::RoutedEvent<event::CharEventArgs>* CharEvent() { return &char_event_; } event::RoutedEvent<event::FocusChangeEventArgs>* GainFocusEvent() { return &gain_focus_event_; } @@ -131,7 +129,7 @@ class Control : public Object { event::RoutedEvent<event::KeyEventArgs> key_down_event_; event::RoutedEvent<event::KeyEventArgs> key_up_event_; - // event::RoutedEvent<event::CharEventArgs> char_event_; + event::RoutedEvent<event::CharEventArgs> char_event_; event::RoutedEvent<event::FocusChangeEventArgs> gain_focus_event_; event::RoutedEvent<event::FocusChangeEventArgs> lose_focus_event_; @@ -142,6 +140,8 @@ class Control : public Object { virtual void OnAttachToWindow(Window* window); virtual void OnDetachToWindow(Window* window); + virtual void OnMouseHoverChange(bool newHover) { CRU_UNUSED(newHover) } + private: Window* window_ = nullptr; Control* parent_ = nullptr; diff --git a/include/cru/ui/controls/text_box.hpp b/include/cru/ui/controls/text_box.hpp index 4a4ed6e7..f5347430 100644 --- a/include/cru/ui/controls/text_box.hpp +++ b/include/cru/ui/controls/text_box.hpp @@ -28,6 +28,12 @@ class TextBox : public NoChildControl { const TextBoxBorderStyle& GetBorderStyle(); void SetBorderStyle(TextBoxBorderStyle border_style); + protected: + void OnMouseHoverChange(bool newHover) override; + + private: + void UpdateBorderStyle(); + private: std::unique_ptr<render::BorderRenderObject> border_render_object_; std::unique_ptr<render::StackLayoutRenderObject> stack_layout_render_object_; diff --git a/include/cru/ui/render/border_render_object.hpp b/include/cru/ui/render/border_render_object.hpp index 259c1530..02672309 100644 --- a/include/cru/ui/render/border_render_object.hpp +++ b/include/cru/ui/render/border_render_object.hpp @@ -60,6 +60,8 @@ class BorderRenderObject : public RenderObject { InvalidatePaint(); } + void SetBorderStyle(const BorderStyle& style); + void Draw(platform::graph::IPainter* painter) override; RenderObject* HitTest(const Point& point) override; diff --git a/include/cru/ui/ui_event.hpp b/include/cru/ui/ui_event.hpp index c5af2b61..d7ab4543 100644 --- a/include/cru/ui/ui_event.hpp +++ b/include/cru/ui/ui_event.hpp @@ -5,6 +5,7 @@ #include <memory> #include <optional> +#include <string> #include <type_traits> namespace cru::platform::graph { @@ -195,21 +196,19 @@ class KeyEventArgs : public UiEventArgs { int virtual_code_; }; -/* class CharEventArgs : public UiEventArgs { public: - CharEventArgs(Object* sender, Object* original_sender, wchar_t c) - : UiEventArgs(sender, original_sender), c_(c) {} + CharEventArgs(Object* sender, Object* original_sender, std::string c) + : UiEventArgs(sender, original_sender), c_(std::move(c)) {} CharEventArgs(const CharEventArgs& other) = default; CharEventArgs(CharEventArgs&& other) = default; CharEventArgs& operator=(const CharEventArgs& other) = default; CharEventArgs& operator=(CharEventArgs&& other) = default; ~CharEventArgs() override = default; - wchar_t GetChar() const { return c_; } + std::string GetChar() const { return c_; } private: - wchar_t c_; + std::string c_; }; -*/ } // namespace cru::ui::event diff --git a/include/cru/ui/window.hpp b/include/cru/ui/window.hpp index 251712cf..ae54d006 100644 --- a/include/cru/ui/window.hpp +++ b/include/cru/ui/window.hpp @@ -96,6 +96,7 @@ class Window final : public ContentControl, public SelfResolvable<Window> { void OnNativeKeyDown(platform::native::INativeWindow* window, int virtual_code); void OnNativeKeyUp(platform::native::INativeWindow* window, int virtual_code); + void OnNativeChar(platform::native::INativeWindow* window, std::string c); //*************** region: event dispatcher helper *************** |