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_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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 | 47 |
| 48 // Toggle to enable/disable an InkDrop on this View. Descendants can override | 48 // Toggle to enable/disable an InkDrop on this View. Descendants can override |
| 49 // CreateInkDropHighlight() and CreateInkDropRipple() to change the look/feel | 49 // CreateInkDropHighlight() and CreateInkDropRipple() to change the look/feel |
| 50 // of the InkDrop. | 50 // of the InkDrop. |
| 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 protected: | 56 protected: |
| 57 static const int kInkDropSmallCornerRadius; | 57 static constexpr int kInkDropSmallCornerRadius = 2; |
| 58 static const int kInkDropLargeCornerRadius; | 58 static constexpr int kInkDropLargeCornerRadius = 4; |
| 59 | |
| 60 // Size used for the default SquareInkDropRipple. | |
| 61 static constexpr int kInkDropSize = 24; | |
|
bruthig
2017/01/31 01:43:19
nit: Can you rename this to |kDefaultInkDropSize|?
Peter Kasting
2017/01/31 02:13:51
Good idea. Done.
| |
| 59 | 62 |
| 60 // Returns a large ink drop size based on the |small_size| that works well | 63 // Returns a large ink drop size based on the |small_size| that works well |
| 61 // with the SquareInkDropRipple animation durations. | 64 // with the SquareInkDropRipple animation durations. |
| 62 static gfx::Size CalculateLargeInkDropSize(const gfx::Size& small_size); | 65 static gfx::Size CalculateLargeInkDropSize(const gfx::Size& small_size); |
| 63 | 66 |
| 64 void set_ink_drop_visible_opacity(float visible_opacity) { | 67 void set_ink_drop_visible_opacity(float visible_opacity) { |
| 65 ink_drop_visible_opacity_ = visible_opacity; | 68 ink_drop_visible_opacity_ = visible_opacity; |
| 66 } | 69 } |
| 67 float ink_drop_visible_opacity() const { return ink_drop_visible_opacity_; } | 70 float ink_drop_visible_opacity() const { return ink_drop_visible_opacity_; } |
| 68 | 71 |
| 69 // Returns the default InkDropRipple centered on |center_point|. | 72 // Returns the default InkDropRipple centered on |center_point|. |
| 70 std::unique_ptr<InkDropRipple> CreateDefaultInkDropRipple( | 73 std::unique_ptr<InkDropRipple> CreateDefaultInkDropRipple( |
| 71 const gfx::Point& center_point) const; | 74 const gfx::Point& center_point, |
| 75 const gfx::Size& size = gfx::Size(kInkDropSize, kInkDropSize)) const; | |
| 72 | 76 |
| 73 // Returns the default InkDropHighlight centered on |center_point|. | 77 // Returns the default InkDropHighlight centered on |center_point|. |
| 74 std::unique_ptr<InkDropHighlight> CreateDefaultInkDropHighlight( | 78 std::unique_ptr<InkDropHighlight> CreateDefaultInkDropHighlight( |
| 75 const gfx::PointF& center_point) const; | 79 const gfx::PointF& center_point, |
| 80 const gfx::Size& size = gfx::Size(kInkDropSize, kInkDropSize)) const; | |
| 76 | 81 |
| 77 // Returns the point of the |last_ripple_triggering_event_| if it was a | 82 // Returns the point of the |last_ripple_triggering_event_| if it was a |
| 78 // LocatedEvent, otherwise the center point of the local bounds is returned. | 83 // LocatedEvent, otherwise the center point of the local bounds is returned. |
| 79 gfx::Point GetInkDropCenterBasedOnLastEvent() const; | 84 gfx::Point GetInkDropCenterBasedOnLastEvent() const; |
| 80 | 85 |
| 81 // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the | 86 // Animates |ink_drop_| to the desired |ink_drop_state|. Caches |event| as the |
| 82 // last_ripple_triggering_event(). | 87 // last_ripple_triggering_event(). |
| 83 // | 88 // |
| 84 // *** NOTE ***: |event| has been plumbed through on a best effort basis for | 89 // *** NOTE ***: |event| has been plumbed through on a best effort basis for |
| 85 // the purposes of centering ink drop ripples on located Events. Thus nullptr | 90 // the purposes of centering ink drop ripples on located Events. Thus nullptr |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 | 148 |
| 144 bool destroying_; | 149 bool destroying_; |
| 145 | 150 |
| 146 std::unique_ptr<views::InkDropMask> ink_drop_mask_; | 151 std::unique_ptr<views::InkDropMask> ink_drop_mask_; |
| 147 | 152 |
| 148 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); | 153 DISALLOW_COPY_AND_ASSIGN(InkDropHostView); |
| 149 }; | 154 }; |
| 150 } // namespace views | 155 } // namespace views |
| 151 | 156 |
| 152 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ | 157 #endif // UI_VIEWS_ANIMATION_INK_DROP_HOST_VIEW_H_ |
| OLD | NEW |