diff options
author | crupest <crupest@outlook.com> | 2020-05-24 01:40:02 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-05-24 01:40:02 +0800 |
commit | d86a71f79afe0e4dac768f61d6bff690567aca5b (patch) | |
tree | 4957e9a64c77680deb07201fbd879bf036616dae /include/cru/ui/render/border_render_object.hpp | |
parent | f3a8fd608a9776ef0a5f547da918a32cf6074060 (diff) | |
download | cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.gz cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.bz2 cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.zip |
...
Diffstat (limited to 'include/cru/ui/render/border_render_object.hpp')
-rw-r--r-- | include/cru/ui/render/border_render_object.hpp | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/include/cru/ui/render/border_render_object.hpp b/include/cru/ui/render/border_render_object.hpp deleted file mode 100644 index 02672309..00000000 --- a/include/cru/ui/render/border_render_object.hpp +++ /dev/null @@ -1,102 +0,0 @@ -#pragma once -#include "render_object.hpp" - -namespace cru::ui::render { -class BorderRenderObject : public RenderObject { - public: - BorderRenderObject(); - BorderRenderObject(const BorderRenderObject& other) = delete; - BorderRenderObject(BorderRenderObject&& other) = delete; - BorderRenderObject& operator=(const BorderRenderObject& other) = delete; - BorderRenderObject& operator=(BorderRenderObject&& other) = delete; - ~BorderRenderObject() override; - - bool IsBorderEnabled() const { return is_border_enabled_; } - void SetBorderEnabled(bool enabled) { is_border_enabled_ = enabled; } - - std::shared_ptr<platform::graph::IBrush> GetBorderBrush() { - return border_brush_; - } - - void SetBorderBrush(std::shared_ptr<platform::graph::IBrush> brush) { - if (brush == border_brush_) return; - border_brush_ = std::move(brush); - InvalidatePaint(); - } - - Thickness GetBorderThickness() { return border_thickness_; } - - void SetBorderThickness(const Thickness thickness) { - if (thickness == border_thickness_) return; - border_thickness_ = thickness; - InvalidateLayout(); - } - - CornerRadius GetBorderRadius() { return border_radius_; } - - void SetBorderRadius(const CornerRadius radius) { - if (radius == border_radius_) return; - border_radius_ = radius; - RecreateGeometry(); - } - - std::shared_ptr<platform::graph::IBrush> GetForegroundBrush() { - return foreground_brush_; - } - - void SetForegroundBrush(std::shared_ptr<platform::graph::IBrush> brush) { - if (brush == foreground_brush_) return; - foreground_brush_ = std::move(brush); - InvalidatePaint(); - } - - std::shared_ptr<platform::graph::IBrush> GetBackgroundBrush() { - return background_brush_; - } - - void SetBackgroundBrush(std::shared_ptr<platform::graph::IBrush> brush) { - if (brush == background_brush_) return; - background_brush_ = std::move(brush); - InvalidatePaint(); - } - - void SetBorderStyle(const BorderStyle& style); - - void Draw(platform::graph::IPainter* painter) override; - - RenderObject* HitTest(const Point& point) override; - - protected: - void OnMeasureCore(const Size& available_size) override; - void OnLayoutCore(const Rect& rect) override; - Size OnMeasureContent(const Size& available_size) override; - void OnLayoutContent(const Rect& content_rect) override; - - void OnAfterLayout() override; - - private: - RenderObject* GetChild() const { - return GetChildren().empty() ? nullptr : GetChildren()[0]; - } - - void RecreateGeometry(); - - private: - bool is_border_enabled_ = false; - - std::shared_ptr<platform::graph::IBrush> border_brush_; - platform::Thickness border_thickness_; - CornerRadius border_radius_; - - std::shared_ptr<platform::graph::IBrush> foreground_brush_; - std::shared_ptr<platform::graph::IBrush> background_brush_; - - // The ring. Used for painting. - std::unique_ptr<platform::graph::IGeometry> geometry_; - // Area including inner area of the border. Used for painting foreground and - // background. - std::unique_ptr<platform::graph::IGeometry> border_inner_geometry_; - // Area including border ring and inner area. Used for hit test. - std::unique_ptr<platform::graph::IGeometry> border_outer_geometry_; -}; -} // namespace cru::ui::render |