Index: ui/views/controls/button/label_button.cc |
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc |
index 0387e1d641e64caa1bb93dc934811e27945bee58..43164e31dfc734fed29ca042092ecdac92734637 100644 |
--- a/ui/views/controls/button/label_button.cc |
+++ b/ui/views/controls/button/label_button.cc |
@@ -287,17 +287,21 @@ void LabelButton::Layout() { |
adjusted_alignment = (adjusted_alignment == gfx::ALIGN_LEFT) ? |
gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT; |
+ // By default, GetChildAreaBounds() ignores the top and bottom border, but we |
msw
2015/02/06 21:24:26
Flip around some of this code: GetChildAreaBounds
Nina
2015/02/09 16:35:09
Done. The idea behind the way I had originally wri
|
+ // want the image to respect it. |
+ gfx::Rect max_image_bounds = GetLocalBounds(); |
+ max_image_bounds.Inset(GetInsets()); |
gfx::Rect child_area(GetChildAreaBounds()); |
- child_area.Inset(GetInsets()); |
gfx::Size image_size(image_->GetPreferredSize()); |
image_size.SetToMin(child_area.size()); |
+ image_size.SetToMin(max_image_bounds.size()); |
// The label takes any remaining width after sizing the image, unless both |
// views are centered. In that case, using the tighter preferred label width |
// avoids wasted space within the label that would look like awkward padding. |
// Labels can paint over the full button height, including the border height. |
- gfx::Size label_size(child_area.width(), height()); |
+ gfx::Size label_size(child_area.size()); |
if (!image_size.IsEmpty() && !label_size.IsEmpty()) { |
label_size.set_width(std::max(child_area.width() - |
image_size.width() - image_label_spacing_, 0)); |
@@ -320,7 +324,7 @@ void LabelButton::Layout() { |
image_origin.Offset(child_area.width() - image_size.width(), 0); |
} |
- gfx::Point label_origin(child_area.x(), 0); |
+ gfx::Point label_origin(child_area.origin()); |
msw
2015/02/06 21:24:26
Then change this to: gfx::Point label_origin(label
Nina
2015/02/09 16:35:09
Done.
|
if (!image_size.IsEmpty() && adjusted_alignment != gfx::ALIGN_RIGHT) { |
label_origin.set_x(image_origin.x() + image_size.width() + |
image_label_spacing_); |
@@ -345,7 +349,10 @@ void LabelButton::SetBorder(scoped_ptr<Border> border) { |
} |
gfx::Rect LabelButton::GetChildAreaBounds() { |
- return GetLocalBounds(); |
+ gfx::Rect bounds = GetLocalBounds(); |
msw
2015/02/06 21:24:26
Revert this to just return GetLocalBounds().
Nina
2015/02/09 16:35:09
Done.
|
+ gfx::Insets insets = GetInsets(); |
+ bounds.Inset(insets.left(), 0, insets.right(), 0); |
+ return bounds; |
} |
void LabelButton::OnPaint(gfx::Canvas* canvas) { |
@@ -512,7 +519,7 @@ ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
void LabelButton::ResetCachedPreferredSize() { |
cached_preferred_size_valid_ = false; |
- cached_preferred_size_= gfx::Size(); |
+ cached_preferred_size_ = gfx::Size(); |
} |
} // namespace views |