| 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" |
| 11 #include "ui/gfx/geometry/point.h" | 11 #include "ui/gfx/geometry/point.h" |
| 12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 13 #include "ui/views/animation/ink_drop.h" | 13 #include "ui/views/animation/ink_drop.h" |
| 14 #include "ui/views/animation/ink_drop_host.h" | 14 #include "ui/views/animation/ink_drop_host.h" |
| 15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 class InkDropImpl; | 18 class InkDropImpl; |
| 19 class InkDropMask; |
| 19 | 20 |
| 20 namespace test { | 21 namespace test { |
| 21 class InkDropHostViewTestApi; | 22 class InkDropHostViewTestApi; |
| 22 } // namespace test | 23 } // namespace test |
| 23 | 24 |
| 24 // A view that provides InkDropHost functionality. | 25 // A view that provides InkDropHost functionality. |
| 25 class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost { | 26 class VIEWS_EXPORT InkDropHostView : public View, public InkDropHost { |
| 26 public: | 27 public: |
| 27 // Used in SetInkDropMode() to specify whether the ink drop effect is enabled | 28 // Used in SetInkDropMode() to specify whether the ink drop effect is enabled |
| 28 // or not for the view. In case of having an ink drop, it also specifies | 29 // or not for the view. In case of having an ink drop, it also specifies |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the | 81 // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the |
| 81 // last_ripple_triggering_event(). | 82 // last_ripple_triggering_event(). |
| 82 // | 83 // |
| 83 // *** NOTE ***: |event| has been plumbed through on a best effort basis for | 84 // *** NOTE ***: |event| has been plumbed through on a best effort basis for |
| 84 // the purposes of centering ink drop ripples on located Events. Thus nullptr | 85 // the purposes of centering ink drop ripples on located Events. Thus nullptr |
| 85 // has been used by clients who do not have an Event instance available to | 86 // has been used by clients who do not have an Event instance available to |
| 86 // them. | 87 // them. |
| 87 void AnimateInkDrop(InkDropState state, const ui::LocatedEvent* event); | 88 void AnimateInkDrop(InkDropState state, const ui::LocatedEvent* event); |
| 88 | 89 |
| 89 // View: | 90 // View: |
| 91 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 90 void VisibilityChanged(View* starting_from, bool is_visible) override; | 92 void VisibilityChanged(View* starting_from, bool is_visible) override; |
| 91 void OnFocus() override; | 93 void OnFocus() override; |
| 92 void OnBlur() override; | 94 void OnBlur() override; |
| 93 void OnMouseEvent(ui::MouseEvent* event) override; | 95 void OnMouseEvent(ui::MouseEvent* event) override; |
| 94 | 96 |
| 95 // Overrideable methods to allow views to provide minor tweaks to the default | 97 // Overrideable methods to allow views to provide minor tweaks to the default |
| 96 // ink drop. | 98 // ink drop. |
| 97 virtual SkColor GetInkDropBaseColor() const; | 99 virtual SkColor GetInkDropBaseColor() const; |
| 98 | 100 |
| 101 // Subclasses can override to return a mask for the ink drop. By default, |
| 102 // returns nullptr (i.e no mask). |
| 103 virtual std::unique_ptr<views::InkDropMask> CreateInkDropMask() const; |
| 104 |
| 99 // Provides access to |ink_drop_|. Implements lazy initialization of | 105 // Provides access to |ink_drop_|. Implements lazy initialization of |
| 100 // |ink_drop_| so as to avoid virtual method calls during construction since | 106 // |ink_drop_| so as to avoid virtual method calls during construction since |
| 101 // subclasses should be able to call SetInkDropMode() during construction. | 107 // subclasses should be able to call SetInkDropMode() during construction. |
| 102 InkDrop* GetInkDrop(); | 108 InkDrop* GetInkDrop(); |
| 103 | 109 |
| 104 // Returns an InkDropImpl configured to work well with a | 110 // Returns an InkDropImpl configured to work well with a |
| 105 // flood-fill ink drop ripple. | 111 // flood-fill ink drop ripple. |
| 106 std::unique_ptr<InkDropImpl> CreateDefaultFloodFillInkDropImpl(); | 112 std::unique_ptr<InkDropImpl> CreateDefaultFloodFillInkDropImpl(); |
| 107 | 113 |
| 108 // Returns an InkDropImpl with default configuration. The base implementation | 114 // Returns an InkDropImpl with default configuration. The base implementation |
| (...skipping 21 matching lines...) Expand all Loading... |
| 130 std::unique_ptr<InkDropGestureHandler> gesture_handler_; | 136 std::unique_ptr<InkDropGestureHandler> gesture_handler_; |
| 131 | 137 |
| 132 float ink_drop_visible_opacity_; | 138 float ink_drop_visible_opacity_; |
| 133 | 139 |
| 134 // Determines whether the view was already painting to layer before adding ink | 140 // Determines whether the view was already painting to layer before adding ink |
| 135 // drop layer. | 141 // drop layer. |
| 136 bool old_paint_to_layer_; | 142 bool old_paint_to_layer_; |
| 137 | 143 |
| 138 bool destroying_; | 144 bool destroying_; |
| 139 | 145 |
| 146 std::unique_ptr<views::InkDropMask> ink_drop_mask_; |
| 147 |
| 140 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); | 148 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); |
| 141 }; | 149 }; |
| 142 } // namespace views | 150 } // namespace views |
| 143 | 151 |
| 144 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ | 152 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ |
| OLD | NEW |