OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UI_VIEWS_CONTROLS_SLIDE_OUT_VIEW_H_ | 5 #ifndef UI_VIEWS_CONTROLS_SLIDE_OUT_VIEW_H_ |
6 #define UI_VIEWS_CONTROLS_SLIDE_OUT_VIEW_H_ | 6 #define UI_VIEWS_CONTROLS_SLIDE_OUT_VIEW_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "ui/compositor/layer_animation_observer.h" | 9 #include "ui/compositor/layer_animation_observer.h" |
10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
11 #include "ui/views/views_export.h" | 11 #include "ui/views/views_export.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 // A View that can be closed by a slide-out touch gesture. | 15 // A View that can be closed by a slide-out touch gesture. |
16 class VIEWS_EXPORT SlideOutView : public views::View, | 16 class VIEWS_EXPORT SlideOutView : public views::View, |
17 public ui::ImplicitAnimationObserver { | 17 public ui::ImplicitAnimationObserver { |
18 public: | 18 public: |
19 static void DisableAnimationsForTesting(); | |
sky
2016/02/16 16:13:06
Constructor/destructor come before other functions
sadrul
2016/02/17 17:29:26
Can you move this into a *TestApi (see other simil
| |
20 | |
19 SlideOutView(); | 21 SlideOutView(); |
20 ~SlideOutView() override; | 22 ~SlideOutView() override; |
21 | 23 |
24 bool slide_out_enabled() { return slide_out_enabled_; } | |
25 | |
22 protected: | 26 protected: |
23 // Called when user intends to close the View by sliding it out. | 27 // Called when user intends to close the View by sliding it out. |
24 virtual void OnSlideOut() = 0; | 28 virtual void OnSlideOut() = 0; |
25 | 29 |
26 // Overridden from views::View. | 30 // Overridden from views::View. |
27 void OnGestureEvent(ui::GestureEvent* event) override; | 31 void OnGestureEvent(ui::GestureEvent* event) override; |
28 | 32 |
33 void set_slide_out_enabled(bool slide_out_enabled) { | |
34 slide_out_enabled_ = slide_out_enabled; | |
35 } | |
36 | |
29 private: | 37 private: |
30 enum SlideDirection { | 38 enum SlideDirection { |
31 SLIDE_LEFT, | 39 SLIDE_LEFT, |
32 SLIDE_RIGHT, | 40 SLIDE_RIGHT, |
33 }; | 41 }; |
34 | 42 |
43 static bool disable_animations_; | |
44 | |
35 // Restores the transform and opacity of the view. | 45 // Restores the transform and opacity of the view. |
36 void RestoreVisualState(); | 46 void RestoreVisualState(); |
37 | 47 |
38 // Slides the view out and closes it after the animation. | 48 // Slides the view out and closes it after the animation. |
39 void SlideOutAndClose(SlideDirection direction); | 49 void SlideOutAndClose(SlideDirection direction); |
40 | 50 |
41 // Overridden from ImplicitAnimationObserver. | 51 // Overridden from ImplicitAnimationObserver. |
42 void OnImplicitAnimationsCompleted() override; | 52 void OnImplicitAnimationsCompleted() override; |
43 | 53 |
44 float gesture_scroll_amount_; | 54 float gesture_amount_ = 0.f; |
55 bool slide_out_enabled_ = true; | |
sky
2016/02/16 16:13:06
is_slide_out_enabled_ (and rename functions to mat
yoshiki
2016/02/22 13:39:27
Done.
| |
45 | 56 |
46 DISALLOW_COPY_AND_ASSIGN(SlideOutView); | 57 DISALLOW_COPY_AND_ASSIGN(SlideOutView); |
47 }; | 58 }; |
48 | 59 |
49 } // namespace views | 60 } // namespace views |
50 | 61 |
51 #endif // UI_VIEWS_CONTROLS_SLIDE_OUT_VIEW_H_ | 62 #endif // UI_VIEWS_CONTROLS_SLIDE_OUT_VIEW_H_ |
OLD | NEW |