From 9397b9fb89e389906ec9f6c9ea3ca18073593c8c Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 4 Sep 2018 00:37:25 +0800 Subject: ... --- CruUI/ui/control.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'CruUI/ui/control.cpp') diff --git a/CruUI/ui/control.cpp b/CruUI/ui/control.cpp index 68713841..e2e6f98b 100644 --- a/CruUI/ui/control.cpp +++ b/CruUI/ui/control.cpp @@ -24,13 +24,13 @@ namespace cru { } - void Control::ForeachChild(Action&& predicate) + void Control::ForeachChild(Action&& predicate) const { for (const auto child : children_) predicate(child); } - void Control::ForeachChild(FlowControlAction&& predicate) + void Control::ForeachChild(FlowControlAction&& predicate) const { for (const auto child : children_) { @@ -39,11 +39,6 @@ namespace cru { } } - std::vector Control::GetChildren() - { - return this->children_; - } - void AddChildCheck(Control* control) { if (control->GetParent() != nullptr) @@ -91,7 +86,7 @@ namespace cru { this->OnRemoveChild(this); } - void Control::RemoveChild(int position) + void Control::RemoveChild(const int position) { if (position < 0 || static_castchildren_.size())>(position) >= this->children_.size()) throw std::invalid_argument("The position is out of range."); @@ -163,18 +158,18 @@ namespace cru { window->Repaint(); } - Point Control::GetPositionAbsolute() + Point Control::GetPositionAbsolute() const { return position_cache_.lefttop_position_absolute; } - Point Control::LocalToAbsolute(const Point& point) + Point Control::LocalToAbsolute(const Point& point) const { return Point(point.x + position_cache_.lefttop_position_absolute.x, point.y + position_cache_.lefttop_position_absolute.y); } - Point Control::AbsoluteToLocal(const Point & point) + Point Control::AbsoluteToLocal(const Point & point) const { return Point(point.x - position_cache_.lefttop_position_absolute.x, point.y - position_cache_.lefttop_position_absolute.y); @@ -182,7 +177,7 @@ namespace cru { bool Control::IsPointInside(const Point & point) { - auto size = GetSize(); + const auto size = GetSize(); return point.x >= 0.0f && point.x < size.width && point.y >= 0.0f && point.y < size.height; } @@ -191,7 +186,7 @@ namespace cru { D2D1::Matrix3x2F old_transform; device_context->GetTransform(&old_transform); - auto position = GetPositionRelative(); + const auto position = GetPositionRelative(); device_context->SetTransform(old_transform * D2D1::Matrix3x2F::Translation(position.x, position.y)); OnDraw(device_context); @@ -234,7 +229,7 @@ namespace cru { OnLayout(rect); } - Size Control::GetDesiredSize() + Size Control::GetDesiredSize() const { return desired_size_; } -- cgit v1.2.3