Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: ash/shelf/shelf.h

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shelf/overflow_button.cc ('k') | ash/shelf/shelf.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shelf/shelf_types.h" 10 #include "ash/shelf/shelf_types.h"
11 #include "ash/shelf/shelf_widget.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
14 #include "ui/views/widget/widget_observer.h" 15 #include "ui/views/widget/widget_observer.h"
15 16
16 namespace app_list { 17 namespace app_list {
17 class ApplicationDragAndDropHost; 18 class ApplicationDragAndDropHost;
18 } 19 }
19 20
20 namespace aura { 21 namespace aura {
21 class Window; 22 class Window;
22 } 23 }
23 24
24 namespace gfx { 25 namespace gfx {
25 class Rect; 26 class Rect;
26 } 27 }
27 28
28 namespace views { 29 namespace views {
29 class View; 30 class View;
30 } 31 }
31 32
32 namespace ash { 33 namespace ash {
33 class FocusCycler; 34 class FocusCycler;
34 class ShelfDelegate; 35 class ShelfDelegate;
35 class ShelfIconObserver; 36 class ShelfIconObserver;
36 class ShelfModel; 37 class ShelfModel;
37 class ShelfView; 38 class ShelfView;
38 class ShelfWidget;
39 39
40 namespace test { 40 namespace test {
41 class ShelfTestAPI; 41 class ShelfTestAPI;
42 } 42 }
43 43
44
45 class ASH_EXPORT Shelf { 44 class ASH_EXPORT Shelf {
46 public: 45 public:
47 static const char kNativeViewName[]; 46 static const char kNativeViewName[];
48 47
49 Shelf(ShelfModel* model, ShelfDelegate* delegate, ShelfWidget* widget); 48 Shelf(ShelfModel* model, ShelfDelegate* delegate, ShelfWidget* widget);
50 virtual ~Shelf(); 49 virtual ~Shelf();
51 50
52 // Return the shelf for the primary display. NULL if no user is logged in yet. 51 // Return the shelf for the primary display. NULL if no user is logged in yet.
53 static Shelf* ForPrimaryDisplay(); 52 static Shelf* ForPrimaryDisplay();
54 53
55 // Return the shelf for the display that |window| is currently on, or a shelf 54 // Return the shelf for the display that |window| is currently on, or a shelf
56 // on primary display if the shelf per display feature is disabled. NULL if 55 // on primary display if the shelf per display feature is disabled. NULL if no
57 // no user is logged in yet. 56 // user is logged in yet.
58 static Shelf* ForWindow(aura::Window* window); 57 static Shelf* ForWindow(const aura::Window* window);
59 58
60 void SetAlignment(ShelfAlignment alignment); 59 void SetAlignment(ShelfAlignment alignment);
61 ShelfAlignment alignment() const { return alignment_; } 60 ShelfAlignment alignment() const { return alignment_; }
61 bool IsHorizontalAlignment() const;
62
63 // A helper functions that chooses values specific to a shelf alignment.
64 template <typename T>
65 T SelectValueForShelfAlignment(T bottom, T left, T right, T top) const {
66 switch (alignment_) {
67 case SHELF_ALIGNMENT_BOTTOM:
68 return bottom;
69 case SHELF_ALIGNMENT_LEFT:
70 return left;
71 case SHELF_ALIGNMENT_RIGHT:
72 return right;
73 case SHELF_ALIGNMENT_TOP:
74 return top;
75 }
76 NOTREACHED();
77 return right;
78 }
79
80 // A helper functions that chooses values specific to a shelf alignment type.
81 template <typename T>
82 T PrimaryAxisValue(T horizontal, T vertical) const {
83 return IsHorizontalAlignment() ? horizontal : vertical;
84 }
62 85
63 // Returns the screen bounds of the item for the specified window. If there is 86 // Returns the screen bounds of the item for the specified window. If there is
64 // no item for the specified window an empty rect is returned. 87 // no item for the specified window an empty rect is returned.
65 gfx::Rect GetScreenBoundsOfItemIconForWindow(const aura::Window* window); 88 gfx::Rect GetScreenBoundsOfItemIconForWindow(const aura::Window* window);
66 89
67 // Updates the icon position given the current window bounds. This is used 90 // Updates the icon position given the current window bounds. This is used
68 // when dragging panels to reposition them with respect to the other panels. 91 // when dragging panels to reposition them with respect to the other panels.
69 void UpdateIconPositionForWindow(aura::Window* window); 92 void UpdateIconPositionForWindow(aura::Window* window);
70 93
71 // Activates the the shelf item specified by the index in the list of shelf 94 // Activates the the shelf item specified by the index in the list of shelf
(...skipping 17 matching lines...) Expand all
89 void SchedulePaint(); 112 void SchedulePaint();
90 113
91 views::View* GetAppListButtonView() const; 114 views::View* GetAppListButtonView() const;
92 115
93 // Launch a 0-indexed shelf item in the shelf. 116 // Launch a 0-indexed shelf item in the shelf.
94 // A negative index launches the last shelf item in the shelf. 117 // A negative index launches the last shelf item in the shelf.
95 void LaunchAppIndexAt(int item_index); 118 void LaunchAppIndexAt(int item_index);
96 119
97 ShelfWidget* shelf_widget() { return shelf_widget_; } 120 ShelfWidget* shelf_widget() { return shelf_widget_; }
98 121
122 // TODO(msw): ShelfLayoutManager should not be accessed externally.
123 ShelfLayoutManager* shelf_layout_manager() {
124 return shelf_widget_->shelf_layout_manager();
125 }
126
99 // Set the bounds of the shelf view. 127 // Set the bounds of the shelf view.
100 void SetShelfViewBounds(gfx::Rect bounds); 128 void SetShelfViewBounds(gfx::Rect bounds);
101 gfx::Rect GetShelfViewBounds() const; 129 gfx::Rect GetShelfViewBounds() const;
102 130
103 // Returns rectangle bounding all visible shelf items. Used screen coordinate 131 // Returns rectangle bounding all visible shelf items. Used screen coordinate
104 // system. 132 // system.
105 gfx::Rect GetVisibleItemsBoundsInScreen() const; 133 gfx::Rect GetVisibleItemsBoundsInScreen() const;
106 134
107 // Returns ApplicationDragAndDropHost for this shelf. 135 // Returns ApplicationDragAndDropHost for this shelf.
108 app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList(); 136 app_list::ApplicationDragAndDropHost* GetDragAndDropHostForAppList();
109 137
110 private: 138 private:
111 friend class test::ShelfTestAPI; 139 friend class test::ShelfTestAPI;
112 140
113 // ShelfView used to display icons. 141 // ShelfView used to display icons.
114 ShelfView* shelf_view_; 142 ShelfView* shelf_view_;
115 143
116 ShelfAlignment alignment_; 144 ShelfAlignment alignment_;
117 145
118 ShelfDelegate* delegate_; 146 ShelfDelegate* delegate_;
119 147
120 ShelfWidget* shelf_widget_; 148 ShelfWidget* shelf_widget_;
121 149
122 DISALLOW_COPY_AND_ASSIGN(Shelf); 150 DISALLOW_COPY_AND_ASSIGN(Shelf);
123 }; 151 };
124 152
125 } // namespace ash 153 } // namespace ash
126 154
127 #endif // ASH_SHELF_SHELF_H_ 155 #endif // ASH_SHELF_SHELF_H_
OLDNEW
« no previous file with comments | « ash/shelf/overflow_button.cc ('k') | ash/shelf/shelf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698