diff options
Diffstat (limited to 'src/ui/controls')
-rw-r--r-- | src/ui/controls/linear_layout.cpp | 6 | ||||
-rw-r--r-- | src/ui/controls/linear_layout.hpp | 2 | ||||
-rw-r--r-- | src/ui/controls/scroll_control.cpp | 10 | ||||
-rw-r--r-- | src/ui/controls/scroll_control.hpp | 4 | ||||
-rw-r--r-- | src/ui/controls/text_control.cpp | 15 | ||||
-rw-r--r-- | src/ui/controls/text_control.hpp | 2 |
6 files changed, 20 insertions, 19 deletions
diff --git a/src/ui/controls/linear_layout.cpp b/src/ui/controls/linear_layout.cpp index 8f2e7e80..2b8f3e43 100644 --- a/src/ui/controls/linear_layout.cpp +++ b/src/ui/controls/linear_layout.cpp @@ -107,7 +107,7 @@ namespace cru::ui::controls return actual_size_for_children; } - void LinearLayout::OnLayoutContent(const Rect& rect) + void LinearLayout::OnLayoutContent(const Rect& rect, const AdditionalLayoutInfo& additional_info) { float current_main_side_anchor = 0; for(auto control: GetChildren()) @@ -138,12 +138,12 @@ namespace cru::ui::controls if (orientation_ == Orientation::Horizontal) { - control->Layout(calculate_rect(current_main_side_anchor, calculate_secondary_side_anchor(rect.height, size.height))); + control->Layout(calculate_rect(current_main_side_anchor, calculate_secondary_side_anchor(rect.height, size.height)), additional_info); current_main_side_anchor += size.width; } else { - control->Layout(calculate_rect(calculate_secondary_side_anchor(rect.width, size.width), current_main_side_anchor)); + control->Layout(calculate_rect(calculate_secondary_side_anchor(rect.width, size.width), current_main_side_anchor), additional_info); current_main_side_anchor += size.height; } } diff --git a/src/ui/controls/linear_layout.hpp b/src/ui/controls/linear_layout.hpp index 9606b8a6..96becc6f 100644 --- a/src/ui/controls/linear_layout.hpp +++ b/src/ui/controls/linear_layout.hpp @@ -42,7 +42,7 @@ namespace cru::ui::controls protected: Size OnMeasureContent(const Size& available_size, const AdditionalMeasureInfo& additional_info) override; - void OnLayoutContent(const Rect& rect) override; + void OnLayoutContent(const Rect& rect, const AdditionalLayoutInfo& additional_info) override; private: Orientation orientation_; diff --git a/src/ui/controls/scroll_control.cpp b/src/ui/controls/scroll_control.cpp index db8ac438..8358abc5 100644 --- a/src/ui/controls/scroll_control.cpp +++ b/src/ui/controls/scroll_control.cpp @@ -283,7 +283,7 @@ namespace cru::ui::controls return result; } - void ScrollControl::OnLayoutContent(const Rect& rect) + void ScrollControl::OnLayoutContent(const Rect& rect, const AdditionalLayoutInfo& additional_info) { auto layout_rect = rect; @@ -304,11 +304,11 @@ namespace cru::ui::controls control->Layout(Rect(Point( calculate_anchor(rect.left, layout_rect.width, size.width, offset_x_), calculate_anchor(rect.top, layout_rect.height, size.height, offset_y_) - ), size)); + ), size), additional_info); } } - void ScrollControl::AfterLayoutSelf() + void ScrollControl::OnRectChange(const Rect& old_rect, const Rect& new_rect) { UpdateScrollBarBorderInfo(); CoerceAndSetOffsets(offset_x_, offset_y_, false); @@ -330,10 +330,10 @@ namespace cru::ui::controls for (auto child : GetChildren()) { const auto old_position = child->GetPositionRelative(); - child->SetPositionRelative(Point( + child->SetRect(Rect(Point( old_position.x + old_offset_x - offset_x_, old_position.y + old_offset_y - offset_y_ - )); + ), child->GetSize())); } } InvalidateDraw(); diff --git a/src/ui/controls/scroll_control.hpp b/src/ui/controls/scroll_control.hpp index d70a7b35..db29b141 100644 --- a/src/ui/controls/scroll_control.hpp +++ b/src/ui/controls/scroll_control.hpp @@ -118,9 +118,9 @@ namespace cru::ui::controls void SetViewHeight(float length); Size OnMeasureContent(const Size& available_size, const AdditionalMeasureInfo& additional_info) override final; - void OnLayoutContent(const Rect& rect) override final; + void OnLayoutContent(const Rect& rect, const AdditionalLayoutInfo& additional_info) override final; - void AfterLayoutSelf() override; + void OnRectChange(const Rect& old_rect, const Rect& new_rect) override; private: void CoerceAndSetOffsets(float offset_x, float offset_y, bool update_children = true); diff --git a/src/ui/controls/text_control.cpp b/src/ui/controls/text_control.cpp index 9a799916..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(); @@ -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(); diff --git a/src/ui/controls/text_control.hpp b/src/ui/controls/text_control.hpp index fddd8ec7..9b83f4bb 100644 --- a/src/ui/controls/text_control.hpp +++ b/src/ui/controls/text_control.hpp @@ -66,6 +66,8 @@ namespace cru::ui::controls virtual void RequestChangeCaretPosition(unsigned position); + void OnRectChange(const Rect& old_rect, const Rect& new_rect) override; + private: void OnTextChangedCore(const String& old_text, const String& new_text); |