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 |
| 178 // (does not go into overflow). |
| 179 int last_visible_index_; |
| 180 |
172 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 181 scoped_ptr<views::BoundsAnimator> bounds_animator_; |
173 | 182 |
174 views::ImageButton* overflow_button_; | 183 views::ImageButton* overflow_button_; |
175 | 184 |
176 // Are we dragging? This is only set if the mouse is dragged far enough to | 185 // Are we dragging? This is only set if the mouse is dragged far enough to |
177 // trigger a drag. | 186 // trigger a drag. |
178 bool dragging_; | 187 bool dragging_; |
179 | 188 |
180 // The view being dragged. This is set immediately when the mouse is pressed. | 189 // 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. | 190 // |dragging_| is set only if the mouse is dragged far enough. |
182 views::View* drag_view_; | 191 views::View* drag_view_; |
183 | 192 |
184 // X coordinate of the mouse down event in |drag_view_|s coordinates. | 193 // X coordinate of the mouse down event in |drag_view_|s coordinates. |
185 int drag_offset_; | 194 int drag_offset_; |
186 | 195 |
187 // Index |drag_view_| was initially at. | 196 // Index |drag_view_| was initially at. |
188 int start_drag_index_; | 197 int start_drag_index_; |
189 | 198 |
190 // Used for the context menu of a particular item. | 199 // Used for the context menu of a particular item. |
191 LauncherID context_menu_id_; | 200 LauncherID context_menu_id_; |
192 | 201 |
193 scoped_ptr<views::FocusSearch> focus_search_; | 202 scoped_ptr<views::FocusSearch> focus_search_; |
194 | 203 |
195 #if !defined(OS_MACOSX) | 204 #if !defined(OS_MACOSX) |
196 scoped_ptr<views::MenuRunner> overflow_menu_runner_; | 205 scoped_ptr<views::MenuRunner> overflow_menu_runner_; |
197 | 206 |
198 scoped_ptr<views::MenuRunner> launcher_menu_runner_; | 207 scoped_ptr<views::MenuRunner> launcher_menu_runner_; |
199 #endif | 208 #endif |
200 | 209 |
| 210 ObserverList<LauncherIconObserver> observers_; |
| 211 |
201 DISALLOW_COPY_AND_ASSIGN(LauncherView); | 212 DISALLOW_COPY_AND_ASSIGN(LauncherView); |
202 }; | 213 }; |
203 | 214 |
204 } // namespace internal | 215 } // namespace internal |
205 } // namespace ash | 216 } // namespace ash |
206 | 217 |
207 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ | 218 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
OLD | NEW |