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_delegate.h" | 5 #include "ui/views/bubble/bubble_delegate.h" |
6 | 6 |
7 #include "ui/base/animation/slide_animation.h" | 7 #include "ui/base/animation/slide_animation.h" |
8 #include "ui/gfx/color_utils.h" | 8 #include "ui/gfx/color_utils.h" |
| 9 #include "ui/gfx/rect.h" |
9 #include "ui/views/bubble/bubble_frame_view.h" | 10 #include "ui/views/bubble/bubble_frame_view.h" |
10 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
11 #include "ui/views/widget/widget_observer.h" | 12 #include "ui/views/widget/widget_observer.h" |
12 | 13 |
13 // The duration of the fade animation in milliseconds. | 14 // The duration of the fade animation in milliseconds. |
14 static const int kHideFadeDurationMS = 200; | 15 static const int kHideFadeDurationMS = 200; |
15 | 16 |
16 // The defaut margin between the content and the inside border, in pixels. | 17 // The defaut margin between the content and the inside border, in pixels. |
17 static const int kDefaultMargin = 6; | 18 static const int kDefaultMargin = 6; |
18 | 19 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 border_widget_->Hide(); | 223 border_widget_->Hide(); |
223 } | 224 } |
224 } | 225 } |
225 | 226 |
226 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, | 227 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, |
227 bool active) { | 228 bool active) { |
228 if (close_on_deactivate() && widget == GetWidget() && !active) | 229 if (close_on_deactivate() && widget == GetWidget() && !active) |
229 GetWidget()->Close(); | 230 GetWidget()->Close(); |
230 } | 231 } |
231 | 232 |
232 void BubbleDelegateView::OnWidgetMoved(Widget* widget) { | 233 void BubbleDelegateView::OnWidgetBoundsChanged(Widget* widget, |
| 234 const gfx::Rect& new_bounds) { |
233 if (move_with_anchor() && anchor_widget() == widget) | 235 if (move_with_anchor() && anchor_widget() == widget) |
234 SizeToContents(); | 236 SizeToContents(); |
235 } | 237 } |
236 | 238 |
237 gfx::Rect BubbleDelegateView::GetAnchorRect() { | 239 gfx::Rect BubbleDelegateView::GetAnchorRect() { |
238 if (!anchor_view()) | 240 if (!anchor_view()) |
239 return gfx::Rect(anchor_point_, gfx::Size()); | 241 return gfx::Rect(anchor_point_, gfx::Size()); |
240 gfx::Rect anchor_bounds = anchor_view()->GetBoundsInScreen(); | 242 gfx::Rect anchor_bounds = anchor_view()->GetBoundsInScreen(); |
241 anchor_bounds.Inset(anchor_insets_); | 243 anchor_bounds.Inset(anchor_insets_); |
242 return anchor_bounds; | 244 return anchor_bounds; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 #if defined(OS_WIN) && !defined(USE_AURA) | 349 #if defined(OS_WIN) && !defined(USE_AURA) |
348 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { | 350 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { |
349 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); | 351 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); |
350 client_bounds.Offset( | 352 client_bounds.Offset( |
351 border_widget_->GetWindowBoundsInScreen().OffsetFromOrigin()); | 353 border_widget_->GetWindowBoundsInScreen().OffsetFromOrigin()); |
352 return client_bounds; | 354 return client_bounds; |
353 } | 355 } |
354 #endif | 356 #endif |
355 | 357 |
356 } // namespace views | 358 } // namespace views |
OLD | NEW |