| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/app_list/app_list_positioner.h" | 5 #include "chrome/browser/ui/app_list/app_list_positioner.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 case SCREEN_EDGE_BOTTOM: | 74 case SCREEN_EDGE_BOTTOM: |
| 75 anchor = gfx::Point(screen_rect.x(), work_area.bottom()); | 75 anchor = gfx::Point(screen_rect.x(), work_area.bottom()); |
| 76 break; | 76 break; |
| 77 default: | 77 default: |
| 78 NOTREACHED(); | 78 NOTREACHED(); |
| 79 anchor = gfx::Point(); | 79 anchor = gfx::Point(); |
| 80 } | 80 } |
| 81 return ClampAnchorPoint(anchor); | 81 return ClampAnchorPoint(anchor); |
| 82 } | 82 } |
| 83 | 83 |
| 84 gfx::Point AppListPositioner::GetAnchorPointForShelfCenter( |
| 85 ScreenEdge shelf_edge) const { |
| 86 const gfx::Rect& work_area = display_.work_area(); |
| 87 gfx::Point anchor; |
| 88 switch (shelf_edge) { |
| 89 case SCREEN_EDGE_LEFT: |
| 90 anchor = |
| 91 gfx::Point(work_area.x(), work_area.y() + work_area.height() / 2); |
| 92 break; |
| 93 case SCREEN_EDGE_RIGHT: |
| 94 anchor = |
| 95 gfx::Point(work_area.right(), work_area.y() + work_area.height() / 2); |
| 96 break; |
| 97 case SCREEN_EDGE_TOP: |
| 98 anchor = gfx::Point(work_area.x() + work_area.width() / 2, work_area.y()); |
| 99 break; |
| 100 case SCREEN_EDGE_BOTTOM: |
| 101 anchor = |
| 102 gfx::Point(work_area.x() + work_area.width() / 2, work_area.bottom()); |
| 103 break; |
| 104 default: |
| 105 NOTREACHED(); |
| 106 anchor = gfx::Point(); |
| 107 } |
| 108 return ClampAnchorPoint(anchor); |
| 109 } |
| 110 |
| 84 gfx::Point AppListPositioner::GetAnchorPointForShelfCursor( | 111 gfx::Point AppListPositioner::GetAnchorPointForShelfCursor( |
| 85 ScreenEdge shelf_edge, | 112 ScreenEdge shelf_edge, |
| 86 const gfx::Point& cursor) const { | 113 const gfx::Point& cursor) const { |
| 87 const gfx::Rect& work_area = display_.work_area(); | 114 const gfx::Rect& work_area = display_.work_area(); |
| 88 gfx::Point anchor; | 115 gfx::Point anchor; |
| 89 switch (shelf_edge) { | 116 switch (shelf_edge) { |
| 90 case SCREEN_EDGE_LEFT: | 117 case SCREEN_EDGE_LEFT: |
| 91 anchor = gfx::Point(work_area.x(), cursor.y()); | 118 anchor = gfx::Point(work_area.x(), cursor.y()); |
| 92 break; | 119 break; |
| 93 case SCREEN_EDGE_RIGHT: | 120 case SCREEN_EDGE_RIGHT: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 191 |
| 165 // Anchor the center of the window in a region that prevents the window | 192 // Anchor the center of the window in a region that prevents the window |
| 166 // showing outside of the work area. | 193 // showing outside of the work area. |
| 167 bounds_rect.Inset(window_size_.width() / 2 + min_distance_from_edge_, | 194 bounds_rect.Inset(window_size_.width() / 2 + min_distance_from_edge_, |
| 168 window_size_.height() / 2 + min_distance_from_edge_); | 195 window_size_.height() / 2 + min_distance_from_edge_); |
| 169 | 196 |
| 170 anchor.SetToMax(bounds_rect.origin()); | 197 anchor.SetToMax(bounds_rect.origin()); |
| 171 anchor.SetToMin(bounds_rect.bottom_right()); | 198 anchor.SetToMin(bounds_rect.bottom_right()); |
| 172 return anchor; | 199 return anchor; |
| 173 } | 200 } |
| OLD | NEW |