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

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

Issue 2899253002: chromeos: Rename ash::WmShelf to Shelf (Closed)
Patch Set: rebase Created 3 years, 7 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/shelf_window_targeter.cc ('k') | ash/shelf/wm_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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ASH_SHELF_WM_SHELF_H_
6 #define ASH_SHELF_WM_SHELF_H_
7
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "ash/public/cpp/shelf_types.h"
12 #include "ash/shelf/shelf_layout_manager_observer.h"
13 #include "ash/shelf/shelf_locking_manager.h"
14 #include "base/observer_list.h"
15
16 namespace aura {
17 class Window;
18 }
19
20 namespace gfx {
21 class Rect;
22 }
23
24 namespace ui {
25 class GestureEvent;
26 }
27
28 namespace ash {
29
30 enum class AnimationChangeType;
31 class ShelfBezelEventHandler;
32 class ShelfLayoutManager;
33 class ShelfLayoutManagerTest;
34 class ShelfLockingManager;
35 class ShelfView;
36 class ShelfWidget;
37 class StatusAreaWidget;
38 class WmShelfObserver;
39 class WmWindow;
40
41 // Controller for the shelf state. One per display, because each display might
42 // have different shelf alignment, autohide, etc. Exists for the lifetime of the
43 // root window controller.
44 class ASH_EXPORT WmShelf : public ShelfLayoutManagerObserver {
45 public:
46 WmShelf();
47 ~WmShelf() override;
48
49 // Returns the shelf for the display that |window| is on. Note that the shelf
50 // widget may not exist, or the shelf may not be visible.
51 static WmShelf* ForWindow(aura::Window* window);
52
53 // Returns if shelf alignment options are enabled, and the user is able to
54 // adjust the alignment (eg. not allowed in guest and supervised user modes).
55 static bool CanChangeShelfAlignment();
56
57 void CreateShelfWidget(WmWindow* root);
58 void ShutdownShelfWidget();
59 void DestroyShelfWidget();
60
61 ShelfLayoutManager* shelf_layout_manager() const {
62 return shelf_layout_manager_;
63 }
64
65 ShelfWidget* shelf_widget() { return shelf_widget_.get(); }
66
67 // TODO(jamescook): Eliminate this method.
68 void NotifyShelfInitialized();
69
70 // Returns the window showing the shelf.
71 WmWindow* GetWindow();
72
73 ShelfAlignment alignment() const { return alignment_; }
74 // TODO(jamescook): Replace with alignment().
75 ShelfAlignment GetAlignment() const { return alignment_; }
76 void SetAlignment(ShelfAlignment alignment);
77
78 // Returns true if the shelf alignment is horizontal (i.e. at the bottom).
79 bool IsHorizontalAlignment() const;
80
81 // Returns a value based on shelf alignment.
82 int SelectValueForShelfAlignment(int bottom, int left, int right) const;
83
84 // Returns |horizontal| is shelf is horizontal, otherwise |vertical|.
85 int PrimaryAxisValue(int horizontal, int vertical) const;
86
87 ShelfAutoHideBehavior auto_hide_behavior() const {
88 return auto_hide_behavior_;
89 }
90 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior);
91
92 ShelfAutoHideState GetAutoHideState() const;
93
94 // Invoke when the auto-hide state may have changed (for example, when the
95 // system tray bubble opens it should force the shelf to be visible).
96 void UpdateAutoHideState();
97
98 ShelfBackgroundType GetBackgroundType() const;
99
100 void UpdateVisibilityState();
101
102 ShelfVisibilityState GetVisibilityState() const;
103
104 // Returns the ideal bounds of the shelf assuming it is visible.
105 gfx::Rect GetIdealBounds();
106
107 gfx::Rect GetUserWorkAreaBounds() const;
108
109 // Updates the icon position given the current window bounds. This is used
110 // when dragging panels to reposition them with respect to the other panels.
111 void UpdateIconPositionForPanel(WmWindow* window);
112
113 // Returns the screen bounds of the item for the specified window. If there is
114 // no item for the specified window an empty rect is returned.
115 gfx::Rect GetScreenBoundsOfItemIconForWindow(WmWindow* window);
116
117 // Launch a 0-indexed shelf item in the shelf. A negative index launches the
118 // last shelf item in the shelf.
119 static void LaunchShelfItem(int item_index);
120
121 // Activates the shelf item specified by the index in the list of shelf items.
122 static void ActivateShelfItem(int item_index);
123
124 // Handles a gesture |event| coming from a source outside the shelf widget
125 // (e.g. the status area widget). Allows support for behaviors like toggling
126 // auto-hide with a swipe, even if that gesture event hits another window.
127 // Returns true if the event was handled.
128 bool ProcessGestureEvent(const ui::GestureEvent& event);
129
130 void AddObserver(WmShelfObserver* observer);
131 void RemoveObserver(WmShelfObserver* observer);
132
133 void NotifyShelfIconPositionsChanged();
134 StatusAreaWidget* GetStatusAreaWidget() const;
135
136 void SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds);
137 ShelfLockingManager* GetShelfLockingManagerForTesting();
138 ShelfView* GetShelfViewForTesting();
139
140 protected:
141 // ShelfLayoutManagerObserver:
142 void WillDeleteShelfLayoutManager() override;
143 void WillChangeVisibilityState(ShelfVisibilityState new_state) override;
144 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override;
145 void OnBackgroundUpdated(ShelfBackgroundType background_type,
146 AnimationChangeType change_type) override;
147
148 private:
149 class AutoHideEventHandler;
150 friend class ShelfLayoutManagerTest;
151
152 // Layout manager for the shelf container window. Instances are constructed by
153 // ShelfWidget and lifetimes are managed by the container windows themselves.
154 ShelfLayoutManager* shelf_layout_manager_ = nullptr;
155
156 std::unique_ptr<ShelfWidget> shelf_widget_;
157
158 // These initial values hide the shelf until user preferences are available.
159 ShelfAlignment alignment_ = SHELF_ALIGNMENT_BOTTOM_LOCKED;
160 ShelfAutoHideBehavior auto_hide_behavior_ = SHELF_AUTO_HIDE_ALWAYS_HIDDEN;
161
162 // Sets shelf alignment to bottom during login and screen lock.
163 ShelfLockingManager shelf_locking_manager_;
164
165 base::ObserverList<WmShelfObserver> observers_;
166
167 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide.
168 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/631216
169 std::unique_ptr<AutoHideEventHandler> auto_hide_event_handler_;
170
171 // Forwards touch gestures on a bezel sensor to the shelf.
172 // TODO(mash): Facilitate simliar functionality in mash: crbug.com/636647
173 std::unique_ptr<ShelfBezelEventHandler> bezel_event_handler_;
174
175 DISALLOW_COPY_AND_ASSIGN(WmShelf);
176 };
177
178 } // namespace ash
179
180 #endif // ASH_SHELF_WM_SHELF_H_
OLDNEW
« no previous file with comments | « ash/shelf/shelf_window_targeter.cc ('k') | ash/shelf/wm_shelf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698