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 #include "chrome/browser/ui/views/payments/view_stack.h" | 5 #include "chrome/browser/ui/views/payments/view_stack.h" |
6 | 6 |
7 #include <memory> | |
8 #include <utility> | |
9 | |
7 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
8 #include "ui/views/layout/fill_layout.h" | 11 #include "ui/views/layout/fill_layout.h" |
12 #include "ui/views/widget/widget.h" | |
anthonyvd
2017/03/21 21:18:24
I don't think this include is required.
MAD
2017/03/22 20:15:42
Done.
| |
9 | 13 |
10 ViewStack::ViewStack() | 14 ViewStack::ViewStack() |
11 : slide_in_animator_(base::MakeUnique<views::BoundsAnimator>(this)), | 15 : slide_in_animator_(base::MakeUnique<views::BoundsAnimator>(this)), |
12 slide_out_animator_(base::MakeUnique<views::BoundsAnimator>(this)) { | 16 slide_out_animator_(base::MakeUnique<views::BoundsAnimator>(this)) { |
13 SetLayoutManager(new views::FillLayout()); | 17 SetLayoutManager(new views::FillLayout()); |
14 | 18 |
15 slide_out_animator_->AddObserver(this); | 19 slide_out_animator_->AddObserver(this); |
16 // Paint to a layer and Mask to Bounds, otherwise descendant views that paint | 20 // Paint to a layer and Mask to Bounds, otherwise descendant views that paint |
17 // to a layer themselves will still paint while they're being animated out and | 21 // to a layer themselves will still paint while they're being animated out and |
18 // are out of bounds of their parent. | 22 // are out of bounds of their parent. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 gfx::Rect out_new_destination = bounds(); | 78 gfx::Rect out_new_destination = bounds(); |
75 out_new_destination.set_origin(gfx::Point(width(), 0)); | 79 out_new_destination.set_origin(gfx::Point(width(), 0)); |
76 UpdateAnimatorBounds(slide_out_animator_.get(), out_new_destination); | 80 UpdateAnimatorBounds(slide_out_animator_.get(), out_new_destination); |
77 } | 81 } |
78 | 82 |
79 void ViewStack::UpdateAnimatorBounds( | 83 void ViewStack::UpdateAnimatorBounds( |
80 views::BoundsAnimator* animator, const gfx::Rect& target) { | 84 views::BoundsAnimator* animator, const gfx::Rect& target) { |
81 // If an animator is currently animating, figure out which views and update | 85 // If an animator is currently animating, figure out which views and update |
82 // their target bounds. | 86 // their target bounds. |
83 if (animator->IsAnimating()) { | 87 if (animator->IsAnimating()) { |
84 for (auto& view: stack_) { | 88 for (auto& view : stack_) { |
85 if (animator->IsAnimating(view.get())) { | 89 if (animator->IsAnimating(view.get())) { |
86 animator->SetTargetBounds(view.get(), target); | 90 animator->SetTargetBounds(view.get(), target); |
87 } | 91 } |
88 } | 92 } |
89 } | 93 } |
90 } | 94 } |
91 | 95 |
92 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 96 void ViewStack::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
93 // This should only be called from slide_out_animator_ when the views going | 97 // This should only be called from slide_out_animator_ when the views going |
94 // out are done animating. | 98 // out are done animating. |
95 DCHECK_EQ(animator, slide_out_animator_.get()); | 99 DCHECK_EQ(animator, slide_out_animator_.get()); |
96 | 100 |
97 stack_.pop_back(); | 101 stack_.pop_back(); |
98 DCHECK(!stack_.empty()) << "State stack should never be empty"; | 102 DCHECK(!stack_.empty()) << "State stack should never be empty"; |
99 } | 103 } |
OLD | NEW |