OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/views/bubble/bubble_frame_view.h" | 8 #include "ui/views/bubble/bubble_frame_view.h" |
9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
10 | 10 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 Widget* bubble_widget = CreateBubbleWidget(bubble_delegate, parent); | 114 Widget* bubble_widget = CreateBubbleWidget(bubble_delegate, parent); |
115 | 115 |
116 #if defined(OS_WIN) && !defined(USE_AURA) | 116 #if defined(OS_WIN) && !defined(USE_AURA) |
117 // First set the contents view to initialize view bounds for widget sizing. | 117 // First set the contents view to initialize view bounds for widget sizing. |
118 bubble_widget->SetContentsView(bubble_delegate->GetContentsView()); | 118 bubble_widget->SetContentsView(bubble_delegate->GetContentsView()); |
119 bubble_delegate->border_widget_ = CreateBorderWidget(bubble_delegate, parent); | 119 bubble_delegate->border_widget_ = CreateBorderWidget(bubble_delegate, parent); |
120 #endif | 120 #endif |
121 | 121 |
122 bubble_delegate->SizeToContents(); | 122 bubble_delegate->SizeToContents(); |
123 bubble_widget->AddObserver(bubble_delegate); | 123 bubble_widget->AddObserver(bubble_delegate); |
124 if (parent && parent->GetTopLevelWidget()) | |
125 parent->GetTopLevelWidget()->DisableInactiveRendering(); | |
126 return bubble_widget; | 124 return bubble_widget; |
127 } | 125 } |
128 | 126 |
129 View* BubbleDelegateView::GetInitiallyFocusedView() { | 127 View* BubbleDelegateView::GetInitiallyFocusedView() { |
130 return this; | 128 return this; |
131 } | 129 } |
132 | 130 |
133 BubbleDelegateView* BubbleDelegateView::AsBubbleDelegate() { | 131 BubbleDelegateView* BubbleDelegateView::AsBubbleDelegate() { |
134 return this; | 132 return this; |
135 } | 133 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 176 |
179 SkColor BubbleDelegateView::GetColor() const { | 177 SkColor BubbleDelegateView::GetColor() const { |
180 return color_; | 178 return color_; |
181 } | 179 } |
182 | 180 |
183 void BubbleDelegateView::Show() { | 181 void BubbleDelegateView::Show() { |
184 if (border_widget_) | 182 if (border_widget_) |
185 border_widget_->Show(); | 183 border_widget_->Show(); |
186 GetWidget()->Show(); | 184 GetWidget()->Show(); |
187 GetFocusManager()->SetFocusedView(GetInitiallyFocusedView()); | 185 GetFocusManager()->SetFocusedView(GetInitiallyFocusedView()); |
| 186 if (anchor_view() && anchor_view()->GetWidget() && |
| 187 anchor_view()->GetWidget()->GetTopLevelWidget()) |
| 188 anchor_view()->GetWidget()->GetTopLevelWidget()->DisableInactiveRendering(); |
188 } | 189 } |
189 | 190 |
190 void BubbleDelegateView::StartFade(bool fade_in) { | 191 void BubbleDelegateView::StartFade(bool fade_in) { |
191 fade_animation_.reset(new ui::SlideAnimation(this)); | 192 fade_animation_.reset(new ui::SlideAnimation(this)); |
192 fade_animation_->SetSlideDuration(kHideFadeDurationMS); | 193 fade_animation_->SetSlideDuration(kHideFadeDurationMS); |
193 fade_animation_->Reset(fade_in ? 0.0 : 1.0); | 194 fade_animation_->Reset(fade_in ? 0.0 : 1.0); |
194 if (fade_in) { | 195 if (fade_in) { |
195 original_opacity_ = 0; | 196 original_opacity_ = 0; |
196 if (border_widget_) | 197 if (border_widget_) |
197 border_widget_->SetOpacity(original_opacity_); | 198 border_widget_->SetOpacity(original_opacity_); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 279 |
279 #if defined(OS_WIN) && !defined(USE_AURA) | 280 #if defined(OS_WIN) && !defined(USE_AURA) |
280 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { | 281 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { |
281 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); | 282 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); |
282 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); | 283 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); |
283 return client_bounds; | 284 return client_bounds; |
284 } | 285 } |
285 #endif | 286 #endif |
286 | 287 |
287 } // namespace views | 288 } // namespace views |
OLD | NEW |