Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: ui/views/controls/button/label_button.cc

Issue 872113004: Modified OverviewMode's LabelButton bounds to cover the entire item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed ignore_border_overlap from label_button as per msw suggestion. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« ash/wm/overview/window_selector_item.cc ('K') | « ash/wm/overview/window_selector_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698