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_border.h" | 5 #include "ui/views/controls/button/label_button_border.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/animation.h" | 9 #include "ui/base/animation/animation.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 SetPainter(false, Button::STATE_HOVERED, | 86 SetPainter(false, Button::STATE_HOVERED, |
87 Painter::CreateImageGridPainter(kTextHoveredImages)); | 87 Painter::CreateImageGridPainter(kTextHoveredImages)); |
88 SetPainter(false, Button::STATE_PRESSED, | 88 SetPainter(false, Button::STATE_PRESSED, |
89 Painter::CreateImageGridPainter(kTextPressedImages)); | 89 Painter::CreateImageGridPainter(kTextPressedImages)); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 LabelButtonBorder::~LabelButtonBorder() {} | 93 LabelButtonBorder::~LabelButtonBorder() {} |
94 | 94 |
95 void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) { | 95 void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) { |
96 DCHECK(!strcmp(view.GetClassName(), LabelButton::kViewClassName)); | 96 //DCHECK(!strcmp(view.GetClassName(), LabelButton::kViewClassName)); |
97 const NativeThemeDelegate* native_theme_delegate = | 97 const NativeThemeDelegate* native_theme_delegate = |
98 static_cast<const LabelButton*>(&view); | 98 static_cast<const LabelButton*>(&view); |
99 ui::NativeTheme::Part part = native_theme_delegate->GetThemePart(); | 99 ui::NativeTheme::Part part = native_theme_delegate->GetThemePart(); |
100 gfx::Rect rect(native_theme_delegate->GetThemePaintRect()); | 100 gfx::Rect rect(native_theme_delegate->GetThemePaintRect()); |
101 ui::NativeTheme::ExtraParams extra; | 101 ui::NativeTheme::ExtraParams extra; |
102 const ui::NativeTheme* theme = view.GetNativeTheme(); | 102 const ui::NativeTheme* theme = view.GetNativeTheme(); |
103 const ui::Animation* animation = native_theme_delegate->GetThemeAnimation(); | 103 const ui::Animation* animation = native_theme_delegate->GetThemeAnimation(); |
104 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); | 104 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); |
105 | 105 |
106 if (animation && animation->is_animating()) { | 106 if (animation && animation->is_animating()) { |
(...skipping 24 matching lines...) Expand all Loading... |
131 } | 131 } |
132 | 132 |
133 gfx::Insets LabelButtonBorder::GetInsets() const { | 133 gfx::Insets LabelButtonBorder::GetInsets() const { |
134 // Return the style-specific insets between button contents and edges. | 134 // Return the style-specific insets between button contents and edges. |
135 if (style() == Button::STYLE_BUTTON) | 135 if (style() == Button::STYLE_BUTTON) |
136 return gfx::Insets(9, 13, 9, 13); | 136 return gfx::Insets(9, 13, 9, 13); |
137 if (style() == Button::STYLE_TEXTBUTTON) | 137 if (style() == Button::STYLE_TEXTBUTTON) |
138 return gfx::Insets(5, 6, 5, 6); | 138 return gfx::Insets(5, 6, 5, 6); |
139 if (style() == Button::STYLE_NATIVE_TEXTBUTTON) | 139 if (style() == Button::STYLE_NATIVE_TEXTBUTTON) |
140 return gfx::Insets(5, 12, 5, 12); | 140 return gfx::Insets(5, 12, 5, 12); |
| 141 if (style() == Button::STYLE_CHECKBOX) |
| 142 return gfx::Insets(5, 12, 5, 12); |
| 143 if (style() == Button::STYLE_RADIO_BUTTON) |
| 144 return gfx::Insets(5, 12, 5, 12); |
141 NOTREACHED(); | 145 NOTREACHED(); |
142 return gfx::Insets(); | 146 return gfx::Insets(); |
143 } | 147 } |
144 | 148 |
145 Painter* LabelButtonBorder::GetPainter(bool focused, | 149 Painter* LabelButtonBorder::GetPainter(bool focused, |
146 Button::ButtonState state) { | 150 Button::ButtonState state) { |
147 return painters_[focused ? 1 : 0][state].get(); | 151 return painters_[focused ? 1 : 0][state].get(); |
148 } | 152 } |
149 | 153 |
150 void LabelButtonBorder::SetPainter(bool focused, | 154 void LabelButtonBorder::SetPainter(bool focused, |
151 Button::ButtonState state, | 155 Button::ButtonState state, |
152 Painter* painter) { | 156 Painter* painter) { |
153 painters_[focused ? 1 : 0][state].reset(painter); | 157 painters_[focused ? 1 : 0][state].reset(painter); |
154 } | 158 } |
155 | 159 |
156 } // namespace views | 160 } // namespace views |
OLD | NEW |