aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/render/GeometryRenderObject.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-03-02 22:07:33 +0800
committercrupest <crupest@outlook.com>2022-03-02 22:07:33 +0800
commit57353bd3acd97957cb5f970016fec52977cc6e95 (patch)
tree6e47a50f33466f7bcdce7c7aa9bf15b82fe4a58a /include/cru/ui/render/GeometryRenderObject.h
parent7adfe813c23d20abe936aa0624fd68e0112717b3 (diff)
downloadcru-57353bd3acd97957cb5f970016fec52977cc6e95.tar.gz
cru-57353bd3acd97957cb5f970016fec52977cc6e95.tar.bz2
cru-57353bd3acd97957cb5f970016fec52977cc6e95.zip
...
Diffstat (limited to 'include/cru/ui/render/GeometryRenderObject.h')
-rw-r--r--include/cru/ui/render/GeometryRenderObject.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/cru/ui/render/GeometryRenderObject.h b/include/cru/ui/render/GeometryRenderObject.h
new file mode 100644
index 00000000..6c5702ae
--- /dev/null
+++ b/include/cru/ui/render/GeometryRenderObject.h
@@ -0,0 +1,50 @@
+#pragma once
+#include "RenderObject.h"
+#include "cru/platform/graphics/Brush.h"
+#include "cru/platform/graphics/Geometry.h"
+
+#include <optional>
+
+namespace cru::ui::render {
+class GeometryRenderObject : public RenderObject {
+ public:
+ GeometryRenderObject();
+
+ CRU_DELETE_COPY(GeometryRenderObject)
+ CRU_DELETE_MOVE(GeometryRenderObject)
+
+ ~GeometryRenderObject() override;
+
+ public:
+ void Draw(platform::graphics::IPainter* painter) override;
+ RenderObject* HitTest(const Point& point) override;
+
+ std::shared_ptr<platform::graphics::IGeometry> GetGeometry() const;
+ void SetGeometry(std::shared_ptr<platform::graphics::IGeometry> geometry,
+ std::optional<Rect> view_port = std::nullopt);
+
+ Rect GetViewPort() const;
+ void SetViewPort(const Rect& view_port);
+
+ std::shared_ptr<platform::graphics::IBrush> GetFillBrush() const;
+ void SetFillBrush(std::shared_ptr<platform::graphics::IBrush> brush);
+
+ std::shared_ptr<platform::graphics::IBrush> GetStrokeBrush() const;
+ void SetStrokeBrush(std::shared_ptr<platform::graphics::IBrush> brush);
+
+ float GetStrokeWidth() const;
+ void SetStrokeWidth(float width);
+
+ protected:
+ Size OnMeasureContent(const MeasureRequirement& requirement,
+ const MeasureSize& preferred_size) override;
+ void OnLayoutContent(const Rect& content_rect) override;
+
+ private:
+ std::shared_ptr<platform::graphics::IGeometry> geometry_ = nullptr;
+ Rect view_port_{};
+ std::shared_ptr<platform::graphics::IBrush> fill_brush_ = nullptr;
+ std::shared_ptr<platform::graphics::IBrush> stroke_brush_ = nullptr;
+ float stroke_width_ = 0;
+};
+} // namespace cru::ui::render