OLD | NEW |
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 #include "ash/wm/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 GetLayer(status_area_widget_)->SetOpacity(target_bounds.opacity); | 240 GetLayer(status_area_widget_)->SetOpacity(target_bounds.opacity); |
241 status_area_widget_->SetBounds( | 241 status_area_widget_->SetBounds( |
242 ScreenAsh::ConvertRectToScreen( | 242 ScreenAsh::ConvertRectToScreen( |
243 status_area_widget_->GetNativeView()->parent(), | 243 status_area_widget_->GetNativeView()->parent(), |
244 target_bounds.status_bounds_in_root)); | 244 target_bounds.status_bounds_in_root)); |
245 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 245 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
246 root_window_, target_bounds.work_area_insets); | 246 root_window_, target_bounds.work_area_insets); |
247 UpdateHitTestBounds(); | 247 UpdateHitTestBounds(); |
248 } | 248 } |
249 | 249 |
| 250 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { |
| 251 switch(auto_hide_behavior_) { |
| 252 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: |
| 253 return SHELF_AUTO_HIDE; |
| 254 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
| 255 return SHELF_VISIBLE; |
| 256 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
| 257 return SHELF_HIDDEN; |
| 258 } |
| 259 return SHELF_VISIBLE; |
| 260 } |
| 261 |
| 262 ShelfVisibilityState |
| 263 ShelfLayoutManager::CalculateShelfVisibilityWhileDragging() { |
| 264 switch(auto_hide_behavior_) { |
| 265 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: |
| 266 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
| 267 return SHELF_AUTO_HIDE; |
| 268 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
| 269 return SHELF_HIDDEN; |
| 270 } |
| 271 return SHELF_VISIBLE; |
| 272 } |
| 273 |
250 void ShelfLayoutManager::UpdateVisibilityState() { | 274 void ShelfLayoutManager::UpdateVisibilityState() { |
251 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 275 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
252 if (delegate && delegate->IsScreenLocked()) { | 276 if (delegate && delegate->IsScreenLocked()) { |
253 SetState(SHELF_VISIBLE); | 277 SetState(SHELF_VISIBLE); |
254 } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) { | 278 } else if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) { |
255 SetState(SHELF_AUTO_HIDE); | 279 // TODO(zelidrag): Verify shelf drag animation still shows on the device |
| 280 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. |
| 281 SetState(CalculateShelfVisibilityWhileDragging()); |
256 } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) { | 282 } else if (GetRootWindowController(root_window_)->IsImmersiveMode()) { |
257 // The user choosing immersive mode indicates he or she wants to maximize | 283 // The user choosing immersive mode indicates he or she wants to maximize |
258 // screen real-estate for content, so always auto-hide the shelf. | 284 // screen real-estate for content, so always auto-hide the shelf. |
| 285 DCHECK_NE(auto_hide_behavior_, SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
259 SetState(SHELF_AUTO_HIDE); | 286 SetState(SHELF_AUTO_HIDE); |
260 } else { | 287 } else { |
261 WorkspaceWindowState window_state(workspace_controller_->GetWindowState()); | 288 WorkspaceWindowState window_state(workspace_controller_->GetWindowState()); |
262 switch (window_state) { | 289 switch (window_state) { |
263 case WORKSPACE_WINDOW_STATE_FULL_SCREEN: | 290 case WORKSPACE_WINDOW_STATE_FULL_SCREEN: |
264 SetState(SHELF_HIDDEN); | 291 SetState(SHELF_HIDDEN); |
265 break; | 292 break; |
266 | 293 |
267 case WORKSPACE_WINDOW_STATE_MAXIMIZED: | 294 case WORKSPACE_WINDOW_STATE_MAXIMIZED: |
268 SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ? | 295 SetState(CalculateShelfVisibility()); |
269 SHELF_AUTO_HIDE : SHELF_VISIBLE); | |
270 break; | 296 break; |
271 | 297 |
272 case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: | 298 case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: |
273 case WORKSPACE_WINDOW_STATE_DEFAULT: | 299 case WORKSPACE_WINDOW_STATE_DEFAULT: |
274 SetState(auto_hide_behavior_ == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ? | 300 SetState(CalculateShelfVisibility()); |
275 SHELF_AUTO_HIDE : SHELF_VISIBLE); | |
276 SetWindowOverlapsShelf(window_state == | 301 SetWindowOverlapsShelf(window_state == |
277 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); | 302 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); |
278 break; | 303 break; |
279 } | 304 } |
280 } | 305 } |
281 } | 306 } |
282 | 307 |
283 void ShelfLayoutManager::UpdateAutoHideState() { | 308 void ShelfLayoutManager::UpdateAutoHideState() { |
284 ShelfAutoHideState auto_hide_state = | 309 ShelfAutoHideState auto_hide_state = |
285 CalculateAutoHideState(state_.visibility_state); | 310 CalculateAutoHideState(state_.visibility_state); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 944 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
920 if (state.visibility_state == SHELF_VISIBLE) | 945 if (state.visibility_state == SHELF_VISIBLE) |
921 return size; | 946 return size; |
922 if (state.visibility_state == SHELF_AUTO_HIDE) | 947 if (state.visibility_state == SHELF_AUTO_HIDE) |
923 return kAutoHideSize; | 948 return kAutoHideSize; |
924 return 0; | 949 return 0; |
925 } | 950 } |
926 | 951 |
927 } // namespace internal | 952 } // namespace internal |
928 } // namespace ash | 953 } // namespace ash |
OLD | NEW |