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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 // When dragging down, the statusbar should move. | 739 // When dragging down, the statusbar should move. |
740 target_bounds->status_bounds_in_root.Offset(0, translate); | 740 target_bounds->status_bounds_in_root.Offset(0, translate); |
741 } else { | 741 } else { |
742 // When dragging up, the launcher height should increase. | 742 // When dragging up, the launcher height should increase. |
743 float move = std::max(translate, | 743 float move = std::max(translate, |
744 -static_cast<float>(resistance_free_region)); | 744 -static_cast<float>(resistance_free_region)); |
745 target_bounds->launcher_bounds_in_root.set_height( | 745 target_bounds->launcher_bounds_in_root.set_height( |
746 target_bounds->launcher_bounds_in_root.height() + move - translate); | 746 target_bounds->launcher_bounds_in_root.height() + move - translate); |
747 | 747 |
748 // The statusbar should be in the center. | 748 // The statusbar should be in the center. |
749 gfx::Rect status_y = target_bounds->launcher_bounds_in_root.Center( | 749 gfx::Rect status_y = target_bounds->launcher_bounds_in_root; |
| 750 status_y.ClampToCenteredSize( |
750 target_bounds->status_bounds_in_root.size()); | 751 target_bounds->status_bounds_in_root.size()); |
751 target_bounds->status_bounds_in_root.set_y(status_y.y()); | 752 target_bounds->status_bounds_in_root.set_y(status_y.y()); |
752 } | 753 } |
753 } else { | 754 } else { |
754 // Move the launcher with the gesture. | 755 // Move the launcher with the gesture. |
755 if (alignment() == SHELF_ALIGNMENT_RIGHT) | 756 if (alignment() == SHELF_ALIGNMENT_RIGHT) |
756 target_bounds->launcher_bounds_in_root.Offset(translate, 0); | 757 target_bounds->launcher_bounds_in_root.Offset(translate, 0); |
757 | 758 |
758 if ((translate > 0 && alignment() == SHELF_ALIGNMENT_RIGHT) || | 759 if ((translate > 0 && alignment() == SHELF_ALIGNMENT_RIGHT) || |
759 (translate < 0 && alignment() == SHELF_ALIGNMENT_LEFT)) { | 760 (translate < 0 && alignment() == SHELF_ALIGNMENT_LEFT)) { |
760 // When dragging towards the edge, the statusbar should move. | 761 // When dragging towards the edge, the statusbar should move. |
761 target_bounds->status_bounds_in_root.Offset(translate, 0); | 762 target_bounds->status_bounds_in_root.Offset(translate, 0); |
762 } else { | 763 } else { |
763 // When dragging away from the edge, the launcher width should increase. | 764 // When dragging away from the edge, the launcher width should increase. |
764 float move = alignment() == SHELF_ALIGNMENT_RIGHT ? | 765 float move = alignment() == SHELF_ALIGNMENT_RIGHT ? |
765 std::max(translate, -static_cast<float>(resistance_free_region)) : | 766 std::max(translate, -static_cast<float>(resistance_free_region)) : |
766 std::min(translate, static_cast<float>(resistance_free_region)); | 767 std::min(translate, static_cast<float>(resistance_free_region)); |
767 | 768 |
768 if (alignment() == SHELF_ALIGNMENT_RIGHT) { | 769 if (alignment() == SHELF_ALIGNMENT_RIGHT) { |
769 target_bounds->launcher_bounds_in_root.set_width( | 770 target_bounds->launcher_bounds_in_root.set_width( |
770 target_bounds->launcher_bounds_in_root.width() + move - translate); | 771 target_bounds->launcher_bounds_in_root.width() + move - translate); |
771 } else { | 772 } else { |
772 target_bounds->launcher_bounds_in_root.set_width( | 773 target_bounds->launcher_bounds_in_root.set_width( |
773 target_bounds->launcher_bounds_in_root.width() - move + translate); | 774 target_bounds->launcher_bounds_in_root.width() - move + translate); |
774 } | 775 } |
775 | 776 |
776 // The statusbar should be in the center. | 777 // The statusbar should be in the center. |
777 gfx::Rect status_x = target_bounds->launcher_bounds_in_root.Center( | 778 gfx::Rect status_x = target_bounds->launcher_bounds_in_root; |
| 779 status_x.ClampToCenteredSize( |
778 target_bounds->status_bounds_in_root.size()); | 780 target_bounds->status_bounds_in_root.size()); |
779 target_bounds->status_bounds_in_root.set_x(status_x.x()); | 781 target_bounds->status_bounds_in_root.set_x(status_x.x()); |
780 } | 782 } |
781 } | 783 } |
782 } | 784 } |
783 | 785 |
784 void ShelfLayoutManager::UpdateShelfBackground( | 786 void ShelfLayoutManager::UpdateShelfBackground( |
785 BackgroundAnimator::ChangeType type) { | 787 BackgroundAnimator::ChangeType type) { |
786 bool launcher_paints = GetLauncherPaintsBackground(); | 788 bool launcher_paints = GetLauncherPaintsBackground(); |
787 if (launcher_) | 789 if (launcher_) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 891 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
890 if (state.visibility_state == VISIBLE) | 892 if (state.visibility_state == VISIBLE) |
891 return size; | 893 return size; |
892 if (state.visibility_state == AUTO_HIDE) | 894 if (state.visibility_state == AUTO_HIDE) |
893 return kAutoHideSize; | 895 return kAutoHideSize; |
894 return 0; | 896 return 0; |
895 } | 897 } |
896 | 898 |
897 } // namespace internal | 899 } // namespace internal |
898 } // namespace ash | 900 } // namespace ash |
OLD | NEW |