| 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/launcher/overflow_bubble.h" | 5 #include "ash/launcher/overflow_bubble.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
| 10 #include "ash/launcher/launcher_view.h" | 10 #include "ash/launcher/launcher_view.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 gfx::Insets bubble_insets; | 200 gfx::Insets bubble_insets; |
| 201 border->GetInsets(&bubble_insets); | 201 border->GetInsets(&bubble_insets); |
| 202 | 202 |
| 203 const int border_size = | 203 const int border_size = |
| 204 views::BubbleBorder::is_arrow_on_horizontal(arrow_location()) ? | 204 views::BubbleBorder::is_arrow_on_horizontal(arrow_location()) ? |
| 205 bubble_insets.left() : bubble_insets.top(); | 205 bubble_insets.left() : bubble_insets.top(); |
| 206 const int arrow_offset = border_size + kPadding + kLauncherViewLeadingInset + | 206 const int arrow_offset = border_size + kPadding + kLauncherViewLeadingInset + |
| 207 kLauncherPreferredSize / 2; | 207 kLauncherPreferredSize / 2; |
| 208 | 208 |
| 209 const gfx::Size content_size = GetPreferredSize(); | 209 const gfx::Size content_size = GetPreferredSize(); |
| 210 border->SetArrowOffset(arrow_offset, content_size); | 210 border->set_arrow_offset(arrow_offset); |
| 211 | 211 |
| 212 const gfx::Rect anchor_rect = GetAnchorRect(); | 212 const gfx::Rect anchor_rect = GetAnchorRect(); |
| 213 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds( | 213 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds( |
| 214 anchor_rect, | 214 anchor_rect, |
| 215 content_size, | 215 content_size, |
| 216 false); | 216 false); |
| 217 | 217 |
| 218 gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestPoint( | 218 gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestPoint( |
| 219 anchor_rect.CenterPoint()).work_area(); | 219 anchor_rect.CenterPoint()).work_area(); |
| 220 | 220 |
| 221 int offset = 0; | 221 int offset = 0; |
| 222 if (views::BubbleBorder::is_arrow_on_horizontal(arrow_location())) { | 222 if (views::BubbleBorder::is_arrow_on_horizontal(arrow_location())) { |
| 223 if (bubble_rect.x() < monitor_rect.x()) | 223 if (bubble_rect.x() < monitor_rect.x()) |
| 224 offset = monitor_rect.x() - bubble_rect.x(); | 224 offset = monitor_rect.x() - bubble_rect.x(); |
| 225 else if (bubble_rect.right() > monitor_rect.right()) | 225 else if (bubble_rect.right() > monitor_rect.right()) |
| 226 offset = monitor_rect.right() - bubble_rect.right(); | 226 offset = monitor_rect.right() - bubble_rect.right(); |
| 227 | 227 |
| 228 bubble_rect.Offset(offset, 0); | 228 bubble_rect.Offset(offset, 0); |
| 229 border->SetArrowOffset(anchor_rect.CenterPoint().x() - bubble_rect.x(), | 229 border->set_arrow_offset(anchor_rect.CenterPoint().x() - bubble_rect.x()); |
| 230 content_size); | |
| 231 } else { | 230 } else { |
| 232 if (bubble_rect.y() < monitor_rect.y()) | 231 if (bubble_rect.y() < monitor_rect.y()) |
| 233 offset = monitor_rect.y() - bubble_rect.y(); | 232 offset = monitor_rect.y() - bubble_rect.y(); |
| 234 else if (bubble_rect.bottom() > monitor_rect.bottom()) | 233 else if (bubble_rect.bottom() > monitor_rect.bottom()) |
| 235 offset = monitor_rect.bottom() - bubble_rect.bottom(); | 234 offset = monitor_rect.bottom() - bubble_rect.bottom(); |
| 236 | 235 |
| 237 bubble_rect.Offset(0, offset); | 236 bubble_rect.Offset(0, offset); |
| 238 border->SetArrowOffset(anchor_rect.CenterPoint().y() - bubble_rect.y(), | 237 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); |
| 239 content_size); | |
| 240 } | 238 } |
| 241 | 239 |
| 242 GetBubbleFrameView()->SchedulePaint(); | 240 GetBubbleFrameView()->SchedulePaint(); |
| 243 return bubble_rect; | 241 return bubble_rect; |
| 244 } | 242 } |
| 245 | 243 |
| 246 } // namespace | 244 } // namespace |
| 247 | 245 |
| 248 OverflowBubble::OverflowBubble() | 246 OverflowBubble::OverflowBubble() |
| 249 : bubble_(NULL) { | 247 : bubble_(NULL) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 bubble_ = NULL; | 279 bubble_ = NULL; |
| 282 } | 280 } |
| 283 | 281 |
| 284 void OverflowBubble::OnWidgetClosing(views::Widget* widget) { | 282 void OverflowBubble::OnWidgetClosing(views::Widget* widget) { |
| 285 DCHECK(widget == bubble_->GetWidget()); | 283 DCHECK(widget == bubble_->GetWidget()); |
| 286 bubble_ = NULL; | 284 bubble_ = NULL; |
| 287 } | 285 } |
| 288 | 286 |
| 289 } // namespace internal | 287 } // namespace internal |
| 290 } // namespace ash | 288 } // namespace ash |
| OLD | NEW |