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

Side by Side Diff: ui/views/controls/button/label_button.cc

Issue 82483003: Add GetMinimumSize() for Borders, and make LabelButton auto-size to at least as (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/bubble/bubble_border.cc ('k') | ui/views/controls/button/label_button_border.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/button/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/animation/throb_animation.h" 10 #include "ui/gfx/animation/throb_animation.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 label.SizeToFit(width() - image_width - (image_width > 0 ? kSpacing : 0)); 181 label.SizeToFit(width() - image_width - (image_width > 0 ? kSpacing : 0));
182 182
183 // Calculate the required size. 183 // Calculate the required size.
184 gfx::Size size(label.GetPreferredSize()); 184 gfx::Size size(label.GetPreferredSize());
185 if (image_width > 0 && size.width() > 0) 185 if (image_width > 0 && size.width() > 0)
186 size.Enlarge(kSpacing, 0); 186 size.Enlarge(kSpacing, 0);
187 size.SetToMax(gfx::Size(0, image_size.height())); 187 size.SetToMax(gfx::Size(0, image_size.height()));
188 const gfx::Insets insets(GetInsets()); 188 const gfx::Insets insets(GetInsets());
189 size.Enlarge(image_size.width() + insets.width(), insets.height()); 189 size.Enlarge(image_size.width() + insets.width(), insets.height());
190 190
191 // Make the size at least as large as the minimum size needed by the border.
192 size.SetToMax(border()->GetMinimumSize());
193
191 // Increase the minimum size monotonically with the preferred size. 194 // Increase the minimum size monotonically with the preferred size.
192 size.SetToMax(min_size_); 195 size.SetToMax(min_size_);
193 min_size_ = size; 196 min_size_ = size;
194 197
195 // Return the largest known size clamped to the maximum size (if valid). 198 // Return the largest known size clamped to the maximum size (if valid).
196 if (max_size_.width() > 0) 199 if (max_size_.width() > 0)
197 size.set_width(std::min(max_size_.width(), size.width())); 200 size.set_width(std::min(max_size_.width(), size.width()));
198 if (max_size_.height() > 0) 201 if (max_size_.height() > 0)
199 size.set_height(std::min(max_size_.height(), size.height())); 202 size.set_height(std::min(max_size_.height(), size.height()));
200 return size; 203 return size;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return ui::NativeTheme::kNormal; 369 return ui::NativeTheme::kNormal;
367 } 370 }
368 371
369 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 372 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
370 ui::NativeTheme::ExtraParams* params) const { 373 ui::NativeTheme::ExtraParams* params) const {
371 GetExtraParams(params); 374 GetExtraParams(params);
372 return ui::NativeTheme::kHovered; 375 return ui::NativeTheme::kHovered;
373 } 376 }
374 377
375 } // namespace views 378 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_border.cc ('k') | ui/views/controls/button/label_button_border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698