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

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

Issue 2094343005: Fix MD button hover shadow effect on odd-sized buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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_utils.h" 10 #include "ui/gfx/color_utils.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // The call to action hover effect is a shadow. 182 // The call to action hover effect is a shadow.
183 const int kYOffset = 2; 183 const int kYOffset = 2;
184 const int kSkiaBlurRadius = 2; 184 const int kSkiaBlurRadius = 2;
185 std::vector<gfx::ShadowValue> shadows; 185 std::vector<gfx::ShadowValue> shadows;
186 // The notion of blur that gfx::ShadowValue uses is twice the skia value, 186 // The notion of blur that gfx::ShadowValue uses is twice the skia value,
187 // which is a number of pixels outside of the shadowed area. 187 // which is a number of pixels outside of the shadowed area.
188 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(0, kYOffset), 188 shadows.push_back(gfx::ShadowValue(gfx::Vector2d(0, kYOffset),
189 2 * kSkiaBlurRadius, 189 2 * kSkiaBlurRadius,
190 SkColorSetA(SK_ColorBLACK, 0x3D))); 190 SkColorSetA(SK_ColorBLACK, 0x3D)));
191 return base::WrapUnique(new InkDropHighlight( 191 return base::WrapUnique(new InkDropHighlight(
192 GetLocalBounds().CenterPoint(), 192 gfx::RectF(GetLocalBounds()).CenterPoint(),
193 base::WrapUnique(new BorderShadowLayerDelegate( 193 base::WrapUnique(new BorderShadowLayerDelegate(
194 shadows, GetLocalBounds(), kInkDropSmallCornerRadius)))); 194 shadows, GetLocalBounds(), kInkDropSmallCornerRadius))));
195 } 195 }
196 196
197 bool MdTextButton::ShouldShowInkDropForFocus() const { 197 bool MdTextButton::ShouldShowInkDropForFocus() const {
198 // These types of button use |focus_ring_|. 198 // These types of button use |focus_ring_|.
199 return false; 199 return false;
200 } 200 }
201 201
202 void MdTextButton::SetEnabledTextColors(SkColor color) { 202 void MdTextButton::SetEnabledTextColors(SkColor color) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color)) 271 SkColor stroke_color = (is_cta_ || color_utils::IsDark(text_color))
272 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity) 272 ? SkColorSetA(SK_ColorBLACK, kStrokeOpacity)
273 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity); 273 : SkColorSetA(SK_ColorWHITE, 2 * kStrokeOpacity);
274 274
275 set_background(Background::CreateBackgroundPainter( 275 set_background(Background::CreateBackgroundPainter(
276 true, Painter::CreateRoundRectWith1PxBorderPainter( 276 true, Painter::CreateRoundRectWith1PxBorderPainter(
277 bg_color, stroke_color, kInkDropSmallCornerRadius))); 277 bg_color, stroke_color, kInkDropSmallCornerRadius)));
278 } 278 }
279 279
280 } // namespace views 280 } // namespace views
OLDNEW
« ui/views/animation/ink_drop_highlight.h ('K') | « ui/views/controls/button/label_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698