OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_VIEW_STACK_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_VIEW_STACK_H_ | |
7 | |
8 #include "ui/views/view.h" | |
9 #include "ui/views/animation/bounds_animator.h" | |
10 #include "ui/views/animation/bounds_animator_observer.h" | |
11 | |
12 class ViewStackState; | |
13 | |
14 // This view represents a stack of views that slide in over one another from | |
15 // left to right. It manages the animation of views that are created by | |
16 // ViewStackState instances, as well as the lifetime of those ViewStackStates. | |
17 // To use this class, add it to a view hierarchy, subclass ViewStackState to | |
18 // create the views that can be pushed on the stack and call PushState/PopState | |
19 // to animate views in and out. | |
20 class ViewStack : public views::BoundsAnimatorObserver, | |
21 public views::View { | |
22 public: | |
23 explicit ViewStack(std::unique_ptr<ViewStackState> initial_state); | |
24 ~ViewStack() override; | |
25 | |
26 // Adds a state to the stack and starts animating it in from the right. | |
27 void PushState(std::unique_ptr<ViewStackState> state); | |
28 | |
29 // Removes a state from the stack, animates it out of view, and makes sure | |
30 // it's properly deleted after the animation. | |
31 void PopState(); | |
32 | |
33 // views::View: | |
34 // The children of this view must not be able to process events when the views | |
sky
2016/12/12 01:54:32
do you really want to disable all events when anim
anthonyvd
2016/12/12 17:01:56
I think we want all events disabled when animating
| |
35 // are being animated so this returns false when an animation is in progress. | |
36 bool CanProcessEventsWithinSubtree() const override; | |
37 | |
38 private: | |
39 FRIEND_TEST_ALL_PREFIXES( | |
40 ViewStackTest, TestPopStateRemovesChildViewAndCleansUpState); | |
41 | |
42 FRIEND_TEST_ALL_PREFIXES(ViewStackTest, TestDeletingViewCleansUpState); | |
43 | |
44 // Returns the top state of the stack, used in tests. | |
45 ViewStackState* top() { return state_stack_.top().get(); } | |
46 | |
47 // views::BoundsAnimatorObserver: | |
48 void OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) override {} | |
49 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override; | |
50 | |
51 std::stack<std::unique_ptr<ViewStackState>> state_stack_; | |
52 | |
53 std::unique_ptr<views::BoundsAnimator> slide_in_animator_; | |
54 std::unique_ptr<views::BoundsAnimator> slide_out_animator_; | |
55 | |
56 bool can_process_events_within_subtree_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(ViewStack); | |
59 }; | |
60 | |
61 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_VIEW_STACK_H_ | |
OLD | NEW |