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_LAUNCHER_LAUNCHER_VIEW_H_ | 5 #ifndef ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
6 #define ASH_LAUNCHER_LAUNCHER_VIEW_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/launcher/launcher_button_host.h" | 12 #include "ash/launcher/launcher_button_host.h" |
13 #include "ash/launcher/launcher_model_observer.h" | 13 #include "ash/launcher/launcher_model_observer.h" |
14 #include "base/observer_list.h" | |
14 #include "ui/views/context_menu_controller.h" | 15 #include "ui/views/context_menu_controller.h" |
15 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
16 #include "ui/views/focus/focus_manager.h" | 17 #include "ui/views/focus/focus_manager.h" |
17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
18 | 19 |
19 namespace views { | 20 namespace views { |
20 class BoundsAnimator; | 21 class BoundsAnimator; |
21 class ImageButton; | 22 class ImageButton; |
22 class MenuRunner; | 23 class MenuRunner; |
23 class ViewModel; | 24 class ViewModel; |
24 } | 25 } |
25 | 26 |
26 namespace ash { | 27 namespace ash { |
27 | 28 |
28 class LauncherDelegate; | 29 class LauncherDelegate; |
29 struct LauncherItem; | 30 struct LauncherItem; |
31 class LauncherIconObserver; | |
30 class LauncherModel; | 32 class LauncherModel; |
31 | 33 |
32 namespace internal { | 34 namespace internal { |
33 | 35 |
34 class LauncherButton; | 36 class LauncherButton; |
35 | 37 |
36 class ASH_EXPORT LauncherView : public views::View, | 38 class ASH_EXPORT LauncherView : public views::View, |
37 public LauncherModelObserver, | 39 public LauncherModelObserver, |
38 public views::ButtonListener, | 40 public views::ButtonListener, |
39 public LauncherButtonHost, | 41 public LauncherButtonHost, |
(...skipping 19 matching lines...) Expand all Loading... | |
59 | 61 |
60 LauncherView(LauncherModel* model, LauncherDelegate* delegate); | 62 LauncherView(LauncherModel* model, LauncherDelegate* delegate); |
61 virtual ~LauncherView(); | 63 virtual ~LauncherView(); |
62 | 64 |
63 void Init(); | 65 void Init(); |
64 | 66 |
65 // Returns the ideal bounds of the specified item, or an empty rect if id | 67 // Returns the ideal bounds of the specified item, or an empty rect if id |
66 // isn't know. | 68 // isn't know. |
67 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); | 69 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); |
68 | 70 |
71 void AddIconObserver(LauncherIconObserver* observer); | |
72 void RemoveIconObserver(LauncherIconObserver* observer); | |
73 | |
69 // Returns true if we're showing a menu. | 74 // Returns true if we're showing a menu. |
70 bool IsShowingMenu() const; | 75 bool IsShowingMenu() const; |
71 | 76 |
72 // Overridden from FocusTraversable: | 77 // Overridden from FocusTraversable: |
73 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; | 78 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; |
74 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; | 79 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; |
75 virtual View* GetFocusTraversableParentView() OVERRIDE; | 80 virtual View* GetFocusTraversableParentView() OVERRIDE; |
76 | 81 |
77 private: | 82 private: |
78 class FadeOutAnimationDelegate; | 83 class FadeOutAnimationDelegate; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 // The model; owned by Launcher. | 167 // The model; owned by Launcher. |
163 LauncherModel* model_; | 168 LauncherModel* model_; |
164 | 169 |
165 // Delegate; owned by Launcher. | 170 // Delegate; owned by Launcher. |
166 LauncherDelegate* delegate_; | 171 LauncherDelegate* delegate_; |
167 | 172 |
168 // Used to manage the set of active launcher buttons. There is a view per | 173 // Used to manage the set of active launcher buttons. There is a view per |
169 // item in |model_|. | 174 // item in |model_|. |
170 scoped_ptr<views::ViewModel> view_model_; | 175 scoped_ptr<views::ViewModel> view_model_; |
171 | 176 |
177 // Last index of a launcher button that is visible (does not go into overflow) | |
sky
2012/04/11 15:47:49
nit: end with '.'.
| |
178 int last_visible_index_; | |
179 | |
172 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 180 scoped_ptr<views::BoundsAnimator> bounds_animator_; |
173 | 181 |
174 views::ImageButton* overflow_button_; | 182 views::ImageButton* overflow_button_; |
175 | 183 |
176 // Are we dragging? This is only set if the mouse is dragged far enough to | 184 // Are we dragging? This is only set if the mouse is dragged far enough to |
177 // trigger a drag. | 185 // trigger a drag. |
178 bool dragging_; | 186 bool dragging_; |
179 | 187 |
180 // The view being dragged. This is set immediately when the mouse is pressed. | 188 // The view being dragged. This is set immediately when the mouse is pressed. |
181 // |dragging_| is set only if the mouse is dragged far enough. | 189 // |dragging_| is set only if the mouse is dragged far enough. |
182 views::View* drag_view_; | 190 views::View* drag_view_; |
183 | 191 |
184 // X coordinate of the mouse down event in |drag_view_|s coordinates. | 192 // X coordinate of the mouse down event in |drag_view_|s coordinates. |
185 int drag_offset_; | 193 int drag_offset_; |
186 | 194 |
187 // Index |drag_view_| was initially at. | 195 // Index |drag_view_| was initially at. |
188 int start_drag_index_; | 196 int start_drag_index_; |
189 | 197 |
190 // Used for the context menu of a particular item. | 198 // Used for the context menu of a particular item. |
191 LauncherID context_menu_id_; | 199 LauncherID context_menu_id_; |
192 | 200 |
193 scoped_ptr<views::FocusSearch> focus_search_; | 201 scoped_ptr<views::FocusSearch> focus_search_; |
194 | 202 |
195 #if !defined(OS_MACOSX) | 203 #if !defined(OS_MACOSX) |
196 scoped_ptr<views::MenuRunner> overflow_menu_runner_; | 204 scoped_ptr<views::MenuRunner> overflow_menu_runner_; |
197 | 205 |
198 scoped_ptr<views::MenuRunner> launcher_menu_runner_; | 206 scoped_ptr<views::MenuRunner> launcher_menu_runner_; |
199 #endif | 207 #endif |
200 | 208 |
209 ObserverList<LauncherIconObserver> observers_; | |
210 | |
201 DISALLOW_COPY_AND_ASSIGN(LauncherView); | 211 DISALLOW_COPY_AND_ASSIGN(LauncherView); |
202 }; | 212 }; |
203 | 213 |
204 } // namespace internal | 214 } // namespace internal |
205 } // namespace ash | 215 } // namespace ash |
206 | 216 |
207 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ | 217 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
OLD | NEW |