Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / ash / wm / app_list_controller.h
blob2226ba4072f4eab7400e367d0bbc5839aef4ee95
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.
5 #ifndef ASH_WM_APP_LIST_CONTROLLER_H_
6 #define ASH_WM_APP_LIST_CONTROLLER_H_
8 #include "ash/shelf/shelf_icon_observer.h"
9 #include "ash/shell_observer.h"
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "ui/app_list/pagination_model_observer.h"
13 #include "ui/aura/client/focus_change_observer.h"
14 #include "ui/aura/window_observer.h"
15 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/events/event_handler.h"
17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/keyboard/keyboard_controller_observer.h"
19 #include "ui/views/widget/widget_observer.h"
21 namespace app_list {
22 class ApplicationDragAndDropHost;
23 class AppListView;
26 namespace ui {
27 class LocatedEvent;
30 namespace ash {
31 namespace test {
32 class AppListControllerTestApi;
35 // AppListController is a controller that manages app list UI for shell.
36 // It creates AppListView and schedules showing/hiding animation.
37 // While the UI is visible, it monitors things such as app list widget's
38 // activation state and desktop mouse click to auto dismiss the UI.
39 class AppListController : public ui::EventHandler,
40 public aura::client::FocusChangeObserver,
41 public aura::WindowObserver,
42 public ui::ImplicitAnimationObserver,
43 public views::WidgetObserver,
44 public keyboard::KeyboardControllerObserver,
45 public ShellObserver,
46 public ShelfIconObserver,
47 public app_list::PaginationModelObserver {
48 public:
49 AppListController();
50 ~AppListController() override;
52 // Show/hide app list window. The |window| is used to deterime in
53 // which display (in which the |window| exists) the app list should
54 // be shown.
55 void Show(aura::Window* window);
56 void Dismiss();
58 // Whether app list window is visible (shown or being shown).
59 bool IsVisible() const;
61 // Returns target visibility. This differs from IsVisible() if an animation
62 // is ongoing.
63 bool GetTargetVisibility() const { return is_visible_; }
65 // Returns app list window or NULL if it is not visible.
66 aura::Window* GetWindow();
68 // Returns app list view or NULL if it is not visible.
69 app_list::AppListView* GetView() { return view_; }
71 private:
72 friend class test::AppListControllerTestApi;
74 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
75 // operations outside the application list.
76 void SetDragAndDropHostOfCurrentAppList(
77 app_list::ApplicationDragAndDropHost* drag_and_drop_host);
79 // Sets the app list view and attempts to show it.
80 void SetView(app_list::AppListView* view);
82 // Forgets the view.
83 void ResetView();
85 // Starts show/hide animation.
86 void ScheduleAnimation();
88 void ProcessLocatedEvent(ui::LocatedEvent* event);
90 // Makes app list bubble update its bounds.
91 void UpdateBounds();
93 // ui::EventHandler overrides:
94 void OnMouseEvent(ui::MouseEvent* event) override;
95 void OnGestureEvent(ui::GestureEvent* event) override;
97 // aura::client::FocusChangeObserver overrides:
98 void OnWindowFocused(aura::Window* gained_focus,
99 aura::Window* lost_focus) override;
101 // aura::WindowObserver overrides:
102 void OnWindowBoundsChanged(aura::Window* root,
103 const gfx::Rect& old_bounds,
104 const gfx::Rect& new_bounds) override;
106 // ui::ImplicitAnimationObserver overrides:
107 void OnImplicitAnimationsCompleted() override;
109 // views::WidgetObserver overrides:
110 void OnWidgetDestroying(views::Widget* widget) override;
112 // KeyboardControllerObserver overrides:
113 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
115 // ShellObserver overrides:
116 void OnShelfAlignmentChanged(aura::Window* root_window) override;
117 void OnMaximizeModeStarted() override;
118 void OnMaximizeModeEnded() override;
120 // ShelfIconObserver overrides:
121 void OnShelfIconPositionsChanged() override;
123 // app_list::PaginationModelObserver overrides:
124 void TotalPagesChanged() override;
125 void SelectedPageChanged(int old_selected, int new_selected) override;
126 void TransitionStarted() override;
127 void TransitionChanged() override;
129 // Whether we should show or hide app list widget.
130 bool is_visible_;
132 // Whether the app list should remain centered.
133 bool is_centered_;
135 // The AppListView this class manages, owned by its widget.
136 app_list::AppListView* view_;
138 // The current page of the AppsGridView of |view_|. This is stored outside of
139 // the view's PaginationModel, so that it persists when the view is destroyed.
140 int current_apps_page_;
142 // Cached bounds of |view_| for snapping back animation after over-scroll.
143 gfx::Rect view_bounds_;
145 // Whether should schedule snap back animation.
146 bool should_snap_back_;
148 DISALLOW_COPY_AND_ASSIGN(AppListController);
151 } // namespace ash
153 #endif // ASH_WM_APP_LIST_CONTROLLER_H_