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

Side by Side Diff: ui/views/animation/ink_drop_host_view.cc

Issue 1890243002: Expand the Material Design hover as it fades out when a ripple is triggered. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed ink_drop_hover_unittest.cc compile error. Created 4 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/animation/ink_drop_host_view.h" 5 #include "ui/views/animation/ink_drop_host_view.h"
6 6
7 #include "ui/gfx/color_palette.h" 7 #include "ui/gfx/color_palette.h"
8 #include "ui/gfx/geometry/size_conversions.h"
8 #include "ui/views/animation/ink_drop_hover.h" 9 #include "ui/views/animation/ink_drop_hover.h"
9 #include "ui/views/animation/square_ink_drop_animation.h" 10 #include "ui/views/animation/square_ink_drop_animation.h"
10 11
11 namespace views { 12 namespace views {
12 13
14 namespace {
15
16 gfx::Size CalculateLargeInkDropSize(const gfx::Size small_size) {
17 return gfx::Size(small_size.width() * 4 / 3, small_size.height() * 4 / 3);
varkha 2016/04/21 16:16:49 nit: There's a ScaleToCeiledSize helper that you m
bruthig 2016/04/21 21:14:04 Done.
18 }
19
20 } // namespace
21
13 // Default sizes for ink drop effects. 22 // Default sizes for ink drop effects.
14 const int kInkDropSize = 24; 23 const int kInkDropSize = 24;
15 const int kInkDropLargeCornerRadius = 4; 24 const int kInkDropLargeCornerRadius = 4;
16 25
17 // static 26 // static
18 const int InkDropHostView::kInkDropSmallCornerRadius = 2; 27 const int InkDropHostView::kInkDropSmallCornerRadius = 2;
19 28
20 InkDropHostView::InkDropHostView() 29 InkDropHostView::InkDropHostView()
21 : ink_drop_size_(kInkDropSize, kInkDropSize) {} 30 : ink_drop_size_(kInkDropSize, kInkDropSize) {}
22 31
23 InkDropHostView::~InkDropHostView() {} 32 InkDropHostView::~InkDropHostView() {}
24 33
25 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) { 34 void InkDropHostView::AddInkDropLayer(ui::Layer* ink_drop_layer) {
26 SetPaintToLayer(true); 35 SetPaintToLayer(true);
27 layer()->SetFillsBoundsOpaquely(false); 36 layer()->SetFillsBoundsOpaquely(false);
28 layer()->Add(ink_drop_layer); 37 layer()->Add(ink_drop_layer);
29 layer()->StackAtBottom(ink_drop_layer); 38 layer()->StackAtBottom(ink_drop_layer);
30 } 39 }
31 40
32 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 41 void InkDropHostView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
33 layer()->Remove(ink_drop_layer); 42 layer()->Remove(ink_drop_layer);
34 SetPaintToLayer(false); 43 SetPaintToLayer(false);
35 } 44 }
36 45
37 std::unique_ptr<InkDropAnimation> InkDropHostView::CreateInkDropAnimation() 46 std::unique_ptr<InkDropAnimation> InkDropHostView::CreateInkDropAnimation()
38 const { 47 const {
39 gfx::Size large_drop(ink_drop_size_.width() * 4 / 3,
40 ink_drop_size_.height() * 4 / 3);
41
42 std::unique_ptr<InkDropAnimation> animation(new SquareInkDropAnimation( 48 std::unique_ptr<InkDropAnimation> animation(new SquareInkDropAnimation(
43 large_drop, kInkDropLargeCornerRadius, ink_drop_size_, 49 CalculateLargeInkDropSize(ink_drop_size_), kInkDropLargeCornerRadius,
44 kInkDropSmallCornerRadius, GetInkDropCenter(), GetInkDropBaseColor())); 50 ink_drop_size_, kInkDropSmallCornerRadius, GetInkDropCenter(),
51 GetInkDropBaseColor()));
45 return animation; 52 return animation;
46 } 53 }
47 54
48 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const { 55 std::unique_ptr<InkDropHover> InkDropHostView::CreateInkDropHover() const {
49 std::unique_ptr<InkDropHover> hover( 56 std::unique_ptr<InkDropHover> hover(
50 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius, 57 new InkDropHover(ink_drop_size_, kInkDropSmallCornerRadius,
51 GetInkDropCenter(), GetInkDropBaseColor())); 58 GetInkDropCenter(), GetInkDropBaseColor()));
59 hover->set_explode_size(
60 gfx::SizeF(CalculateLargeInkDropSize(ink_drop_size_)));
52 return hover; 61 return hover;
53 } 62 }
54 63
55 gfx::Point InkDropHostView::GetInkDropCenter() const { 64 gfx::Point InkDropHostView::GetInkDropCenter() const {
56 return GetLocalBounds().CenterPoint(); 65 return GetLocalBounds().CenterPoint();
57 } 66 }
58 67
59 SkColor InkDropHostView::GetInkDropBaseColor() const { 68 SkColor InkDropHostView::GetInkDropBaseColor() const {
60 NOTREACHED(); 69 NOTREACHED();
61 return gfx::kPlaceholderColor; 70 return gfx::kPlaceholderColor;
62 } 71 }
63 72
64 } // namespace views 73 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698