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

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

Issue 2447523002: [ash-md] Added different highlighting modes to the InkDropImpl. (Closed)
Patch Set: Fixed compile errors. 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/md_text_button.h" 5 #include "ui/views/controls/button/md_text_button.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "ui/base/material_design/material_design_controller.h" 8 #include "ui/base/material_design/material_design_controller.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/color_palette.h" 10 #include "ui/gfx/color_palette.h"
11 #include "ui/gfx/color_utils.h" 11 #include "ui/gfx/color_utils.h"
12 #include "ui/native_theme/native_theme.h" 12 #include "ui/native_theme/native_theme.h"
13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
14 #include "ui/views/animation/ink_drop_highlight.h" 14 #include "ui/views/animation/ink_drop_highlight.h"
15 #include "ui/views/animation/ink_drop_impl.h"
15 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" 16 #include "ui/views/animation/ink_drop_painted_layer_delegates.h"
16 #include "ui/views/background.h" 17 #include "ui/views/background.h"
17 #include "ui/views/border.h" 18 #include "ui/views/border.h"
18 #include "ui/views/controls/button/blue_button.h" 19 #include "ui/views/controls/button/blue_button.h"
19 #include "ui/views/controls/focus_ring.h" 20 #include "ui/views/controls/focus_ring.h"
20 #include "ui/views/painter.h" 21 #include "ui/views/painter.h"
21 #include "ui/views/style/platform_style.h" 22 #include "ui/views/style/platform_style.h"
22 23
23 namespace views { 24 namespace views {
24 25
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 void MdTextButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { 116 void MdTextButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
116 LabelButton::OnNativeThemeChanged(theme); 117 LabelButton::OnNativeThemeChanged(theme);
117 UpdateColors(); 118 UpdateColors();
118 } 119 }
119 120
120 SkColor MdTextButton::GetInkDropBaseColor() const { 121 SkColor MdTextButton::GetInkDropBaseColor() const {
121 return color_utils::DeriveDefaultIconColor(label()->enabled_color()); 122 return color_utils::DeriveDefaultIconColor(label()->enabled_color());
122 } 123 }
123 124
125 std::unique_ptr<InkDrop> MdTextButton::CreateInkDrop() {
126 return CreateDefaultFloodFillInkDropImpl();
127 }
128
124 std::unique_ptr<views::InkDropRipple> MdTextButton::CreateInkDropRipple() 129 std::unique_ptr<views::InkDropRipple> MdTextButton::CreateInkDropRipple()
125 const { 130 const {
126 return std::unique_ptr<views::InkDropRipple>( 131 return std::unique_ptr<views::InkDropRipple>(
127 new views::FloodFillInkDropRipple( 132 new views::FloodFillInkDropRipple(
128 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(), 133 GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(),
129 GetInkDropBaseColor(), ink_drop_visible_opacity())); 134 GetInkDropBaseColor(), ink_drop_visible_opacity()));
130 } 135 }
131 136
132 void MdTextButton::StateChanged() { 137 void MdTextButton::StateChanged() {
133 LabelButton::StateChanged(); 138 LabelButton::StateChanged();
134 UpdateColors(); 139 UpdateColors();
135 } 140 }
136 141
137 std::unique_ptr<views::InkDropHighlight> MdTextButton::CreateInkDropHighlight() 142 std::unique_ptr<views::InkDropHighlight> MdTextButton::CreateInkDropHighlight()
138 const { 143 const {
139 if (!ShouldShowInkDropHighlight())
140 return nullptr;
141
142 // The prominent button hover effect is a shadow. 144 // The prominent button hover effect is a shadow.
143 const int kYOffset = 1; 145 const int kYOffset = 1;
144 const int kSkiaBlurRadius = 2; 146 const int kSkiaBlurRadius = 2;
145 const int shadow_alpha = is_prominent_ ? 0x3D : 0x1A; 147 const int shadow_alpha = is_prominent_ ? 0x3D : 0x1A;
146 std::vector<gfx::ShadowValue> shadows; 148 std::vector<gfx::ShadowValue> shadows;
147 // The notion of blur that gfx::ShadowValue uses is twice the Skia/CSS value. 149 // The notion of blur that gfx::ShadowValue uses is twice the Skia/CSS value.
148 // Skia counts the number of pixels outside the mask area whereas 150 // Skia counts the number of pixels outside the mask area whereas
149 // gfx::ShadowValue counts together the number of pixels inside and outside 151 // gfx::ShadowValue counts together the number of pixels inside and outside
150 // the mask bounds. 152 // the mask bounds.
151 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(0, kYOffset), 153 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(0, kYOffset),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 stroke_color, gfx::kDisabledControlAlpha); 298 stroke_color, gfx::kDisabledControlAlpha);
297 } 299 }
298 300
299 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color))); 301 DCHECK_EQ(SK_AlphaOPAQUE, static_cast<int>(SkColorGetA(bg_color)));
300 set_background(Background::CreateBackgroundPainter( 302 set_background(Background::CreateBackgroundPainter(
301 true, Painter::CreateRoundRectWith1PxBorderPainter( 303 true, Painter::CreateRoundRectWith1PxBorderPainter(
302 bg_color, stroke_color, kInkDropSmallCornerRadius))); 304 bg_color, stroke_color, kInkDropSmallCornerRadius)));
303 } 305 }
304 306
305 } // namespace views 307 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698