Chromium Code Reviews| Index: ui/views/bubble/bubble_delegate.cc |
| diff --git a/ui/views/bubble/bubble_delegate.cc b/ui/views/bubble/bubble_delegate.cc |
| index f262a3346a049ffe29c8a7c29042dc91509c62d0..211b5048ffc47370ff278b4209ec13815bd1e82c 100644 |
| --- a/ui/views/bubble/bubble_delegate.cc |
| +++ b/ui/views/bubble/bubble_delegate.cc |
| @@ -154,12 +154,12 @@ void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, |
| } |
| } |
| -gfx::Point BubbleDelegateView::GetAnchorPoint() { |
| +gfx::Rect BubbleDelegateView::GetAnchorRect() { |
| if (!anchor_view()) |
| - return gfx::Point(); |
| + return gfx::Rect(); |
| BubbleBorder::ArrowLocation location = GetArrowLocation(); |
| - gfx::Point anchor(anchor_view()->bounds().CenterPoint()); |
| + gfx::Point anchor; |
| // By default, pick the middle of |anchor_view_|'s edge opposite the arrow. |
| if (BubbleBorder::is_arrow_on_horizontal(location)) { |
| anchor.SetPoint(anchor_view()->width() / 2, |
| @@ -168,9 +168,11 @@ gfx::Point BubbleDelegateView::GetAnchorPoint() { |
| anchor.SetPoint( |
| BubbleBorder::is_arrow_on_left(location) ? anchor_view()->width() : 0, |
| anchor_view_->height() / 2); |
| + } else { |
| + anchor = anchor_view()->bounds().CenterPoint(); |
| } |
| View::ConvertPointToScreen(anchor_view(), &anchor); |
| - return anchor; |
| + return gfx::Rect(anchor, gfx::Size()); |
| } |
| BubbleBorder::ArrowLocation BubbleDelegateView::GetArrowLocation() const { |
| @@ -215,6 +217,12 @@ void BubbleDelegateView::ResetFade() { |
| GetWidget()->SetOpacity(original_opacity_); |
| } |
| +void BubbleDelegateView::SetAlignment(BubbleBorder::BubbleAlignment alignment) { |
| + GetBubbleFrameView()->bubble_border()->set_alignment( |
| + views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
|
msw
2011/12/08 00:40:14
Pass along alignment, not this hard-coded value.
sail
2011/12/08 01:41:10
Done.
|
| + SizeToContents(); |
| +} |
| + |
| bool BubbleDelegateView::AcceleratorPressed( |
| const ui::Accelerator& accelerator) { |
| if (!close_on_esc() || accelerator.key_code() != ui::VKEY_ESCAPE) |
| @@ -276,8 +284,8 @@ BubbleFrameView* BubbleDelegateView::GetBubbleFrameView() const { |
| gfx::Rect BubbleDelegateView::GetBubbleBounds() { |
| // The argument rect has its origin at the bubble's arrow anchor point; |
| // its size is the preferred size of the bubble's client view (this view). |
| - return GetBubbleFrameView()->GetWindowBoundsForClientBounds( |
| - gfx::Rect(GetAnchorPoint(), GetPreferredSize())); |
| + return GetBubbleFrameView()->GetWindowBoundsForAnchorAndClientSize( |
| + GetAnchorRect(), GetPreferredSize()); |
| } |
| #if defined(OS_WIN) && !defined(USE_AURA) |