| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |