diff options
author | crupest <crupest@outlook.com> | 2019-04-10 19:42:46 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-04-10 19:42:46 +0800 |
commit | 7351020a582d70a1495249fba87d342c8a1fb634 (patch) | |
tree | e80f225041dc3816b3dce21c7e15aadbb211602e /include/cru/ui | |
parent | a94a806f69586e08a30fff0cdb3e52b0ce7acfa5 (diff) | |
download | cru-7351020a582d70a1495249fba87d342c8a1fb634.tar.gz cru-7351020a582d70a1495249fba87d342c8a1fb634.tar.bz2 cru-7351020a582d70a1495249fba87d342c8a1fb634.zip |
Refactor.
Diffstat (limited to 'include/cru/ui')
-rw-r--r-- | include/cru/ui/control.hpp | 6 | ||||
-rw-r--r-- | include/cru/ui/event/ui_event.hpp | 23 | ||||
-rw-r--r-- | include/cru/ui/render/border_render_object.hpp | 16 | ||||
-rw-r--r-- | include/cru/ui/render/flex_layout_render_object.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/render/render_object.hpp | 4 | ||||
-rw-r--r-- | include/cru/ui/render/text_render_object.hpp | 32 | ||||
-rw-r--r-- | include/cru/ui/render/window_render_object.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/ui_manager.hpp | 10 | ||||
-rw-r--r-- | include/cru/ui/window.hpp | 13 |
9 files changed, 54 insertions, 54 deletions
diff --git a/include/cru/ui/control.hpp b/include/cru/ui/control.hpp index 684af2f0..652efe89 100644 --- a/include/cru/ui/control.hpp +++ b/include/cru/ui/control.hpp @@ -1,7 +1,7 @@ #pragma once #include "cru/common/base.hpp" -#include "cru/platform/basic_types.hpp" +#include "cru/platform/native/basic_types.hpp" #include "event/ui_event.hpp" #include <string_view> @@ -127,8 +127,8 @@ class Control : public Object { //*************** region: additional mouse event *************** protected: - virtual void OnMouseClickBegin(platform::MouseButton button); - virtual void OnMouseClickEnd(platform::MouseButton button); + virtual void OnMouseClickBegin(platform::native::MouseButton button); + virtual void OnMouseClickEnd(platform::native::MouseButton button); private: Window* window_ = nullptr; diff --git a/include/cru/ui/event/ui_event.hpp b/include/cru/ui/event/ui_event.hpp index ba8940cb..c84116b9 100644 --- a/include/cru/ui/event/ui_event.hpp +++ b/include/cru/ui/event/ui_event.hpp @@ -3,11 +3,11 @@ #include "cru/common/event.hpp" #include "cru/common/ui_base.hpp" -#include "cru/platform/basic_types.hpp" +#include "cru/platform/native/basic_types.hpp" #include <optional> -namespace cru::platform { +namespace cru::platform::graph { struct Painter; } @@ -19,9 +19,7 @@ namespace cru::ui::event { class UiEventArgs : public Object { public: UiEventArgs(Object* sender, Object* original_sender) - : sender_(sender), - original_sender_(original_sender), - handled_(false) {} + : sender_(sender), original_sender_(original_sender), handled_(false) {} UiEventArgs(const UiEventArgs& other) = default; UiEventArgs(UiEventArgs&& other) = default; @@ -80,7 +78,8 @@ class MouseEventArgs : public UiEventArgs { class MouseButtonEventArgs : public MouseEventArgs { public: MouseButtonEventArgs(Object* sender, Object* original_sender, - const Point& point, const platform::MouseButton button) + const Point& point, + const platform::native::MouseButton button) : MouseEventArgs(sender, original_sender, point), button_(button) {} MouseButtonEventArgs(const MouseButtonEventArgs& other) = default; MouseButtonEventArgs(MouseButtonEventArgs&& other) = default; @@ -88,10 +87,10 @@ class MouseButtonEventArgs : public MouseEventArgs { MouseButtonEventArgs& operator=(MouseButtonEventArgs&& other) = default; ~MouseButtonEventArgs() override = default; - platform::MouseButton GetMouseButton() const { return button_; } + platform::native::MouseButton GetMouseButton() const { return button_; } private: - platform::MouseButton button_; + platform::native::MouseButton button_; }; class MouseWheelEventArgs : public MouseEventArgs { @@ -114,7 +113,7 @@ class MouseWheelEventArgs : public MouseEventArgs { class PaintEventArgs : public UiEventArgs { public: PaintEventArgs(Object* sender, Object* original_sender, - platform::Painter* painter) + platform::graph::Painter* painter) : UiEventArgs(sender, original_sender), painter_(painter) {} PaintEventArgs(const PaintEventArgs& other) = default; PaintEventArgs(PaintEventArgs&& other) = default; @@ -122,10 +121,10 @@ class PaintEventArgs : public UiEventArgs { PaintEventArgs& operator=(PaintEventArgs&& other) = default; ~PaintEventArgs() = default; - platform::Painter* GetPainter() const { return painter_; } + platform::graph::Painter* GetPainter() const { return painter_; } private: - platform::Painter* painter_; + platform::graph::Painter* painter_; }; class FocusChangeEventArgs : public UiEventArgs { @@ -197,4 +196,4 @@ class CharEventArgs : public UiEventArgs { wchar_t c_; }; */ -} // namespace cru::ui::events +} // namespace cru::ui::event diff --git a/include/cru/ui/render/border_render_object.hpp b/include/cru/ui/render/border_render_object.hpp index 35b98948..44382c63 100644 --- a/include/cru/ui/render/border_render_object.hpp +++ b/include/cru/ui/render/border_render_object.hpp @@ -3,7 +3,7 @@ #include <memory> -namespace cru::platform { +namespace cru::platform::graph { struct Brush; struct Geometry; } // namespace cru::platform @@ -32,7 +32,7 @@ struct CornerRadius { class BorderRenderObject : public RenderObject { public: - explicit BorderRenderObject(std::shared_ptr<platform::Brush> brush); + explicit BorderRenderObject(std::shared_ptr<platform::graph::Brush> brush); BorderRenderObject(const BorderRenderObject& other) = delete; BorderRenderObject(BorderRenderObject&& other) = delete; BorderRenderObject& operator=(const BorderRenderObject& other) = delete; @@ -42,8 +42,8 @@ class BorderRenderObject : public RenderObject { bool IsEnabled() const { return is_enabled_; } void SetEnabled(bool enabled) { is_enabled_ = enabled; } - std::shared_ptr<platform::Brush> GetBrush() const { return border_brush_; } - void SetBrush(std::shared_ptr<platform::Brush> new_brush) { + std::shared_ptr<platform::graph::Brush> GetBrush() const { return border_brush_; } + void SetBrush(std::shared_ptr<platform::graph::Brush> new_brush) { border_brush_ = std::move(new_brush); } @@ -59,7 +59,7 @@ class BorderRenderObject : public RenderObject { void Refresh() { RecreateGeometry(); } - void Draw(platform::Painter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; @@ -83,11 +83,11 @@ class BorderRenderObject : public RenderObject { private: bool is_enabled_ = false; - std::shared_ptr<platform::Brush> border_brush_ = nullptr; + std::shared_ptr<platform::graph::Brush> border_brush_ = nullptr; Thickness border_thickness_{}; CornerRadius corner_radius_{}; - std::shared_ptr<platform::Geometry> geometry_ = nullptr; - std::shared_ptr<platform::Geometry> border_outer_geometry_ = nullptr; + std::shared_ptr<platform::graph::Geometry> geometry_ = nullptr; + std::shared_ptr<platform::graph::Geometry> border_outer_geometry_ = nullptr; }; } // namespace cru::ui::render diff --git a/include/cru/ui/render/flex_layout_render_object.hpp b/include/cru/ui/render/flex_layout_render_object.hpp index 278bf8c2..d225e679 100644 --- a/include/cru/ui/render/flex_layout_render_object.hpp +++ b/include/cru/ui/render/flex_layout_render_object.hpp @@ -38,7 +38,7 @@ class FlexLayoutRenderObject : public RenderObject { FlexChildLayoutData* GetChildLayoutData(int position); - void Draw(platform::Painter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; diff --git a/include/cru/ui/render/render_object.hpp b/include/cru/ui/render/render_object.hpp index 3cd14a6a..7f5f7ac6 100644 --- a/include/cru/ui/render/render_object.hpp +++ b/include/cru/ui/render/render_object.hpp @@ -10,7 +10,7 @@ namespace cru::ui { class Control; } -namespace cru::platform { +namespace cru::platform::graph { struct Painter; } @@ -58,7 +58,7 @@ class RenderObject : public Object { void Measure(const Size& available_size); void Layout(const Rect& rect); - virtual void Draw(platform::Painter* render_target) = 0; + virtual void Draw(platform::graph::Painter* painter) = 0; virtual RenderObject* HitTest(const Point& point) = 0; diff --git a/include/cru/ui/render/text_render_object.hpp b/include/cru/ui/render/text_render_object.hpp index 527fcd71..9f03551d 100644 --- a/include/cru/ui/render/text_render_object.hpp +++ b/include/cru/ui/render/text_render_object.hpp @@ -5,18 +5,18 @@ #include <string> // forward declarations -namespace cru::platform { +namespace cru::platform::graph { struct Brush; struct FontDescriptor; struct TextLayout; -} // namespace cru::platform +} // namespace cru::platform::graph namespace cru::ui::render { class TextRenderObject : public RenderObject { public: - TextRenderObject(std::shared_ptr<platform::Brush> brush, - std::shared_ptr<platform::FontDescriptor> font, - std::shared_ptr<platform::Brush> selection_brush); + TextRenderObject(std::shared_ptr<platform::graph::Brush> brush, + std::shared_ptr<platform::graph::FontDescriptor> font, + std::shared_ptr<platform::graph::Brush> selection_brush); TextRenderObject(const TextRenderObject& other) = delete; TextRenderObject(TextRenderObject&& other) = delete; TextRenderObject& operator=(const TextRenderObject& other) = delete; @@ -26,13 +26,13 @@ class TextRenderObject : public RenderObject { std::wstring GetText() const; void SetText(std::wstring new_text); - std::shared_ptr<platform::Brush> GetBrush() const { return brush_; } - void SetBrush(std::shared_ptr<platform::Brush> new_brush) { + std::shared_ptr<platform::graph::Brush> GetBrush() const { return brush_; } + void SetBrush(std::shared_ptr<platform::graph::Brush> new_brush) { new_brush.swap(brush_); } - std::shared_ptr<platform::FontDescriptor> GetFont() const; - void SetFont(std::shared_ptr<platform::FontDescriptor> font); + std::shared_ptr<platform::graph::FontDescriptor> GetFont() const; + void SetFont(std::shared_ptr<platform::graph::FontDescriptor> font); std::optional<TextRange> GetSelectionRange() const { return selection_range_; @@ -41,14 +41,14 @@ class TextRenderObject : public RenderObject { selection_range_ = std::move(new_range); } - std::shared_ptr<platform::Brush> GetSelectionBrush() const { + std::shared_ptr<platform::graph::Brush> GetSelectionBrush() const { return selection_brush_; } - void SetSelectionBrush(std::shared_ptr<platform::Brush> new_brush) { + void SetSelectionBrush(std::shared_ptr<platform::graph::Brush> new_brush) { new_brush.swap(selection_brush_); } - void Draw(platform::Painter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; @@ -59,11 +59,11 @@ class TextRenderObject : public RenderObject { void OnLayoutContent(const Rect& content_rect) override; private: - std::shared_ptr<platform::Brush> brush_; - std::shared_ptr<platform::FontDescriptor> font_; - std::shared_ptr<platform::TextLayout> text_layout_; + std::shared_ptr<platform::graph::Brush> brush_; + std::shared_ptr<platform::graph::FontDescriptor> font_; + std::shared_ptr<platform::graph::TextLayout> text_layout_; std::optional<TextRange> selection_range_ = std::nullopt; - std::shared_ptr<platform::Brush> selection_brush_; + std::shared_ptr<platform::graph::Brush> selection_brush_; }; } // namespace cru::ui::render diff --git a/include/cru/ui/render/window_render_object.hpp b/include/cru/ui/render/window_render_object.hpp index e0a7c74e..dfeae487 100644 --- a/include/cru/ui/render/window_render_object.hpp +++ b/include/cru/ui/render/window_render_object.hpp @@ -17,7 +17,7 @@ class WindowRenderObject : public RenderObject { void MeasureAndLayout(); - void Draw(platform::Painter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; diff --git a/include/cru/ui/ui_manager.hpp b/include/cru/ui/ui_manager.hpp index 6f4a3bc0..5317f579 100644 --- a/include/cru/ui/ui_manager.hpp +++ b/include/cru/ui/ui_manager.hpp @@ -3,7 +3,7 @@ #include <memory> -namespace cru::platform { +namespace cru::platform::graph { struct Brush; struct FontDescriptor; } // namespace cru::platform @@ -19,12 +19,12 @@ class PredefineResources : public Object { ~PredefineResources() override = default; // region Button - std::shared_ptr<platform::Brush> button_normal_border_brush; + std::shared_ptr<platform::graph::Brush> button_normal_border_brush; // region TextBlock - std::shared_ptr<platform::Brush> text_block_selection_brush; - std::shared_ptr<platform::Brush> text_block_text_brush; - std::shared_ptr<platform::FontDescriptor> text_block_font; + std::shared_ptr<platform::graph::Brush> text_block_selection_brush; + std::shared_ptr<platform::graph::Brush> text_block_text_brush; + std::shared_ptr<platform::graph::FontDescriptor> text_block_font; }; class UiManager : public Object { diff --git a/include/cru/ui/window.hpp b/include/cru/ui/window.hpp index 9a76f30f..0a81e2e1 100644 --- a/include/cru/ui/window.hpp +++ b/include/cru/ui/window.hpp @@ -5,7 +5,7 @@ #include <memory> -namespace cru::platform { +namespace cru::platform::native { struct NativeWindow; } @@ -38,7 +38,7 @@ class Window final : public ContentControl { render::RenderObject* GetRenderObject() const override; - platform::NativeWindow* GetNativeWindow() const { return native_window_; } + platform::native::NativeWindow* GetNativeWindow() const { return native_window_; } Control* GetMouseHoverControl() const { return mouse_hover_control_; } @@ -66,13 +66,14 @@ class Window final : public ContentControl { void OnNativeMouseEnterLeave(bool enter); void OnNativeMouseMove(const Point& point); - void OnNativeMouseDown(platform::MouseButton button, const Point& point); - void OnNativeMouseUp(platform::MouseButton button, const Point& point); + void OnNativeMouseDown(platform::native::MouseButton button, + const Point& point); + void OnNativeMouseUp(platform::native::MouseButton button, + const Point& point); void OnNativeKeyDown(int virtual_code); void OnNativeKeyUp(int virtual_code); - //*************** region: event dispatcher helper *************** void DispatchMouseHoverControlChangeEvent(Control* old_control, @@ -80,7 +81,7 @@ class Window final : public ContentControl { const Point& point); private: - platform::NativeWindow* native_window_; + platform::native::NativeWindow* native_window_; EventRevokerGuard event_revoker_guard_; std::shared_ptr<render::WindowRenderObject> render_object_; |