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