1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_APP_LIST_CONTROLLER_H_
#define ASH_WM_APP_LIST_CONTROLLER_H_
#include "ash/launcher/launcher_icon_observer.h"
#include "ash/shell_observer.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/observer_list.h"
#include "base/timer.h"
#include "ui/app_list/pagination_model_observer.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/root_window_observer.h"
#include "ui/base/events/event_handler.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/gfx/rect.h"
#include "ui/views/widget/widget_observer.h"
namespace app_list {
class AppListView;
class PaginationModel;
}
namespace ui {
class LocatedEvent;
}
namespace ash {
class Shell;
namespace internal {
class AppListControllerObserver;
// AppListController is a controller that manages app list UI for shell.
// It creates AppListView and schedules showing/hiding animation.
// While the UI is visible, it monitors things such as app list widget's
// activation state and desktop mouse click to auto dismiss the UI.
class AppListController : public ui::EventHandler,
public aura::client::FocusChangeObserver,
public aura::RootWindowObserver,
public ui::ImplicitAnimationObserver,
public views::WidgetObserver,
public ShellObserver,
public LauncherIconObserver,
public app_list::PaginationModelObserver {
public:
explicit AppListController(Shell* shell);
virtual ~AppListController();
// Closes opened app list and cleans up its dependency on shell.
void Shutdown();
// Show/hide app list window. The |window| is used to deterime in
// which display (in which the |window| exists) the app list should
// be shown.
void SetVisible(bool visible, aura::Window* window);
// Whether app list window is visible (shown or being shown).
bool IsVisible() const;
// Convenience wrapper to toggle visibility using the SetVisible() and
// IsVisible().
void Toggle(aura::Window* window);
// Returns target visibility. This differs from IsVisible() if an animation
// is ongoing.
bool GetTargetVisibility() const { return is_visible_; }
// Returns app list window or NULL if it is not visible.
aura::Window* GetWindow();
void AddObserver(AppListControllerObserver* observer);
void RemoveObserver(AppListControllerObserver* observer);
private:
// Sets the app list view and attempts to show it.
void SetView(app_list::AppListView* view);
// Forgets the view.
void ResetView();
// Starts show/hide animation.
void ScheduleAnimation();
void ProcessLocatedEvent(ui::LocatedEvent* event);
// Makes app list bubble update its bounds.
void UpdateBounds();
// ui::EventHandler overrides:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
// aura::client::FocusChangeObserver overrides:
virtual void OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) OVERRIDE;
// aura::RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) OVERRIDE;
// ui::ImplicitAnimationObserver overrides:
virtual void OnImplicitAnimationsCompleted() OVERRIDE;
// views::WidgetObserver overrides:
virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
// ShellObserver overrides:
virtual void OnShelfAlignmentChanged(aura::RootWindow* root_window) OVERRIDE;
// LauncherIconObserver overrides:
virtual void OnLauncherIconPositionsChanged() OVERRIDE;
// app_list::PaginationModelObserver overrides:
virtual void TotalPagesChanged() OVERRIDE;
virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE;
virtual void TransitionChanged() OVERRIDE;
Shell* shell_;
scoped_ptr<app_list::PaginationModel> pagination_model_;
// Whether we should show or hide app list widget.
bool is_visible_;
// The AppListView this class manages, owned by its widget.
app_list::AppListView* view_;
// Cached bounds of |view_| for snapping back animation after over-scroll.
gfx::Rect view_bounds_;
// Whether should schedule snap back animation.
bool should_snap_back_;
ObserverList<AppListControllerObserver, true> observers_;
DISALLOW_COPY_AND_ASSIGN(AppListController);
};
} // namespace internal
} // namespace ash
#endif // ASH_WM_APP_LIST_CONTROLLER_H_
|