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 ASH_WM_WORKSPACE_CONTROLLER_H_ | 5 #ifndef ASH_WM_WORKSPACE_CONTROLLER_H_ |
6 #define ASH_WM_WORKSPACE_CONTROLLER_H_ | 6 #define ASH_WM_WORKSPACE_CONTROLLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/launcher/launcher_model_observer.h" | 9 #include "ash/launcher/launcher_model_observer.h" |
10 #include "ash/wm/workspace/workspace_observer.h" | |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
13 #include "ui/aura/root_window_observer.h" | 12 #include "ui/aura/root_window_observer.h" |
14 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
15 #include "ash/ash_export.h" | 14 #include "ash/ash_export.h" |
16 | 15 |
17 namespace aura { | 16 namespace aura { |
18 class Window; | 17 class Window; |
19 } | 18 } |
20 | 19 |
21 namespace gfx { | 20 namespace gfx { |
22 class Size; | 21 class Size; |
23 } | 22 } |
24 | 23 |
25 namespace ash { | 24 namespace ash { |
26 class LauncherModel; | 25 class LauncherModel; |
27 | 26 |
28 namespace internal { | 27 namespace internal { |
29 | 28 |
30 class WorkspaceManager; | 29 class WorkspaceManager; |
31 | 30 |
32 // WorkspaceController owns a WorkspaceManager. WorkspaceController bridges | 31 // WorkspaceController owns a WorkspaceManager. WorkspaceController bridges |
33 // events from RootWindowObserver translating them to WorkspaceManager, and | 32 // events from RootWindowObserver translating them to WorkspaceManager, and |
34 // a move event between Launcher and Workspace. | 33 // a move event between Launcher and Workspace. |
35 class ASH_EXPORT WorkspaceController : | 34 class ASH_EXPORT WorkspaceController : |
36 public aura::RootWindowObserver, | 35 public aura::RootWindowObserver, |
37 public aura::WindowObserver, | 36 public aura::WindowObserver, |
38 public ash::internal::WorkspaceObserver, | |
39 public ash::LauncherModelObserver { | 37 public ash::LauncherModelObserver { |
40 public: | 38 public: |
41 explicit WorkspaceController(aura::Window* workspace_viewport); | 39 explicit WorkspaceController(aura::Window* workspace_viewport); |
42 virtual ~WorkspaceController(); | 40 virtual ~WorkspaceController(); |
43 | 41 |
44 void ToggleOverview(); | 42 void ToggleOverview(); |
45 | 43 |
46 void SetLauncherModel(LauncherModel* launcher_model); | 44 void SetLauncherModel(LauncherModel* launcher_model); |
47 | 45 |
48 // Returns the workspace manager that this controler owns. | 46 // Returns the workspace manager that this controler owns. |
49 WorkspaceManager* workspace_manager() { | 47 WorkspaceManager* workspace_manager() { |
50 return workspace_manager_.get(); | 48 return workspace_manager_.get(); |
51 } | 49 } |
52 | 50 |
53 // aura::RootWindowObserver overrides: | 51 // aura::RootWindowObserver overrides: |
54 virtual void OnRootWindowResized(const gfx::Size& new_size) OVERRIDE; | 52 virtual void OnRootWindowResized(const gfx::Size& new_size) OVERRIDE; |
55 | 53 |
56 // aura::WindowObserver overrides: | 54 // aura::WindowObserver overrides: |
57 virtual void OnWindowPropertyChanged(aura::Window* window, | 55 virtual void OnWindowPropertyChanged(aura::Window* window, |
58 const char* key, | 56 const char* key, |
59 void* old) OVERRIDE; | 57 void* old) OVERRIDE; |
60 | 58 |
61 // WorkspaceObserver overrides: | |
62 virtual void WindowMoved(WorkspaceManager* manager, | |
63 aura::Window* source, | |
64 aura::Window* target) OVERRIDE; | |
65 virtual void ActiveWorkspaceChanged(WorkspaceManager* manager, | |
66 Workspace* old) OVERRIDE; | |
67 | |
68 // Invoked after an item has been added to the model. | 59 // Invoked after an item has been added to the model. |
69 virtual void LauncherItemAdded(int index) OVERRIDE; | 60 virtual void LauncherItemAdded(int index) OVERRIDE; |
70 virtual void LauncherItemRemoved(int index) OVERRIDE; | 61 virtual void LauncherItemRemoved(int index) OVERRIDE; |
71 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; | 62 virtual void LauncherItemMoved(int start_index, int target_index) OVERRIDE; |
72 virtual void LauncherItemChanged(int index, | 63 virtual void LauncherItemChanged(int index, |
73 const ash::LauncherItem& old_item) OVERRIDE; | 64 const ash::LauncherItem& old_item) OVERRIDE; |
74 virtual void LauncherItemWillChange(int index) OVERRIDE {} | 65 virtual void LauncherItemWillChange(int index) OVERRIDE {} |
75 | 66 |
76 private: | 67 private: |
77 scoped_ptr<WorkspaceManager> workspace_manager_; | 68 scoped_ptr<WorkspaceManager> workspace_manager_; |
78 | 69 |
79 // Owned by Launcher. | 70 // Owned by Launcher. |
80 LauncherModel* launcher_model_; | 71 LauncherModel* launcher_model_; |
81 | 72 |
82 // True while the controller is moving window either on workspace or launcher. | 73 // True while the controller is moving window either on workspace or launcher. |
83 // Used to prevent infinite recursive call between the workspace and launcher. | 74 // Used to prevent infinite recursive call between the workspace and launcher. |
84 bool ignore_move_event_; | 75 bool ignore_move_event_; |
85 | 76 |
86 DISALLOW_COPY_AND_ASSIGN(WorkspaceController); | 77 DISALLOW_COPY_AND_ASSIGN(WorkspaceController); |
87 }; | 78 }; |
88 | 79 |
89 } // namespace internal | 80 } // namespace internal |
90 } // namespace ash | 81 } // namespace ash |
91 | 82 |
92 #endif // ASH_WM_WORKSPACE_CONTROLLER_H_ | 83 #endif // ASH_WM_WORKSPACE_CONTROLLER_H_ |
OLD | NEW |