| 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 rectangle | 
|   37 // rectangle of the given size. The circle is clipped to the rectangles bounds. |   38 // of the size determined by |host_size| and |clip_insets| (if provided). The | 
 |   39 // circle is clipped to this rectangle's bounds. | 
 |   40 // Constructors take |host_size| and |clip_insets| and calculate the effective | 
 |   41 // bounds of the flood fill based on them. This way, the ripple's bounds are | 
 |   42 // defined relative to the host size and can be recalculated whenever the host | 
 |   43 // size is changed. | 
|   38 // |   44 // | 
|   39 // The valid InkDropState transitions are defined below: |   45 // The valid InkDropState transitions are defined below: | 
|   40 // |   46 // | 
|   41 //   {All InkDropStates}      => HIDDEN |   47 //   {All InkDropStates}      => HIDDEN | 
|   42 //   HIDDEN                   => ACTION_PENDING |   48 //   HIDDEN                   => ACTION_PENDING | 
|   43 //   HIDDEN, ACTION_PENDING   => ACTION_TRIGGERED |   49 //   HIDDEN, ACTION_PENDING   => ACTION_TRIGGERED | 
|   44 //   ACTION_PENDING           => ALTERNATE_ACTION_PENDING |   50 //   ACTION_PENDING           => ALTERNATE_ACTION_PENDING | 
|   45 //   ALTERNATE_ACTION_PENDING => ALTERNATE_ACTION_TRIGGERED |   51 //   ALTERNATE_ACTION_PENDING => ALTERNATE_ACTION_TRIGGERED | 
|   46 //   {All InkDropStates}      => ACTIVATED |   52 //   {All InkDropStates}      => ACTIVATED | 
|   47 //   {All InkDropStates}      => DEACTIVATED |   53 //   {All InkDropStates}      => DEACTIVATED | 
|   48 // |   54 // | 
|   49 class VIEWS_EXPORT FloodFillInkDropRipple : public InkDropRipple { |   55 class VIEWS_EXPORT FloodFillInkDropRipple : public InkDropRipple { | 
|   50  public: |   56  public: | 
|   51   FloodFillInkDropRipple(const gfx::Rect& clip_bounds, |   57   FloodFillInkDropRipple(const gfx::Size& host_size, | 
 |   58                          const gfx::Insets& clip_insets, | 
 |   59                          const gfx::Point& center_point, | 
 |   60                          SkColor color, | 
 |   61                          float visible_opacity); | 
 |   62   FloodFillInkDropRipple(const gfx::Size& host_size, | 
|   52                          const gfx::Point& center_point, |   63                          const gfx::Point& center_point, | 
|   53                          SkColor color, |   64                          SkColor color, | 
|   54                          float visible_opacity); |   65                          float visible_opacity); | 
|   55   ~FloodFillInkDropRipple() override; |   66   ~FloodFillInkDropRipple() override; | 
|   56  |   67  | 
|   57   // InkDropRipple: |   68   // InkDropRipple: | 
 |   69   void HostSizeChanged(const gfx::Size& new_size) override; | 
|   58   void SnapToActivated() override; |   70   void SnapToActivated() override; | 
|   59   ui::Layer* GetRootLayer() override; |   71   ui::Layer* GetRootLayer() override; | 
|   60  |   72  | 
|   61  private: |   73  private: | 
|   62   friend class test::FloodFillInkDropRippleTestApi; |   74   friend class test::FloodFillInkDropRippleTestApi; | 
|   63  |   75  | 
|   64   // InkDropRipple: |   76   // InkDropRipple: | 
|   65   void AnimateStateChange(InkDropState old_ink_drop_state, |   77   void AnimateStateChange(InkDropState old_ink_drop_state, | 
|   66                           InkDropState new_ink_drop_state, |   78                           InkDropState new_ink_drop_state, | 
|   67                           ui::LayerAnimationObserver* observer) override; |   79                           ui::LayerAnimationObserver* observer) override; | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|   98   // |target_radius|. |  110   // |target_radius|. | 
|   99   gfx::Transform CalculateTransform(float target_radius) const; |  111   gfx::Transform CalculateTransform(float target_radius) const; | 
|  100  |  112  | 
|  101   // Returns the target Transform for when the ink drop is fully shown. |  113   // Returns the target Transform for when the ink drop is fully shown. | 
|  102   gfx::Transform GetMaxSizeTargetTransform() const; |  114   gfx::Transform GetMaxSizeTargetTransform() const; | 
|  103  |  115  | 
|  104   // Returns the largest distance from |point| to the corners of the |  116   // Returns the largest distance from |point| to the corners of the | 
|  105   // |root_layer_| bounds. |  117   // |root_layer_| bounds. | 
|  106   float MaxDistanceToCorners(const gfx::Point& point) const; |  118   float MaxDistanceToCorners(const gfx::Point& point) const; | 
|  107  |  119  | 
 |  120   // Insets of the clip area relative to the host bounds. | 
 |  121   gfx::Insets clip_insets_; | 
 |  122  | 
|  108   // The point where the Center of the ink drop's circle should be drawn. |  123   // The point where the Center of the ink drop's circle should be drawn. | 
|  109   gfx::Point center_point_; |  124   gfx::Point center_point_; | 
|  110  |  125  | 
|  111   // Ink drop opacity when it is visible. |  126   // Ink drop opacity when it is visible. | 
|  112   float visible_opacity_; |  127   float visible_opacity_; | 
|  113  |  128  | 
|  114   // The root layer that parents the animating layer. The root layer is used to |  129   // 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 |  130   // manipulate opacity and clipping bounds, and it child is used to manipulate | 
|  116   // the different shape of the ink drop. |  131   // the different shape of the ink drop. | 
|  117   ui::Layer root_layer_; |  132   ui::Layer root_layer_; | 
|  118  |  133  | 
|  119   // ui::LayerDelegate to paint the |painted_layer_|. |  134   // ui::LayerDelegate to paint the |painted_layer_|. | 
|  120   CircleLayerDelegate circle_layer_delegate_; |  135   CircleLayerDelegate circle_layer_delegate_; | 
|  121  |  136  | 
|  122   // Child ui::Layer of |root_layer_|. Used to  manipulate the different size |  137   // Child ui::Layer of |root_layer_|. Used to  manipulate the different size | 
|  123   // and shape of the ink drop. |  138   // and shape of the ink drop. | 
|  124   ui::Layer painted_layer_; |  139   ui::Layer painted_layer_; | 
|  125  |  140  | 
|  126   // The current ink drop state. |  141   // The current ink drop state. | 
|  127   InkDropState ink_drop_state_; |  142   InkDropState ink_drop_state_; | 
|  128  |  143  | 
|  129   DISALLOW_COPY_AND_ASSIGN(FloodFillInkDropRipple); |  144   DISALLOW_COPY_AND_ASSIGN(FloodFillInkDropRipple); | 
|  130 }; |  145 }; | 
|  131  |  146  | 
|  132 }  // namespace views |  147 }  // namespace views | 
|  133  |  148  | 
|  134 #endif  // UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ |  149 #endif  // UI_VIEWS_ANIMATION_FLOOD_FILL_INK_DROP_RIPPLE_H_ | 
| OLD | NEW |