| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/pinned_contents_info_bubble.h" | |
| 6 | |
| 7 #include "views/bubble/bubble_border.h" | |
| 8 | |
| 9 void PinnedContentsBorderContents::SizeAndGetBounds( | |
| 10 const gfx::Rect& position_relative_to, | |
| 11 views::BubbleBorder::ArrowLocation arrow_location, | |
| 12 bool allow_bubble_offscreen, | |
| 13 const gfx::Size& contents_size, | |
| 14 gfx::Rect* contents_bounds, | |
| 15 gfx::Rect* window_bounds) { | |
| 16 // Arrow offset is calculated from the middle of the |position_relative_to|. | |
| 17 int offset = position_relative_to.x() + (position_relative_to.width() / 2); | |
| 18 offset -= bubble_anchor_.x(); | |
| 19 | |
| 20 gfx::Insets insets; | |
| 21 bubble_border()->GetInsets(&insets); | |
| 22 offset += content_margins().left() + insets.left() + 1; | |
| 23 bubble_border()->SetArrowOffset(offset, contents_size); | |
| 24 | |
| 25 BorderContents::SizeAndGetBounds( | |
| 26 position_relative_to, arrow_location, | |
| 27 true, // Don't move the bubble around if it does not fit on the screen. | |
| 28 contents_size, contents_bounds, window_bounds); | |
| 29 | |
| 30 // Now move the y position to make sure the bubble contents overlap the view. | |
| 31 window_bounds->Offset(0, -(content_margins().top() + 1)); | |
| 32 } | |
| 33 | |
| 34 // Bubble ----------------------------------------------------------------- | |
| 35 | |
| 36 // static | |
| 37 PinnedContentsInfoBubble* PinnedContentsInfoBubble::Show( | |
| 38 views::Widget* parent, | |
| 39 const gfx::Rect& position_relative_to, | |
| 40 views::BubbleBorder::ArrowLocation arrow_location, | |
| 41 const gfx::Point& bubble_anchor, | |
| 42 views::View* contents, | |
| 43 BubbleDelegate* delegate) { | |
| 44 PinnedContentsInfoBubble* bubble = | |
| 45 new PinnedContentsInfoBubble(bubble_anchor); | |
| 46 bubble->InitBubble(parent, position_relative_to, arrow_location, | |
| 47 views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, | |
| 48 contents, delegate); | |
| 49 return bubble; | |
| 50 } | |
| 51 | |
| 52 BorderContents* PinnedContentsInfoBubble::CreateBorderContents() { | |
| 53 return new PinnedContentsBorderContents(bubble_anchor_); | |
| 54 } | |
| OLD | NEW |