OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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_AURA_SHELL_APP_LIST_H_ | |
6 #define UI_AURA_SHELL_APP_LIST_H_ | |
7 #pragma once | |
8 | |
9 #include "base/basictypes.h" | |
10 #include "base/compiler_specific.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "ui/aura/event_filter.h" | |
13 #include "ui/gfx/compositor/layer_animation_observer.h" | |
14 #include "ui/views/widget/widget.h" | |
15 | |
16 namespace aura_shell { | |
17 namespace internal { | |
18 | |
19 // AppList is a controller that manages app list UI for shell. To show the UI, | |
20 // it requests app list widget from ShellDelegate and shows it when ready. | |
21 // While the UI is visible, it monitors things such as app list widget's | |
22 // activation state and desktop mouse click to auto dismiss the UI. | |
23 class AppList : public aura::EventFilter, | |
24 public ui::LayerAnimationObserver, | |
25 public views::Widget::Observer { | |
26 public: | |
27 AppList(); | |
28 virtual ~AppList(); | |
29 | |
30 // Show/hide app list window. | |
31 void SetVisible(bool visible); | |
32 | |
33 // Whether app list window is visible (shown or being shown). | |
34 bool IsVisible(); | |
35 | |
36 private: | |
37 // Sets app list widget. If we are in visible mode, start showing animation. | |
38 // Otherwise, we just close the widget. | |
39 void SetWidget(views::Widget* widget); | |
40 | |
41 // Forgets the widget. | |
42 void ResetWidget(); | |
43 | |
44 // Starts show/hide animation. | |
45 void ScheduleAnimation(); | |
46 | |
47 // aura::EventFilter overrides: | |
48 virtual bool PreHandleKeyEvent(aura::Window* target, | |
49 aura::KeyEvent* event) OVERRIDE; | |
50 virtual bool PreHandleMouseEvent(aura::Window* target, | |
51 aura::MouseEvent* event) OVERRIDE; | |
52 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | |
53 aura::TouchEvent* event) OVERRIDE; | |
54 | |
55 // ui::LayerAnimationObserver overrides: | |
56 virtual void OnLayerAnimationEnded( | |
57 const ui::LayerAnimationSequence* sequence) OVERRIDE; | |
58 virtual void OnLayerAnimationAborted( | |
59 const ui::LayerAnimationSequence* sequence) OVERRIDE; | |
60 virtual void OnLayerAnimationScheduled( | |
61 const ui::LayerAnimationSequence* sequence) OVERRIDE; | |
62 | |
63 // views::Widget::Observer overrides: | |
64 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | |
65 virtual void OnWidgetActivationChanged(views::Widget* widget, | |
66 bool active) OVERRIDE; | |
67 | |
68 // Whether we should show or hide app list widget. | |
69 bool is_visible_; | |
70 | |
71 // App list widget we get from ShellDelegate. | |
72 views::Widget* widget_; | |
73 | |
74 // A weak ptr factory for callbacks that ShellDelegate used to set widget. | |
75 base::WeakPtrFactory<AppList> set_widget_factory_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(AppList); | |
78 }; | |
79 | |
80 } // namespace internal | |
81 } // namespace aura_shell | |
82 | |
83 #endif // UI_AURA_SHELL_APP_LIST_H_ | |
OLD | NEW |