blob: 1994daf3064401b12d3c8135d2a6d5532ef97e0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#pragma once
#include "MeasureRequirement.h"
#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:
static constexpr auto kRenderObjectName = "GeometryRenderObject";
GeometryRenderObject();
public:
void Draw(platform::graphics::IPainter* painter) override;
RenderObject* HitTest(const Point& point) override;
std::shared_ptr<platform::graphics::IGeometry> GetGeometry();
void SetGeometry(std::shared_ptr<platform::graphics::IGeometry> geometry,
std::optional<Rect> view_port = std::nullopt);
Rect GetViewPort();
void SetViewPort(const Rect& view_port);
std::shared_ptr<platform::graphics::IBrush> GetFillBrush();
void SetFillBrush(std::shared_ptr<platform::graphics::IBrush> brush);
std::shared_ptr<platform::graphics::IBrush> GetStrokeBrush();
void SetStrokeBrush(std::shared_ptr<platform::graphics::IBrush> brush);
float GetStrokeWidth();
void SetStrokeWidth(float width);
protected:
Size OnMeasureContent(const MeasureRequirement& requirement) 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
|