| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "ui/views/animation/ink_drop_highlight.h" | 5 #include "ui/views/animation/ink_drop_highlight.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkColor.h" | 7 #include "third_party/skia/include/core/SkColor.h" |
| 8 #include "ui/compositor/callback_layer_animation_observer.h" | 8 #include "ui/compositor/callback_layer_animation_observer.h" |
| 9 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
| 10 #include "ui/compositor/layer_animation_sequence.h" | 10 #include "ui/compositor/layer_animation_sequence.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 return std::string("FADE_IN"); | 28 return std::string("FADE_IN"); |
| 29 case InkDropHighlight::FADE_OUT: | 29 case InkDropHighlight::FADE_OUT: |
| 30 return std::string("FADE_OUT"); | 30 return std::string("FADE_OUT"); |
| 31 } | 31 } |
| 32 NOTREACHED() | 32 NOTREACHED() |
| 33 << "Should never be reached but is necessary for some compilers."; | 33 << "Should never be reached but is necessary for some compilers."; |
| 34 return std::string("UNKNOWN"); | 34 return std::string("UNKNOWN"); |
| 35 } | 35 } |
| 36 | 36 |
| 37 InkDropHighlight::InkDropHighlight( | 37 InkDropHighlight::InkDropHighlight( |
| 38 const gfx::Point& center_point, | 38 const gfx::PointF& center_point, |
| 39 std::unique_ptr<BasePaintedLayerDelegate> layer_delegate) | 39 std::unique_ptr<BasePaintedLayerDelegate> layer_delegate) |
| 40 : center_point_(center_point), | 40 : center_point_(center_point), |
| 41 visible_opacity_(1.f), | 41 visible_opacity_(1.f), |
| 42 last_animation_initiated_was_fade_in_(false), | 42 last_animation_initiated_was_fade_in_(false), |
| 43 layer_delegate_(std::move(layer_delegate)), | 43 layer_delegate_(std::move(layer_delegate)), |
| 44 layer_(new ui::Layer()), | 44 layer_(new ui::Layer()), |
| 45 observer_(nullptr) { | 45 observer_(nullptr) { |
| 46 const gfx::Rect layer_bounds = layer_delegate_->GetPaintedBounds(); | 46 const gfx::Rect layer_bounds = layer_delegate_->GetPaintedBounds(); |
| 47 size_ = explode_size_ = layer_bounds.size(); | 47 size_ = explode_size_ = layer_bounds.size(); |
| 48 | 48 |
| 49 layer_->SetBounds(layer_bounds); | 49 layer_->SetBounds(layer_bounds); |
| 50 layer_->SetFillsBoundsOpaquely(false); | 50 layer_->SetFillsBoundsOpaquely(false); |
| 51 layer_->set_delegate(layer_delegate_.get()); | 51 layer_->set_delegate(layer_delegate_.get()); |
| 52 layer_->SetVisible(false); | 52 layer_->SetVisible(false); |
| 53 layer_->SetMasksToBounds(false); | 53 layer_->SetMasksToBounds(false); |
| 54 layer_->set_name("InkDropHighlight:layer"); | 54 layer_->set_name("InkDropHighlight:layer"); |
| 55 } | 55 } |
| 56 | 56 |
| 57 InkDropHighlight::InkDropHighlight(const gfx::Size& size, | 57 InkDropHighlight::InkDropHighlight(const gfx::Size& size, |
| 58 int corner_radius, | 58 int corner_radius, |
| 59 const gfx::Point& center_point, | 59 const gfx::PointF& center_point, |
| 60 SkColor color) | 60 SkColor color) |
| 61 : InkDropHighlight( | 61 : InkDropHighlight( |
| 62 center_point, | 62 center_point, |
| 63 std::unique_ptr<BasePaintedLayerDelegate>( | 63 std::unique_ptr<BasePaintedLayerDelegate>( |
| 64 new RoundedRectangleLayerDelegate(color, size, corner_radius))) { | 64 new RoundedRectangleLayerDelegate(color, size, corner_radius))) { |
| 65 visible_opacity_ = 0.128f; | 65 visible_opacity_ = 0.128f; |
| 66 layer_->SetOpacity(visible_opacity_); | 66 layer_->SetOpacity(visible_opacity_); |
| 67 } | 67 } |
| 68 | 68 |
| 69 InkDropHighlight::~InkDropHighlight() {} | 69 InkDropHighlight::~InkDropHighlight() {} |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (observer_) { | 159 if (observer_) { |
| 160 observer_->AnimationEnded(animation_type, | 160 observer_->AnimationEnded(animation_type, |
| 161 observer.aborted_count() | 161 observer.aborted_count() |
| 162 ? InkDropAnimationEndedReason::PRE_EMPTED | 162 ? InkDropAnimationEndedReason::PRE_EMPTED |
| 163 : InkDropAnimationEndedReason::SUCCESS); | 163 : InkDropAnimationEndedReason::SUCCESS); |
| 164 } | 164 } |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace views | 168 } // namespace views |
| OLD | NEW |