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 "ui/views/context_menu_controller.h" | 14 #include "ui/views/context_menu_controller.h" |
15 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
16 #include "ui/views/focus/focus_manager.h" | 16 #include "ui/views/focus/focus_manager.h" |
17 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
18 | 18 |
19 namespace views { | 19 namespace views { |
20 class BoundsAnimator; | 20 class BoundsAnimator; |
21 class ImageButton; | 21 class ImageButton; |
22 class MenuRunner; | 22 class MenuRunner; |
23 class ViewModel; | 23 class ViewModel; |
24 } | 24 } |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 | 27 |
| 28 namespace test { |
| 29 class LauncherViewTestAPI; |
| 30 } |
| 31 |
28 class LauncherDelegate; | 32 class LauncherDelegate; |
29 struct LauncherItem; | 33 struct LauncherItem; |
30 class LauncherModel; | 34 class LauncherModel; |
31 | 35 |
32 namespace internal { | 36 namespace internal { |
33 | 37 |
34 class LauncherButton; | 38 class LauncherButton; |
35 | 39 |
36 class ASH_EXPORT LauncherView : public views::View, | 40 class ASH_EXPORT LauncherView : public views::View, |
37 public LauncherModelObserver, | 41 public LauncherModelObserver, |
38 public views::ButtonListener, | 42 public views::ButtonListener, |
39 public LauncherButtonHost, | 43 public LauncherButtonHost, |
40 public views::ContextMenuController, | 44 public views::ContextMenuController, |
41 public views::FocusTraversable { | 45 public views::FocusTraversable { |
42 public: | 46 public: |
43 // Use the api in this class for testing only. | |
44 class ASH_EXPORT TestAPI { | |
45 public: | |
46 explicit TestAPI(LauncherView* launcher_view) | |
47 : launcher_view_(launcher_view) { | |
48 } | |
49 // Number of icons displayed. | |
50 int GetButtonCount(); | |
51 // Retrieve the button at |index|. | |
52 LauncherButton* GetButton(int index); | |
53 | |
54 private: | |
55 LauncherView* launcher_view_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(TestAPI); | |
58 }; | |
59 | |
60 LauncherView(LauncherModel* model, LauncherDelegate* delegate); | 47 LauncherView(LauncherModel* model, LauncherDelegate* delegate); |
61 virtual ~LauncherView(); | 48 virtual ~LauncherView(); |
62 | 49 |
63 void Init(); | 50 void Init(); |
64 | 51 |
65 // Returns the ideal bounds of the specified item, or an empty rect if id | 52 // Returns the ideal bounds of the specified item, or an empty rect if id |
66 // isn't know. | 53 // isn't know. |
67 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); | 54 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); |
68 | 55 |
69 // Returns true if we're showing a menu. | 56 // Returns true if we're showing a menu. |
70 bool IsShowingMenu() const; | 57 bool IsShowingMenu() const; |
71 | 58 |
72 // Overridden from FocusTraversable: | 59 // Overridden from FocusTraversable: |
73 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; | 60 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; |
74 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; | 61 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; |
75 virtual View* GetFocusTraversableParentView() OVERRIDE; | 62 virtual View* GetFocusTraversableParentView() OVERRIDE; |
76 | 63 |
77 private: | 64 private: |
| 65 friend class ash::test::LauncherViewTestAPI; |
| 66 |
78 class FadeOutAnimationDelegate; | 67 class FadeOutAnimationDelegate; |
79 class StartFadeAnimationDelegate; | 68 class StartFadeAnimationDelegate; |
80 | 69 |
81 struct IdealBounds { | 70 struct IdealBounds { |
82 gfx::Rect overflow_bounds; | 71 gfx::Rect overflow_bounds; |
83 }; | 72 }; |
84 | 73 |
85 // Sets the bounds of each view to its ideal bounds. | 74 // Sets the bounds of each view to its ideal bounds. |
86 void LayoutToIdealBounds(); | 75 void LayoutToIdealBounds(); |
87 | 76 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // The model; owned by Launcher. | 151 // The model; owned by Launcher. |
163 LauncherModel* model_; | 152 LauncherModel* model_; |
164 | 153 |
165 // Delegate; owned by Launcher. | 154 // Delegate; owned by Launcher. |
166 LauncherDelegate* delegate_; | 155 LauncherDelegate* delegate_; |
167 | 156 |
168 // Used to manage the set of active launcher buttons. There is a view per | 157 // Used to manage the set of active launcher buttons. There is a view per |
169 // item in |model_|. | 158 // item in |model_|. |
170 scoped_ptr<views::ViewModel> view_model_; | 159 scoped_ptr<views::ViewModel> view_model_; |
171 | 160 |
| 161 // Index of the last visible launcher button (does not go into overflow). |
| 162 int last_visible_index_; |
| 163 |
172 scoped_ptr<views::BoundsAnimator> bounds_animator_; | 164 scoped_ptr<views::BoundsAnimator> bounds_animator_; |
173 | 165 |
174 views::ImageButton* overflow_button_; | 166 views::ImageButton* overflow_button_; |
175 | 167 |
176 // Are we dragging? This is only set if the mouse is dragged far enough to | 168 // Are we dragging? This is only set if the mouse is dragged far enough to |
177 // trigger a drag. | 169 // trigger a drag. |
178 bool dragging_; | 170 bool dragging_; |
179 | 171 |
180 // The view being dragged. This is set immediately when the mouse is pressed. | 172 // 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. | 173 // |dragging_| is set only if the mouse is dragged far enough. |
(...skipping 16 matching lines...) Expand all Loading... |
198 scoped_ptr<views::MenuRunner> launcher_menu_runner_; | 190 scoped_ptr<views::MenuRunner> launcher_menu_runner_; |
199 #endif | 191 #endif |
200 | 192 |
201 DISALLOW_COPY_AND_ASSIGN(LauncherView); | 193 DISALLOW_COPY_AND_ASSIGN(LauncherView); |
202 }; | 194 }; |
203 | 195 |
204 } // namespace internal | 196 } // namespace internal |
205 } // namespace ash | 197 } // namespace ash |
206 | 198 |
207 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ | 199 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
OLD | NEW |