diff options
author | crupest <crupest@outlook.com> | 2018-09-30 20:38:10 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-09-30 20:38:10 +0800 |
commit | 88765aab936724cb01fa2ffd86d65181182a1cd2 (patch) | |
tree | cf8f400d221756add6c6a61ef001130812f57313 /src/ui/control.cpp | |
parent | 20dc75e2ce6a9c38dd1888fdbf793fd8a3bc9cd3 (diff) | |
download | cru-88765aab936724cb01fa2ffd86d65181182a1cd2.tar.gz cru-88765aab936724cb01fa2ffd86d65181182a1cd2.tar.bz2 cru-88765aab936724cb01fa2ffd86d65181182a1cd2.zip |
Create border delegate.
Diffstat (limited to 'src/ui/control.cpp')
-rw-r--r-- | src/ui/control.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/ui/control.cpp b/src/ui/control.cpp index 81cfe9b1..480f7d46 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -257,7 +257,7 @@ namespace cru { { SetPositionRelative(rect.GetLeftTop()); SetSize(rect.GetSize()); - OnLayout(rect); + OnLayout(Rect(Point::Zero(), rect.GetSize())); } Size Control::GetDesiredSize() const @@ -617,24 +617,24 @@ namespace cru { const auto layout_params = control->GetLayoutParams(); const auto size = control->GetDesiredSize(); - auto&& calculate_anchor = [](const Alignment alignment, const float layout_length, const float control_length) -> float + auto&& calculate_anchor = [](const float anchor, const Alignment alignment, const float layout_length, const float control_length) -> float { switch (alignment) { case Alignment::Center: - return (layout_length - control_length) / 2; + return anchor + (layout_length - control_length) / 2; case Alignment::Start: - return 0; + return anchor; case Alignment::End: - return layout_length - control_length; + return anchor + layout_length - control_length; default: UnreachableCode(); } }; control->Layout(Rect(Point( - calculate_anchor(layout_params->width.alignment, rect.width, size.width), - calculate_anchor(layout_params->height.alignment, rect.height, size.height) + calculate_anchor(rect.left, layout_params->width.alignment, rect.width, size.width), + calculate_anchor(rect.top, layout_params->height.alignment, rect.height, size.height) ), size)); }); } |