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> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 namespace { | 53 namespace { |
54 | 54 |
55 // Delay before showing the launcher. This is after the mouse stops moving. | 55 // Delay before showing the launcher. This is after the mouse stops moving. |
56 const int kAutoHideDelayMS = 200; | 56 const int kAutoHideDelayMS = 200; |
57 | 57 |
58 // To avoid hiding the shelf when the mouse transitions from a message bubble | 58 // To avoid hiding the shelf when the mouse transitions from a message bubble |
59 // into the shelf, the hit test area is enlarged by this amount of pixels to | 59 // into the shelf, the hit test area is enlarged by this amount of pixels to |
60 // keep the shelf from hiding. | 60 // keep the shelf from hiding. |
61 const int kNotificationBubbleGapHeight = 6; | 61 const int kNotificationBubbleGapHeight = 6; |
62 | 62 |
| 63 // Const inset from the edget of the shelf to the edget of the status area. |
| 64 const int kStatusAreaInset = 3; |
| 65 |
63 ui::Layer* GetLayer(views::Widget* widget) { | 66 ui::Layer* GetLayer(views::Widget* widget) { |
64 return widget->GetNativeView()->layer(); | 67 return widget->GetNativeView()->layer(); |
65 } | 68 } |
66 | 69 |
67 bool IsDraggingTrayEnabled() { | 70 bool IsDraggingTrayEnabled() { |
68 static bool dragging_tray_allowed = CommandLine::ForCurrentProcess()-> | 71 static bool dragging_tray_allowed = CommandLine::ForCurrentProcess()-> |
69 HasSwitch(ash::switches::kAshEnableTrayDragging); | 72 HasSwitch(ash::switches::kAshEnableTrayDragging); |
70 return dragging_tray_allowed; | 73 return dragging_tray_allowed; |
71 } | 74 } |
72 | 75 |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 gfx::Rect(available_bounds.x(), available_bounds.y(), | 726 gfx::Rect(available_bounds.x(), available_bounds.y(), |
724 shelf_width, available_bounds.height()), | 727 shelf_width, available_bounds.height()), |
725 gfx::Rect(available_bounds.right() - shelf_width, available_bounds.y(), | 728 gfx::Rect(available_bounds.right() - shelf_width, available_bounds.y(), |
726 shelf_width, available_bounds.height()), | 729 shelf_width, available_bounds.height()), |
727 gfx::Rect(available_bounds.x(), available_bounds.y(), | 730 gfx::Rect(available_bounds.x(), available_bounds.y(), |
728 available_bounds.width(), shelf_height)); | 731 available_bounds.width(), shelf_height)); |
729 | 732 |
730 int status_inset = std::max(0, GetPreferredShelfSize() - | 733 int status_inset = std::max(0, GetPreferredShelfSize() - |
731 PrimaryAxisValue(status_size.height(), status_size.width())); | 734 PrimaryAxisValue(status_size.height(), status_size.width())); |
732 | 735 |
| 736 if (ash::switches::UseAlternateShelfLayout()) |
| 737 status_inset = kStatusAreaInset; |
| 738 |
733 target_bounds->status_bounds_in_shelf = SelectValueForShelfAlignment( | 739 target_bounds->status_bounds_in_shelf = SelectValueForShelfAlignment( |
734 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), | 740 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), |
735 status_inset, status_size.width(), status_size.height()), | 741 status_inset, status_size.width(), status_size.height()), |
736 gfx::Rect(shelf_width - (status_size.width() + status_inset), | 742 gfx::Rect(shelf_width - (status_size.width() + status_inset), |
737 shelf_height - status_size.height(), status_size.width(), | 743 shelf_height - status_size.height(), status_size.width(), |
738 status_size.height()), | 744 status_size.height()), |
739 gfx::Rect(status_inset, shelf_height - status_size.height(), | 745 gfx::Rect(status_inset, shelf_height - status_size.height(), |
740 status_size.width(), status_size.height()), | 746 status_size.width(), status_size.height()), |
741 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), | 747 gfx::Rect(base::i18n::IsRTL() ? 0 : shelf_width - status_size.width(), |
742 shelf_height - (status_size.height() + status_inset), | 748 shelf_height - (status_size.height() + status_inset), |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 if (horizontal) { | 837 if (horizontal) { |
832 // Move and size the launcher with the gesture. | 838 // Move and size the launcher with the gesture. |
833 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate; | 839 int shelf_height = target_bounds->shelf_bounds_in_root.height() - translate; |
834 shelf_height = std::max(shelf_height, kAutoHideSize); | 840 shelf_height = std::max(shelf_height, kAutoHideSize); |
835 target_bounds->shelf_bounds_in_root.set_height(shelf_height); | 841 target_bounds->shelf_bounds_in_root.set_height(shelf_height); |
836 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { | 842 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { |
837 target_bounds->shelf_bounds_in_root.set_y( | 843 target_bounds->shelf_bounds_in_root.set_y( |
838 available_bounds.bottom() - shelf_height); | 844 available_bounds.bottom() - shelf_height); |
839 } | 845 } |
840 | 846 |
841 // The statusbar should be in the center of the shelf. | 847 if (ash::switches::UseAlternateShelfLayout()) { |
842 gfx::Rect status_y = target_bounds->shelf_bounds_in_root; | 848 target_bounds->status_bounds_in_shelf.set_y(kStatusAreaInset); |
843 status_y.set_y(0); | 849 } else { |
844 status_y.ClampToCenteredSize( | 850 // The statusbar should be in the center of the shelf. |
845 target_bounds->status_bounds_in_shelf.size()); | 851 gfx::Rect status_y = target_bounds->shelf_bounds_in_root; |
846 target_bounds->status_bounds_in_shelf.set_y(status_y.y()); | 852 status_y.set_y(0); |
| 853 status_y.ClampToCenteredSize( |
| 854 target_bounds->status_bounds_in_shelf.size()); |
| 855 target_bounds->status_bounds_in_shelf.set_y(status_y.y()); |
| 856 } |
847 } else { | 857 } else { |
848 // Move and size the launcher with the gesture. | 858 // Move and size the launcher with the gesture. |
849 int shelf_width = target_bounds->shelf_bounds_in_root.width(); | 859 int shelf_width = target_bounds->shelf_bounds_in_root.width(); |
850 if (alignment_ == SHELF_ALIGNMENT_RIGHT) | 860 if (alignment_ == SHELF_ALIGNMENT_RIGHT) |
851 shelf_width -= translate; | 861 shelf_width -= translate; |
852 else | 862 else |
853 shelf_width += translate; | 863 shelf_width += translate; |
854 shelf_width = std::max(shelf_width, kAutoHideSize); | 864 shelf_width = std::max(shelf_width, kAutoHideSize); |
855 target_bounds->shelf_bounds_in_root.set_width(shelf_width); | 865 target_bounds->shelf_bounds_in_root.set_width(shelf_width); |
856 if (alignment_ == SHELF_ALIGNMENT_RIGHT) { | 866 if (alignment_ == SHELF_ALIGNMENT_RIGHT) { |
857 target_bounds->shelf_bounds_in_root.set_x( | 867 target_bounds->shelf_bounds_in_root.set_x( |
858 available_bounds.right() - shelf_width); | 868 available_bounds.right() - shelf_width); |
859 } | 869 } |
860 | 870 |
861 // The statusbar should be in the center of the shelf. | 871 if (ash::switches::UseAlternateShelfLayout()) { |
862 gfx::Rect status_x = target_bounds->shelf_bounds_in_root; | 872 if (alignment_ == SHELF_ALIGNMENT_RIGHT) { |
863 status_x.set_x(0); | 873 target_bounds->shelf_bounds_in_root.set_x( |
864 status_x.ClampToCenteredSize( | 874 available_bounds.right() - shelf_width + kStatusAreaInset); |
865 target_bounds->status_bounds_in_shelf.size()); | 875 } else { |
866 target_bounds->status_bounds_in_shelf.set_x(status_x.x()); | 876 target_bounds->shelf_bounds_in_root.set_x(kStatusAreaInset); |
| 877 } |
| 878 } else { |
| 879 // The statusbar should be in the center of the shelf. |
| 880 gfx::Rect status_x = target_bounds->shelf_bounds_in_root; |
| 881 status_x.set_x(0); |
| 882 status_x.ClampToCenteredSize( |
| 883 target_bounds->status_bounds_in_shelf.size()); |
| 884 target_bounds->status_bounds_in_shelf.set_x(status_x.x()); |
| 885 } |
867 } | 886 } |
868 } | 887 } |
869 | 888 |
870 void ShelfLayoutManager::UpdateShelfBackground( | 889 void ShelfLayoutManager::UpdateShelfBackground( |
871 BackgroundAnimator::ChangeType type) { | 890 BackgroundAnimator::ChangeType type) { |
872 shelf_->SetPaintsBackground(GetShelfBackgroundType(), type); | 891 shelf_->SetPaintsBackground(GetShelfBackgroundType(), type); |
873 } | 892 } |
874 | 893 |
875 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { | 894 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { |
876 if (state_.visibility_state != SHELF_AUTO_HIDE && | 895 if (state_.visibility_state != SHELF_AUTO_HIDE && |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 return gfx::Insets(0, distance, 0, 0); | 1039 return gfx::Insets(0, distance, 0, 0); |
1021 case SHELF_ALIGNMENT_TOP: | 1040 case SHELF_ALIGNMENT_TOP: |
1022 return gfx::Insets(0, 0, distance, 0); | 1041 return gfx::Insets(0, 0, distance, 0); |
1023 } | 1042 } |
1024 NOTREACHED(); | 1043 NOTREACHED(); |
1025 return gfx::Insets(); | 1044 return gfx::Insets(); |
1026 } | 1045 } |
1027 | 1046 |
1028 } // namespace internal | 1047 } // namespace internal |
1029 } // namespace ash | 1048 } // namespace ash |
OLD | NEW |