Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ | 5 #ifndef UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ |
| 6 #define UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ | 6 #define UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
| 14 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
| 15 #include "ui/compositor/layer_animator.h" | 15 #include "ui/compositor/layer_animator.h" |
| 16 #include "ui/gfx/animation/tween.h" | 16 #include "ui/gfx/animation/tween.h" |
| 17 #include "ui/gfx/geometry/insets.h" | |
| 17 #include "ui/gfx/geometry/point.h" | 18 #include "ui/gfx/geometry/point.h" |
| 18 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
| 19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
| 20 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" | 21 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" |
| 21 #include "ui/views/animation/ink_drop_ripple.h" | 22 #include "ui/views/animation/ink_drop_ripple.h" |
| 22 #include "ui/views/animation/ink_drop_state.h" | 23 #include "ui/views/animation/ink_drop_state.h" |
| 23 #include "ui/views/views_export.h" | 24 #include "ui/views/views_export.h" |
| 24 | 25 |
| 25 namespace ui { | 26 namespace ui { |
| 26 class Layer; | 27 class Layer; |
| 27 } // namespace ui | 28 } // namespace ui |
| 28 | 29 |
| 29 namespace views { | 30 namespace views { |
| 30 class CircleLayerDelegate; | 31 class CircleLayerDelegate; |
| 31 | 32 |
| 32 namespace test { | 33 namespace test { |
| 33 class FloodFillInkDropRippleTestApi; | 34 class FloodFillInkDropRippleTestApi; |
| 34 } // namespace test | 35 } // namespace test |
| 35 | 36 |
| 36 // An ink drop ripple that starts as a small circle and flood fills a | 37 // An ink drop ripple that starts as a small circle and flood fills a |
| 37 // rectangle of the given size. The circle is clipped to the rectangles bounds. | 38 // rectangle of the given size. The circle is clipped to the rectangles bounds. |
|
bruthig
2016/11/28 22:13:46
This doc should be updated. i.e. 'size' is very am
mohsen
2016/11/29 00:07:12
Done. Take a look...
bruthig
2016/11/29 01:37:48
looks good, thx
| |
| 38 // | 39 // |
| 39 // The valid InkDropState transitions are defined below: | 40 // The valid InkDropState transitions are defined below: |
| 40 // | 41 // |
| 41 // {All InkDropStates} => HIDDEN | 42 // {All InkDropStates} => HIDDEN |
| 42 // HIDDEN => ACTION_PENDING | 43 // HIDDEN => ACTION_PENDING |
| 43 // HIDDEN, ACTION_PENDING => ACTION_TRIGGERED | 44 // HIDDEN, ACTION_PENDING => ACTION_TRIGGERED |
| 44 // ACTION_PENDING => ALTERNATE_ACTION_PENDING | 45 // ACTION_PENDING => ALTERNATE_ACTION_PENDING |
| 45 // ALTERNATE_ACTION_PENDING => ALTERNATE_ACTION_TRIGGERED | 46 // ALTERNATE_ACTION_PENDING => ALTERNATE_ACTION_TRIGGERED |
| 46 // {All InkDropStates} => ACTIVATED | 47 // {All InkDropStates} => ACTIVATED |
| 47 // {All InkDropStates} => DEACTIVATED | 48 // {All InkDropStates} => DEACTIVATED |
| 48 // | 49 // |
| 49 class VIEWS_EXPORT FloodFillInkDropRipple : public InkDropRipple { | 50 class VIEWS_EXPORT FloodFillInkDropRipple : public InkDropRipple { |
| 50 public: | 51 public: |
| 51 FloodFillInkDropRipple(const gfx::Rect& clip_bounds, | 52 FloodFillInkDropRipple(const gfx::Size& host_size, |
| 53 const gfx::Insets& clip_insets, | |
| 52 const gfx::Point& center_point, | 54 const gfx::Point& center_point, |
| 53 SkColor color, | 55 SkColor color, |
| 54 float visible_opacity); | 56 float visible_opacity); |
| 55 ~FloodFillInkDropRipple() override; | 57 ~FloodFillInkDropRipple() override; |
| 56 | 58 |
| 57 // InkDropRipple: | 59 // InkDropRipple: |
| 60 void HostSizeChanged(const gfx::Size& new_size) override; | |
| 58 void SnapToActivated() override; | 61 void SnapToActivated() override; |
| 59 ui::Layer* GetRootLayer() override; | 62 ui::Layer* GetRootLayer() override; |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 friend class test::FloodFillInkDropRippleTestApi; | 65 friend class test::FloodFillInkDropRippleTestApi; |
| 63 | 66 |
| 64 // InkDropRipple: | 67 // InkDropRipple: |
| 65 void AnimateStateChange(InkDropState old_ink_drop_state, | 68 void AnimateStateChange(InkDropState old_ink_drop_state, |
| 66 InkDropState new_ink_drop_state, | 69 InkDropState new_ink_drop_state, |
| 67 ui::LayerAnimationObserver* observer) override; | 70 ui::LayerAnimationObserver* observer) override; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 98 // |target_radius|. | 101 // |target_radius|. |
| 99 gfx::Transform CalculateTransform(float target_radius) const; | 102 gfx::Transform CalculateTransform(float target_radius) const; |
| 100 | 103 |
| 101 // Returns the target Transform for when the ink drop is fully shown. | 104 // Returns the target Transform for when the ink drop is fully shown. |
| 102 gfx::Transform GetMaxSizeTargetTransform() const; | 105 gfx::Transform GetMaxSizeTargetTransform() const; |
| 103 | 106 |
| 104 // Returns the largest distance from |point| to the corners of the | 107 // Returns the largest distance from |point| to the corners of the |
| 105 // |root_layer_| bounds. | 108 // |root_layer_| bounds. |
| 106 float MaxDistanceToCorners(const gfx::Point& point) const; | 109 float MaxDistanceToCorners(const gfx::Point& point) const; |
| 107 | 110 |
| 111 // Insets of the clip area relative to the host bounds. | |
| 112 gfx::Insets clip_insets_; | |
| 113 | |
| 108 // The point where the Center of the ink drop's circle should be drawn. | 114 // The point where the Center of the ink drop's circle should be drawn. |
| 109 gfx::Point center_point_; | 115 gfx::Point center_point_; |
| 110 | 116 |
| 111 // Ink drop opacity when it is visible. | 117 // Ink drop opacity when it is visible. |
| 112 float visible_opacity_; | 118 float visible_opacity_; |
| 113 | 119 |
| 114 // The root layer that parents the animating layer. The root layer is used to | 120 // The root layer that parents the animating layer. The root layer is used to |
| 115 // manipulate opacity and clipping bounds, and it child is used to manipulate | 121 // manipulate opacity and clipping bounds, and it child is used to manipulate |
| 116 // the different shape of the ink drop. | 122 // the different shape of the ink drop. |
| 117 ui::Layer root_layer_; | 123 ui::Layer root_layer_; |
| 118 | 124 |
| 119 // ui::LayerDelegate to paint the |painted_layer_|. | 125 // ui::LayerDelegate to paint the |painted_layer_|. |
| 120 CircleLayerDelegate circle_layer_delegate_; | 126 CircleLayerDelegate circle_layer_delegate_; |
| 121 | 127 |
| 122 // Child ui::Layer of |root_layer_|. Used to manipulate the different size | 128 // Child ui::Layer of |root_layer_|. Used to manipulate the different size |
| 123 // and shape of the ink drop. | 129 // and shape of the ink drop. |
| 124 ui::Layer painted_layer_; | 130 ui::Layer painted_layer_; |
| 125 | 131 |
| 126 // The current ink drop state. | 132 // The current ink drop state. |
| 127 InkDropState ink_drop_state_; | 133 InkDropState ink_drop_state_; |
| 128 | 134 |
| 129 DISALLOW_COPY_AND_ASSIGN(FloodFillInkDropRipple); | 135 DISALLOW_COPY_AND_ASSIGN(FloodFillInkDropRipple); |
| 130 }; | 136 }; |
| 131 | 137 |
| 132 } // namespace views | 138 } // namespace views |
| 133 | 139 |
| 134 #endif // UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ | 140 #endif // UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ |
| OLD | NEW |