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

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

Issue 14367021: Rename ClampToMin and ClampToMax (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | ui/views/controls/scrollbar/kennedy_scroll_bar.cc » ('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/animation/throb_animation.h" 9 #include "ui/base/animation/throb_animation.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Resize multi-line labels given the current limited available width. 167 // Resize multi-line labels given the current limited available width.
168 const gfx::Size image_size(image_->GetPreferredSize()); 168 const gfx::Size image_size(image_->GetPreferredSize());
169 const int image_width = image_size.width(); 169 const int image_width = image_size.width();
170 if (GetTextMultiLine() && (width() > image_width + kSpacing)) 170 if (GetTextMultiLine() && (width() > image_width + kSpacing))
171 label.SizeToFit(width() - image_width - (image_width > 0 ? kSpacing : 0)); 171 label.SizeToFit(width() - image_width - (image_width > 0 ? kSpacing : 0));
172 172
173 // Calculate the required size. 173 // Calculate the required size.
174 gfx::Size size(label.GetPreferredSize()); 174 gfx::Size size(label.GetPreferredSize());
175 if (image_width > 0 && size.width() > 0) 175 if (image_width > 0 && size.width() > 0)
176 size.Enlarge(kSpacing, 0); 176 size.Enlarge(kSpacing, 0);
177 size.ClampToMin(gfx::Size(0, image_size.height())); 177 size.SetToMax(gfx::Size(0, image_size.height()));
178 const gfx::Insets insets(GetInsets()); 178 const gfx::Insets insets(GetInsets());
179 size.Enlarge(image_size.width() + insets.width(), insets.height()); 179 size.Enlarge(image_size.width() + insets.width(), insets.height());
180 180
181 // Increase the minimum size monotonically with the preferred size. 181 // Increase the minimum size monotonically with the preferred size.
182 size.ClampToMin(min_size_); 182 size.SetToMax(min_size_);
183 min_size_ = size; 183 min_size_ = size;
184 184
185 // Return the largest known size clamped to the maximum size (if valid). 185 // Return the largest known size clamped to the maximum size (if valid).
186 if (max_size_.width() > 0) 186 if (max_size_.width() > 0)
187 size.set_width(std::min(max_size_.width(), size.width())); 187 size.set_width(std::min(max_size_.width(), size.width()));
188 if (max_size_.height() > 0) 188 if (max_size_.height() > 0)
189 size.set_height(std::min(max_size_.height(), size.height())); 189 size.set_height(std::min(max_size_.height(), size.height()));
190 return size; 190 return size;
191 } 191 }
192 192
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return ui::NativeTheme::kNormal; 339 return ui::NativeTheme::kNormal;
340 } 340 }
341 341
342 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 342 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
343 ui::NativeTheme::ExtraParams* params) const { 343 ui::NativeTheme::ExtraParams* params) const {
344 GetExtraParams(params); 344 GetExtraParams(params);
345 return ui::NativeTheme::kHovered; 345 return ui::NativeTheme::kHovered;
346 } 346 }
347 347
348 } // namespace views 348 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | ui/views/controls/scrollbar/kennedy_scroll_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698