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

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

Issue 10388036: Adds the option of aligning the launcher to the left or right. There (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/shelf_auto_hide_behavior.h ('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 #pragma once 7 #pragma once
8 8
9 #include "ash/ash_export.h" 9 #include "ash/ash_export.h"
10 #include "ash/launcher/launcher.h" 10 #include "ash/launcher/launcher.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 }; 57 };
58 58
59 // We reserve a small area at the bottom of the workspace area to ensure that 59 // We reserve a small area at the bottom of the workspace area to ensure that
60 // the bottom-of-window resize handle can be hit. 60 // the bottom-of-window resize handle can be hit.
61 // TODO(jamescook): Some day we may want the workspace area to be an even 61 // TODO(jamescook): Some day we may want the workspace area to be an even
62 // multiple of the size of the grid (currently 8 pixels), which will require 62 // multiple of the size of the grid (currently 8 pixels), which will require
63 // removing this and finding a way for hover and click events to pass through 63 // removing this and finding a way for hover and click events to pass through
64 // the invisible parts of the launcher. 64 // the invisible parts of the launcher.
65 static const int kWorkspaceAreaBottomInset; 65 static const int kWorkspaceAreaBottomInset;
66 66
67 // Height of the shelf when auto-hidden. 67 // Size of the shelf when auto-hidden.
68 static const int kAutoHideHeight; 68 static const int kAutoHideSize;
69 69
70 explicit ShelfLayoutManager(views::Widget* status); 70 explicit ShelfLayoutManager(views::Widget* status);
71 virtual ~ShelfLayoutManager(); 71 virtual ~ShelfLayoutManager();
72 72
73 // Sets the ShelfAutoHideBehavior. See enum description for details. 73 // Sets the ShelfAutoHideBehavior. See enum description for details.
74 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior); 74 void SetAutoHideBehavior(ShelfAutoHideBehavior behavior);
75 ShelfAutoHideBehavior auto_hide_behavior() const { 75 ShelfAutoHideBehavior auto_hide_behavior() const {
76 return auto_hide_behavior_; 76 return auto_hide_behavior_;
77 } 77 }
78 78
79 // Sets the alignment.
80 void SetAlignment(ShelfAlignment alignment);
81 ShelfAlignment alignment() const { return alignment_; }
82
79 void set_workspace_manager(WorkspaceManager* manager) { 83 void set_workspace_manager(WorkspaceManager* manager) {
80 workspace_manager_ = manager; 84 workspace_manager_ = manager;
81 } 85 }
82 86
83 views::Widget* launcher_widget() { 87 views::Widget* launcher_widget() {
84 return launcher_ ? launcher_->widget() : NULL; 88 return launcher_ ? launcher_->widget() : NULL;
85 } 89 }
86 const views::Widget* launcher_widget() const { 90 const views::Widget* launcher_widget() const {
87 return launcher_ ? launcher_->widget() : NULL; 91 return launcher_ ? launcher_->widget() : NULL;
88 } 92 }
89 views::Widget* status() { return status_; } 93 views::Widget* status() { return status_; }
90 94
91 bool in_layout() const { return in_layout_; } 95 bool in_layout() const { return in_layout_; }
92 96
93 // See description above field.
94 int shelf_height() const { return shelf_height_; }
95
96 // Returns whether the shelf and its contents (launcher, status) are visible 97 // Returns whether the shelf and its contents (launcher, status) are visible
97 // on the screen. 98 // on the screen.
98 bool IsVisible() const; 99 bool IsVisible() const;
99 100
100 // Returns the bounds the specified window should be when maximized. 101 // Returns the bounds the specified window should be when maximized.
101 gfx::Rect GetMaximizedWindowBounds(aura::Window* window) const; 102 gfx::Rect GetMaximizedWindowBounds(aura::Window* window);
102 gfx::Rect GetUnmaximizedWorkAreaBounds(aura::Window* window) const; 103 gfx::Rect GetUnmaximizedWorkAreaBounds(aura::Window* window);
103 104
104 // The launcher is typically created after the layout manager. 105 // The launcher is typically created after the layout manager.
105 void SetLauncher(Launcher* launcher); 106 void SetLauncher(Launcher* launcher);
106 Launcher* launcher() { return launcher_; } 107 Launcher* launcher() { return launcher_; }
107 108
109 // Returns the ideal bounds of the shelf assuming it is visible.
110 gfx::Rect GetIdealBounds();
111
108 // Stops any animations and sets the bounds of the launcher and status 112 // Stops any animations and sets the bounds of the launcher and status
109 // widgets. 113 // widgets.
110 void LayoutShelf(); 114 void LayoutShelf();
111 115
112 // Updates the visibility state. 116 // Updates the visibility state.
113 void UpdateVisibilityState(); 117 void UpdateVisibilityState();
114 118
115 // Invoked by the shelf/launcher when the auto-hide state may have changed. 119 // Invoked by the shelf/launcher when the auto-hide state may have changed.
116 void UpdateAutoHideState(); 120 void UpdateAutoHideState();
117 121
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 AutoHideState auto_hide_state; 173 AutoHideState auto_hide_state;
170 bool is_screen_locked; 174 bool is_screen_locked;
171 }; 175 };
172 176
173 // Sets the visibility of the shelf to |state|. 177 // Sets the visibility of the shelf to |state|.
174 void SetState(VisibilityState visibility_state); 178 void SetState(VisibilityState visibility_state);
175 179
176 // Stops any animations. 180 // Stops any animations.
177 void StopAnimating(); 181 void StopAnimating();
178 182
183 // Returns the width (if aligned to the side) or height (if aligned to the
184 // bottom).
185 void GetShelfSize(int* width, int* height);
186
187 // Insets |bounds| by |inset| on the edge the shelf is aligned to.
188 void AdjustBoundsBasedOnAlignment(int inset, gfx::Rect* bounds) const;
189
179 // Calculates the target bounds assuming visibility of |visible|. 190 // Calculates the target bounds assuming visibility of |visible|.
180 void CalculateTargetBounds(const State& state, 191 void CalculateTargetBounds(const State& state, TargetBounds* target_bounds);
181 TargetBounds* target_bounds) const;
182 192
183 // Updates the background of the shelf. 193 // Updates the background of the shelf.
184 void UpdateShelfBackground(BackgroundAnimator::ChangeType type); 194 void UpdateShelfBackground(BackgroundAnimator::ChangeType type);
185 195
186 // Returns whether the launcher should draw a background. 196 // Returns whether the launcher should draw a background.
187 bool GetLauncherPaintsBackground() const; 197 bool GetLauncherPaintsBackground() const;
188 198
189 // Updates the auto hide state immediately. 199 // Updates the auto hide state immediately.
190 void UpdateAutoHideStateNow(); 200 void UpdateAutoHideStateNow();
191 201
192 // Returns the AutoHideState. This value is determined from the launcher and 202 // Returns the AutoHideState. This value is determined from the launcher and
193 // tray. 203 // tray.
194 AutoHideState CalculateAutoHideState(VisibilityState visibility_state) const; 204 AutoHideState CalculateAutoHideState(VisibilityState visibility_state) const;
195 205
196 // Updates the hit test bounds override for launcher and status area. 206 // Updates the hit test bounds override for launcher and status area.
197 void UpdateHitTestBounds(); 207 void UpdateHitTestBounds();
198 208
199 // Returns true if |window| is a descendant of the shelf. 209 // Returns true if |window| is a descendant of the shelf.
200 bool IsShelfWindow(aura::Window* window); 210 bool IsShelfWindow(aura::Window* window);
201 211
212 int GetWorkAreaSize(const State& state, int size) const;
213
214 int axis_position(int x, int y) const{
215 return alignment_ == SHELF_ALIGNMENT_BOTTOM ? y : x;
216 }
217
202 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from 218 // The RootWindow is cached so that we don't invoke Shell::GetInstance() from
203 // our destructor. We avoid that as at the time we're deleted Shell is being 219 // our destructor. We avoid that as at the time we're deleted Shell is being
204 // deleted too. 220 // deleted too.
205 aura::RootWindow* root_window_; 221 aura::RootWindow* root_window_;
206 222
207 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf 223 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf
208 // again from SetChildBounds(). 224 // again from SetChildBounds().
209 bool in_layout_; 225 bool in_layout_;
210 226
211 // See description above setter. 227 // See description above setter.
212 ShelfAutoHideBehavior auto_hide_behavior_; 228 ShelfAutoHideBehavior auto_hide_behavior_;
213 229
230 ShelfAlignment alignment_;
231
214 // Current state. 232 // Current state.
215 State state_; 233 State state_;
216 234
217 // Height of the shelf (max of launcher and status).
218 int shelf_height_;
219
220 Launcher* launcher_; 235 Launcher* launcher_;
221 views::Widget* status_; 236 views::Widget* status_;
222 237
223 WorkspaceManager* workspace_manager_; 238 WorkspaceManager* workspace_manager_;
224 239
225 // Do any windows overlap the shelf? This is maintained by WorkspaceManager. 240 // Do any windows overlap the shelf? This is maintained by WorkspaceManager.
226 bool window_overlaps_shelf_; 241 bool window_overlaps_shelf_;
227 242
228 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_; 243 base::OneShotTimer<ShelfLayoutManager> auto_hide_timer_;
229 244
230 // EventFilter used to detect when user moves the mouse over the launcher to 245 // EventFilter used to detect when user moves the mouse over the launcher to
231 // trigger showing the launcher. 246 // trigger showing the launcher.
232 scoped_ptr<AutoHideEventFilter> event_filter_; 247 scoped_ptr<AutoHideEventFilter> event_filter_;
233 248
234 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); 249 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager);
235 }; 250 };
236 251
237 } // namespace internal 252 } // namespace internal
238 } // namespace ash 253 } // namespace ash
239 254
240 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ 255 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/wm/shelf_auto_hide_behavior.h ('k') | ash/wm/shelf_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698