OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SHELF_SHELF_H_ | 5 #ifndef ASH_SHELF_SHELF_H_ |
6 #define ASH_SHELF_SHELF_H_ | 6 #define ASH_SHELF_SHELF_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
9 #include "ash/shelf/shelf_constants.h" | 11 #include "ash/shelf/shelf_constants.h" |
10 #include "ash/shelf/shelf_locking_manager.h" | 12 #include "ash/shelf/shelf_locking_manager.h" |
11 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
12 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
15 #include "ui/views/widget/widget_observer.h" | 17 #include "ui/views/widget/widget_observer.h" |
16 | 18 |
17 namespace app_list { | 19 namespace app_list { |
(...skipping 12 matching lines...) Expand all Loading... |
30 class View; | 32 class View; |
31 } | 33 } |
32 | 34 |
33 namespace ash { | 35 namespace ash { |
34 class FocusCycler; | 36 class FocusCycler; |
35 class ShelfDelegate; | 37 class ShelfDelegate; |
36 class ShelfIconObserver; | 38 class ShelfIconObserver; |
37 class ShelfModel; | 39 class ShelfModel; |
38 class ShelfView; | 40 class ShelfView; |
39 | 41 |
| 42 namespace wm { |
| 43 class WmShelfAura; |
| 44 } |
| 45 |
40 namespace test { | 46 namespace test { |
41 class ShelfTestAPI; | 47 class ShelfTestAPI; |
42 } | 48 } |
43 | 49 |
44 class ASH_EXPORT Shelf { | 50 class ASH_EXPORT Shelf { |
45 public: | 51 public: |
46 static const char kNativeViewName[]; | 52 static const char kNativeViewName[]; |
47 | 53 |
48 Shelf(ShelfModel* model, ShelfDelegate* delegate, ShelfWidget* widget); | 54 Shelf(ShelfModel* model, ShelfDelegate* delegate, ShelfWidget* widget); |
49 virtual ~Shelf(); | 55 virtual ~Shelf(); |
50 | 56 |
51 // Return the shelf for the primary display. NULL if no user is logged in yet. | 57 // Return the shelf for the primary display. NULL if no user is logged in yet. |
52 static Shelf* ForPrimaryDisplay(); | 58 static Shelf* ForPrimaryDisplay(); |
53 | 59 |
54 // Return the shelf for the display that |window| is currently on, or a shelf | 60 // Return the shelf for the display that |window| is currently on, or a shelf |
55 // on primary display if the shelf per display feature is disabled. NULL if no | 61 // on primary display if the shelf per display feature is disabled. NULL if no |
56 // user is logged in yet. | 62 // user is logged in yet. |
57 static Shelf* ForWindow(const aura::Window* window); | 63 static Shelf* ForWindow(const aura::Window* window); |
58 | 64 |
59 void SetAlignment(ShelfAlignment alignment); | 65 void SetAlignment(wm::ShelfAlignment alignment); |
60 ShelfAlignment alignment() const { return alignment_; } | 66 wm::ShelfAlignment alignment() const { return alignment_; } |
61 bool IsHorizontalAlignment() const; | 67 bool IsHorizontalAlignment() const; |
62 | 68 |
63 // Sets the ShelfAutoHideBehavior. See enum description for details. | 69 // Sets the ShelfAutoHideBehavior. See enum description for details. |
64 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior); | 70 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior); |
65 ShelfAutoHideBehavior auto_hide_behavior() const { | 71 ShelfAutoHideBehavior auto_hide_behavior() const { |
66 return auto_hide_behavior_; | 72 return auto_hide_behavior_; |
67 } | 73 } |
68 | 74 |
69 // TODO(msw): Remove this accessor, kept temporarily to simplify changes. | 75 // TODO(msw): Remove this accessor, kept temporarily to simplify changes. |
70 ShelfAutoHideBehavior GetAutoHideBehavior() const; | 76 ShelfAutoHideBehavior GetAutoHideBehavior() const; |
71 | 77 |
72 // A helper functions that chooses values specific to a shelf alignment. | 78 // A helper functions that chooses values specific to a shelf alignment. |
73 template <typename T> | 79 template <typename T> |
74 T SelectValueForShelfAlignment(T bottom, T left, T right) const { | 80 T SelectValueForShelfAlignment(T bottom, T left, T right) const { |
75 switch (alignment_) { | 81 switch (alignment_) { |
76 case SHELF_ALIGNMENT_BOTTOM: | 82 case wm::SHELF_ALIGNMENT_BOTTOM: |
77 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 83 case wm::SHELF_ALIGNMENT_BOTTOM_LOCKED: |
78 return bottom; | 84 return bottom; |
79 case SHELF_ALIGNMENT_LEFT: | 85 case wm::SHELF_ALIGNMENT_LEFT: |
80 return left; | 86 return left; |
81 case SHELF_ALIGNMENT_RIGHT: | 87 case wm::SHELF_ALIGNMENT_RIGHT: |
82 return right; | 88 return right; |
83 } | 89 } |
84 NOTREACHED(); | 90 NOTREACHED(); |
85 return right; | 91 return right; |
86 } | 92 } |
87 | 93 |
88 // A helper functions that chooses values specific to a shelf alignment type. | 94 // A helper functions that chooses values specific to a shelf alignment type. |
89 template <typename T> | 95 template <typename T> |
90 T PrimaryAxisValue(T horizontal, T vertical) const { | 96 T PrimaryAxisValue(T horizontal, T vertical) const { |
91 return IsHorizontalAlignment() ? horizontal : vertical; | 97 return IsHorizontalAlignment() ? horizontal : vertical; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 return shelf_widget_->shelf_layout_manager(); | 138 return shelf_widget_->shelf_layout_manager(); |
133 } | 139 } |
134 | 140 |
135 // Returns rectangle bounding all visible shelf items. Used screen coordinate | 141 // Returns rectangle bounding all visible shelf items. Used screen coordinate |
136 // system. | 142 // system. |
137 gfx::Rect GetVisibleItemsBoundsInScreen() const; | 143 gfx::Rect GetVisibleItemsBoundsInScreen() const; |
138 | 144 |
139 // Returns ApplicationDragAndDropHost for this shelf. | 145 // Returns ApplicationDragAndDropHost for this shelf. |
140 app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList(); | 146 app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList(); |
141 | 147 |
| 148 wm::WmShelfAura* wm_shelf() { return wm_shelf_.get(); } |
| 149 |
142 private: | 150 private: |
143 friend class test::ShelfTestAPI; | 151 friend class test::ShelfTestAPI; |
144 | 152 |
| 153 std::unique_ptr<wm::WmShelfAura> wm_shelf_; |
145 ShelfDelegate* delegate_; | 154 ShelfDelegate* delegate_; |
146 ShelfWidget* shelf_widget_; | 155 ShelfWidget* shelf_widget_; |
147 ShelfView* shelf_view_; | 156 ShelfView* shelf_view_; |
148 ShelfLockingManager shelf_locking_manager_; | 157 ShelfLockingManager shelf_locking_manager_; |
149 | 158 |
150 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM; | 159 wm::ShelfAlignment alignment_ = wm::SHELF_ALIGNMENT_BOTTOM; |
151 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_BEHAVIOR_NEVER; | 160 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_BEHAVIOR_NEVER; |
152 | 161 |
153 DISALLOW_COPY_AND_ASSIGN(Shelf); | 162 DISALLOW_COPY_AND_ASSIGN(Shelf); |
154 }; | 163 }; |
155 | 164 |
156 } // namespace ash | 165 } // namespace ash |
157 | 166 |
158 #endif // ASH_SHELF_SHELF_H_ | 167 #endif // ASH_SHELF_SHELF_H_ |
OLD | NEW |