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/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 path.moveTo(SkIntToScalar(0), SkIntToScalar(0)); | 72 path.moveTo(SkIntToScalar(0), SkIntToScalar(0)); |
73 path.lineTo(SkIntToScalar(kArrowWidth / 2), | 73 path.lineTo(SkIntToScalar(kArrowWidth / 2), |
74 SkIntToScalar(kArrowHeight)); | 74 SkIntToScalar(kArrowHeight)); |
75 path.lineTo(SkIntToScalar(kArrowWidth), SkIntToScalar(0)); | 75 path.lineTo(SkIntToScalar(kArrowWidth), SkIntToScalar(0)); |
76 break; | 76 break; |
77 case SHELF_ALIGNMENT_LEFT: | 77 case SHELF_ALIGNMENT_LEFT: |
78 path.moveTo(SkIntToScalar(kArrowHeight), SkIntToScalar(kArrowWidth)); | 78 path.moveTo(SkIntToScalar(kArrowHeight), SkIntToScalar(kArrowWidth)); |
79 path.lineTo(SkIntToScalar(0), SkIntToScalar(kArrowWidth / 2)); | 79 path.lineTo(SkIntToScalar(0), SkIntToScalar(kArrowWidth / 2)); |
80 path.lineTo(SkIntToScalar(kArrowHeight), SkIntToScalar(0)); | 80 path.lineTo(SkIntToScalar(kArrowHeight), SkIntToScalar(0)); |
81 break; | 81 break; |
82 case SHELF_ALIGNMENT_TOP: | |
83 path.moveTo(SkIntToScalar(0), SkIntToScalar(kArrowHeight)); | |
84 path.lineTo(SkIntToScalar(kArrowWidth / 2), SkIntToScalar(0)); | |
85 path.lineTo(SkIntToScalar(kArrowWidth), SkIntToScalar(kArrowHeight)); | |
86 break; | |
87 case SHELF_ALIGNMENT_RIGHT: | 82 case SHELF_ALIGNMENT_RIGHT: |
88 path.moveTo(SkIntToScalar(0), SkIntToScalar(0)); | 83 path.moveTo(SkIntToScalar(0), SkIntToScalar(0)); |
89 path.lineTo(SkIntToScalar(kArrowHeight), | 84 path.lineTo(SkIntToScalar(kArrowHeight), |
90 SkIntToScalar(kArrowWidth / 2)); | 85 SkIntToScalar(kArrowWidth / 2)); |
91 path.lineTo(SkIntToScalar(0), SkIntToScalar(kArrowWidth)); | 86 path.lineTo(SkIntToScalar(0), SkIntToScalar(kArrowWidth)); |
92 break; | 87 break; |
93 } | 88 } |
94 // Hard code the arrow color for now. | 89 // Hard code the arrow color for now. |
95 SkPaint paint; | 90 SkPaint paint; |
96 paint.setStyle(SkPaint::kFill_Style); | 91 paint.setStyle(SkPaint::kFill_Style); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 switch (alignment) { | 181 switch (alignment) { |
187 case SHELF_ALIGNMENT_BOTTOM: | 182 case SHELF_ALIGNMENT_BOTTOM: |
188 offset.set_y(kPanelSlideInOffset); | 183 offset.set_y(kPanelSlideInOffset); |
189 break; | 184 break; |
190 case SHELF_ALIGNMENT_LEFT: | 185 case SHELF_ALIGNMENT_LEFT: |
191 offset.set_x(-kPanelSlideInOffset); | 186 offset.set_x(-kPanelSlideInOffset); |
192 break; | 187 break; |
193 case SHELF_ALIGNMENT_RIGHT: | 188 case SHELF_ALIGNMENT_RIGHT: |
194 offset.set_x(kPanelSlideInOffset); | 189 offset.set_x(kPanelSlideInOffset); |
195 break; | 190 break; |
196 case SHELF_ALIGNMENT_TOP: | |
197 offset.set_y(-kPanelSlideInOffset); | |
198 break; | |
199 } | 191 } |
200 return offset; | 192 return offset; |
201 } | 193 } |
202 | 194 |
203 } // namespace | 195 } // namespace |
204 | 196 |
205 class PanelCalloutWidget : public views::Widget { | 197 class PanelCalloutWidget : public views::Widget { |
206 public: | 198 public: |
207 explicit PanelCalloutWidget(aura::Window* container) | 199 explicit PanelCalloutWidget(aura::Window* container) |
208 : background_(NULL) { | 200 : background_(NULL) { |
209 InitWidget(container); | 201 InitWidget(container); |
210 } | 202 } |
211 | 203 |
212 void SetAlignment(ShelfAlignment alignment) { | 204 void SetAlignment(ShelfAlignment alignment) { |
213 gfx::Rect callout_bounds = GetWindowBoundsInScreen(); | 205 gfx::Rect callout_bounds = GetWindowBoundsInScreen(); |
214 if (alignment == SHELF_ALIGNMENT_BOTTOM || | 206 if (alignment == SHELF_ALIGNMENT_BOTTOM) { |
215 alignment == SHELF_ALIGNMENT_TOP) { | |
216 callout_bounds.set_width(kArrowWidth); | 207 callout_bounds.set_width(kArrowWidth); |
217 callout_bounds.set_height(kArrowHeight); | 208 callout_bounds.set_height(kArrowHeight); |
218 } else { | 209 } else { |
219 callout_bounds.set_width(kArrowHeight); | 210 callout_bounds.set_width(kArrowHeight); |
220 callout_bounds.set_height(kArrowWidth); | 211 callout_bounds.set_height(kArrowWidth); |
221 } | 212 } |
222 GetNativeWindow()->SetBounds(callout_bounds); | 213 GetNativeWindow()->SetBounds(callout_bounds); |
223 if (background_->alignment() != alignment) { | 214 if (background_->alignment() != alignment) { |
224 background_->set_alignment(alignment); | 215 background_->set_alignment(alignment); |
225 SchedulePaintInRect(gfx::Rect(gfx::Point(), callout_bounds.size())); | 216 SchedulePaintInRect(gfx::Rect(gfx::Point(), callout_bounds.size())); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 switch (alignment) { | 705 switch (alignment) { |
715 case SHELF_ALIGNMENT_BOTTOM: | 706 case SHELF_ALIGNMENT_BOTTOM: |
716 bounds.set_y(shelf_bounds.y() - bounds.height()); | 707 bounds.set_y(shelf_bounds.y() - bounds.height()); |
717 break; | 708 break; |
718 case SHELF_ALIGNMENT_LEFT: | 709 case SHELF_ALIGNMENT_LEFT: |
719 bounds.set_x(shelf_bounds.right()); | 710 bounds.set_x(shelf_bounds.right()); |
720 break; | 711 break; |
721 case SHELF_ALIGNMENT_RIGHT: | 712 case SHELF_ALIGNMENT_RIGHT: |
722 bounds.set_x(shelf_bounds.x() - bounds.width()); | 713 bounds.set_x(shelf_bounds.x() - bounds.width()); |
723 break; | 714 break; |
724 case SHELF_ALIGNMENT_TOP: | |
725 bounds.set_y(shelf_bounds.bottom()); | |
726 break; | |
727 } | 715 } |
728 bool on_shelf = visible_panels[i].window->GetTargetBounds() == bounds; | 716 bool on_shelf = visible_panels[i].window->GetTargetBounds() == bounds; |
729 | 717 |
730 if (horizontal) { | 718 if (horizontal) { |
731 bounds.set_x(visible_panels[i].major_pos - | 719 bounds.set_x(visible_panels[i].major_pos - |
732 visible_panels[i].major_length / 2); | 720 visible_panels[i].major_length / 2); |
733 } else { | 721 } else { |
734 bounds.set_y(visible_panels[i].major_pos - | 722 bounds.set_y(visible_panels[i].major_pos - |
735 visible_panels[i].major_length / 2); | 723 visible_panels[i].major_length / 2); |
736 } | 724 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 switch (shelf_->alignment()) { | 848 switch (shelf_->alignment()) { |
861 case SHELF_ALIGNMENT_BOTTOM: | 849 case SHELF_ALIGNMENT_BOTTOM: |
862 callout_bounds.set_y(bounds.bottom()); | 850 callout_bounds.set_y(bounds.bottom()); |
863 break; | 851 break; |
864 case SHELF_ALIGNMENT_LEFT: | 852 case SHELF_ALIGNMENT_LEFT: |
865 callout_bounds.set_x(bounds.x() - callout_bounds.width()); | 853 callout_bounds.set_x(bounds.x() - callout_bounds.width()); |
866 break; | 854 break; |
867 case SHELF_ALIGNMENT_RIGHT: | 855 case SHELF_ALIGNMENT_RIGHT: |
868 callout_bounds.set_x(bounds.right()); | 856 callout_bounds.set_x(bounds.right()); |
869 break; | 857 break; |
870 case SHELF_ALIGNMENT_TOP: | |
871 callout_bounds.set_y(bounds.y() - callout_bounds.height()); | |
872 break; | |
873 } | 858 } |
874 callout_bounds = ScreenUtil::ConvertRectFromScreen( | 859 callout_bounds = ScreenUtil::ConvertRectFromScreen( |
875 callout_widget->GetNativeWindow()->parent(), | 860 callout_widget->GetNativeWindow()->parent(), |
876 callout_bounds); | 861 callout_bounds); |
877 | 862 |
878 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds); | 863 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds); |
879 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(), | 864 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(), |
880 panel); | 865 panel); |
881 | 866 |
882 ui::Layer* layer = callout_widget->GetNativeWindow()->layer(); | 867 ui::Layer* layer = callout_widget->GetNativeWindow()->layer(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 // Keyboard hidden, restore original bounds if they exist. | 928 // Keyboard hidden, restore original bounds if they exist. |
944 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen()); | 929 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen()); |
945 } | 930 } |
946 } | 931 } |
947 // This bounds change will have caused a change to the Shelf which does not | 932 // This bounds change will have caused a change to the Shelf which does not |
948 // propogate automatically to this class, so manually recalculate bounds. | 933 // propogate automatically to this class, so manually recalculate bounds. |
949 OnWindowResized(); | 934 OnWindowResized(); |
950 } | 935 } |
951 | 936 |
952 } // namespace ash | 937 } // namespace ash |
OLD | NEW |