diff options
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/platform/native/window.hpp | 3 | ||||
-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 | ||||
-rw-r--r-- | include/cru/win/native/window.hpp | 2 |
7 files changed, 23 insertions, 10 deletions
diff --git a/include/cru/platform/native/window.hpp b/include/cru/platform/native/window.hpp index 85f809e5..0d40702f 100644 --- a/include/cru/platform/native/window.hpp +++ b/include/cru/platform/native/window.hpp @@ -3,6 +3,8 @@ #include "base.hpp" #include "cru/common/event.hpp" +#include <string> + namespace cru::platform::native { // Represents a native window, which exposes some low-level events and // operations. @@ -55,6 +57,7 @@ struct INativeWindow : virtual INativeResource { virtual IEvent<NativeMouseButtonEventArgs>* MouseUpEvent() = 0; virtual IEvent<int>* KeyDownEvent() = 0; virtual IEvent<int>* KeyUpEvent() = 0; + virtual IEvent<std::string>* CharEvent() = 0; }; // See INativeWindow for more info. 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 *************** diff --git a/include/cru/win/native/window.hpp b/include/cru/win/native/window.hpp index 3c883338..d5f41e47 100644 --- a/include/cru/win/native/window.hpp +++ b/include/cru/win/native/window.hpp @@ -75,6 +75,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { } IEvent<int>* KeyDownEvent() override { return &key_down_event_; } IEvent<int>* KeyUpEvent() override { return &key_up_event_; } + IEvent<std::string>* CharEvent() override { return &char_event_; }; IEvent<WindowNativeMessageEventArgs&>* NativeMessageEvent() { return &native_message_event_; @@ -148,6 +149,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { Event<platform::native::NativeMouseButtonEventArgs> mouse_up_event_; Event<int> key_down_event_; Event<int> key_up_event_; + Event<std::string> char_event_; Event<WindowNativeMessageEventArgs&> native_message_event_; }; |