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 "base/observer_list.h" |
15 #include "ui/views/context_menu_controller.h" | 15 #include "ui/views/context_menu_controller.h" |
16 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
17 #include "ui/views/focus/focus_manager.h" | 17 #include "ui/views/focus/focus_manager.h" |
18 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 class BoundsAnimator; | 21 class BoundsAnimator; |
22 class ImageButton; | 22 class ImageButton; |
23 class MenuRunner; | 23 class MenuRunner; |
24 class ViewModel; | 24 class ViewModel; |
25 } | 25 } |
26 | 26 |
27 namespace ash { | 27 namespace ash { |
28 | 28 |
| 29 namespace test { |
| 30 class LauncherViewTestAPI; |
| 31 } |
| 32 |
29 class LauncherDelegate; | 33 class LauncherDelegate; |
30 struct LauncherItem; | 34 struct LauncherItem; |
31 class LauncherIconObserver; | 35 class LauncherIconObserver; |
32 class LauncherModel; | 36 class LauncherModel; |
33 | 37 |
34 namespace internal { | 38 namespace internal { |
35 | 39 |
36 class LauncherButton; | 40 class LauncherButton; |
37 | 41 |
38 class ASH_EXPORT LauncherView : public views::View, | 42 class ASH_EXPORT LauncherView : public views::View, |
39 public LauncherModelObserver, | 43 public LauncherModelObserver, |
40 public views::ButtonListener, | 44 public views::ButtonListener, |
41 public LauncherButtonHost, | 45 public LauncherButtonHost, |
42 public views::ContextMenuController, | 46 public views::ContextMenuController, |
43 public views::FocusTraversable { | 47 public views::FocusTraversable { |
44 public: | 48 public: |
45 // Use the api in this class for testing only. | |
46 class ASH_EXPORT TestAPI { | |
47 public: | |
48 explicit TestAPI(LauncherView* launcher_view) | |
49 : launcher_view_(launcher_view) { | |
50 } | |
51 // Number of icons displayed. | |
52 int GetButtonCount(); | |
53 // Retrieve the button at |index|. | |
54 LauncherButton* GetButton(int index); | |
55 | |
56 private: | |
57 LauncherView* launcher_view_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(TestAPI); | |
60 }; | |
61 | |
62 LauncherView(LauncherModel* model, LauncherDelegate* delegate); | 49 LauncherView(LauncherModel* model, LauncherDelegate* delegate); |
63 virtual ~LauncherView(); | 50 virtual ~LauncherView(); |
64 | 51 |
65 void Init(); | 52 void Init(); |
66 | 53 |
67 // Returns the ideal bounds of the specified item, or an empty rect if id | 54 // Returns the ideal bounds of the specified item, or an empty rect if id |
68 // isn't know. | 55 // isn't know. |
69 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); | 56 gfx::Rect GetIdealBoundsOfItemIcon(LauncherID id); |
70 | 57 |
71 void AddIconObserver(LauncherIconObserver* observer); | 58 void AddIconObserver(LauncherIconObserver* observer); |
72 void RemoveIconObserver(LauncherIconObserver* observer); | 59 void RemoveIconObserver(LauncherIconObserver* observer); |
73 | 60 |
74 // Returns true if we're showing a menu. | 61 // Returns true if we're showing a menu. |
75 bool IsShowingMenu() const; | 62 bool IsShowingMenu() const; |
76 | 63 |
77 // Overridden from FocusTraversable: | 64 // Overridden from FocusTraversable: |
78 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; | 65 virtual views::FocusSearch* GetFocusSearch() OVERRIDE; |
79 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; | 66 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; |
80 virtual View* GetFocusTraversableParentView() OVERRIDE; | 67 virtual View* GetFocusTraversableParentView() OVERRIDE; |
81 | 68 |
82 private: | 69 private: |
| 70 friend class ash::test::LauncherViewTestAPI; |
| 71 |
83 class FadeOutAnimationDelegate; | 72 class FadeOutAnimationDelegate; |
84 class StartFadeAnimationDelegate; | 73 class StartFadeAnimationDelegate; |
85 | 74 |
86 struct IdealBounds { | 75 struct IdealBounds { |
87 gfx::Rect overflow_bounds; | 76 gfx::Rect overflow_bounds; |
88 }; | 77 }; |
89 | 78 |
90 // Sets the bounds of each view to its ideal bounds. | 79 // Sets the bounds of each view to its ideal bounds. |
91 void LayoutToIdealBounds(); | 80 void LayoutToIdealBounds(); |
92 | 81 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 198 |
210 ObserverList<LauncherIconObserver> observers_; | 199 ObserverList<LauncherIconObserver> observers_; |
211 | 200 |
212 DISALLOW_COPY_AND_ASSIGN(LauncherView); | 201 DISALLOW_COPY_AND_ASSIGN(LauncherView); |
213 }; | 202 }; |
214 | 203 |
215 } // namespace internal | 204 } // namespace internal |
216 } // namespace ash | 205 } // namespace ash |
217 | 206 |
218 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ | 207 #endif // ASH_LAUNCHER_LAUNCHER_VIEW_H_ |
OLD | NEW |