aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/render_object.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-12-11 23:59:26 +0800
committercrupest <crupest@outlook.com>2018-12-11 23:59:26 +0800
commit3540c1718c74e9fa3538ae92a6418eb02d27f1c5 (patch)
tree5b5ba264c7ef50e2f563d2b097596ddac20fb19d /src/ui/render/render_object.cpp
parent5220ab4fee1281b2daeacf4dd50448e06eb1f5e8 (diff)
downloadcru-3540c1718c74e9fa3538ae92a6418eb02d27f1c5.tar.gz
cru-3540c1718c74e9fa3538ae92a6418eb02d27f1c5.tar.bz2
cru-3540c1718c74e9fa3538ae92a6418eb02d27f1c5.zip
...
Diffstat (limited to 'src/ui/render/render_object.cpp')
-rw-r--r--src/ui/render/render_object.cpp138
1 files changed, 0 insertions, 138 deletions
diff --git a/src/ui/render/render_object.cpp b/src/ui/render/render_object.cpp
index 6796f382..3e2e5265 100644
--- a/src/ui/render/render_object.cpp
+++ b/src/ui/render/render_object.cpp
@@ -24,113 +24,6 @@ namespace cru::ui::render
render_host_->InvalidateRender();
}
- SingleChildRenderObject::~SingleChildRenderObject()
- {
- delete child_;
- }
-
- void SingleChildRenderObject::SetChild(RenderObject* new_child)
- {
- const auto old = child_;
- if (old)
- old->SetRenderHost(nullptr);
- child_ = new_child;
- if (new_child)
- new_child->SetRenderHost(GetRenderHost());
- OnChildChange(old, new_child);
- InvalidateRenderHost();
- }
-
- void SingleChildRenderObject::OnRenderHostChanged(IRenderHost* old_render_host, IRenderHost* new_render_host)
- {
- if (child_)
- child_->SetRenderHost(new_render_host);
- }
-
- void SingleChildRenderObject::OnChildChange(RenderObject* old_child, RenderObject* new_object)
- {
-
- }
-
- ClipRenderObject::ClipRenderObject(Microsoft::WRL::ComPtr<ID2D1Geometry> clip_geometry)
- : clip_geometry_(std::move(clip_geometry))
- {
-
- }
-
- void ClipRenderObject::SetClipGeometry(Microsoft::WRL::ComPtr<ID2D1Geometry> new_clip_geometry)
- {
- clip_geometry_ = std::move(new_clip_geometry);
- InvalidateRenderHost();
- }
-
- void ClipRenderObject::Draw(ID2D1RenderTarget* render_target)
- {
- if (clip_geometry_ != nullptr)
- render_target->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), clip_geometry_.Get()), nullptr);
- const auto child = GetChild();
- if (child != nullptr)
- child->Draw(render_target);
- if (clip_geometry_ != nullptr)
- render_target->PopLayer();
- }
-
- void MatrixRenderObject::ApplyAppendMatrix(ID2D1RenderTarget* render_target, const D2D1_MATRIX_3X2_F& matrix)
- {
- D2D1::Matrix3x2F old_matrix;
- render_target->GetTransform(&old_matrix);
- render_target->SetTransform(old_matrix * matrix);
- }
-
- void MatrixRenderObject::ApplySetMatrix(ID2D1RenderTarget* render_target, const D2D1_MATRIX_3X2_F& matrix)
- {
- render_target->SetTransform(matrix);
- }
-
- const MatrixRenderObject::MatrixApplier MatrixRenderObject::append_applier(ApplyAppendMatrix);
- const MatrixRenderObject::MatrixApplier MatrixRenderObject::set_applier(ApplySetMatrix);
-
- MatrixRenderObject::MatrixRenderObject(const D2D1_MATRIX_3X2_F& matrix, MatrixApplier applier)
- : matrix_(matrix), applier_(std::move(applier))
- {
-
- }
-
- void MatrixRenderObject::SetMatrix(const D2D1_MATRIX_3X2_F& new_matrix)
- {
- matrix_ = new_matrix;
- InvalidateRenderHost();
- }
-
- void MatrixRenderObject::SetMatrixApplier(MatrixApplier applier)
- {
- applier_ = std::move(applier);
- InvalidateRenderHost();
- }
-
- void MatrixRenderObject::Draw(ID2D1RenderTarget* render_target)
- {
- D2D1_MATRIX_3X2_F old_matrix;
- render_target->GetTransform(&old_matrix);
- applier_(render_target, matrix_);
- const auto child = GetChild();
- if (child)
- child->Draw(render_target);
- render_target->SetTransform(&old_matrix);
- }
-
- void OffsetRenderObject::SetOffsetX(const float new_offset_x)
- {
- offset_x_ = new_offset_x;
- SetMatrix(D2D1::Matrix3x2F::Translation(offset_x_, offset_y_));
- }
-
- void OffsetRenderObject::SetOffsetY(const float new_offset_y)
- {
- offset_y_ = new_offset_y;
- SetMatrix(D2D1::Matrix3x2F::Translation(offset_x_, offset_y_));
- }
-
void StrokeRenderObject::SetStrokeWidth(const float new_stroke_width)
{
if (stroke_width_ == new_stroke_width)
@@ -225,35 +118,4 @@ namespace cru::ui::render
if (draw_handler_ != nullptr)
draw_handler_(render_target);
}
-
- ContainerRenderObject::~ContainerRenderObject()
- {
- for (const auto child : children_)
- delete child;
- }
-
- void ContainerRenderObject::AddChild(RenderObject* child)
- {
- children_.push_back(child);
- }
-
- void ContainerRenderObject::AddChild(RenderObject* child, const int position)
- {
- assert(position >= 0);
- assert(position <= children_.size());
- children_.insert(children_.cbegin() + position, child);
- }
-
- void ContainerRenderObject::RemoveChild(const int position)
- {
- assert(position >= 0);
- assert(position < children_.size());
- children_.erase(children_.cbegin() + position);
- }
-
- void ContainerRenderObject::Draw(ID2D1RenderTarget* render_target)
- {
- for (const auto child : children_)
- child->Draw(render_target);
- }
}