aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/controls')
-rw-r--r--src/ui/controls/border_delegate.cpp12
-rw-r--r--src/ui/controls/border_delegate.h6
-rw-r--r--src/ui/controls/button.cpp10
-rw-r--r--src/ui/controls/button.h3
4 files changed, 17 insertions, 14 deletions
diff --git a/src/ui/controls/border_delegate.cpp b/src/ui/controls/border_delegate.cpp
index ec7ba437..0b460997 100644
--- a/src/ui/controls/border_delegate.cpp
+++ b/src/ui/controls/border_delegate.cpp
@@ -82,16 +82,4 @@ namespace cru::ui::controls
border_property_->GetStrokeStyle().Get()
);
}
-
- Size BorderDelegate::GetBorderSize() const
- {
- const auto width = border_property_->GetWidth();
- return Size(width * 2, width * 2);
- }
-
- Rect BorderDelegate::CoerceLayoutRect(const Rect& rect) const
- {
- const auto width = border_property_->GetWidth();
- return Rect(rect.left + width, rect.top + width, rect.width - width * 2, rect.height - width * 2);
- }
}
diff --git a/src/ui/controls/border_delegate.h b/src/ui/controls/border_delegate.h
index 5a7dfbed..6d3b31db 100644
--- a/src/ui/controls/border_delegate.h
+++ b/src/ui/controls/border_delegate.h
@@ -90,8 +90,10 @@ namespace cru::ui::controls
void Draw(ID2D1DeviceContext* device_context, const Size& size) const;
- Size GetBorderSize() const;
- Rect CoerceLayoutRect(const Rect& rect) const;
+ Thickness GetBorderThickness() const
+ {
+ return Thickness(border_property_->GetWidth());
+ }
private:
Control* control_;
diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp
index 630c0c39..2ecc9f14 100644
--- a/src/ui/controls/button.cpp
+++ b/src/ui/controls/button.cpp
@@ -29,6 +29,16 @@ namespace cru::ui::controls
border_delegate_->Draw(device_context, GetSize());
}
+ Size Button::OnMeasure(const Size& available_size)
+ {
+ return Control::DefaultMeasureWithPadding(available_size, border_delegate_->GetBorderThickness());
+ }
+
+ void Button::OnLayout(const Rect& rect)
+ {
+ Control::DefaultLayoutWithPadding(rect, border_delegate_->GetBorderThickness());
+ }
+
void Button::OnMouseClickBegin(MouseButton button)
{
border_delegate_->SetBorderProperty(pressed_border_border_);
diff --git a/src/ui/controls/button.h b/src/ui/controls/button.h
index 7a303984..4b57a5a3 100644
--- a/src/ui/controls/button.h
+++ b/src/ui/controls/button.h
@@ -31,6 +31,9 @@ namespace cru::ui::controls
protected:
void OnDraw(ID2D1DeviceContext* device_context) override;
+ Size OnMeasure(const Size& available_size) override;
+ void OnLayout(const Rect& rect) override;
+
void OnMouseClickBegin(MouseButton button) override final;
void OnMouseClickEnd(MouseButton button) override final;