| 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_INK_DROP_HOST_VIEW_H_ | 5 #ifndef UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ |
| 6 #define UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ | 6 #define UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // | 51 // |
| 52 // TODO(bruthig): Add an easier mechanism than overriding functions to allow | 52 // TODO(bruthig): Add an easier mechanism than overriding functions to allow |
| 53 // subclasses/clients to specify the flavor of ink drop. | 53 // subclasses/clients to specify the flavor of ink drop. |
| 54 void SetInkDropMode(InkDropMode ink_drop_mode); | 54 void SetInkDropMode(InkDropMode ink_drop_mode); |
| 55 | 55 |
| 56 void set_ink_drop_visible_opacity(float visible_opacity) { | 56 void set_ink_drop_visible_opacity(float visible_opacity) { |
| 57 ink_drop_visible_opacity_ = visible_opacity; | 57 ink_drop_visible_opacity_ = visible_opacity; |
| 58 } | 58 } |
| 59 float ink_drop_visible_opacity() const { return ink_drop_visible_opacity_; } | 59 float ink_drop_visible_opacity() const { return ink_drop_visible_opacity_; } |
| 60 | 60 |
| 61 // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the |
| 62 // last_ripple_triggering_event(). |
| 63 // |
| 64 // *** NOTE ***: |event| has been plumbed through on a best effort basis for |
| 65 // the purposes of centering ink drop ripples on located Events. Thus nullptr |
| 66 // has been used by clients who do not have an Event instance available to |
| 67 // them. |
| 68 void AnimateInkDrop(InkDropState state, const ui::LocatedEvent* event); |
| 69 |
| 61 protected: | 70 protected: |
| 62 static constexpr int kInkDropSmallCornerRadius = 2; | 71 static constexpr int kInkDropSmallCornerRadius = 2; |
| 63 static constexpr int kInkDropLargeCornerRadius = 4; | 72 static constexpr int kInkDropLargeCornerRadius = 4; |
| 64 | 73 |
| 65 // Size used for the default SquareInkDropRipple. | 74 // Size used for the default SquareInkDropRipple. |
| 66 static constexpr int kDefaultInkDropSize = 24; | 75 static constexpr int kDefaultInkDropSize = 24; |
| 67 | 76 |
| 68 // Returns a large ink drop size based on the |small_size| that works well | 77 // Returns a large ink drop size based on the |small_size| that works well |
| 69 // with the SquareInkDropRipple animation durations. | 78 // with the SquareInkDropRipple animation durations. |
| 70 static gfx::Size CalculateLargeInkDropSize(const gfx::Size& small_size); | 79 static gfx::Size CalculateLargeInkDropSize(const gfx::Size& small_size); |
| 71 | 80 |
| 72 // Returns the default InkDropRipple centered on |center_point|. | 81 // Returns the default InkDropRipple centered on |center_point|. |
| 73 std::unique_ptr<InkDropRipple> CreateDefaultInkDropRipple( | 82 std::unique_ptr<InkDropRipple> CreateDefaultInkDropRipple( |
| 74 const gfx::Point& center_point, | 83 const gfx::Point& center_point) const; |
| 75 const gfx::Size& size = gfx::Size(kDefaultInkDropSize, | |
| 76 kDefaultInkDropSize)) const; | |
| 77 | 84 |
| 78 // Returns the default InkDropHighlight centered on |center_point|. | 85 // Returns the default InkDropHighlight centered on |center_point|. |
| 79 std::unique_ptr<InkDropHighlight> CreateDefaultInkDropHighlight( | 86 std::unique_ptr<InkDropHighlight> CreateDefaultInkDropHighlight( |
| 80 const gfx::PointF& center_point, | 87 const gfx::PointF& center_point) const; |
| 81 const gfx::Size& size = gfx::Size(kDefaultInkDropSize, | |
| 82 kDefaultInkDropSize)) const; | |
| 83 | 88 |
| 84 // Returns the point of the |last_ripple_triggering_event_| if it was a | 89 // Returns the point of the |last_ripple_triggering_event_| if it was a |
| 85 // LocatedEvent, otherwise the center point of the local bounds is returned. | 90 // LocatedEvent, otherwise the center point of the local bounds is returned. |
| 86 gfx::Point GetInkDropCenterBasedOnLastEvent() const; | 91 gfx::Point GetInkDropCenterBasedOnLastEvent() const; |
| 87 | 92 |
| 88 // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the | |
| 89 // last_ripple_triggering_event(). | |
| 90 // | |
| 91 // *** NOTE ***: |event| has been plumbed through on a best effort basis for | |
| 92 // the purposes of centering ink drop ripples on located Events. Thus nullptr | |
| 93 // has been used by clients who do not have an Event instance available to | |
| 94 // them. | |
| 95 void AnimateInkDrop(InkDropState state, const ui::LocatedEvent* event); | |
| 96 | |
| 97 // View: | 93 // View: |
| 98 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 94 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 99 void VisibilityChanged(View* starting_from, bool is_visible) override; | 95 void VisibilityChanged(View* starting_from, bool is_visible) override; |
| 100 void OnFocus() override; | 96 void OnFocus() override; |
| 101 void OnBlur() override; | 97 void OnBlur() override; |
| 102 void OnMouseEvent(ui::MouseEvent* event) override; | 98 void OnMouseEvent(ui::MouseEvent* event) override; |
| 103 | 99 |
| 104 // Overrideable methods to allow views to provide minor tweaks to the default | 100 // Overrideable methods to allow views to provide minor tweaks to the default |
| 105 // ink drop. | 101 // ink drop. |
| 106 virtual SkColor GetInkDropBaseColor() const; | 102 virtual SkColor GetInkDropBaseColor() const; |
| 107 | 103 |
| 108 // Subclasses can override to return a mask for the ink drop. By default, | 104 // Subclasses can override to return a mask for the ink drop. By default, |
| 109 // returns nullptr (i.e no mask). | 105 // returns nullptr (i.e no mask). |
| 110 virtual std::unique_ptr<views::InkDropMask> CreateInkDropMask() const; | 106 virtual std::unique_ptr<views::InkDropMask> CreateInkDropMask() const; |
| 111 | 107 |
| 112 // Provides access to |ink_drop_|. Implements lazy initialization of | 108 // Provides access to |ink_drop_|. Implements lazy initialization of |
| 113 // |ink_drop_| so as to avoid virtual method calls during construction since | 109 // |ink_drop_| so as to avoid virtual method calls during construction since |
| 114 // subclasses should be able to call SetInkDropMode() during construction. | 110 // subclasses should be able to call SetInkDropMode() during construction. |
| 115 InkDrop* GetInkDrop(); | 111 InkDrop* GetInkDrop(); |
| 116 | 112 |
| 117 // Returns an InkDropImpl configured to work well with a | 113 // Returns an InkDropImpl configured to work well with a |
| 118 // flood-fill ink drop ripple. | 114 // flood-fill ink drop ripple. |
| 119 std::unique_ptr<InkDropImpl> CreateDefaultFloodFillInkDropImpl(); | 115 std::unique_ptr<InkDropImpl> CreateDefaultFloodFillInkDropImpl(); |
| 120 | 116 |
| 121 // Returns an InkDropImpl with default configuration. The base implementation | 117 // Returns an InkDropImpl with default configuration. The base implementation |
| 122 // of CreateInkDrop() delegates to this function. | 118 // of CreateInkDrop() delegates to this function. |
| 123 std::unique_ptr<InkDropImpl> CreateDefaultInkDropImpl(); | 119 std::unique_ptr<InkDropImpl> CreateDefaultInkDropImpl(); |
| 124 | 120 |
| 121 gfx::Size GetInkDropSize() const; |
| 122 |
| 125 private: | 123 private: |
| 126 class InkDropGestureHandler; | 124 class InkDropGestureHandler; |
| 127 friend class InkDropGestureHandler; | 125 friend class InkDropGestureHandler; |
| 128 friend class test::InkDropHostViewTestApi; | 126 friend class test::InkDropHostViewTestApi; |
| 129 | 127 |
| 130 // The last user Event to trigger an ink drop ripple animation. | 128 // The last user Event to trigger an ink drop ripple animation. |
| 131 std::unique_ptr<ui::LocatedEvent> last_ripple_triggering_event_; | 129 std::unique_ptr<ui::LocatedEvent> last_ripple_triggering_event_; |
| 132 | 130 |
| 133 // Defines what type of |ink_drop_| to create. | 131 // Defines what type of |ink_drop_| to create. |
| 134 InkDropMode ink_drop_mode_; | 132 InkDropMode ink_drop_mode_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 148 | 146 |
| 149 bool destroying_; | 147 bool destroying_; |
| 150 | 148 |
| 151 std::unique_ptr<views::InkDropMask> ink_drop_mask_; | 149 std::unique_ptr<views::InkDropMask> ink_drop_mask_; |
| 152 | 150 |
| 153 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); | 151 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); |
| 154 }; | 152 }; |
| 155 } // namespace views | 153 } // namespace views |
| 156 | 154 |
| 157 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ | 155 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ |
| OLD | NEW |