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& screen_rect = display_.bounds(); | |
87 const gfx::Rect& work_area = display_.work_area(); | |
88 gfx::Point anchor; | |
89 switch (shelf_edge) { | |
90 case SCREEN_EDGE_LEFT: | |
91 anchor = gfx::Point(work_area.x(), | |
92 screen_rect.y() + screen_rect.height() / 2); | |
tapted
2013/11/29 02:12:51
Maybe s/screen_rect/work_area? My left dock looks
Matt Giuca
2013/11/29 05:24:08
Done.
| |
93 break; | |
94 case SCREEN_EDGE_RIGHT: | |
95 anchor = gfx::Point(work_area.right(), | |
96 screen_rect.y() + screen_rect.height() / 2); | |
97 break; | |
98 case SCREEN_EDGE_TOP: | |
tapted
2013/11/29 02:12:51
Do we need this? I'm not sure if consistency outwe
Matt Giuca
2013/11/29 05:24:08
I think that would be a Bad Idea. This is a genera
tapted
2013/11/29 06:05:59
I see the rationale for adding the case statement
Matt Giuca
2013/12/02 05:02:03
No, there aren't (although there are probably Linu
| |
99 anchor = gfx::Point(screen_rect.x() + screen_rect.width() / 2, | |
100 work_area.y()); | |
101 break; | |
102 case SCREEN_EDGE_BOTTOM: | |
103 anchor = gfx::Point(screen_rect.x() + screen_rect.width() / 2, | |
104 work_area.bottom()); | |
105 break; | |
106 default: | |
107 NOTREACHED(); | |
108 anchor = gfx::Point(); | |
109 } | |
110 return ClampAnchorPoint(anchor); | |
111 } | |
112 | |
84 gfx::Point AppListPositioner::GetAnchorPointForShelfCursor( | 113 gfx::Point AppListPositioner::GetAnchorPointForShelfCursor( |
85 ScreenEdge shelf_edge, | 114 ScreenEdge shelf_edge, |
86 const gfx::Point& cursor) const { | 115 const gfx::Point& cursor) const { |
87 const gfx::Rect& work_area = display_.work_area(); | 116 const gfx::Rect& work_area = display_.work_area(); |
88 gfx::Point anchor; | 117 gfx::Point anchor; |
89 switch (shelf_edge) { | 118 switch (shelf_edge) { |
90 case SCREEN_EDGE_LEFT: | 119 case SCREEN_EDGE_LEFT: |
91 anchor = gfx::Point(work_area.x(), cursor.y()); | 120 anchor = gfx::Point(work_area.x(), cursor.y()); |
92 break; | 121 break; |
93 case SCREEN_EDGE_RIGHT: | 122 case SCREEN_EDGE_RIGHT: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 | 192 |
164 // Anchor the center of the window in a region that prevents the window | 193 // Anchor the center of the window in a region that prevents the window |
165 // showing outside of the work area. | 194 // showing outside of the work area. |
166 bounds_rect.Inset(window_size_.width() / 2 + min_distance_from_edge_, | 195 bounds_rect.Inset(window_size_.width() / 2 + min_distance_from_edge_, |
167 window_size_.height() / 2 + min_distance_from_edge_); | 196 window_size_.height() / 2 + min_distance_from_edge_); |
168 | 197 |
169 anchor.SetToMax(bounds_rect.origin()); | 198 anchor.SetToMax(bounds_rect.origin()); |
170 anchor.SetToMin(bounds_rect.bottom_right()); | 199 anchor.SetToMin(bounds_rect.bottom_right()); |
171 return anchor; | 200 return anchor; |
172 } | 201 } |
OLD | NEW |