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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
15 #include "ash/screen_ash.h" | 15 #include "ash/screen_util.h" |
16 #include "ash/session_state_delegate.h" | 16 #include "ash/session_state_delegate.h" |
17 #include "ash/shelf/shelf.h" | 17 #include "ash/shelf/shelf.h" |
18 #include "ash/shelf/shelf_bezel_event_filter.h" | 18 #include "ash/shelf/shelf_bezel_event_filter.h" |
19 #include "ash/shelf/shelf_constants.h" | 19 #include "ash/shelf/shelf_constants.h" |
20 #include "ash/shelf/shelf_layout_manager_observer.h" | 20 #include "ash/shelf/shelf_layout_manager_observer.h" |
21 #include "ash/shelf/shelf_widget.h" | 21 #include "ash/shelf/shelf_widget.h" |
22 #include "ash/shell.h" | 22 #include "ash/shell.h" |
23 #include "ash/shell_window_ids.h" | 23 #include "ash/shell_window_ids.h" |
24 #include "ash/system/status_area_widget.h" | 24 #include "ash/system/status_area_widget.h" |
25 #include "ash/wm/gestures/shelf_gesture_handler.h" | 25 #include "ash/wm/gestures/shelf_gesture_handler.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 264 |
265 ShelfAlignment ShelfLayoutManager::GetAlignment() const { | 265 ShelfAlignment ShelfLayoutManager::GetAlignment() const { |
266 // When the screen is locked, the shelf is forced into bottom alignment. | 266 // When the screen is locked, the shelf is forced into bottom alignment. |
267 if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) | 267 if (Shell::GetInstance()->session_state_delegate()->IsScreenLocked()) |
268 return SHELF_ALIGNMENT_BOTTOM; | 268 return SHELF_ALIGNMENT_BOTTOM; |
269 return alignment_; | 269 return alignment_; |
270 } | 270 } |
271 | 271 |
272 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 272 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
273 gfx::Rect bounds( | 273 gfx::Rect bounds( |
274 ScreenAsh::GetDisplayBoundsInParent(shelf_->GetNativeView())); | 274 ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); |
275 int width = 0, height = 0; | 275 int width = 0, height = 0; |
276 GetShelfSize(&width, &height); | 276 GetShelfSize(&width, &height); |
277 return SelectValueForShelfAlignment( | 277 return SelectValueForShelfAlignment( |
278 gfx::Rect(bounds.x(), bounds.bottom() - height, bounds.width(), height), | 278 gfx::Rect(bounds.x(), bounds.bottom() - height, bounds.width(), height), |
279 gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()), | 279 gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()), |
280 gfx::Rect(bounds.right() - width, bounds.y(), width, bounds.height()), | 280 gfx::Rect(bounds.right() - width, bounds.y(), width, bounds.height()), |
281 gfx::Rect(bounds.x(), bounds.y(), bounds.width(), height)); | 281 gfx::Rect(bounds.x(), bounds.y(), bounds.width(), height)); |
282 } | 282 } |
283 | 283 |
284 void ShelfLayoutManager::LayoutShelf() { | 284 void ShelfLayoutManager::LayoutShelf() { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 667 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
668 } else { | 668 } else { |
669 StopAnimating(); | 669 StopAnimating(); |
670 shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); | 670 shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); |
671 status_animation_setter.SetTransitionDuration(base::TimeDelta()); | 671 status_animation_setter.SetTransitionDuration(base::TimeDelta()); |
672 } | 672 } |
673 if (observer) | 673 if (observer) |
674 status_animation_setter.AddObserver(observer); | 674 status_animation_setter.AddObserver(observer); |
675 | 675 |
676 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); | 676 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); |
677 shelf_->SetBounds(ScreenAsh::ConvertRectToScreen( | 677 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( |
678 shelf_->GetNativeView()->parent(), | 678 shelf_->GetNativeView()->parent(), |
679 target_bounds.shelf_bounds_in_root)); | 679 target_bounds.shelf_bounds_in_root)); |
680 | 680 |
681 GetLayer(shelf_->status_area_widget())->SetOpacity( | 681 GetLayer(shelf_->status_area_widget())->SetOpacity( |
682 target_bounds.status_opacity); | 682 target_bounds.status_opacity); |
683 // TODO(harrym): Once status area widget is a child view of shelf | 683 // TODO(harrym): Once status area widget is a child view of shelf |
684 // this can be simplified. | 684 // this can be simplified. |
685 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; | 685 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; |
686 status_bounds.set_x(status_bounds.x() + | 686 status_bounds.set_x(status_bounds.x() + |
687 target_bounds.shelf_bounds_in_root.x()); | 687 target_bounds.shelf_bounds_in_root.x()); |
688 status_bounds.set_y(status_bounds.y() + | 688 status_bounds.set_y(status_bounds.y() + |
689 target_bounds.shelf_bounds_in_root.y()); | 689 target_bounds.shelf_bounds_in_root.y()); |
690 shelf_->status_area_widget()->SetBounds( | 690 shelf_->status_area_widget()->SetBounds( |
691 ScreenAsh::ConvertRectToScreen( | 691 ScreenUtil::ConvertRectToScreen( |
692 shelf_->status_area_widget()->GetNativeView()->parent(), | 692 shelf_->status_area_widget()->GetNativeView()->parent(), |
693 status_bounds)); | 693 status_bounds)); |
694 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 694 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
695 root_window_, target_bounds.work_area_insets); | 695 root_window_, target_bounds.work_area_insets); |
696 UpdateHitTestBounds(); | 696 UpdateHitTestBounds(); |
697 } | 697 } |
698 | 698 |
699 void ShelfLayoutManager::StopAnimating() { | 699 void ShelfLayoutManager::StopAnimating() { |
700 GetLayer(shelf_)->GetAnimator()->StopAnimating(); | 700 GetLayer(shelf_)->GetAnimator()->StopAnimating(); |
701 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); | 701 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 return gfx::Insets(0, distance, 0, 0); | 1157 return gfx::Insets(0, distance, 0, 0); |
1158 case SHELF_ALIGNMENT_TOP: | 1158 case SHELF_ALIGNMENT_TOP: |
1159 return gfx::Insets(0, 0, distance, 0); | 1159 return gfx::Insets(0, 0, distance, 0); |
1160 } | 1160 } |
1161 NOTREACHED(); | 1161 NOTREACHED(); |
1162 return gfx::Insets(); | 1162 return gfx::Insets(); |
1163 } | 1163 } |
1164 | 1164 |
1165 } // namespace internal | 1165 } // namespace internal |
1166 } // namespace ash | 1166 } // namespace ash |
OLD | NEW |