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 "ui/views/bubble/bubble_frame_view.h" | 5 #include "ui/views/bubble/bubble_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ui/gfx/screen.h" | 9 #include "ui/gfx/screen.h" |
10 #include "ui/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Calculate the bounds with the arrow in its updated location. | 94 // Calculate the bounds with the arrow in its updated location. |
95 return bubble_border_->GetBounds(anchor_rect, client_size); | 95 return bubble_border_->GetBounds(anchor_rect, client_size); |
96 } | 96 } |
97 | 97 |
98 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { | 98 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { |
99 bubble_border_ = border; | 99 bubble_border_ = border; |
100 set_border(bubble_border_); | 100 set_border(bubble_border_); |
101 } | 101 } |
102 | 102 |
103 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { | 103 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { |
104 return gfx::Screen::GetMonitorNearestPoint(rect.CenterPoint()).work_area(); | 104 return gfx::Screen::GetDisplayNearestPoint(rect.CenterPoint()).work_area(); |
105 } | 105 } |
106 | 106 |
107 void BubbleFrameView::MirrorArrowIfOffScreen( | 107 void BubbleFrameView::MirrorArrowIfOffScreen( |
108 bool vertical, | 108 bool vertical, |
109 const gfx::Rect& anchor_rect, | 109 const gfx::Rect& anchor_rect, |
110 const gfx::Size& client_size) { | 110 const gfx::Size& client_size) { |
111 // Check if the bounds don't fit on screen. | 111 // Check if the bounds don't fit on screen. |
112 gfx::Rect monitor_rect(GetMonitorBounds(anchor_rect)); | 112 gfx::Rect monitor_rect(GetMonitorBounds(anchor_rect)); |
113 gfx::Rect window_bounds(bubble_border_->GetBounds(anchor_rect, client_size)); | 113 gfx::Rect window_bounds(bubble_border_->GetBounds(anchor_rect, client_size)); |
114 if (GetOffScreenLength(monitor_rect, window_bounds, vertical) > 0) { | 114 if (GetOffScreenLength(monitor_rect, window_bounds, vertical) > 0) { |
115 BubbleBorder::ArrowLocation arrow = bubble_border()->arrow_location(); | 115 BubbleBorder::ArrowLocation arrow = bubble_border()->arrow_location(); |
116 // Mirror the arrow and get the new bounds. | 116 // Mirror the arrow and get the new bounds. |
117 bubble_border_->set_arrow_location( | 117 bubble_border_->set_arrow_location( |
118 vertical ? BubbleBorder::vertical_mirror(arrow) : | 118 vertical ? BubbleBorder::vertical_mirror(arrow) : |
119 BubbleBorder::horizontal_mirror(arrow)); | 119 BubbleBorder::horizontal_mirror(arrow)); |
120 gfx::Rect mirror_bounds = | 120 gfx::Rect mirror_bounds = |
121 bubble_border_->GetBounds(anchor_rect, client_size); | 121 bubble_border_->GetBounds(anchor_rect, client_size); |
122 // Restore the original arrow if mirroring doesn't show more of the bubble. | 122 // Restore the original arrow if mirroring doesn't show more of the bubble. |
123 if (GetOffScreenLength(monitor_rect, mirror_bounds, vertical) >= | 123 if (GetOffScreenLength(monitor_rect, mirror_bounds, vertical) >= |
124 GetOffScreenLength(monitor_rect, window_bounds, vertical)) | 124 GetOffScreenLength(monitor_rect, window_bounds, vertical)) |
125 bubble_border_->set_arrow_location(arrow); | 125 bubble_border_->set_arrow_location(arrow); |
126 else | 126 else |
127 SchedulePaint(); | 127 SchedulePaint(); |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 } // namespace views | 131 } // namespace views |
OLD | NEW |