| 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 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 bounds->Inset(SelectValueForShelfAlignment( | 633 bounds->Inset(SelectValueForShelfAlignment( |
| 634 gfx::Insets(0, 0, inset, 0), | 634 gfx::Insets(0, 0, inset, 0), |
| 635 gfx::Insets(0, inset, 0, 0), | 635 gfx::Insets(0, inset, 0, 0), |
| 636 gfx::Insets(0, 0, 0, inset), | 636 gfx::Insets(0, 0, 0, inset), |
| 637 gfx::Insets(inset, 0, 0, 0))); | 637 gfx::Insets(inset, 0, 0, 0))); |
| 638 } | 638 } |
| 639 | 639 |
| 640 void ShelfLayoutManager::CalculateTargetBounds( | 640 void ShelfLayoutManager::CalculateTargetBounds( |
| 641 const State& state, | 641 const State& state, |
| 642 TargetBounds* target_bounds) { | 642 TargetBounds* target_bounds) { |
| 643 const gfx::Rect& available_bounds(root_window_->bounds()); | 643 const gfx::Rect available_bounds(GetAvailableBounds()); |
| 644 gfx::Rect status_size( | 644 gfx::Rect status_size( |
| 645 shelf_->status_area_widget()->GetWindowBoundsInScreen().size()); | 645 shelf_->status_area_widget()->GetWindowBoundsInScreen().size()); |
| 646 int shelf_width = 0, shelf_height = 0; | 646 int shelf_width = 0, shelf_height = 0; |
| 647 GetShelfSize(&shelf_width, &shelf_height); | 647 GetShelfSize(&shelf_width, &shelf_height); |
| 648 if (IsHorizontalAlignment()) | 648 if (IsHorizontalAlignment()) |
| 649 shelf_width = available_bounds.width(); | 649 shelf_width = available_bounds.width(); |
| 650 else | 650 else |
| 651 shelf_height = available_bounds.height(); | 651 shelf_height = available_bounds.height(); |
| 652 | 652 |
| 653 if (state.visibility_state == SHELF_AUTO_HIDE && | 653 if (state.visibility_state == SHELF_AUTO_HIDE && |
| 654 state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { | 654 state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
| 655 // Auto-hidden shelf always starts with the default size. If a gesture-drag | 655 // Auto-hidden shelf always starts with the default size. If a gesture-drag |
| 656 // is in progress, then the call to UpdateTargetBoundsForGesture() below | 656 // is in progress, then the call to UpdateTargetBoundsForGesture() below |
| 657 // takes care of setting the height properly. | 657 // takes care of setting the height properly. |
| 658 if (IsHorizontalAlignment()) | 658 if (IsHorizontalAlignment()) |
| 659 shelf_height = kAutoHideSize; | 659 shelf_height = kAutoHideSize; |
| 660 else | 660 else |
| 661 shelf_width = kAutoHideSize; | 661 shelf_width = kAutoHideSize; |
| 662 } else if (state.visibility_state == SHELF_HIDDEN) { | 662 } else if (state.visibility_state == SHELF_HIDDEN || |
| 663 !keyboard_bounds_.IsEmpty()) { |
| 663 if (IsHorizontalAlignment()) | 664 if (IsHorizontalAlignment()) |
| 664 shelf_height = 0; | 665 shelf_height = 0; |
| 665 else | 666 else |
| 666 shelf_width = 0; | 667 shelf_width = 0; |
| 667 } | 668 } |
| 668 | 669 |
| 669 target_bounds->shelf_bounds_in_root = SelectValueForShelfAlignment( | 670 target_bounds->shelf_bounds_in_root = SelectValueForShelfAlignment( |
| 670 gfx::Rect(available_bounds.x(), available_bounds.bottom() - shelf_height, | 671 gfx::Rect(available_bounds.x(), available_bounds.bottom() - shelf_height, |
| 671 available_bounds.width(), shelf_height), | 672 available_bounds.width(), shelf_height), |
| 672 gfx::Rect(available_bounds.x(), available_bounds.y(), | 673 gfx::Rect(available_bounds.x(), available_bounds.y(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 690 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), | 691 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), |
| 691 shelf_height - (status_size.height() + status_inset), | 692 shelf_height - (status_size.height() + status_inset), |
| 692 status_size.width(), status_size.height())); | 693 status_size.width(), status_size.height())); |
| 693 | 694 |
| 694 target_bounds->work_area_insets = SelectValueForShelfAlignment( | 695 target_bounds->work_area_insets = SelectValueForShelfAlignment( |
| 695 gfx::Insets(0, 0, GetWorkAreaSize(state, shelf_height), 0), | 696 gfx::Insets(0, 0, GetWorkAreaSize(state, shelf_height), 0), |
| 696 gfx::Insets(0, GetWorkAreaSize(state, shelf_width), 0, 0), | 697 gfx::Insets(0, GetWorkAreaSize(state, shelf_width), 0, 0), |
| 697 gfx::Insets(0, 0, 0, GetWorkAreaSize(state, shelf_width)), | 698 gfx::Insets(0, 0, 0, GetWorkAreaSize(state, shelf_width)), |
| 698 gfx::Insets(GetWorkAreaSize(state, shelf_height), 0, 0, 0)); | 699 gfx::Insets(GetWorkAreaSize(state, shelf_height), 0, 0, 0)); |
| 699 | 700 |
| 701 // Also push in the work area inset for the keyboard if it is visible. |
| 702 if (!keyboard_bounds_.IsEmpty()) { |
| 703 target_bounds->work_area_insets.Set( |
| 704 target_bounds->work_area_insets.top(), |
| 705 target_bounds->work_area_insets.left(), |
| 706 target_bounds->work_area_insets.bottom() + keyboard_bounds_.height(), |
| 707 target_bounds->work_area_insets.right()); |
| 708 } |
| 709 |
| 700 target_bounds->opacity = | 710 target_bounds->opacity = |
| 701 (gesture_drag_status_ != GESTURE_DRAG_NONE || | 711 (gesture_drag_status_ != GESTURE_DRAG_NONE || |
| 702 state.visibility_state == SHELF_VISIBLE || | 712 state.visibility_state == SHELF_VISIBLE || |
| 703 state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; | 713 state.visibility_state == SHELF_AUTO_HIDE) ? 1.0f : 0.0f; |
| 704 | 714 |
| 705 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) | 715 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS) |
| 706 UpdateTargetBoundsForGesture(target_bounds); | 716 UpdateTargetBoundsForGesture(target_bounds); |
| 707 | 717 |
| 708 // This needs to happen after calling UpdateTargetBoundsForGesture(), because | 718 // This needs to happen after calling UpdateTargetBoundsForGesture(), because |
| 709 // that can change the size of the shelf. | 719 // that can change the size of the shelf. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 } | 916 } |
| 907 | 917 |
| 908 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 918 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
| 909 if (state.visibility_state == SHELF_VISIBLE) | 919 if (state.visibility_state == SHELF_VISIBLE) |
| 910 return size; | 920 return size; |
| 911 if (state.visibility_state == SHELF_AUTO_HIDE) | 921 if (state.visibility_state == SHELF_AUTO_HIDE) |
| 912 return kAutoHideSize; | 922 return kAutoHideSize; |
| 913 return 0; | 923 return 0; |
| 914 } | 924 } |
| 915 | 925 |
| 926 gfx::Rect ShelfLayoutManager::GetAvailableBounds() const { |
| 927 gfx::Rect bounds(root_window_->bounds()); |
| 928 bounds.set_height(bounds.height() - keyboard_bounds_.height()); |
| 929 return bounds; |
| 930 } |
| 931 |
| 932 void ShelfLayoutManager::OnKeyboardBoundsChanging( |
| 933 const gfx::Rect& keyboard_bounds) { |
| 934 keyboard_bounds_ = keyboard_bounds; |
| 935 OnWindowResized(); |
| 936 } |
| 937 |
| 916 } // namespace internal | 938 } // namespace internal |
| 917 } // namespace ash | 939 } // namespace ash |
| OLD | NEW |