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

Side by Side Diff: ash/wm/shelf_layout_manager.h

Issue 11316323: Cleanup enums for shelf (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/gestures/shelf_gesture_handler.cc ('k') | ash/wm/shelf_layout_manager.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 (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_WM_SHELF_LAYOUT_MANAGER_H_ 5 #ifndef ASH_WM_SHELF_LAYOUT_MANAGER_H_
6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ 6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/launcher/launcher.h" 9 #include "ash/launcher/launcher.h"
10 #include "ash/shelf_types.h"
10 #include "ash/shell_observer.h" 11 #include "ash/shell_observer.h"
11 #include "ash/wm/shelf_types.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/timer.h" 16 #include "base/timer.h"
17 #include "ui/aura/layout_manager.h" 17 #include "ui/aura/layout_manager.h"
18 #include "ui/gfx/insets.h" 18 #include "ui/gfx/insets.h"
19 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
20 #include "ui/views/corewm/activation_change_shim.h" 20 #include "ui/views/corewm/activation_change_shim.h"
21 21
(...skipping 17 matching lines...) Expand all
39 // status widgets. The launcher is given the total available width and told the 39 // status widgets. The launcher is given the total available width and told the
40 // width of the status area. This allows the launcher to draw the background and 40 // width of the status area. This allows the launcher to draw the background and
41 // layout to the status area. 41 // layout to the status area.
42 // To respond to bounds changes in the status area StatusAreaLayoutManager works 42 // To respond to bounds changes in the status area StatusAreaLayoutManager works
43 // closely with ShelfLayoutManager. 43 // closely with ShelfLayoutManager.
44 class ASH_EXPORT ShelfLayoutManager : 44 class ASH_EXPORT ShelfLayoutManager :
45 public aura::LayoutManager, 45 public aura::LayoutManager,
46 public ash::ShellObserver, 46 public ash::ShellObserver,
47 public views::corewm::ActivationChangeShim { 47 public views::corewm::ActivationChangeShim {
48 public: 48 public:
49 enum VisibilityState {
50 // Completely visible.
51 VISIBLE,
52
53 // A couple of pixels are reserved at the bottom for the shelf.
54 AUTO_HIDE,
55
56 // Nothing is shown. Used for fullscreen windows.
57 HIDDEN,
58 };
59
60 enum AutoHideState {
61 AUTO_HIDE_SHOWN,
62 AUTO_HIDE_HIDDEN,
63 };
64
65 class ASH_EXPORT Observer { 49 class ASH_EXPORT Observer {
66 public: 50 public:
67 // Called when the target ShelfLayoutManager will be deleted. 51 // Called when the target ShelfLayoutManager will be deleted.
68 virtual void WillDeleteShelf() {} 52 virtual void WillDeleteShelf() {}
69 53
70 // Called when the visibility change is scheduled. 54 // Called when the visibility change is scheduled.
71 virtual void WillChangeVisibilityState(VisibilityState new_state) {} 55 virtual void WillChangeVisibilityState(ShelfVisibilityState new_state) {}
72 56
73 // Called when the auto hide state is changed. 57 // Called when the auto hide state is changed.
74 virtual void OnAutoHideStateChanged(AutoHideState new_state) {} 58 virtual void OnAutoHideStateChanged(ShelfAutoHideState new_state) {}
75 }; 59 };
76 60
77 // We reserve a small area at the bottom of the workspace area to ensure that 61 // We reserve a small area at the bottom of the workspace area to ensure that
78 // the bottom-of-window resize handle can be hit. 62 // the bottom-of-window resize handle can be hit.
79 static const int kWorkspaceAreaBottomInset; 63 static const int kWorkspaceAreaBottomInset;
80 64
81 // Size of the shelf when auto-hidden. 65 // Size of the shelf when auto-hidden.
82 static const int kAutoHideSize; 66 static const int kAutoHideSize;
83 67
84 explicit ShelfLayoutManager(StatusAreaWidget* status); 68 explicit ShelfLayoutManager(StatusAreaWidget* status);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Stops any animations and sets the bounds of the launcher and status 107 // Stops any animations and sets the bounds of the launcher and status
124 // widgets. 108 // widgets.
125 void LayoutShelf(); 109 void LayoutShelf();
126 110
127 // Updates the visibility state. 111 // Updates the visibility state.
128 void UpdateVisibilityState(); 112 void UpdateVisibilityState();
129 113
130 // Invoked by the shelf/launcher when the auto-hide state may have changed. 114 // Invoked by the shelf/launcher when the auto-hide state may have changed.
131 void UpdateAutoHideState(); 115 void UpdateAutoHideState();
132 116
133 VisibilityState visibility_state() const { return state_.visibility_state; } 117 ShelfVisibilityState visibility_state() const {
134 AutoHideState auto_hide_state() const { return state_.auto_hide_state; } 118 return state_.visibility_state;
119 }
120 ShelfAutoHideState auto_hide_state() const { return state_.auto_hide_state; }
135 121
136 // Sets whether any windows overlap the shelf. If a window overlaps the shelf 122 // Sets whether any windows overlap the shelf. If a window overlaps the shelf
137 // the shelf renders slightly differently. 123 // the shelf renders slightly differently.
138 void SetWindowOverlapsShelf(bool value); 124 void SetWindowOverlapsShelf(bool value);
139 bool window_overlaps_shelf() const { return window_overlaps_shelf_; } 125 bool window_overlaps_shelf() const { return window_overlaps_shelf_; }
140 126
141 void AddObserver(Observer* observer); 127 void AddObserver(Observer* observer);
142 void RemoveObserver(Observer* observer); 128 void RemoveObserver(Observer* observer);
143 129
144 // Gesture dragging related functions: 130 // Gesture dragging related functions:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 struct TargetBounds { 167 struct TargetBounds {
182 TargetBounds(); 168 TargetBounds();
183 169
184 float opacity; 170 float opacity;
185 gfx::Rect launcher_bounds_in_root; 171 gfx::Rect launcher_bounds_in_root;
186 gfx::Rect status_bounds_in_root; 172 gfx::Rect status_bounds_in_root;
187 gfx::Insets work_area_insets; 173 gfx::Insets work_area_insets;
188 }; 174 };
189 175
190 struct State { 176 struct State {
191 State() : visibility_state(VISIBLE), 177 State() : visibility_state(SHELF_VISIBLE),
192 auto_hide_state(AUTO_HIDE_HIDDEN), 178 auto_hide_state(SHELF_AUTO_HIDE_HIDDEN),
193 is_screen_locked(false) {} 179 is_screen_locked(false) {}
194 180
195 // Returns true if the two states are considered equal. As 181 // Returns true if the two states are considered equal. As
196 // |auto_hide_state| only matters if |visibility_state| is |AUTO_HIDE|, 182 // |auto_hide_state| only matters if |visibility_state| is
197 // Equals() ignores the |auto_hide_state| as appropriate. 183 // |SHELF_AUTO_HIDE|, Equals() ignores the |auto_hide_state| as
184 // appropriate.
198 bool Equals(const State& other) const { 185 bool Equals(const State& other) const {
199 return other.visibility_state == visibility_state && 186 return other.visibility_state == visibility_state &&
200 (visibility_state != AUTO_HIDE || 187 (visibility_state != SHELF_AUTO_HIDE ||
201 other.auto_hide_state == auto_hide_state) && 188 other.auto_hide_state == auto_hide_state) &&
202 other.is_screen_locked == is_screen_locked; 189 other.is_screen_locked == is_screen_locked;
203 } 190 }
204 191
205 VisibilityState visibility_state; 192 ShelfVisibilityState visibility_state;
206 AutoHideState auto_hide_state; 193 ShelfAutoHideState auto_hide_state;
207 bool is_screen_locked; 194 bool is_screen_locked;
208 }; 195 };
209 196
210 // Sets the visibility of the shelf to |state|. 197 // Sets the visibility of the shelf to |state|.
211 void SetState(VisibilityState visibility_state); 198 void SetState(ShelfVisibilityState visibility_state);
212 199
213 // Stops any animations. 200 // Stops any animations.
214 void StopAnimating(); 201 void StopAnimating();
215 202
216 // Returns the width (if aligned to the side) or height (if aligned to the 203 // Returns the width (if aligned to the side) or height (if aligned to the
217 // bottom). 204 // bottom).
218 void GetShelfSize(int* width, int* height); 205 void GetShelfSize(int* width, int* height);
219 206
220 // Insets |bounds| by |inset| on the edge the shelf is aligned to. 207 // Insets |bounds| by |inset| on the edge the shelf is aligned to.
221 void AdjustBoundsBasedOnAlignment(int inset, gfx::Rect* bounds) const; 208 void AdjustBoundsBasedOnAlignment(int inset, gfx::Rect* bounds) const;
222 209
223 // Calculates the target bounds assuming visibility of |visible|. 210 // Calculates the target bounds assuming visibility of |visible|.
224 void CalculateTargetBounds(const State& state, TargetBounds* target_bounds); 211 void CalculateTargetBounds(const State& state, TargetBounds* target_bounds);
225 212
226 // Updates the target bounds if a gesture-drag is in progress. This is only 213 // Updates the target bounds if a gesture-drag is in progress. This is only
227 // used by |CalculateTargetBounds()|. 214 // used by |CalculateTargetBounds()|.
228 void UpdateTargetBoundsForGesture(TargetBounds* target_bounds) const; 215 void UpdateTargetBoundsForGesture(TargetBounds* target_bounds) const;
229 216
230 // Updates the background of the shelf. 217 // Updates the background of the shelf.
231 void UpdateShelfBackground(BackgroundAnimator::ChangeType type); 218 void UpdateShelfBackground(BackgroundAnimator::ChangeType type);
232 219
233 // Returns whether the launcher should draw a background. 220 // Returns whether the launcher should draw a background.
234 bool GetLauncherPaintsBackground() const; 221 bool GetLauncherPaintsBackground() const;
235 222
236 // Updates the auto hide state immediately. 223 // Updates the auto hide state immediately.
237 void UpdateAutoHideStateNow(); 224 void UpdateAutoHideStateNow();
238 225
239 // Returns the AutoHideState. This value is determined from the launcher and 226 // Returns the AutoHideState. This value is determined from the launcher and
240 // tray. 227 // tray.
241 AutoHideState CalculateAutoHideState(VisibilityState visibility_state) const; 228 ShelfAutoHideState CalculateAutoHideState(
229 ShelfVisibilityState visibility_state) const;
242 230
243 // Updates the hit test bounds override for launcher and status area. 231 // Updates the hit test bounds override for launcher and status area.
244 void UpdateHitTestBounds(); 232 void UpdateHitTestBounds();
245 233
246 // Returns true if |window| is a descendant of the shelf. 234 // Returns true if |window| is a descendant of the shelf.
247 bool IsShelfWindow(aura::Window* window); 235 bool IsShelfWindow(aura::Window* window);
248 236
249 int GetWorkAreaSize(const State& state, int size) const; 237 int GetWorkAreaSize(const State& state, int size) const;
250 238
251 int axis_position(int x, int y) const { 239 int axis_position(int x, int y) const {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 GESTURE_DRAG_IN_PROGRESS, 282 GESTURE_DRAG_IN_PROGRESS,
295 GESTURE_DRAG_COMPLETE_IN_PROGRESS 283 GESTURE_DRAG_COMPLETE_IN_PROGRESS
296 }; 284 };
297 GestureDragStatus gesture_drag_status_; 285 GestureDragStatus gesture_drag_status_;
298 286
299 // Tracks the amount of the drag. The value is only valid when 287 // Tracks the amount of the drag. The value is only valid when
300 // |gesture_drag_status_| is set to GESTURE_DRAG_IN_PROGRESS. 288 // |gesture_drag_status_| is set to GESTURE_DRAG_IN_PROGRESS.
301 float gesture_drag_amount_; 289 float gesture_drag_amount_;
302 290
303 // Manage the auto-hide state during the gesture. 291 // Manage the auto-hide state during the gesture.
304 AutoHideState gesture_drag_auto_hide_state_; 292 ShelfAutoHideState gesture_drag_auto_hide_state_;
305 293
306 // Used to delay updating shelf background. 294 // Used to delay updating shelf background.
307 UpdateShelfObserver* update_shelf_observer_; 295 UpdateShelfObserver* update_shelf_observer_;
308 296
309 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); 297 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager);
310 }; 298 };
311 299
312 } // namespace internal 300 } // namespace internal
313 } // namespace ash 301 } // namespace ash
314 302
315 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ 303 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/wm/gestures/shelf_gesture_handler.cc ('k') | ash/wm/shelf_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698