aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/text_control.cpp
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2018-12-06 03:48:18 +0800
committerGitHub <noreply@github.com>2018-12-06 03:48:18 +0800
commitf0e2b2d3763dd100a5e9d6cda566724d2b7da965 (patch)
tree24a3c1d5d4a37b724a5a5d694894ac9c09d2e6f0 /src/ui/controls/text_control.cpp
parent1166da612f01172270114921eb6785998ef88476 (diff)
parenta0ddf6549313f4b81d55d3c25c724c809230967f (diff)
downloadcru-f0e2b2d3763dd100a5e9d6cda566724d2b7da965.tar.gz
cru-f0e2b2d3763dd100a5e9d6cda566724d2b7da965.tar.bz2
cru-f0e2b2d3763dd100a5e9d6cda566724d2b7da965.zip
Merge pull request #34 from crupest/dev
Improve layout.
Diffstat (limited to 'src/ui/controls/text_control.cpp')
-rw-r--r--src/ui/controls/text_control.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ui/controls/text_control.cpp b/src/ui/controls/text_control.cpp
index f32c068f..6412eec9 100644
--- a/src/ui/controls/text_control.cpp
+++ b/src/ui/controls/text_control.cpp
@@ -56,14 +56,6 @@ namespace cru::ui::controls
SetClipContent(true);
- size_changed_event.AddHandler([this](events::SizeChangedEventArgs& args)
- {
- const auto content = GetRect(RectRange::Content);
- ThrowIfFailed(text_layout_->SetMaxWidth(content.width));
- ThrowIfFailed(text_layout_->SetMaxHeight(content.height));
- InvalidateDraw();
- });
-
draw_content_event.AddHandler([this](events::DrawEventArgs& args)
{
const auto device_context = args.GetDeviceContext();
@@ -177,7 +169,7 @@ namespace cru::ui::controls
}
}
- Size TextControl::OnMeasureContent(const Size& available_size)
+ Size TextControl::OnMeasureContent(const Size& available_size, const AdditionalMeasureInfo&)
{
ThrowIfFailed(text_layout_->SetMaxWidth(available_size.width));
ThrowIfFailed(text_layout_->SetMaxHeight(available_size.height));
@@ -196,6 +188,13 @@ namespace cru::ui::controls
}
+ void TextControl::OnRectChange(const Rect& old_rect, const Rect& new_rect)
+ {
+ const auto content = GetRect(RectRange::Content);
+ ThrowIfFailed(text_layout_->SetMaxWidth(content.width));
+ ThrowIfFailed(text_layout_->SetMaxHeight(content.height));
+ }
+
void TextControl::OnTextChangedCore(const String& old_text, const String& new_text)
{
RecreateTextLayout();