aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/render')
-rw-r--r--src/ui/render/border_render_object.cpp10
-rw-r--r--src/ui/render/border_render_object.hpp11
-rw-r--r--src/ui/render/text_render_object.hpp8
3 files changed, 22 insertions, 7 deletions
diff --git a/src/ui/render/border_render_object.cpp b/src/ui/render/border_render_object.cpp
index e1550665..49700869 100644
--- a/src/ui/render/border_render_object.cpp
+++ b/src/ui/render/border_render_object.cpp
@@ -77,8 +77,9 @@ void BorderRenderObject::RecreateGeometry() {
const auto size = GetSize();
const auto margin = GetMargin();
- const Rect outer_rect{margin.left, margin.top, size.width - margin.right,
- size.height - size.height};
+ const Rect outer_rect{margin.left, margin.top,
+ size.width - margin.GetHorizontalTotal(),
+ size.height - margin.GetVerticalTotal()};
ThrowIfFailed(border_outer_geometry->Open(&sink));
f(outer_rect, corner_radius_);
ThrowIfFailed(sink->Close());
@@ -137,6 +138,11 @@ void BorderRenderObject::OnAddChild(RenderObject* new_child, int position) {
assert(GetChildren().size() == 1);
}
+void BorderRenderObject::OnSizeChanged(const Size& old_size,
+ const Size& new_size) {
+ RecreateGeometry();
+}
+
void BorderRenderObject::OnMeasureCore(const Size& available_size) {
const auto margin = GetMargin();
const auto padding = GetPadding();
diff --git a/src/ui/render/border_render_object.hpp b/src/ui/render/border_render_object.hpp
index eccb1219..6f9a8c11 100644
--- a/src/ui/render/border_render_object.hpp
+++ b/src/ui/render/border_render_object.hpp
@@ -13,6 +13,11 @@ namespace cru::ui::render {
struct CornerRadius {
constexpr CornerRadius()
: left_top(), right_top(), left_bottom(), right_bottom() {}
+ constexpr CornerRadius(const Point& value)
+ : left_top(value),
+ right_top(value),
+ left_bottom(value),
+ right_bottom(value) {}
constexpr CornerRadius(Point left_top, Point right_top, Point left_bottom,
Point right_bottom)
: left_top(left_top),
@@ -42,7 +47,9 @@ class BorderRenderObject : public RenderObject {
void SetBrush(ID2D1Brush* new_brush);
Thickness GetBorderWidth() const { return border_thickness_; }
- void SetBorderWidth(const Thickness& thickness) { border_thickness_ = thickness; }
+ void SetBorderWidth(const Thickness& thickness) {
+ border_thickness_ = thickness;
+ }
CornerRadius GetCornerRadius() const { return corner_radius_; }
void SetCornerRadius(const CornerRadius& new_corner_radius) {
@@ -58,6 +65,8 @@ class BorderRenderObject : public RenderObject {
protected:
void OnAddChild(RenderObject* new_child, int position) override;
+ void OnSizeChanged(const Size& old_size, const Size& new_size) override;
+
void OnMeasureCore(const Size& available_size) override;
void OnLayoutCore(const Rect& rect) override;
Size OnMeasureContent(const Size& available_size) override;
diff --git a/src/ui/render/text_render_object.hpp b/src/ui/render/text_render_object.hpp
index 30d78736..db102b04 100644
--- a/src/ui/render/text_render_object.hpp
+++ b/src/ui/render/text_render_object.hpp
@@ -59,11 +59,11 @@ class TextRenderObject : public RenderObject {
private:
String text_;
- ID2D1Brush* brush_;
- IDWriteTextFormat* text_format_;
- IDWriteTextLayout* text_layout_;
+ ID2D1Brush* brush_ = nullptr;
+ IDWriteTextFormat* text_format_ = nullptr;
+ IDWriteTextLayout* text_layout_ = nullptr;
std::optional<TextRange> selection_range_ = std::nullopt;
- ID2D1Brush* selection_brush_;
+ ID2D1Brush* selection_brush_ = nullptr;
};
} // namespace cru::ui::render