OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_SLIDE_OUT_CONTROLLER_H_ | |
6 #define UI_VIEWS_CONTROLS_SLIDE_OUT_CONTROLLER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "ui/compositor/layer_animation_observer.h" | |
10 #include "ui/events/scoped_target_handler.h" | |
11 #include "ui/views/view.h" | |
12 #include "ui/views/views_export.h" | |
13 | |
14 namespace views { | |
15 | |
16 // A View that can be closed by a slide-out touch gesture. | |
sky
2017/04/28 22:35:36
Please update description.
Evan Stade
2017/04/28 23:18:38
Done.
| |
17 class VIEWS_EXPORT SlideOutController : public ui::EventHandler, | |
sky
2017/04/28 22:35:36
I would prefer this code move to where it is used,
Evan Stade
2017/04/28 23:18:38
Done.
| |
18 public ui::ImplicitAnimationObserver { | |
19 public: | |
20 class Delegate { | |
21 public: | |
22 // Returns the layer to for slide operations. | |
sky
2017/04/28 22:35:36
'to for' -> 'for' ?
Evan Stade
2017/04/28 23:18:38
Done.
| |
23 virtual ui::Layer* GetSlideOutLayer() = 0; | |
24 | |
25 // Called when user intends to close the View by sliding it out. | |
26 virtual void OnSlideOut() = 0; | |
27 }; | |
28 | |
29 SlideOutController(ui::EventTarget* target, Delegate* delegate); | |
30 ~SlideOutController() override; | |
31 | |
32 void set_enabled(bool enabled) { enabled_ = enabled; } | |
33 bool enabled() { return enabled_; } | |
34 | |
35 // ui::EventHandler | |
36 void OnGestureEvent(ui::GestureEvent* event) override; | |
37 | |
38 // ui::ImplicitAnimationObserver | |
39 void OnImplicitAnimationsCompleted() override; | |
40 | |
41 private: | |
42 enum SlideDirection { | |
sky
2017/04/28 22:35:36
enum class?
Evan Stade
2017/04/28 23:18:38
removed this.
| |
43 SLIDE_LEFT, | |
44 SLIDE_RIGHT, | |
45 }; | |
46 | |
47 // Restores the transform and opacity of the view. | |
48 void RestoreVisualState(); | |
49 | |
50 // Slides the view out and closes it after the animation. | |
51 void SlideOutAndClose(SlideDirection direction); | |
52 | |
53 ui::ScopedTargetHandler target_handling_; | |
54 Delegate* delegate_; | |
55 | |
56 float gesture_amount_ = 0.f; | |
57 bool enabled_ = true; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(SlideOutController); | |
60 }; | |
61 | |
62 } // namespace views | |
63 | |
64 #endif // UI_VIEWS_CONTROLS_SLIDE_OUT_CONTROLLER_H_ | |
OLD | NEW |