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 "ash/shelf/overflow_bubble_view.h" | 5 #include "ash/shelf/overflow_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf_constants.h" | 10 #include "ash/shelf/shelf_constants.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 DCHECK_GE(contents_size.width(), visible_bounds.width()); | 105 DCHECK_GE(contents_size.width(), visible_bounds.width()); |
106 int y = std::min(contents_size.height() - visible_bounds.height(), | 106 int y = std::min(contents_size.height() - visible_bounds.height(), |
107 std::max(0, scroll_offset_.y() + y_offset)); | 107 std::max(0, scroll_offset_.y() + y_offset)); |
108 scroll_offset_.set_y(y); | 108 scroll_offset_.set_y(y); |
109 } | 109 } |
110 | 110 |
111 gfx::Size OverflowBubbleView::GetPreferredSize() const { | 111 gfx::Size OverflowBubbleView::GetPreferredSize() const { |
112 gfx::Size preferred_size = GetContentsSize(); | 112 gfx::Size preferred_size = GetContentsSize(); |
113 | 113 |
114 const gfx::Rect monitor_rect = Shell::GetScreen()->GetDisplayNearestPoint( | 114 const gfx::Rect monitor_rect = |
115 GetAnchorRect().CenterPoint()).work_area(); | 115 gfx::Screen::GetScreen() |
| 116 ->GetDisplayNearestPoint(GetAnchorRect().CenterPoint()) |
| 117 .work_area(); |
116 if (!monitor_rect.IsEmpty()) { | 118 if (!monitor_rect.IsEmpty()) { |
117 if (IsHorizontalAlignment()) { | 119 if (IsHorizontalAlignment()) { |
118 preferred_size.set_width(std::min( | 120 preferred_size.set_width(std::min( |
119 preferred_size.width(), | 121 preferred_size.width(), |
120 static_cast<int>(monitor_rect.width() * | 122 static_cast<int>(monitor_rect.width() * |
121 kMaxBubbleSizeToScreenRatio))); | 123 kMaxBubbleSizeToScreenRatio))); |
122 } else { | 124 } else { |
123 preferred_size.set_height(std::min( | 125 preferred_size.set_height(std::min( |
124 preferred_size.height(), | 126 preferred_size.height(), |
125 static_cast<int>(monitor_rect.height() * | 127 static_cast<int>(monitor_rect.height() * |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 189 |
188 const gfx::Size content_size = GetPreferredSize(); | 190 const gfx::Size content_size = GetPreferredSize(); |
189 border->set_arrow_offset(arrow_offset); | 191 border->set_arrow_offset(arrow_offset); |
190 | 192 |
191 const gfx::Rect anchor_rect = GetAnchorRect(); | 193 const gfx::Rect anchor_rect = GetAnchorRect(); |
192 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds( | 194 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds( |
193 anchor_rect, | 195 anchor_rect, |
194 content_size, | 196 content_size, |
195 false); | 197 false); |
196 | 198 |
197 gfx::Rect monitor_rect = Shell::GetScreen()->GetDisplayNearestPoint( | 199 gfx::Rect monitor_rect = |
198 anchor_rect.CenterPoint()).work_area(); | 200 gfx::Screen::GetScreen() |
| 201 ->GetDisplayNearestPoint(anchor_rect.CenterPoint()) |
| 202 .work_area(); |
199 | 203 |
200 int offset = 0; | 204 int offset = 0; |
201 if (views::BubbleBorder::is_arrow_on_horizontal(arrow())) { | 205 if (views::BubbleBorder::is_arrow_on_horizontal(arrow())) { |
202 if (bubble_rect.x() < monitor_rect.x()) | 206 if (bubble_rect.x() < monitor_rect.x()) |
203 offset = monitor_rect.x() - bubble_rect.x(); | 207 offset = monitor_rect.x() - bubble_rect.x(); |
204 else if (bubble_rect.right() > monitor_rect.right()) | 208 else if (bubble_rect.right() > monitor_rect.right()) |
205 offset = monitor_rect.right() - bubble_rect.right(); | 209 offset = monitor_rect.right() - bubble_rect.right(); |
206 | 210 |
207 bubble_rect.Offset(offset, 0); | 211 bubble_rect.Offset(offset, 0); |
208 border->set_arrow_offset(anchor_rect.CenterPoint().x() - bubble_rect.x()); | 212 border->set_arrow_offset(anchor_rect.CenterPoint().x() - bubble_rect.x()); |
209 } else { | 213 } else { |
210 if (bubble_rect.y() < monitor_rect.y()) | 214 if (bubble_rect.y() < monitor_rect.y()) |
211 offset = monitor_rect.y() - bubble_rect.y(); | 215 offset = monitor_rect.y() - bubble_rect.y(); |
212 else if (bubble_rect.bottom() > monitor_rect.bottom()) | 216 else if (bubble_rect.bottom() > monitor_rect.bottom()) |
213 offset = monitor_rect.bottom() - bubble_rect.bottom(); | 217 offset = monitor_rect.bottom() - bubble_rect.bottom(); |
214 | 218 |
215 bubble_rect.Offset(0, offset); | 219 bubble_rect.Offset(0, offset); |
216 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); | 220 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); |
217 } | 221 } |
218 | 222 |
219 GetBubbleFrameView()->SchedulePaint(); | 223 GetBubbleFrameView()->SchedulePaint(); |
220 return bubble_rect; | 224 return bubble_rect; |
221 } | 225 } |
222 | 226 |
223 } // namespace ash | 227 } // namespace ash |
OLD | NEW |