| 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/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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets( | 158 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets( |
| 159 gfx::Insets(3, 3, 3, 3))); | 159 gfx::Insets(3, 3, 3, 3))); |
| 160 } | 160 } |
| 161 if (style == STYLE_BUTTON) { | 161 if (style == STYLE_BUTTON) { |
| 162 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 162 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 163 SetFocusable(true); | 163 SetFocusable(true); |
| 164 } | 164 } |
| 165 if (style == STYLE_BUTTON) | 165 if (style == STYLE_BUTTON) |
| 166 set_min_size(gfx::Size(70, 33)); | 166 set_min_size(gfx::Size(70, 33)); |
| 167 | 167 |
| 168 OnNativeThemeChanged(GetNativeTheme()); | 168 ResetColorsFromNativeTheme(); |
| 169 UpdateThemedBorder(scoped_ptr<Border>(new LabelButtonBorder(style_))); |
| 170 // Invalidate the layout to pickup the new insets from the border. |
| 171 InvalidateLayout(); |
| 169 } | 172 } |
| 170 | 173 |
| 171 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { | 174 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { |
| 172 focus_painter_ = focus_painter.Pass(); | 175 focus_painter_ = focus_painter.Pass(); |
| 173 } | 176 } |
| 174 | 177 |
| 175 gfx::Size LabelButton::GetPreferredSize() { | 178 gfx::Size LabelButton::GetPreferredSize() { |
| 176 // Use a temporary label copy for sizing to avoid calculation side-effects. | 179 // Use a temporary label copy for sizing to avoid calculation side-effects. |
| 177 Label label(GetText(), cached_normal_font_list_); | 180 Label label(GetText(), cached_normal_font_list_); |
| 178 label.SetMultiLine(GetTextMultiLine()); | 181 label.SetMultiLine(GetTextMultiLine()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 if (image_->GetPreferredSize() != previous_image_size) | 370 if (image_->GetPreferredSize() != previous_image_size) |
| 368 Layout(); | 371 Layout(); |
| 369 } | 372 } |
| 370 | 373 |
| 371 void LabelButton::ChildPreferredSizeChanged(View* child) { | 374 void LabelButton::ChildPreferredSizeChanged(View* child) { |
| 372 PreferredSizeChanged(); | 375 PreferredSizeChanged(); |
| 373 } | 376 } |
| 374 | 377 |
| 375 void LabelButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 378 void LabelButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 376 ResetColorsFromNativeTheme(); | 379 ResetColorsFromNativeTheme(); |
| 377 UpdateThemedBorder(scoped_ptr<Border>(new LabelButtonBorder(style_))); | |
| 378 // Invalidate the layout to pickup the new insets from the border. | |
| 379 InvalidateLayout(); | |
| 380 } | 380 } |
| 381 | 381 |
| 382 ui::NativeTheme::Part LabelButton::GetThemePart() const { | 382 ui::NativeTheme::Part LabelButton::GetThemePart() const { |
| 383 return ui::NativeTheme::kPushButton; | 383 return ui::NativeTheme::kPushButton; |
| 384 } | 384 } |
| 385 | 385 |
| 386 gfx::Rect LabelButton::GetThemePaintRect() const { | 386 gfx::Rect LabelButton::GetThemePaintRect() const { |
| 387 return GetLocalBounds(); | 387 return GetLocalBounds(); |
| 388 } | 388 } |
| 389 | 389 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 410 return ui::NativeTheme::kNormal; | 410 return ui::NativeTheme::kNormal; |
| 411 } | 411 } |
| 412 | 412 |
| 413 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 413 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
| 414 ui::NativeTheme::ExtraParams* params) const { | 414 ui::NativeTheme::ExtraParams* params) const { |
| 415 GetExtraParams(params); | 415 GetExtraParams(params); |
| 416 return ui::NativeTheme::kHovered; | 416 return ui::NativeTheme::kHovered; |
| 417 } | 417 } |
| 418 | 418 |
| 419 } // namespace views | 419 } // namespace views |
| OLD | NEW |