aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/ui')
-rw-r--r--include/cru/ui/base.hpp21
-rw-r--r--include/cru/ui/control.hpp1
-rw-r--r--include/cru/ui/event/ui_event.hpp17
-rw-r--r--include/cru/ui/render/border_render_object.hpp22
-rw-r--r--include/cru/ui/render/flex_layout_render_object.hpp2
-rw-r--r--include/cru/ui/render/render_object.hpp6
-rw-r--r--include/cru/ui/render/text_render_object.hpp34
-rw-r--r--include/cru/ui/render/window_render_object.hpp2
-rw-r--r--include/cru/ui/ui_manager.hpp17
-rw-r--r--include/cru/ui/window.hpp6
10 files changed, 76 insertions, 52 deletions
diff --git a/include/cru/ui/base.hpp b/include/cru/ui/base.hpp
new file mode 100644
index 00000000..427615b9
--- /dev/null
+++ b/include/cru/ui/base.hpp
@@ -0,0 +1,21 @@
+#pragma once
+#include "cru/platform/graphic_base.hpp"
+#include "cru/platform/matrix.hpp"
+#include "cru/platform/native/basic_types.hpp"
+
+namespace cru::ui {
+using cru::platform::Color;
+using cru::platform::Ellipse;
+using cru::platform::Matrix;
+using cru::platform::Point;
+using cru::platform::Rect;
+using cru::platform::RoundedRect;
+using cru::platform::Size;
+using cru::platform::TextRange;
+using cru::platform::Thickness;
+using cru::platform::native::MouseButton;
+
+namespace colors {
+using namespace cru::platform::colors;
+}
+} // namespace cru::ui \ No newline at end of file
diff --git a/include/cru/ui/control.hpp b/include/cru/ui/control.hpp
index 652efe89..15eeb6fa 100644
--- a/include/cru/ui/control.hpp
+++ b/include/cru/ui/control.hpp
@@ -1,5 +1,6 @@
#pragma once
#include "cru/common/base.hpp"
+#include "base.hpp"
#include "cru/platform/native/basic_types.hpp"
#include "event/ui_event.hpp"
diff --git a/include/cru/ui/event/ui_event.hpp b/include/cru/ui/event/ui_event.hpp
index 2704cc4f..62045808 100644
--- a/include/cru/ui/event/ui_event.hpp
+++ b/include/cru/ui/event/ui_event.hpp
@@ -1,14 +1,13 @@
#pragma once
#include "cru/common/base.hpp"
+#include "../base.hpp"
#include "cru/common/event.hpp"
-#include "cru/common/ui_base.hpp"
-#include "cru/platform/native/basic_types.hpp"
#include <optional>
namespace cru::platform::graph {
-struct IPainter;
+class Painter;
}
namespace cru::ui {
@@ -79,7 +78,7 @@ class MouseButtonEventArgs : public MouseEventArgs {
public:
MouseButtonEventArgs(Object* sender, Object* original_sender,
const Point& point,
- const platform::native::MouseButton button)
+ const MouseButton button)
: MouseEventArgs(sender, original_sender, point), button_(button) {}
MouseButtonEventArgs(const MouseButtonEventArgs& other) = default;
MouseButtonEventArgs(MouseButtonEventArgs&& other) = default;
@@ -87,10 +86,10 @@ class MouseButtonEventArgs : public MouseEventArgs {
MouseButtonEventArgs& operator=(MouseButtonEventArgs&& other) = default;
~MouseButtonEventArgs() override = default;
- platform::native::MouseButton GetMouseButton() const { return button_; }
+ MouseButton GetMouseButton() const { return button_; }
private:
- platform::native::MouseButton button_;
+ MouseButton button_;
};
class MouseWheelEventArgs : public MouseEventArgs {
@@ -113,7 +112,7 @@ class MouseWheelEventArgs : public MouseEventArgs {
class PaintEventArgs : public UiEventArgs {
public:
PaintEventArgs(Object* sender, Object* original_sender,
- platform::graph::IPainter* painter)
+ platform::graph::Painter* painter)
: UiEventArgs(sender, original_sender), painter_(painter) {}
PaintEventArgs(const PaintEventArgs& other) = default;
PaintEventArgs(PaintEventArgs&& other) = default;
@@ -121,10 +120,10 @@ class PaintEventArgs : public UiEventArgs {
PaintEventArgs& operator=(PaintEventArgs&& other) = default;
~PaintEventArgs() = default;
- platform::graph::IPainter* GetPainter() const { return painter_; }
+ platform::graph::Painter* GetPainter() const { return painter_; }
private:
- platform::graph::IPainter* painter_;
+ platform::graph::Painter* painter_;
};
class FocusChangeEventArgs : public UiEventArgs {
diff --git a/include/cru/ui/render/border_render_object.hpp b/include/cru/ui/render/border_render_object.hpp
index 407edbb3..ab424e60 100644
--- a/include/cru/ui/render/border_render_object.hpp
+++ b/include/cru/ui/render/border_render_object.hpp
@@ -4,9 +4,9 @@
#include <memory>
namespace cru::platform::graph {
-struct IBrush;
-struct IGeometry;
-} // namespace cru::platform
+class Brush;
+class Geometry;
+} // namespace cru::platform::graph
namespace cru::ui::render {
struct CornerRadius {
@@ -32,7 +32,7 @@ struct CornerRadius {
class BorderRenderObject : public RenderObject {
public:
- explicit BorderRenderObject(std::shared_ptr<platform::graph::IBrush> 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,10 @@ class BorderRenderObject : public RenderObject {
bool IsEnabled() const { return is_enabled_; }
void SetEnabled(bool enabled) { is_enabled_ = enabled; }
- std::shared_ptr<platform::graph::IBrush> GetBrush() const { return border_brush_; }
- void SetBrush(std::shared_ptr<platform::graph::IBrush> 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 +61,7 @@ class BorderRenderObject : public RenderObject {
void Refresh() { RecreateGeometry(); }
- void Draw(platform::graph::IPainter* painter) override;
+ void Draw(platform::graph::Painter* painter) override;
RenderObject* HitTest(const Point& point) override;
@@ -83,11 +85,11 @@ class BorderRenderObject : public RenderObject {
private:
bool is_enabled_ = false;
- std::shared_ptr<platform::graph::IBrush> border_brush_ = nullptr;
+ std::shared_ptr<platform::graph::Brush> border_brush_ = nullptr;
Thickness border_thickness_{};
CornerRadius corner_radius_{};
- std::shared_ptr<platform::graph::IGeometry> geometry_ = nullptr;
- std::shared_ptr<platform::graph::IGeometry> 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 8d881239..1234b920 100644
--- a/include/cru/ui/render/flex_layout_render_object.hpp
+++ b/include/cru/ui/render/flex_layout_render_object.hpp
@@ -64,7 +64,7 @@ class FlexLayoutRenderObject : public RenderObject {
FlexChildLayoutData* GetChildLayoutData(int position);
- void Draw(platform::graph::IPainter* 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 b6614317..dca254cc 100644
--- a/include/cru/ui/render/render_object.hpp
+++ b/include/cru/ui/render/render_object.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "cru/common/base.hpp"
-#include "cru/common/ui_base.hpp"
+#include "../base.hpp"
#include <vector>
@@ -11,7 +11,7 @@ class Control;
}
namespace cru::platform::graph {
-struct IPainter;
+class Painter;
}
namespace cru::ui::render {
@@ -58,7 +58,7 @@ class RenderObject : public Object {
void Measure(const Size& available_size);
void Layout(const Rect& rect);
- virtual void Draw(platform::graph::IPainter* painter) = 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 ecad6bb8..054d9b47 100644
--- a/include/cru/ui/render/text_render_object.hpp
+++ b/include/cru/ui/render/text_render_object.hpp
@@ -6,17 +6,17 @@
// forward declarations
namespace cru::platform::graph {
-struct IBrush;
-struct IFontDescriptor;
-struct ITextLayout;
+class Brush;
+class Font;
+class TextLayout;
} // namespace cru::platform::graph
namespace cru::ui::render {
class TextRenderObject : public RenderObject {
public:
- TextRenderObject(std::shared_ptr<platform::graph::IBrush> brush,
- std::shared_ptr<platform::graph::IFontDescriptor> font,
- std::shared_ptr<platform::graph::IBrush> selection_brush);
+ TextRenderObject(std::shared_ptr<platform::graph::Brush> brush,
+ std::shared_ptr<platform::graph::Font> 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::graph::IBrush> GetBrush() const { return brush_; }
- void SetBrush(std::shared_ptr<platform::graph::IBrush> 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::graph::IFontDescriptor> GetFont() const;
- void SetFont(std::shared_ptr<platform::graph::IFontDescriptor> font);
+ std::shared_ptr<platform::graph::Font> GetFont() const;
+ void SetFont(std::shared_ptr<platform::graph::Font> 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::graph::IBrush> GetSelectionBrush() const {
+ std::shared_ptr<platform::graph::Brush> GetSelectionBrush() const {
return selection_brush_;
}
- void SetSelectionBrush(std::shared_ptr<platform::graph::IBrush> new_brush) {
+ void SetSelectionBrush(std::shared_ptr<platform::graph::Brush> new_brush) {
new_brush.swap(selection_brush_);
}
- void Draw(platform::graph::IPainter* 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::graph::IBrush> brush_;
- std::shared_ptr<platform::graph::IFontDescriptor> font_;
- std::shared_ptr<platform::graph::ITextLayout> text_layout_;
+ std::shared_ptr<platform::graph::Brush> brush_;
+ std::shared_ptr<platform::graph::Font> font_;
+ std::shared_ptr<platform::graph::TextLayout> text_layout_;
std::optional<TextRange> selection_range_ = std::nullopt;
- std::shared_ptr<platform::graph::IBrush> 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 b95acbce..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::graph::IPainter* 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 f3f78722..d2b8ad53 100644
--- a/include/cru/ui/ui_manager.hpp
+++ b/include/cru/ui/ui_manager.hpp
@@ -1,15 +1,16 @@
#pragma once
+#include "base.hpp"
#include "cru/common/base.hpp"
#include <memory>
namespace cru::platform::graph {
-struct IBrush;
-struct IFontDescriptor;
-} // namespace cru::platform
+class Brush;
+class Font;
+} // namespace cru::platform::graph
namespace cru::ui {
-//TODO: Make this theme resource.
+// TODO: Make this theme resource.
class PredefineResources : public Object {
public:
PredefineResources();
@@ -20,12 +21,12 @@ class PredefineResources : public Object {
~PredefineResources() override = default;
// region Button
- std::shared_ptr<platform::graph::IBrush> button_normal_border_brush;
+ std::shared_ptr<platform::graph::Brush> button_normal_border_brush;
// region TextBlock
- std::shared_ptr<platform::graph::IBrush> text_block_selection_brush;
- std::shared_ptr<platform::graph::IBrush> text_block_text_brush;
- std::shared_ptr<platform::graph::IFontDescriptor> 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::Font> text_block_font;
};
class UiManager : public Object {
diff --git a/include/cru/ui/window.hpp b/include/cru/ui/window.hpp
index e175b234..311f1487 100644
--- a/include/cru/ui/window.hpp
+++ b/include/cru/ui/window.hpp
@@ -9,7 +9,7 @@
#include <vector>
namespace cru::platform::native {
-struct INativeWindow;
+class NativeWindow;
}
namespace cru::ui {
@@ -41,7 +41,7 @@ class Window final : public ContentControl, public SelfResovable<Window> {
render::RenderObject* GetRenderObject() const override;
- platform::native::INativeWindow* GetNativeWindow() const {
+ platform::native::NativeWindow* GetNativeWindow() const {
return native_window_;
}
@@ -91,7 +91,7 @@ class Window final : public ContentControl, public SelfResovable<Window> {
const Point& point);
private:
- platform::native::INativeWindow* native_window_;
+ platform::native::NativeWindow* native_window_;
std::vector<EventRevokerGuard> event_revoker_guards_;
std::shared_ptr<render::WindowRenderObject> render_object_;