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 ASH_APP_LIST_APP_LIST_H_ | |
6 #define ASH_APP_LIST_APP_LIST_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/compiler_specific.h" | |
11 #include "base/timer.h" | |
12 #include "ui/aura/event_filter.h" | |
13 #include "ui/aura/root_window_observer.h" | |
14 #include "ui/compositor/layer_animation_observer.h" | |
15 #include "ui/views/widget/widget.h" | |
16 | |
17 namespace ash { | |
18 | |
19 class AppListView; | |
20 | |
21 namespace internal { | |
22 | |
23 // AppList is a controller that manages app list UI for shell. To show the UI, | |
24 // it requests app list widget from ShellDelegate and shows it when ready. | |
25 // While the UI is visible, it monitors things such as app list widget's | |
26 // activation state and desktop mouse click to auto dismiss the UI. | |
27 class AppList : public aura::EventFilter, | |
28 public aura::RootWindowObserver, | |
29 public ui::ImplicitAnimationObserver, | |
30 public views::Widget::Observer { | |
31 public: | |
32 AppList(); | |
33 virtual ~AppList(); | |
34 | |
35 // Returns true if AppListV2 is enabled. | |
36 static bool UseAppListV2(); | |
37 | |
38 // Show/hide app list window. | |
39 void SetVisible(bool visible); | |
40 | |
41 // Whether app list window is visible (shown or being shown). | |
42 bool IsVisible(); | |
43 | |
44 // Returns target visibility. This differs from IsVisible() if an animation | |
45 // is ongoing. | |
46 bool GetTargetVisibility() const { return is_visible_; } | |
47 | |
48 // Returns app list window or NULL if it is not visible. | |
49 aura::Window* GetWindow(); | |
50 | |
51 private: | |
52 // Sets app list view. If we are in visible mode, start showing animation. | |
53 // Otherwise, we just close it. | |
54 void SetView(AppListView* view); | |
55 | |
56 // Forgets the view. | |
57 void ResetView(); | |
58 | |
59 // Starts show/hide animation. ScheduleAnimation is the master who manages | |
60 // when to call sub animations. There are three sub animations: background | |
61 // dimming, browser windows scale/fade and app list scale/fade. The background | |
62 // dimming runs in parallel with the other two and spans the whole animation | |
63 // time. The rest sub animations run in two steps. On showing, the first step | |
64 // is browser windows scale-out and fade-out and the 2nd step is app list | |
65 // scale-in and fade-in. The 2nd step animation is started via a timer and | |
66 // there is is a little overlap between the two animations. Hiding animation | |
67 // is the reverse of the showing animation. | |
68 void ScheduleAnimation(); | |
69 | |
70 void ScheduleBrowserWindowsAnimationForContainer(aura::Window* container); | |
71 void ScheduleBrowserWindowsAnimation(); | |
72 void ScheduleDimmingAnimation(); | |
73 void ScheduleAppListAnimation(); | |
74 | |
75 // aura::EventFilter overrides: | |
76 virtual bool PreHandleKeyEvent(aura::Window* target, | |
77 aura::KeyEvent* event) OVERRIDE; | |
78 virtual bool PreHandleMouseEvent(aura::Window* target, | |
79 aura::MouseEvent* event) OVERRIDE; | |
80 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | |
81 aura::TouchEvent* event) OVERRIDE; | |
82 virtual ui::GestureStatus PreHandleGestureEvent( | |
83 aura::Window* target, | |
84 aura::GestureEvent* event) OVERRIDE; | |
85 | |
86 // aura::RootWindowObserver overrides: | |
87 virtual void OnRootWindowResized(const aura::RootWindow* root, | |
88 const gfx::Size& old_size) OVERRIDE; | |
89 virtual void OnWindowFocused(aura::Window* window) OVERRIDE; | |
90 | |
91 // ui::ImplicitAnimationObserver overrides: | |
92 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | |
93 | |
94 // views::Widget::Observer overrides: | |
95 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | |
96 | |
97 // Whether we should show or hide app list widget. | |
98 bool is_visible_; | |
99 | |
100 // The AppListView this class manages, owned by its widget. | |
101 AppListView* view_; | |
102 | |
103 // Timer to schedule the 2nd step animation, started when the first step | |
104 // animation is scheduled in ScheduleAnimation. | |
105 base::OneShotTimer<AppList> second_animation_timer_; | |
106 | |
107 DISALLOW_COPY_AND_ASSIGN(AppList); | |
108 }; | |
109 | |
110 } // namespace internal | |
111 } // namespace ash | |
112 | |
113 #endif // ASH_APP_LIST_APP_LIST_H_ | |
OLD | NEW |