Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: chrome/browser/ui/views/payments/view_stack.h

Issue 2528503002: [WebPayments] Implement state transitions in desktop WebPayments dialog. (Closed)
Patch Set: Change the ViewStack interface to take std::unique_ptr<views::View> directly. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // This view represents a stack of views that slide in over one another from
13 // left to right. It manages the animation and lifetime of views that are
14 // pushed and popped on it. To use this class, add it to a view hierarchy, and
15 // call Push/Pop to animate views in and out.
16 class ViewStack : public views::BoundsAnimatorObserver,
17 public views::View {
18 public:
19 explicit ViewStack(std::unique_ptr<views::View> initial_view);
sky 2016/12/12 17:38:07 Can you make the constructor take no args and inst
anthonyvd 2016/12/12 18:47:57 Done, good point. To avoid the situation where the
20 ~ViewStack() override;
21
22 // Adds a view to the stack and starts animating it in from the right. This
23 // takes ownership of the view and calls set_owned_by_client() on it.
24 void Push(std::unique_ptr<views::View> state);
25
26 // Removes a view from the stack, animates it out of view, and makes sure
27 // it's properly deleted after the animation.
28 void Pop();
29
30 // views::View:
31 // The children of this view must not be able to process events when the views
32 // are being animated so this returns false when an animation is in progress.
33 bool CanProcessEventsWithinSubtree() const override;
34
35 private:
36 FRIEND_TEST_ALL_PREFIXES(
37 ViewStackTest, TestPopStateRemovesChildViewAndCleansUpState);
38
39 FRIEND_TEST_ALL_PREFIXES(ViewStackTest, TestDeletingViewCleansUpState);
40
41 // Returns the top state of the stack, used in tests.
42 views::View* top() { return stack_.top().get(); }
43
44 // views::BoundsAnimatorObserver:
45 void OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) override {}
46 void OnBoundsAnimatorDone(views::BoundsAnimator* animator) override;
47
48 std::stack<std::unique_ptr<views::View>> stack_;
49
50 std::unique_ptr<views::BoundsAnimator> slide_in_animator_;
51 std::unique_ptr<views::BoundsAnimator> slide_out_animator_;
52
53 bool can_process_events_within_subtree_;
sky 2016/12/12 17:38:08 Does the value of this always match that of whethe
anthonyvd 2016/12/12 18:47:57 It does, good catch! Done.
54
55 DISALLOW_COPY_AND_ASSIGN(ViewStack);
56 };
57
58 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_VIEW_STACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698