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

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

Issue 2447523002: [ash-md] Added different highlighting modes to the InkDropImpl. (Closed)
Patch Set: Fixed InkDropHostView::GetInkDrop() to use CreateInkDrop(). Created 4 years, 1 month 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
« no previous file with comments | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/custom_button.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/checkbox.h" 5 #include "ui/views/controls/button/checkbox.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "ui/accessibility/ax_node_data.h" 11 #include "ui/accessibility/ax_node_data.h"
12 #include "ui/base/material_design/material_design_controller.h" 12 #include "ui/base/material_design/material_design_controller.h"
13 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/color_utils.h" 15 #include "ui/gfx/color_utils.h"
16 #include "ui/gfx/paint_vector_icon.h" 16 #include "ui/gfx/paint_vector_icon.h"
17 #include "ui/gfx/vector_icons_public.h" 17 #include "ui/gfx/vector_icons_public.h"
18 #include "ui/resources/grit/ui_resources.h" 18 #include "ui/resources/grit/ui_resources.h"
19 #include "ui/views/animation/ink_drop_highlight.h"
20 #include "ui/views/animation/ink_drop_ripple.h" 19 #include "ui/views/animation/ink_drop_ripple.h"
20 #include "ui/views/animation/square_ink_drop_ripple.h"
21 #include "ui/views/controls/button/label_button_border.h" 21 #include "ui/views/controls/button/label_button_border.h"
22 #include "ui/views/painter.h" 22 #include "ui/views/painter.h"
23 #include "ui/views/resources/grit/views_resources.h" 23 #include "ui/views/resources/grit/views_resources.h"
24 #include "ui/views/style/platform_style.h" 24 #include "ui/views/style/platform_style.h"
25 25
26 namespace views { 26 namespace views {
27 27
28 // static 28 // static
29 const char Checkbox::kViewClassName[] = "Checkbox"; 29 const char Checkbox::kViewClassName[] = "Checkbox";
30 30
31 Checkbox::Checkbox(const base::string16& label) 31 Checkbox::Checkbox(const base::string16& label)
32 : LabelButton(NULL, label), 32 : LabelButton(NULL, label),
33 checked_(false) { 33 checked_(false) {
34 SetHorizontalAlignment(gfx::ALIGN_LEFT); 34 SetHorizontalAlignment(gfx::ALIGN_LEFT);
35 SetFocusForPlatform(); 35 SetFocusForPlatform();
36 36
37 if (UseMd()) { 37 if (UseMd()) {
38 set_request_focus_on_press(false); 38 set_request_focus_on_press(false);
39 SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON 39 SetInkDropMode(PlatformStyle::kUseRipples ? InkDropMode::ON
40 : InkDropMode::OFF); 40 : InkDropMode::OFF);
41 set_has_ink_drop_action_on_click(true); 41 set_has_ink_drop_action_on_click(true);
42 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp.
43 set_ink_drop_size(gfx::Size(21, 21));
44 SetFocusPainter(nullptr); 42 SetFocusPainter(nullptr);
45 } else { 43 } else {
46 std::unique_ptr<LabelButtonBorder> button_border(new LabelButtonBorder()); 44 std::unique_ptr<LabelButtonBorder> button_border(new LabelButtonBorder());
47 // Inset the trailing side by a couple pixels for the focus border. 45 // Inset the trailing side by a couple pixels for the focus border.
48 button_border->set_insets(gfx::Insets(0, 0, 0, 2)); 46 button_border->set_insets(gfx::Insets(0, 0, 0, 2));
49 SetBorder(std::move(button_border)); 47 SetBorder(std::move(button_border));
50 set_request_focus_on_press(true); 48 set_request_focus_on_press(true);
51 49
52 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 50 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
53 51
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 UpdateImage(); 156 UpdateImage();
159 } 157 }
160 158
161 void Checkbox::OnNativeThemeChanged(const ui::NativeTheme* theme) { 159 void Checkbox::OnNativeThemeChanged(const ui::NativeTheme* theme) {
162 LabelButton::OnNativeThemeChanged(theme); 160 LabelButton::OnNativeThemeChanged(theme);
163 if (UseMd()) 161 if (UseMd())
164 UpdateImage(); 162 UpdateImage();
165 } 163 }
166 164
167 std::unique_ptr<InkDropRipple> Checkbox::CreateInkDropRipple() const { 165 std::unique_ptr<InkDropRipple> Checkbox::CreateInkDropRipple() const {
168 return CreateDefaultInkDropRipple(image()->GetMirroredBounds().CenterPoint()); 166 // The "small" size is 21dp, the large size is 1.33 * 21dp = 28dp.
169 } 167 const gfx::Size size(21, 21);
170 168 std::unique_ptr<InkDropRipple> ripple(new SquareInkDropRipple(
171 std::unique_ptr<InkDropHighlight> Checkbox::CreateInkDropHighlight() const { 169 CalculateLargeInkDropSize(size), kInkDropLargeCornerRadius, size,
172 return nullptr; 170 kInkDropSmallCornerRadius, image()->GetMirroredBounds().CenterPoint(),
171 GetInkDropBaseColor(), ink_drop_visible_opacity()));
172 return ripple;
173 } 173 }
174 174
175 SkColor Checkbox::GetInkDropBaseColor() const { 175 SkColor Checkbox::GetInkDropBaseColor() const {
176 return GetNativeTheme()->GetSystemColor( 176 return GetNativeTheme()->GetSystemColor(
177 ui::NativeTheme::kColorId_ButtonEnabledColor); 177 ui::NativeTheme::kColorId_ButtonEnabledColor);
178 } 178 }
179 179
180 gfx::ImageSkia Checkbox::GetImage(ButtonState for_state) const { 180 gfx::ImageSkia Checkbox::GetImage(ButtonState for_state) const {
181 if (UseMd()) { 181 if (UseMd()) {
182 return gfx::CreateVectorIcon( 182 return gfx::CreateVectorIcon(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 ui::NativeTheme::Part Checkbox::GetThemePart() const { 223 ui::NativeTheme::Part Checkbox::GetThemePart() const {
224 return ui::NativeTheme::kCheckbox; 224 return ui::NativeTheme::kCheckbox;
225 } 225 }
226 226
227 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const { 227 void Checkbox::GetExtraParams(ui::NativeTheme::ExtraParams* params) const {
228 LabelButton::GetExtraParams(params); 228 LabelButton::GetExtraParams(params);
229 params->button.checked = checked_; 229 params->button.checked = checked_;
230 } 230 }
231 231
232 } // namespace views 232 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/checkbox.h ('k') | ui/views/controls/button/custom_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698