diff options
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/platform/graphics/Base.hpp (renamed from include/cru/platform/graph/Base.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/Brush.hpp (renamed from include/cru/platform/graph/Brush.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/Factory.hpp (renamed from include/cru/platform/graph/Factory.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/Font.hpp (renamed from include/cru/platform/graph/Font.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/Geometry.hpp (renamed from include/cru/platform/graph/Geometry.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/Painter.hpp (renamed from include/cru/platform/graph/Painter.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/Resource.hpp (renamed from include/cru/platform/graph/Resource.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/TextLayout.hpp (renamed from include/cru/platform/graph/TextLayout.hpp) | 2 | ||||
-rw-r--r-- | include/cru/platform/graphics/util/Painter.hpp (renamed from include/cru/platform/graph/util/Painter.hpp) | 4 | ||||
-rw-r--r-- | include/cru/platform/gui/Base.hpp (renamed from include/cru/platform/native/Base.hpp) | 6 | ||||
-rw-r--r-- | include/cru/platform/gui/Cursor.hpp (renamed from include/cru/platform/native/Cursor.hpp) | 4 | ||||
-rw-r--r-- | include/cru/platform/gui/InputMethod.hpp (renamed from include/cru/platform/native/InputMethod.hpp) | 8 | ||||
-rw-r--r-- | include/cru/platform/gui/Keyboard.hpp (renamed from include/cru/platform/native/Keyboard.hpp) | 4 | ||||
-rw-r--r-- | include/cru/platform/gui/UiApplication.hpp (renamed from include/cru/platform/native/UiApplication.hpp) | 6 | ||||
-rw-r--r-- | include/cru/platform/gui/Window.hpp (renamed from include/cru/platform/native/Window.hpp) | 6 | ||||
-rw-r--r-- | include/cru/ui/Base.hpp | 20 | ||||
-rw-r--r-- | include/cru/ui/Control.hpp | 8 | ||||
-rw-r--r-- | include/cru/ui/ShortcutHub.hpp | 22 | ||||
-rw-r--r-- | include/cru/ui/UiEvent.hpp | 30 | ||||
-rw-r--r-- | include/cru/ui/UiManager.hpp | 8 | ||||
-rw-r--r-- | include/cru/ui/WindowHost.hpp | 42 | ||||
-rw-r--r-- | include/cru/ui/render/BorderRenderObject.hpp | 26 | ||||
-rw-r--r-- | include/cru/ui/render/CanvasRenderObject.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/render/LayoutRenderObject.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/render/RenderObject.hpp | 12 | ||||
-rw-r--r-- | include/cru/ui/render/ScrollRenderObject.hpp | 4 | ||||
-rw-r--r-- | include/cru/ui/render/TextRenderObject.hpp | 38 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/Brush.hpp (renamed from include/cru/win/graph/direct/Brush.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/ComResource.hpp (renamed from include/cru/win/graph/direct/ComResource.hpp) | 4 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/ConvertUtil.hpp (renamed from include/cru/win/graph/direct/ConvertUtil.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/Exception.hpp (renamed from include/cru/win/graph/direct/Exception.hpp) | 4 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/Factory.hpp (renamed from include/cru/win/graph/direct/Factory.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/Font.hpp (renamed from include/cru/win/graph/direct/Font.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/Geometry.hpp (renamed from include/cru/win/graph/direct/Geometry.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/Painter.hpp (renamed from include/cru/win/graph/direct/Painter.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/Resource.hpp (renamed from include/cru/win/graph/direct/Resource.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/TextLayout.hpp (renamed from include/cru/win/graph/direct/TextLayout.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/WindowPainter.hpp (renamed from include/cru/win/graph/direct/WindowPainter.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/graphics/direct/WindowRenderTarget.hpp (renamed from include/cru/win/graph/direct/WindowRenderTarget.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/gui/Base.hpp (renamed from include/cru/win/native/Base.hpp) | 4 | ||||
-rw-r--r-- | include/cru/win/gui/Cursor.hpp (renamed from include/cru/win/native/Cursor.hpp) | 8 | ||||
-rw-r--r-- | include/cru/win/gui/Exception.hpp (renamed from include/cru/win/native/Exception.hpp) | 4 | ||||
-rw-r--r-- | include/cru/win/gui/GodWindow.hpp (renamed from include/cru/win/native/GodWindow.hpp) | 6 | ||||
-rw-r--r-- | include/cru/win/gui/InputMethod.hpp (renamed from include/cru/win/native/InputMethod.hpp) | 10 | ||||
-rw-r--r-- | include/cru/win/gui/Keyboard.hpp | 9 | ||||
-rw-r--r-- | include/cru/win/gui/Resource.hpp (renamed from include/cru/win/native/Resource.hpp) | 4 | ||||
-rw-r--r-- | include/cru/win/gui/UiApplication.hpp (renamed from include/cru/win/native/UiApplication.hpp) | 16 | ||||
-rw-r--r-- | include/cru/win/gui/Window.hpp (renamed from include/cru/win/native/Window.hpp) | 38 | ||||
-rw-r--r-- | include/cru/win/gui/WindowClass.hpp (renamed from include/cru/win/native/WindowClass.hpp) | 4 | ||||
-rw-r--r-- | include/cru/win/gui/WindowNativeMessageEventArgs.hpp (renamed from include/cru/win/native/WindowNativeMessageEventArgs.hpp) | 4 | ||||
-rw-r--r-- | include/cru/win/native/Keyboard.hpp | 9 |
51 files changed, 226 insertions, 226 deletions
diff --git a/include/cru/platform/graph/Base.hpp b/include/cru/platform/graphics/Base.hpp index 61cfc5ef..e751ebdb 100644 --- a/include/cru/platform/graph/Base.hpp +++ b/include/cru/platform/graphics/Base.hpp @@ -5,7 +5,7 @@ #include <memory> -namespace cru::platform::graph { +namespace cru::platform::graphics { // forward declarations struct IGraphFactory; struct IBrush; diff --git a/include/cru/platform/graph/Brush.hpp b/include/cru/platform/graphics/Brush.hpp index e67384de..10c666b5 100644 --- a/include/cru/platform/graph/Brush.hpp +++ b/include/cru/platform/graphics/Brush.hpp @@ -1,7 +1,7 @@ #pragma once #include "Resource.hpp" -namespace cru::platform::graph { +namespace cru::platform::graphics { struct IBrush : virtual IGraphResource {}; struct ISolidColorBrush : virtual IBrush { diff --git a/include/cru/platform/graph/Factory.hpp b/include/cru/platform/graphics/Factory.hpp index b4e68f12..d1b37783 100644 --- a/include/cru/platform/graph/Factory.hpp +++ b/include/cru/platform/graphics/Factory.hpp @@ -9,7 +9,7 @@ #include <string> #include <string_view> -namespace cru::platform::graph { +namespace cru::platform::graphics { // Entry point of the graph module. struct IGraphFactory : virtual INativeResource { virtual std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush() = 0; diff --git a/include/cru/platform/graph/Font.hpp b/include/cru/platform/graphics/Font.hpp index 182cc15b..70392a69 100644 --- a/include/cru/platform/graph/Font.hpp +++ b/include/cru/platform/graphics/Font.hpp @@ -1,7 +1,7 @@ #pragma once #include "Resource.hpp" -namespace cru::platform::graph { +namespace cru::platform::graphics { struct IFont : virtual IGraphResource { virtual float GetFontSize() = 0; }; diff --git a/include/cru/platform/graph/Geometry.hpp b/include/cru/platform/graphics/Geometry.hpp index 354efd97..b0ce6ad9 100644 --- a/include/cru/platform/graph/Geometry.hpp +++ b/include/cru/platform/graphics/Geometry.hpp @@ -1,7 +1,7 @@ #pragma once #include "Resource.hpp" -namespace cru::platform::graph { +namespace cru::platform::graphics { struct IGeometry : virtual IGraphResource { virtual bool FillContains(const Point& point) = 0; }; diff --git a/include/cru/platform/graph/Painter.hpp b/include/cru/platform/graphics/Painter.hpp index 27ae420b..76140c32 100644 --- a/include/cru/platform/graph/Painter.hpp +++ b/include/cru/platform/graphics/Painter.hpp @@ -1,7 +1,7 @@ #pragma once #include "Resource.hpp" -namespace cru::platform::graph { +namespace cru::platform::graphics { struct IPainter : virtual INativeResource { virtual Matrix GetTransform() = 0; diff --git a/include/cru/platform/graph/Resource.hpp b/include/cru/platform/graphics/Resource.hpp index 8859360c..a1625ce4 100644 --- a/include/cru/platform/graph/Resource.hpp +++ b/include/cru/platform/graphics/Resource.hpp @@ -1,7 +1,7 @@ #pragma once #include "Base.hpp" -namespace cru::platform::graph { +namespace cru::platform::graphics { struct IGraphFactory; struct IGraphResource : virtual INativeResource { diff --git a/include/cru/platform/graph/TextLayout.hpp b/include/cru/platform/graphics/TextLayout.hpp index a101983f..efd017d6 100644 --- a/include/cru/platform/graph/TextLayout.hpp +++ b/include/cru/platform/graphics/TextLayout.hpp @@ -4,7 +4,7 @@ #include <string> #include <vector> -namespace cru::platform::graph { +namespace cru::platform::graphics { struct ITextLayout : virtual IGraphResource { virtual std::u16string GetText() = 0; virtual std::u16string_view GetTextView() = 0; diff --git a/include/cru/platform/graph/util/Painter.hpp b/include/cru/platform/graphics/util/Painter.hpp index f9aec027..af3a1997 100644 --- a/include/cru/platform/graph/util/Painter.hpp +++ b/include/cru/platform/graphics/util/Painter.hpp @@ -4,7 +4,7 @@ #include <functional> #include <type_traits> -namespace cru::platform::graph::util { +namespace cru::platform::graphics::util { template <typename Fn> void WithTransform(IPainter* painter, const Matrix& matrix, const Fn& action) { static_assert(std::is_invocable_v<decltype(action), IPainter*>, @@ -14,4 +14,4 @@ void WithTransform(IPainter* painter, const Matrix& matrix, const Fn& action) { action(painter); painter->SetTransform(old); } -} // namespace cru::platform::graph::util +} // namespace cru::platform::graphics::util diff --git a/include/cru/platform/native/Base.hpp b/include/cru/platform/gui/Base.hpp index c3e87439..fb196f02 100644 --- a/include/cru/platform/native/Base.hpp +++ b/include/cru/platform/gui/Base.hpp @@ -2,11 +2,11 @@ #include "Keyboard.hpp" #include "cru/common/Base.hpp" #include "cru/common/Bitmask.hpp" -#include "cru/platform/graph/Base.hpp" +#include "cru/platform/graphics/Base.hpp" #include "../Resource.hpp" -namespace cru::platform::native { +namespace cru::platform::gui { struct ICursor; struct ICursorManager; struct IUiApplication; @@ -44,4 +44,4 @@ struct NativeKeyEventArgs { enum class FocusChangeType { Gain, Lost }; enum class MouseEnterLeaveType { Enter, Leave }; -} // namespace cru::platform::native +} // namespace cru::platform::gui diff --git a/include/cru/platform/native/Cursor.hpp b/include/cru/platform/gui/Cursor.hpp index 447cd694..3f1679e4 100644 --- a/include/cru/platform/native/Cursor.hpp +++ b/include/cru/platform/gui/Cursor.hpp @@ -3,7 +3,7 @@ #include <memory> -namespace cru::platform::native { +namespace cru::platform::gui { struct ICursor : virtual INativeResource {}; struct ICursorManager : virtual INativeResource { @@ -11,4 +11,4 @@ struct ICursorManager : virtual INativeResource { // TODO: Add method to create cursor. }; -} // namespace cru::platform::native +} // namespace cru::platform::gui diff --git a/include/cru/platform/native/InputMethod.hpp b/include/cru/platform/gui/InputMethod.hpp index de752417..53a8d671 100644 --- a/include/cru/platform/native/InputMethod.hpp +++ b/include/cru/platform/gui/InputMethod.hpp @@ -7,7 +7,7 @@ #include <memory> #include <vector> -namespace cru::platform::native { +namespace cru::platform::gui { struct CompositionClause { int start; int end; @@ -51,17 +51,17 @@ struct IInputMethodContext : virtual INativeResource { virtual IEvent<std::u16string_view>* TextEvent() = 0; }; -} // namespace cru::platform::native +} // namespace cru::platform::gui template <> -struct fmt::formatter<cru::platform::native::CompositionText, char16_t> +struct fmt::formatter<cru::platform::gui::CompositionText, char16_t> : fmt::formatter<std::u16string_view, char16_t> { auto parse(fmt::basic_format_parse_context<char16_t>& ctx) { return fmt::formatter<std::u16string_view, char16_t>::parse(ctx); } template <typename FormatContext> - auto format(const cru::platform::native::CompositionText& ct, + auto format(const cru::platform::gui::CompositionText& ct, FormatContext& ctx) { auto output = ctx.out(); output = format_to(output, u"text: {}\n", ct.text); diff --git a/include/cru/platform/native/Keyboard.hpp b/include/cru/platform/gui/Keyboard.hpp index 67a35c8a..e12cccda 100644 --- a/include/cru/platform/native/Keyboard.hpp +++ b/include/cru/platform/gui/Keyboard.hpp @@ -4,7 +4,7 @@ #include <string> #include <string_view> -namespace cru::platform::native { +namespace cru::platform::gui { // Because of the complexity of keyboard layout, I only add code in US keyboard // layout, the most widely used layout in China. We should try to make it easy // to add new keyboard layout. @@ -124,4 +124,4 @@ struct KeyModifiers { std::u16string_view ToString(KeyCode key_code); std::u16string ToString(KeyModifier key_modifier, std::u16string_view separator = u"+"); -} // namespace cru::platform::native +} // namespace cru::platform::gui diff --git a/include/cru/platform/native/UiApplication.hpp b/include/cru/platform/gui/UiApplication.hpp index 2b1b047a..6a2eb067 100644 --- a/include/cru/platform/native/UiApplication.hpp +++ b/include/cru/platform/gui/UiApplication.hpp @@ -6,7 +6,7 @@ #include <memory> #include <vector> -namespace cru::platform::native { +namespace cru::platform::gui { // The entry point of a ui application. struct IUiApplication : public virtual INativeResource { public: @@ -45,7 +45,7 @@ struct IUiApplication : public virtual INativeResource { virtual std::vector<INativeWindow*> GetAllWindow() = 0; virtual INativeWindow* CreateWindow(INativeWindow* parent) = 0; - virtual cru::platform::graph::IGraphFactory* GetGraphFactory() = 0; + virtual cru::platform::graphics::IGraphFactory* GetGraphFactory() = 0; virtual ICursorManager* GetCursorManager() = 0; }; @@ -106,4 +106,4 @@ class TimerListAutoCanceler { // Bootstrap from this. std::unique_ptr<IUiApplication> CreateUiApplication(); -} // namespace cru::platform::native +} // namespace cru::platform::gui diff --git a/include/cru/platform/native/Window.hpp b/include/cru/platform/gui/Window.hpp index c8abdeac..26d1a476 100644 --- a/include/cru/platform/native/Window.hpp +++ b/include/cru/platform/gui/Window.hpp @@ -5,7 +5,7 @@ #include <string_view> -namespace cru::platform::native { +namespace cru::platform::gui { // Represents a native window, which exposes some low-level events and // operations. struct INativeWindow : virtual INativeResource { @@ -38,7 +38,7 @@ struct INativeWindow : virtual INativeResource { virtual void RequestRepaint() = 0; // Remember to call EndDraw on return value and destroy it. - virtual std::unique_ptr<graph::IPainter> BeginPaint() = 0; + virtual std::unique_ptr<graphics::IPainter> BeginPaint() = 0; // Don't use this instance after receive this event. virtual IEvent<std::nullptr_t>* DestroyEvent() = 0; @@ -54,4 +54,4 @@ struct INativeWindow : virtual INativeResource { virtual IInputMethodContext* GetInputMethodContext() = 0; }; -} // namespace cru::platform::native +} // namespace cru::platform::gui diff --git a/include/cru/ui/Base.hpp b/include/cru/ui/Base.hpp index dd93f187..36d0eb78 100644 --- a/include/cru/ui/Base.hpp +++ b/include/cru/ui/Base.hpp @@ -1,7 +1,7 @@ #pragma once #include "cru/common/Base.hpp" -#include "cru/platform/graph/Base.hpp" -#include "cru/platform/native/Base.hpp" +#include "cru/platform/graphics/Base.hpp" +#include "cru/platform/gui/Base.hpp" #include <functional> #include <memory> @@ -19,9 +19,9 @@ using cru::platform::RoundedRect; using cru::platform::Size; using cru::platform::TextRange; using cru::platform::Thickness; -using cru::platform::native::MouseButton; +using cru::platform::gui::MouseButton; -namespace mouse_buttons = cru::platform::native::mouse_buttons; +namespace mouse_buttons = cru::platform::gui::mouse_buttons; namespace colors = cru::platform::colors; @@ -83,27 +83,27 @@ inline bool operator!=(const CornerRadius& left, const CornerRadius& right) { } struct BorderStyle { - std::shared_ptr<platform::graph::IBrush> border_brush; + std::shared_ptr<platform::graphics::IBrush> border_brush; Thickness border_thickness; CornerRadius border_radius; - std::shared_ptr<platform::graph::IBrush> foreground_brush; - std::shared_ptr<platform::graph::IBrush> background_brush; + std::shared_ptr<platform::graphics::IBrush> foreground_brush; + std::shared_ptr<platform::graphics::IBrush> background_brush; }; class CanvasPaintEventArgs { public: - CanvasPaintEventArgs(platform::graph::IPainter* painter, + CanvasPaintEventArgs(platform::graphics::IPainter* painter, const Size& paint_size) : painter_(painter), paint_size_(paint_size) {} CRU_DEFAULT_COPY(CanvasPaintEventArgs) CRU_DEFAULT_MOVE(CanvasPaintEventArgs) ~CanvasPaintEventArgs() = default; - platform::graph::IPainter* GetPainter() const { return painter_; } + platform::graphics::IPainter* GetPainter() const { return painter_; } Size GetPaintSize() const { return paint_size_; } private: - platform::graph::IPainter* painter_; + platform::graphics::IPainter* painter_; Size paint_size_; }; diff --git a/include/cru/ui/Control.hpp b/include/cru/ui/Control.hpp index 0021ad62..5f381965 100644 --- a/include/cru/ui/Control.hpp +++ b/include/cru/ui/Control.hpp @@ -58,13 +58,13 @@ class Control : public Object { // Cursor is inherited from parent recursively if not set. public: // null for not set - std::shared_ptr<platform::native::ICursor> GetCursor(); + std::shared_ptr<platform::gui::ICursor> GetCursor(); // will not return nullptr - std::shared_ptr<platform::native::ICursor> GetInheritedCursor(); + std::shared_ptr<platform::gui::ICursor> GetInheritedCursor(); // null to unset - void SetCursor(std::shared_ptr<platform::native::ICursor> cursor); + void SetCursor(std::shared_ptr<platform::gui::ICursor> cursor); //*************** region: events *************** public: @@ -146,6 +146,6 @@ class Control : public Object { private: bool is_mouse_over_ = false; - std::shared_ptr<platform::native::ICursor> cursor_ = nullptr; + std::shared_ptr<platform::gui::ICursor> cursor_ = nullptr; }; } // namespace cru::ui diff --git a/include/cru/ui/ShortcutHub.hpp b/include/cru/ui/ShortcutHub.hpp index 5382f63e..1145c661 100644 --- a/include/cru/ui/ShortcutHub.hpp +++ b/include/cru/ui/ShortcutHub.hpp @@ -3,7 +3,7 @@ #include "cru/common/Base.hpp" #include "cru/common/Event.hpp" -#include "cru/platform/native/Keyboard.hpp" +#include "cru/platform/gui/Keyboard.hpp" #include "cru/ui/UiEvent.hpp" #include <cstddef> @@ -20,8 +20,8 @@ namespace cru::ui { class ShortcutKeyBind { public: - ShortcutKeyBind(platform::native::KeyCode key, - platform::native::KeyModifier modifier) + ShortcutKeyBind(platform::gui::KeyCode key, + platform::gui::KeyModifier modifier) : key_(key), modifier_(modifier) {} CRU_DEFAULT_COPY(ShortcutKeyBind) @@ -29,11 +29,11 @@ class ShortcutKeyBind { ~ShortcutKeyBind() = default; - platform::native::KeyCode GetKey() const { return key_; } - platform::native::KeyModifier GetModifier() const { return modifier_; } + platform::gui::KeyCode GetKey() const { return key_; } + platform::gui::KeyModifier GetModifier() const { return modifier_; } - bool Is(platform::native::KeyCode key, - platform::native::KeyModifier modifier) const { + bool Is(platform::gui::KeyCode key, + platform::gui::KeyModifier modifier) const { return key == key_ && modifier == modifier_; } @@ -47,15 +47,15 @@ class ShortcutKeyBind { std::u16string ToString() { std::u16string result = u"("; - result += platform::native::ToString(modifier_); + result += platform::gui::ToString(modifier_); result += u")"; - result += platform::native::ToString(key_); + result += platform::gui::ToString(key_); return result; } private: - platform::native::KeyCode key_; - platform::native::KeyModifier modifier_; + platform::gui::KeyCode key_; + platform::gui::KeyModifier modifier_; }; } // namespace cru::ui diff --git a/include/cru/ui/UiEvent.hpp b/include/cru/ui/UiEvent.hpp index 5adace8a..c0b2a902 100644 --- a/include/cru/ui/UiEvent.hpp +++ b/include/cru/ui/UiEvent.hpp @@ -2,14 +2,14 @@ #include "Base.hpp" #include "cru/common/Event.hpp" -#include "cru/platform/native/Keyboard.hpp" +#include "cru/platform/gui/Keyboard.hpp" #include <memory> #include <optional> #include <string> #include <type_traits> -namespace cru::platform::graph { +namespace cru::platform::graphics { struct IPainter; } @@ -94,13 +94,13 @@ class MouseButtonEventArgs : public MouseEventArgs { public: MouseButtonEventArgs(Object* sender, Object* original_sender, const Point& point, const MouseButton button, - platform::native::KeyModifier key_modifier) + platform::gui::KeyModifier key_modifier) : MouseEventArgs(sender, original_sender, point), button_(button), key_modifier_(key_modifier) {} MouseButtonEventArgs(Object* sender, Object* original_sender, const MouseButton button, - platform::native::KeyModifier key_modifier) + platform::gui::KeyModifier key_modifier) : MouseEventArgs(sender, original_sender), button_(button), key_modifier_(key_modifier) {} @@ -111,11 +111,11 @@ class MouseButtonEventArgs : public MouseEventArgs { ~MouseButtonEventArgs() override = default; MouseButton GetButton() const { return button_; } - platform::native::KeyModifier GetKeyModifier() const { return key_modifier_; } + platform::gui::KeyModifier GetKeyModifier() const { return key_modifier_; } private: MouseButton button_; - platform::native::KeyModifier key_modifier_; + platform::gui::KeyModifier key_modifier_; }; class MouseWheelEventArgs : public MouseEventArgs { @@ -138,7 +138,7 @@ class MouseWheelEventArgs : public MouseEventArgs { class PaintEventArgs : public UiEventArgs { public: PaintEventArgs(Object* sender, Object* original_sender, - platform::graph::IPainter* painter) + platform::graphics::IPainter* painter) : UiEventArgs(sender, original_sender), painter_(painter) {} PaintEventArgs(const PaintEventArgs& other) = default; PaintEventArgs(PaintEventArgs&& other) = default; @@ -146,10 +146,10 @@ class PaintEventArgs : public UiEventArgs { PaintEventArgs& operator=(PaintEventArgs&& other) = default; ~PaintEventArgs() = default; - platform::graph::IPainter* GetPainter() const { return painter_; } + platform::graphics::IPainter* GetPainter() const { return painter_; } private: - platform::graph::IPainter* painter_; + platform::graphics::IPainter* painter_; }; class FocusChangeEventArgs : public UiEventArgs { @@ -191,8 +191,8 @@ class ToggleEventArgs : public UiEventArgs { class KeyEventArgs : public UiEventArgs { public: KeyEventArgs(Object* sender, Object* original_sender, - platform::native::KeyCode key_code, - platform::native::KeyModifier key_modifier) + platform::gui::KeyCode key_code, + platform::gui::KeyModifier key_modifier) : UiEventArgs(sender, original_sender), key_code_(key_code), key_modifier_(key_modifier) {} @@ -202,12 +202,12 @@ class KeyEventArgs : public UiEventArgs { KeyEventArgs& operator=(KeyEventArgs&& other) = default; ~KeyEventArgs() override = default; - platform::native::KeyCode GetKeyCode() const { return key_code_; } - platform::native::KeyModifier GetKeyModifier() const { return key_modifier_; } + platform::gui::KeyCode GetKeyCode() const { return key_code_; } + platform::gui::KeyModifier GetKeyModifier() const { return key_modifier_; } private: - platform::native::KeyCode key_code_; - platform::native::KeyModifier key_modifier_; + platform::gui::KeyCode key_code_; + platform::gui::KeyModifier key_modifier_; }; class CharEventArgs : public UiEventArgs { diff --git a/include/cru/ui/UiManager.hpp b/include/cru/ui/UiManager.hpp index 46f06ac2..64599d99 100644 --- a/include/cru/ui/UiManager.hpp +++ b/include/cru/ui/UiManager.hpp @@ -9,10 +9,10 @@ namespace cru::ui { struct ThemeResources { std::u16string default_font_family; - std::shared_ptr<platform::graph::IFont> default_font; - std::shared_ptr<platform::graph::IBrush> text_brush; - std::shared_ptr<platform::graph::IBrush> text_selection_brush; - std::shared_ptr<platform::graph::IBrush> caret_brush; + std::shared_ptr<platform::graphics::IFont> default_font; + std::shared_ptr<platform::graphics::IBrush> text_brush; + std::shared_ptr<platform::graphics::IBrush> text_selection_brush; + std::shared_ptr<platform::graphics::IBrush> caret_brush; controls::ButtonStyle button_style; controls::TextBoxBorderStyle text_box_border_style; }; diff --git a/include/cru/ui/WindowHost.hpp b/include/cru/ui/WindowHost.hpp index c3221dcf..97acf72e 100644 --- a/include/cru/ui/WindowHost.hpp +++ b/include/cru/ui/WindowHost.hpp @@ -2,8 +2,8 @@ #include "Base.hpp" #include "cru/common/Event.hpp" -#include "cru/platform/native/UiApplication.hpp" -#include "cru/platform/native/Window.hpp" +#include "cru/platform/gui/UiApplication.hpp" +#include "cru/platform/gui/Window.hpp" #include "render/Base.hpp" #include <functional> @@ -24,7 +24,7 @@ class WindowHost : public Object { ~WindowHost() override; public: - platform::native::INativeWindow* GetNativeWindow() { return native_window_; } + platform::gui::INativeWindow* GetNativeWindow() { return native_window_; } // Mark the layout as invalid, and arrange a re-layout later. // This method could be called more than one times in a message cycle. But @@ -87,30 +87,30 @@ class WindowHost : public Object { private: //*************** region: native messages *************** - void OnNativeDestroy(platform::native::INativeWindow* window, std::nullptr_t); - void OnNativePaint(platform::native::INativeWindow* window, std::nullptr_t); - void OnNativeResize(platform::native::INativeWindow* window, + void OnNativeDestroy(platform::gui::INativeWindow* window, std::nullptr_t); + void OnNativePaint(platform::gui::INativeWindow* window, std::nullptr_t); + void OnNativeResize(platform::gui::INativeWindow* window, const Size& size); - void OnNativeFocus(platform::native::INativeWindow* window, - cru::platform::native::FocusChangeType focus); + void OnNativeFocus(platform::gui::INativeWindow* window, + cru::platform::gui::FocusChangeType focus); void OnNativeMouseEnterLeave( - platform::native::INativeWindow* window, - cru::platform::native::MouseEnterLeaveType enter); - void OnNativeMouseMove(platform::native::INativeWindow* window, + platform::gui::INativeWindow* window, + cru::platform::gui::MouseEnterLeaveType enter); + void OnNativeMouseMove(platform::gui::INativeWindow* window, const Point& point); void OnNativeMouseDown( - platform::native::INativeWindow* window, - const platform::native::NativeMouseButtonEventArgs& args); + platform::gui::INativeWindow* window, + const platform::gui::NativeMouseButtonEventArgs& args); void OnNativeMouseUp( - platform::native::INativeWindow* window, - const platform::native::NativeMouseButtonEventArgs& args); + platform::gui::INativeWindow* window, + const platform::gui::NativeMouseButtonEventArgs& args); - void OnNativeKeyDown(platform::native::INativeWindow* window, - const platform::native::NativeKeyEventArgs& args); - void OnNativeKeyUp(platform::native::INativeWindow* window, - const platform::native::NativeKeyEventArgs& args); + void OnNativeKeyDown(platform::gui::INativeWindow* window, + const platform::gui::NativeKeyEventArgs& args); + void OnNativeKeyUp(platform::gui::INativeWindow* window, + const platform::gui::NativeKeyEventArgs& args); //*************** region: event dispatcher helper *************** @@ -123,10 +123,10 @@ class WindowHost : public Object { Control* root_control_ = nullptr; render::RenderObject* root_render_object_ = nullptr; - platform::native::INativeWindow* native_window_ = nullptr; + platform::gui::INativeWindow* native_window_ = nullptr; bool need_layout_ = false; - platform::native::TimerAutoCanceler relayout_timer_canceler_; + platform::gui::TimerAutoCanceler relayout_timer_canceler_; Event<AfterLayoutEventArgs> after_layout_event_; std::vector<std::function<void()> > after_layout_stable_action_; diff --git a/include/cru/ui/render/BorderRenderObject.hpp b/include/cru/ui/render/BorderRenderObject.hpp index 587f051a..f1b957cf 100644 --- a/include/cru/ui/render/BorderRenderObject.hpp +++ b/include/cru/ui/render/BorderRenderObject.hpp @@ -16,11 +16,11 @@ class BorderRenderObject : public RenderObject { bool IsBorderEnabled() const { return is_border_enabled_; } void SetBorderEnabled(bool enabled) { is_border_enabled_ = enabled; } - std::shared_ptr<platform::graph::IBrush> GetBorderBrush() { + std::shared_ptr<platform::graphics::IBrush> GetBorderBrush() { return border_brush_; } - void SetBorderBrush(std::shared_ptr<platform::graph::IBrush> brush) { + void SetBorderBrush(std::shared_ptr<platform::graphics::IBrush> brush) { if (brush == border_brush_) return; border_brush_ = std::move(brush); InvalidatePaint(); @@ -42,21 +42,21 @@ class BorderRenderObject : public RenderObject { RecreateGeometry(); } - std::shared_ptr<platform::graph::IBrush> GetForegroundBrush() { + std::shared_ptr<platform::graphics::IBrush> GetForegroundBrush() { return foreground_brush_; } - void SetForegroundBrush(std::shared_ptr<platform::graph::IBrush> brush) { + void SetForegroundBrush(std::shared_ptr<platform::graphics::IBrush> brush) { if (brush == foreground_brush_) return; foreground_brush_ = std::move(brush); InvalidatePaint(); } - std::shared_ptr<platform::graph::IBrush> GetBackgroundBrush() { + std::shared_ptr<platform::graphics::IBrush> GetBackgroundBrush() { return background_brush_; } - void SetBackgroundBrush(std::shared_ptr<platform::graph::IBrush> brush) { + void SetBackgroundBrush(std::shared_ptr<platform::graphics::IBrush> brush) { if (brush == background_brush_) return; background_brush_ = std::move(brush); InvalidatePaint(); @@ -67,7 +67,7 @@ class BorderRenderObject : public RenderObject { RenderObject* HitTest(const Point& point) override; protected: - void OnDrawCore(platform::graph::IPainter* painter) override; + void OnDrawCore(platform::graphics::IPainter* painter) override; Size OnMeasureCore(const MeasureRequirement& requirement, const MeasureSize& preferred_size) override; @@ -87,19 +87,19 @@ class BorderRenderObject : public RenderObject { private: bool is_border_enabled_ = false; - std::shared_ptr<platform::graph::IBrush> border_brush_; + std::shared_ptr<platform::graphics::IBrush> border_brush_; Thickness border_thickness_; CornerRadius border_radius_; - std::shared_ptr<platform::graph::IBrush> foreground_brush_; - std::shared_ptr<platform::graph::IBrush> background_brush_; + std::shared_ptr<platform::graphics::IBrush> foreground_brush_; + std::shared_ptr<platform::graphics::IBrush> background_brush_; // The ring. Used for painting. - std::unique_ptr<platform::graph::IGeometry> geometry_; + std::unique_ptr<platform::graphics::IGeometry> geometry_; // Area including inner area of the border. Used for painting foreground and // background. - std::unique_ptr<platform::graph::IGeometry> border_inner_geometry_; + std::unique_ptr<platform::graphics::IGeometry> border_inner_geometry_; // Area including border ring and inner area. Used for hit test. - std::unique_ptr<platform::graph::IGeometry> border_outer_geometry_; + std::unique_ptr<platform::graphics::IGeometry> border_outer_geometry_; }; } // namespace cru::ui::render diff --git a/include/cru/ui/render/CanvasRenderObject.hpp b/include/cru/ui/render/CanvasRenderObject.hpp index 3216f08c..58fee59c 100644 --- a/include/cru/ui/render/CanvasRenderObject.hpp +++ b/include/cru/ui/render/CanvasRenderObject.hpp @@ -22,7 +22,7 @@ class CanvasRenderObject : public RenderObject { IEvent<CanvasPaintEventArgs>* PaintEvent() { return &paint_event_; } protected: - void OnDrawContent(platform::graph::IPainter* painter) override; + void OnDrawContent(platform::graphics::IPainter* painter) override; Size OnMeasureContent(const MeasureRequirement& requirement, const MeasureSize& preferred_size) override; diff --git a/include/cru/ui/render/LayoutRenderObject.hpp b/include/cru/ui/render/LayoutRenderObject.hpp index b46ba0d0..732031a1 100644 --- a/include/cru/ui/render/LayoutRenderObject.hpp +++ b/include/cru/ui/render/LayoutRenderObject.hpp @@ -1,7 +1,7 @@ #pragma once #include "RenderObject.hpp" -#include "cru/platform/graph/util/Painter.hpp" +#include "cru/platform/graphics/util/Painter.hpp" namespace cru::ui::render { template <typename TChildLayoutData> diff --git a/include/cru/ui/render/RenderObject.hpp b/include/cru/ui/render/RenderObject.hpp index 20e095fa..436cf6b2 100644 --- a/include/cru/ui/render/RenderObject.hpp +++ b/include/cru/ui/render/RenderObject.hpp @@ -33,7 +33,7 @@ namespace cru::ui::render { // // To write a custom RenderObject, override following methods: // public: -// void Draw(platform::graph::IPainter* painter) override; +// void Draw(platform::graphics::IPainter* painter) override; // RenderObject* HitTest(const Point& point) override; // protected: // Size OnMeasureContent(const MeasureRequirement& requirement) override; @@ -129,7 +129,7 @@ class RenderObject : public Object { // This will set offset of this render object and call OnLayoutCore. void Layout(const Point& offset); - void Draw(platform::graph::IPainter* painter); + void Draw(platform::graphics::IPainter* painter); // Param point must be relative the lefttop of render object including margin. // Add offset before pass point to children. @@ -163,15 +163,15 @@ class RenderObject : public Object { virtual void OnRemoveChild(RenderObject* removed_child, Index position); // Draw all children with offset. - void DefaultDrawChildren(platform::graph::IPainter* painter); + void DefaultDrawChildren(platform::graphics::IPainter* painter); // Draw all children with translation of content rect lefttop. - void DefaultDrawContent(platform::graph::IPainter* painter); + void DefaultDrawContent(platform::graphics::IPainter* painter); // Call DefaultDrawContent. Then call DefaultDrawChildren. - virtual void OnDrawCore(platform::graph::IPainter* painter); + virtual void OnDrawCore(platform::graphics::IPainter* painter); - virtual void OnDrawContent(platform::graph::IPainter* painter); + virtual void OnDrawContent(platform::graphics::IPainter* painter); // Size measure including margin and padding. Please reduce margin and padding // or other custom things and pass the result content measure requirement and diff --git a/include/cru/ui/render/ScrollRenderObject.hpp b/include/cru/ui/render/ScrollRenderObject.hpp index 9b0cbf9a..3cc0e4c4 100644 --- a/include/cru/ui/render/ScrollRenderObject.hpp +++ b/include/cru/ui/render/ScrollRenderObject.hpp @@ -1,7 +1,7 @@ #pragma once #include "RenderObject.hpp" -#include "cru/platform/graph/util/Painter.hpp" +#include "cru/platform/graphics/util/Painter.hpp" #include <optional> @@ -44,7 +44,7 @@ class ScrollRenderObject : public RenderObject { void ScrollToContain(const Rect& rect, const Thickness& margin = Thickness{}); protected: - void OnDrawCore(platform::graph::IPainter* painter) override; + void OnDrawCore(platform::graphics::IPainter* painter) override; // Logic: // If available size is bigger than child's preferred size, then child's diff --git a/include/cru/ui/render/TextRenderObject.hpp b/include/cru/ui/render/TextRenderObject.hpp index 3be42bbb..fa569c8c 100644 --- a/include/cru/ui/render/TextRenderObject.hpp +++ b/include/cru/ui/render/TextRenderObject.hpp @@ -24,10 +24,10 @@ class TextRenderObject : public RenderObject { constexpr static float default_caret_width = 2; public: - TextRenderObject(std::shared_ptr<platform::graph::IBrush> brush, - std::shared_ptr<platform::graph::IFont> font, - std::shared_ptr<platform::graph::IBrush> selection_brush, - std::shared_ptr<platform::graph::IBrush> caret_brush); + TextRenderObject(std::shared_ptr<platform::graphics::IBrush> brush, + std::shared_ptr<platform::graphics::IFont> font, + std::shared_ptr<platform::graphics::IBrush> selection_brush, + std::shared_ptr<platform::graphics::IBrush> caret_brush); TextRenderObject(const TextRenderObject& other) = delete; TextRenderObject(TextRenderObject&& other) = delete; TextRenderObject& operator=(const TextRenderObject& other) = delete; @@ -38,25 +38,25 @@ class TextRenderObject : public RenderObject { std::u16string_view GetTextView() const; void SetText(std::u16string new_text); - std::shared_ptr<platform::graph::IBrush> GetBrush() const { return brush_; } - void SetBrush(std::shared_ptr<platform::graph::IBrush> new_brush); + std::shared_ptr<platform::graphics::IBrush> GetBrush() const { return brush_; } + void SetBrush(std::shared_ptr<platform::graphics::IBrush> new_brush); - std::shared_ptr<platform::graph::IFont> GetFont() const; - void SetFont(std::shared_ptr<platform::graph::IFont> font); + std::shared_ptr<platform::graphics::IFont> GetFont() const; + void SetFont(std::shared_ptr<platform::graphics::IFont> font); std::vector<Rect> TextRangeRect(const TextRange& text_range); Point TextSinglePoint(gsl::index position, bool trailing); - platform::graph::TextHitTestResult TextHitTest(const Point& point); + platform::graphics::TextHitTestResult TextHitTest(const Point& point); std::optional<TextRange> GetSelectionRange() const { return selection_range_; } void SetSelectionRange(std::optional<TextRange> new_range); - std::shared_ptr<platform::graph::IBrush> GetSelectionBrush() const { + std::shared_ptr<platform::graphics::IBrush> GetSelectionBrush() const { return selection_brush_; } - void SetSelectionBrush(std::shared_ptr<platform::graph::IBrush> new_brush); + void SetSelectionBrush(std::shared_ptr<platform::graphics::IBrush> new_brush); bool IsDrawCaret() const { return draw_caret_; } void SetDrawCaret(bool draw_caret); @@ -72,10 +72,10 @@ class TextRenderObject : public RenderObject { // Lefttop relative to render object lefttop. Rect GetCaretRect(); - std::shared_ptr<platform::graph::IBrush> GetCaretBrush() const { + std::shared_ptr<platform::graphics::IBrush> GetCaretBrush() const { return caret_brush_; } - void GetCaretBrush(std::shared_ptr<platform::graph::IBrush> brush); + void GetCaretBrush(std::shared_ptr<platform::graphics::IBrush> brush); float GetCaretWidth() const { return caret_width_; } void SetCaretWidth(float width); @@ -83,7 +83,7 @@ class TextRenderObject : public RenderObject { RenderObject* HitTest(const Point& point) override; protected: - void OnDrawContent(platform::graph::IPainter* painter) override; + void OnDrawContent(platform::graphics::IPainter* painter) override; // See remarks of this class. Size OnMeasureContent(const MeasureRequirement& requirement, @@ -93,16 +93,16 @@ class TextRenderObject : public RenderObject { void OnAfterLayout() override; private: - std::shared_ptr<platform::graph::IBrush> brush_; - std::shared_ptr<platform::graph::IFont> font_; - std::unique_ptr<platform::graph::ITextLayout> text_layout_; + std::shared_ptr<platform::graphics::IBrush> brush_; + std::shared_ptr<platform::graphics::IFont> font_; + std::unique_ptr<platform::graphics::ITextLayout> text_layout_; std::optional<TextRange> selection_range_ = std::nullopt; - std::shared_ptr<platform::graph::IBrush> selection_brush_; + std::shared_ptr<platform::graphics::IBrush> selection_brush_; bool draw_caret_ = false; gsl::index caret_position_ = 0; - std::shared_ptr<platform::graph::IBrush> caret_brush_; + std::shared_ptr<platform::graphics::IBrush> caret_brush_; float caret_width_ = default_caret_width; }; } // namespace cru::ui::render diff --git a/include/cru/win/graph/direct/Brush.hpp b/include/cru/win/graphics/direct/Brush.hpp index df1debe3..fbff83b5 100644 --- a/include/cru/win/graph/direct/Brush.hpp +++ b/include/cru/win/graphics/direct/Brush.hpp @@ -2,9 +2,9 @@ #include "ComResource.hpp" #include "Resource.hpp" -#include "cru/platform/graph/Brush.hpp" +#include "cru/platform/graphics/Brush.hpp" -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { struct ID2DBrush : virtual IBrush { virtual ID2D1Brush* GetD2DBrushInterface() const = 0; }; @@ -36,4 +36,4 @@ class D2DSolidColorBrush : public DirectGraphResource, Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> brush_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/ComResource.hpp b/include/cru/win/graphics/direct/ComResource.hpp index 2ac332cd..34ea39ed 100644 --- a/include/cru/win/graph/direct/ComResource.hpp +++ b/include/cru/win/graphics/direct/ComResource.hpp @@ -3,9 +3,9 @@ #include "cru/common/Base.hpp" -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { template <typename TInterface> struct IComResource : virtual Interface { virtual TInterface* GetComInterface() const = 0; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/ConvertUtil.hpp b/include/cru/win/graphics/direct/ConvertUtil.hpp index 12a04c7b..0d8da8a1 100644 --- a/include/cru/win/graph/direct/ConvertUtil.hpp +++ b/include/cru/win/graphics/direct/ConvertUtil.hpp @@ -1,9 +1,9 @@ #pragma once #include "../../WinPreConfig.hpp" -#include "cru/platform/graph/Base.hpp" +#include "cru/platform/graphics/Base.hpp" -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { inline D2D1_MATRIX_3X2_F Convert(const platform::Matrix& matrix) { D2D1_MATRIX_3X2_F m; m._11 = matrix.m11; @@ -104,4 +104,4 @@ inline bool operator==(const D2D1_ELLIPSE& left, const D2D1_ELLIPSE& right) { inline bool operator!=(const D2D1_ELLIPSE& left, const D2D1_ELLIPSE& right) { return !(left == right); } -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/Exception.hpp b/include/cru/win/graphics/direct/Exception.hpp index 8b62e8fa..72493f2f 100644 --- a/include/cru/win/graph/direct/Exception.hpp +++ b/include/cru/win/graphics/direct/Exception.hpp @@ -1,7 +1,7 @@ #pragma once #include "../../Exception.hpp" -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { using platform::win::HResultError; using platform::win::ThrowIfFailed; -} // namespace cru::platform::graph::win::direct
\ No newline at end of file +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/Factory.hpp b/include/cru/win/graphics/direct/Factory.hpp index e70454f5..70f3ede1 100644 --- a/include/cru/win/graph/direct/Factory.hpp +++ b/include/cru/win/graphics/direct/Factory.hpp @@ -1,9 +1,9 @@ #pragma once #include "Resource.hpp" -#include "cru/platform/graph/Factory.hpp" +#include "cru/platform/graphics/Factory.hpp" -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { class DirectGraphFactory : public DirectResource, public virtual IGraphFactory { public: DirectGraphFactory(); @@ -55,4 +55,4 @@ class DirectGraphFactory : public DirectResource, public virtual IGraphFactory { Microsoft::WRL::ComPtr<IDWriteFactory> dwrite_factory_; Microsoft::WRL::ComPtr<IDWriteFontCollection> dwrite_system_font_collection_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/Font.hpp b/include/cru/win/graphics/direct/Font.hpp index 2195f3e4..fd3921a3 100644 --- a/include/cru/win/graph/direct/Font.hpp +++ b/include/cru/win/graphics/direct/Font.hpp @@ -2,11 +2,11 @@ #include "ComResource.hpp" #include "Resource.hpp" -#include "cru/platform/graph/Font.hpp" +#include "cru/platform/graphics/Font.hpp" #include <string_view> -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { class DWriteFont : public DirectGraphResource, public virtual IFont, public virtual IComResource<IDWriteTextFormat> { @@ -30,4 +30,4 @@ class DWriteFont : public DirectGraphResource, std::u16string font_family_; Microsoft::WRL::ComPtr<IDWriteTextFormat> text_format_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/Geometry.hpp b/include/cru/win/graphics/direct/Geometry.hpp index 87987d3e..edfec590 100644 --- a/include/cru/win/graph/direct/Geometry.hpp +++ b/include/cru/win/graphics/direct/Geometry.hpp @@ -2,9 +2,9 @@ #include "ComResource.hpp" #include "Resource.hpp" -#include "cru/platform/graph/Geometry.hpp" +#include "cru/platform/graphics/Geometry.hpp" -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { class D2DGeometryBuilder : public DirectGraphResource, public virtual IGeometryBuilder { public: @@ -54,4 +54,4 @@ class D2DGeometry : public DirectGraphResource, private: Microsoft::WRL::ComPtr<ID2D1PathGeometry> geometry_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/Painter.hpp b/include/cru/win/graphics/direct/Painter.hpp index a50f962d..93c768e7 100644 --- a/include/cru/win/graph/direct/Painter.hpp +++ b/include/cru/win/graphics/direct/Painter.hpp @@ -2,11 +2,11 @@ #include "ComResource.hpp" #include "Resource.hpp" -#include "cru/platform/graph/Painter.hpp" +#include "cru/platform/graphics/Painter.hpp" #include <vector> -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { class D2DPainter : public DirectResource, public virtual IPainter, public virtual IComResource<ID2D1RenderTarget> { @@ -57,4 +57,4 @@ class D2DPainter : public DirectResource, bool is_drawing_ = true; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/Resource.hpp b/include/cru/win/graphics/direct/Resource.hpp index 6162ebd8..f60f373e 100644 --- a/include/cru/win/graph/direct/Resource.hpp +++ b/include/cru/win/graphics/direct/Resource.hpp @@ -1,11 +1,11 @@ #pragma once #include "../../WinPreConfig.hpp" -#include "cru/platform/graph/Resource.hpp" +#include "cru/platform/graphics/Resource.hpp" #include <string_view> -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { class DirectGraphFactory; class DirectResource : public Object, public virtual INativeResource { @@ -46,4 +46,4 @@ class DirectGraphResource : public DirectResource, private: DirectGraphFactory* factory_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/TextLayout.hpp b/include/cru/win/graphics/direct/TextLayout.hpp index 016009ab..3320431f 100644 --- a/include/cru/win/graph/direct/TextLayout.hpp +++ b/include/cru/win/graphics/direct/TextLayout.hpp @@ -2,12 +2,12 @@ #include "ComResource.hpp" #include "Resource.hpp" -#include "cru/platform/graph/TextLayout.hpp" +#include "cru/platform/graphics/TextLayout.hpp" #include <limits> #include <memory> -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { class DWriteFont; class DWriteTextLayout : public DirectGraphResource, @@ -52,4 +52,4 @@ class DWriteTextLayout : public DirectGraphResource, float max_height_ = std::numeric_limits<float>::max(); Microsoft::WRL::ComPtr<IDWriteTextLayout> text_layout_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/WindowPainter.hpp b/include/cru/win/graphics/direct/WindowPainter.hpp index 53961586..b5faf7b5 100644 --- a/include/cru/win/graph/direct/WindowPainter.hpp +++ b/include/cru/win/graphics/direct/WindowPainter.hpp @@ -2,8 +2,8 @@ #include "Painter.hpp" #include "WindowRenderTarget.hpp" -namespace cru::platform::graph::win::direct { -class D2DWindowPainter : public graph::win::direct::D2DPainter { +namespace cru::platform::graphics::win::direct { +class D2DWindowPainter : public graphics::win::direct::D2DPainter { public: explicit D2DWindowPainter(D2DWindowRenderTarget* window); @@ -18,4 +18,4 @@ class D2DWindowPainter : public graph::win::direct::D2DPainter { private: D2DWindowRenderTarget* render_target_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/graph/direct/WindowRenderTarget.hpp b/include/cru/win/graphics/direct/WindowRenderTarget.hpp index c9ee098f..75b1bf20 100644 --- a/include/cru/win/graph/direct/WindowRenderTarget.hpp +++ b/include/cru/win/graphics/direct/WindowRenderTarget.hpp @@ -1,7 +1,7 @@ #pragma once #include "Factory.hpp" -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { // Represents a window render target. class D2DWindowRenderTarget : public Object { public: @@ -13,7 +13,7 @@ class D2DWindowRenderTarget : public Object { ~D2DWindowRenderTarget() override = default; public: - graph::win::direct::DirectGraphFactory* GetDirectFactory() const { + graphics::win::direct::DirectGraphFactory* GetDirectFactory() const { return factory_; } @@ -39,4 +39,4 @@ class D2DWindowRenderTarget : public Object { Microsoft::WRL::ComPtr<IDXGISwapChain1> dxgi_swap_chain_; Microsoft::WRL::ComPtr<ID2D1Bitmap1> target_bitmap_; }; -} // namespace cru::platform::graph::win::direct +} // namespace cru::platform::graphics::win::direct diff --git a/include/cru/win/native/Base.hpp b/include/cru/win/gui/Base.hpp index 881dd8b1..00782663 100644 --- a/include/cru/win/native/Base.hpp +++ b/include/cru/win/gui/Base.hpp @@ -3,7 +3,7 @@ #include "cru/common/Base.hpp" -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class GodWindow; class TimerManager; class WinCursor; @@ -13,4 +13,4 @@ class WindowManager; class WinNativeWindow; class WinUiApplication; class WinInputMethodContext; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/Cursor.hpp b/include/cru/win/gui/Cursor.hpp index 373b9170..cd13ded7 100644 --- a/include/cru/win/native/Cursor.hpp +++ b/include/cru/win/gui/Cursor.hpp @@ -1,13 +1,13 @@ #pragma once #include "Resource.hpp" -#include "cru/platform/native/Cursor.hpp" +#include "cru/platform/gui/Cursor.hpp" #include <memory> -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class WinCursor : public WinNativeResource, public virtual ICursor { - CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::native::win::WinCursor") + CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::gui::win::WinCursor") public: WinCursor(HCURSOR handle, bool auto_destroy); @@ -46,4 +46,4 @@ class WinCursorManager : public WinNativeResource, std::shared_ptr<WinCursor> sys_arrow_; std::shared_ptr<WinCursor> sys_hand_; }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/Exception.hpp b/include/cru/win/gui/Exception.hpp index 6a5265c1..895e6c14 100644 --- a/include/cru/win/native/Exception.hpp +++ b/include/cru/win/gui/Exception.hpp @@ -1,7 +1,7 @@ #pragma once #include "../Exception.hpp" -namespace cru::platform::native::win { +namespace cru::platform::gui::win { using platform::win::Win32Error; using platform::win::HResultError; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/GodWindow.hpp b/include/cru/win/gui/GodWindow.hpp index 93d1acad..0343b159 100644 --- a/include/cru/win/native/GodWindow.hpp +++ b/include/cru/win/gui/GodWindow.hpp @@ -6,9 +6,9 @@ #include <memory> -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class GodWindow : public Object { - CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::native::win::GodWindow") + CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::gui::win::GodWindow") public: explicit GodWindow(WinUiApplication* application); @@ -35,4 +35,4 @@ class GodWindow : public Object { Event<WindowNativeMessageEventArgs&> message_event_; }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/InputMethod.hpp b/include/cru/win/gui/InputMethod.hpp index f3dc15c0..51a007d8 100644 --- a/include/cru/win/native/InputMethod.hpp +++ b/include/cru/win/gui/InputMethod.hpp @@ -6,13 +6,13 @@ #include "Resource.hpp" #include "WindowNativeMessageEventArgs.hpp" -#include "cru/platform/native/InputMethod.hpp" +#include "cru/platform/gui/InputMethod.hpp" #include <imm.h> -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class AutoHIMC : public Object { - CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::native::win::AutoHIMC") + CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::gui::win::AutoHIMC") public: explicit AutoHIMC(HWND hwnd); @@ -35,7 +35,7 @@ class AutoHIMC : public Object { class WinInputMethodContext : public WinNativeResource, public virtual IInputMethodContext { - CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::native::win::WinInputMethodContext") + CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::gui::win::WinInputMethodContext") public: WinInputMethodContext(gsl::not_null<WinNativeWindow*> window); @@ -84,4 +84,4 @@ class WinInputMethodContext : public WinNativeResource, Event<std::nullptr_t> composition_event_; Event<std::u16string_view> text_event_; }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/gui/Keyboard.hpp b/include/cru/win/gui/Keyboard.hpp new file mode 100644 index 00000000..5b98833c --- /dev/null +++ b/include/cru/win/gui/Keyboard.hpp @@ -0,0 +1,9 @@ +#pragma once +#include "Base.hpp" + +#include "cru/platform/gui/Keyboard.hpp" + +namespace cru::platform::gui::win { +KeyCode VirtualKeyToKeyCode(int virtual_key); +KeyModifier RetrieveKeyMofifier(); +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/Resource.hpp b/include/cru/win/gui/Resource.hpp index 0de0e1a8..1f6f0a4a 100644 --- a/include/cru/win/native/Resource.hpp +++ b/include/cru/win/gui/Resource.hpp @@ -3,7 +3,7 @@ #include "cru/platform/Resource.hpp" -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class WinNativeResource : public Object, public virtual INativeResource { public: static constexpr std::u16string_view k_platform_id = u"Windows"; @@ -20,4 +20,4 @@ class WinNativeResource : public Object, public virtual INativeResource { public: std::u16string_view GetPlatformId() const final { return k_platform_id; } }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/UiApplication.hpp b/include/cru/win/gui/UiApplication.hpp index 170be532..0f733cd4 100644 --- a/include/cru/win/native/UiApplication.hpp +++ b/include/cru/win/gui/UiApplication.hpp @@ -1,16 +1,16 @@ #pragma once #include "Resource.hpp" -#include "cru/platform/native/Base.hpp" -#include "cru/platform/native/UiApplication.hpp" +#include "cru/platform/gui/Base.hpp" +#include "cru/platform/gui/UiApplication.hpp" #include <memory> -namespace cru::platform::graph::win::direct { +namespace cru::platform::graphics::win::direct { class DirectGraphFactory; } -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class WinUiApplication : public WinNativeResource, public virtual IUiApplication { public: @@ -43,9 +43,9 @@ class WinUiApplication : public WinNativeResource, std::vector<INativeWindow*> GetAllWindow() override; INativeWindow* CreateWindow(INativeWindow* parent) override; - cru::platform::graph::IGraphFactory* GetGraphFactory() override; + cru::platform::graphics::IGraphFactory* GetGraphFactory() override; - cru::platform::graph::win::direct::DirectGraphFactory* GetDirectFactory() { + cru::platform::graphics::win::direct::DirectGraphFactory* GetDirectFactory() { return graph_factory_.get(); } @@ -60,7 +60,7 @@ class WinUiApplication : public WinNativeResource, private: HINSTANCE instance_handle_; - std::unique_ptr<cru::platform::graph::win::direct::DirectGraphFactory> + std::unique_ptr<cru::platform::graphics::win::direct::DirectGraphFactory> graph_factory_; std::unique_ptr<GodWindow> god_window_; @@ -71,4 +71,4 @@ class WinUiApplication : public WinNativeResource, std::vector<std::function<void()>> quit_handlers_; }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/Window.hpp b/include/cru/win/gui/Window.hpp index 6bf71601..3ba9ef68 100644 --- a/include/cru/win/native/Window.hpp +++ b/include/cru/win/gui/Window.hpp @@ -3,15 +3,15 @@ #include "WindowNativeMessageEventArgs.hpp" #include "cru/platform/GraphBase.hpp" -#include "cru/platform/native/Base.hpp" -#include "cru/platform/native/Window.hpp" -#include "cru/win/graph/direct/WindowRenderTarget.hpp" +#include "cru/platform/gui/Base.hpp" +#include "cru/platform/gui/Window.hpp" +#include "cru/win/graphics/direct/WindowRenderTarget.hpp" #include <memory> -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { - CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::native::win::WinNativeWindow") + CRU_DEFINE_CLASS_LOG_TAG(u"cru::platform::gui::win::WinNativeWindow") public: WinNativeWindow(WinUiApplication* application, WindowClass* window_class, @@ -47,7 +47,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { bool ReleaseMouse() override; void RequestRepaint() override; - std::unique_ptr<graph::IPainter> BeginPaint() override; + std::unique_ptr<graphics::IPainter> BeginPaint() override; void SetCursor(std::shared_ptr<ICursor> cursor) override; @@ -59,18 +59,18 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { return &mouse_enter_leave_event_; } IEvent<Point>* MouseMoveEvent() override { return &mouse_move_event_; } - IEvent<platform::native::NativeMouseButtonEventArgs>* MouseDownEvent() + IEvent<platform::gui::NativeMouseButtonEventArgs>* MouseDownEvent() override { return &mouse_down_event_; } - IEvent<platform::native::NativeMouseButtonEventArgs>* MouseUpEvent() + IEvent<platform::gui::NativeMouseButtonEventArgs>* MouseUpEvent() override { return &mouse_up_event_; } - IEvent<platform::native::NativeKeyEventArgs>* KeyDownEvent() override { + IEvent<platform::gui::NativeKeyEventArgs>* KeyDownEvent() override { return &key_down_event_; } - IEvent<platform::native::NativeKeyEventArgs>* KeyUpEvent() override { + IEvent<platform::gui::NativeKeyEventArgs>* KeyUpEvent() override { return &key_up_event_; } @@ -86,7 +86,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { bool HandleNativeWindowMessage(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param, LRESULT* result); - graph::win::direct::D2DWindowRenderTarget* GetWindowRenderTarget() const { + graphics::win::direct::D2DWindowRenderTarget* GetWindowRenderTarget() const { return window_render_target_.get(); } @@ -127,8 +127,8 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { void OnMouseMoveInternal(POINT point); void OnMouseLeaveInternal(); - void OnMouseDownInternal(platform::native::MouseButton button, POINT point); - void OnMouseUpInternal(platform::native::MouseButton button, POINT point); + void OnMouseDownInternal(platform::gui::MouseButton button, POINT point); + void OnMouseUpInternal(platform::gui::MouseButton button, POINT point); void OnMouseWheelInternal(short delta, POINT point); void OnKeyDownInternal(int virtual_code); @@ -155,7 +155,7 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { bool has_focus_ = false; bool is_mouse_in_ = false; - std::unique_ptr<graph::win::direct::D2DWindowRenderTarget> + std::unique_ptr<graphics::win::direct::D2DWindowRenderTarget> window_render_target_; std::shared_ptr<WinCursor> cursor_; @@ -168,11 +168,11 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { Event<FocusChangeType> focus_event_; Event<MouseEnterLeaveType> mouse_enter_leave_event_; Event<Point> mouse_move_event_; - Event<platform::native::NativeMouseButtonEventArgs> mouse_down_event_; - Event<platform::native::NativeMouseButtonEventArgs> mouse_up_event_; - Event<platform::native::NativeKeyEventArgs> key_down_event_; - Event<platform::native::NativeKeyEventArgs> key_up_event_; + Event<platform::gui::NativeMouseButtonEventArgs> mouse_down_event_; + Event<platform::gui::NativeMouseButtonEventArgs> mouse_up_event_; + Event<platform::gui::NativeKeyEventArgs> key_down_event_; + Event<platform::gui::NativeKeyEventArgs> key_up_event_; Event<WindowNativeMessageEventArgs&> native_message_event_; }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/WindowClass.hpp b/include/cru/win/gui/WindowClass.hpp index fdd55065..2c07b68f 100644 --- a/include/cru/win/native/WindowClass.hpp +++ b/include/cru/win/gui/WindowClass.hpp @@ -3,7 +3,7 @@ #include <string> -namespace cru::platform::native::win { +namespace cru::platform::gui::win { class WindowClass : public Object { public: WindowClass(std::wstring name, WNDPROC window_proc, HINSTANCE h_instance); @@ -21,4 +21,4 @@ class WindowClass : public Object { std::wstring name_; ATOM atom_; }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/WindowNativeMessageEventArgs.hpp b/include/cru/win/gui/WindowNativeMessageEventArgs.hpp index 84a7a123..834ba3c2 100644 --- a/include/cru/win/native/WindowNativeMessageEventArgs.hpp +++ b/include/cru/win/gui/WindowNativeMessageEventArgs.hpp @@ -3,7 +3,7 @@ #include "cru/common/Base.hpp" -namespace cru::platform::native::win { +namespace cru::platform::gui::win { struct WindowNativeMessage { HWND hwnd; UINT msg; @@ -37,4 +37,4 @@ class WindowNativeMessageEventArgs : public Object { LRESULT result_; bool handled_ = false; }; -} // namespace cru::platform::native::win +} // namespace cru::platform::gui::win diff --git a/include/cru/win/native/Keyboard.hpp b/include/cru/win/native/Keyboard.hpp deleted file mode 100644 index 790e0015..00000000 --- a/include/cru/win/native/Keyboard.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "Base.hpp" - -#include "cru/platform/native/Keyboard.hpp" - -namespace cru::platform::native::win { -KeyCode VirtualKeyToKeyCode(int virtual_key); -KeyModifier RetrieveKeyMofifier(); -} // namespace cru::platform::native::win |