| 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_ANIMATION_H_ | 5 #ifndef UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ |
| 6 #define UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_ANIMATION_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/point.h" | 17 #include "ui/gfx/geometry/point.h" |
| 18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 19 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 20 #include "ui/views/animation/ink_drop_animation.h" | |
| 21 #include "ui/views/animation/ink_drop_painted_layer_delegates.h" | 20 #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_state.h" | 22 #include "ui/views/animation/ink_drop_state.h" |
| 23 #include "ui/views/views_export.h" | 23 #include "ui/views/views_export.h" |
| 24 | 24 |
| 25 namespace ui { | 25 namespace ui { |
| 26 class Layer; | 26 class Layer; |
| 27 } // namespace ui | 27 } // namespace ui |
| 28 | 28 |
| 29 namespace views { | 29 namespace views { |
| 30 class CircleLayerDelegate; | 30 class CircleLayerDelegate; |
| 31 | 31 |
| 32 namespace test { | 32 namespace test { |
| 33 class FloodFillInkDropAnimationTestApi; | 33 class FloodFillInkDropRippleTestApi; |
| 34 } // namespace test | 34 } // namespace test |
| 35 | 35 |
| 36 // An ink drop animation that starts as a small circle and flood fills a | 36 // 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. | 37 // rectangle of the given size. The circle is clipped to the rectangles bounds. |
| 38 // | 38 // |
| 39 // The valid InkDropState transitions are defined below: | 39 // The valid InkDropState transitions are defined below: |
| 40 // | 40 // |
| 41 // {All InkDropStates} => HIDDEN | 41 // {All InkDropStates} => HIDDEN |
| 42 // HIDDEN => ACTION_PENDING | 42 // HIDDEN => ACTION_PENDING |
| 43 // HIDDEN, ACTION_PENDING => ACTION_TRIGGERED | 43 // HIDDEN, ACTION_PENDING => ACTION_TRIGGERED |
| 44 // ACTION_PENDING => ALTERNATE_ACTION_PENDING | 44 // ACTION_PENDING => ALTERNATE_ACTION_PENDING |
| 45 // ALTERNATE_ACTION_PENDING => ALTERNATE_ACTION_TRIGGERED | 45 // ALTERNATE_ACTION_PENDING => ALTERNATE_ACTION_TRIGGERED |
| 46 // {All InkDropStates} => ACTIVATED | 46 // {All InkDropStates} => ACTIVATED |
| 47 // {All InkDropStates} => DEACTIVATED | 47 // {All InkDropStates} => DEACTIVATED |
| 48 // | 48 // |
| 49 class VIEWS_EXPORT FloodFillInkDropAnimation : public InkDropAnimation { | 49 class VIEWS_EXPORT FloodFillInkDropRipple : public InkDropRipple { |
| 50 public: | 50 public: |
| 51 FloodFillInkDropAnimation(const gfx::Rect& clip_bounds, | 51 FloodFillInkDropRipple(const gfx::Rect& clip_bounds, |
| 52 const gfx::Point& center_point, | 52 const gfx::Point& center_point, |
| 53 SkColor color); | 53 SkColor color); |
| 54 ~FloodFillInkDropAnimation() override; | 54 ~FloodFillInkDropRipple() override; |
| 55 | 55 |
| 56 // InkDropAnimation: | 56 // InkDropRipple: |
| 57 void SnapToActivated() override; | 57 void SnapToActivated() override; |
| 58 ui::Layer* GetRootLayer() override; | 58 ui::Layer* GetRootLayer() override; |
| 59 bool IsVisible() const override; | 59 bool IsVisible() const override; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 friend class test::FloodFillInkDropAnimationTestApi; | 62 friend class test::FloodFillInkDropRippleTestApi; |
| 63 | 63 |
| 64 // InkDropAnimation: | 64 // InkDropRipple: |
| 65 void AnimateStateChange(InkDropState old_ink_drop_state, | 65 void AnimateStateChange(InkDropState old_ink_drop_state, |
| 66 InkDropState new_ink_drop_state, | 66 InkDropState new_ink_drop_state, |
| 67 ui::LayerAnimationObserver* observer) override; | 67 ui::LayerAnimationObserver* observer) override; |
| 68 void SetStateToHidden() override; | 68 void SetStateToHidden() override; |
| 69 void AbortAllAnimations() override; | 69 void AbortAllAnimations() override; |
| 70 | 70 |
| 71 // Animates the |painted_layer_| to the specified |transform|. The animation | 71 // Animates the |painted_layer_| to the specified |transform|. The animation |
| 72 // will be configured with the given |duration|, |tween|, and | 72 // will be configured with the given |duration|, |tween|, and |
| 73 // |preemption_strategy| values. The |observer| will be added to all | 73 // |preemption_strategy| values. The |observer| will be added to all |
| 74 // LayerAnimationSequences if not null. | 74 // LayerAnimationSequences if not null. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // ui::LayerDelegate to paint the |painted_layer_|. | 115 // ui::LayerDelegate to paint the |painted_layer_|. |
| 116 CircleLayerDelegate circle_layer_delegate_; | 116 CircleLayerDelegate circle_layer_delegate_; |
| 117 | 117 |
| 118 // Child ui::Layer of |root_layer_|. Used to manipulate the different size | 118 // Child ui::Layer of |root_layer_|. Used to manipulate the different size |
| 119 // and shape of the ink drop. | 119 // and shape of the ink drop. |
| 120 ui::Layer painted_layer_; | 120 ui::Layer painted_layer_; |
| 121 | 121 |
| 122 // The current ink drop state. | 122 // The current ink drop state. |
| 123 InkDropState ink_drop_state_; | 123 InkDropState ink_drop_state_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(FloodFillInkDropAnimation); | 125 DISALLOW_COPY_AND_ASSIGN(FloodFillInkDropRipple); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace views | 128 } // namespace views |
| 129 | 129 |
| 130 #endif // UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_ANIMATION_H_ | 130 #endif // UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ |
| OLD | NEW |