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/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
8 #include "ui/gfx/animation/slide_animation.h" | 8 #include "ui/gfx/animation/slide_animation.h" |
9 #include "ui/gfx/color_utils.h" | 9 #include "ui/gfx/color_utils.h" |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 anchor_rect_ = GetAnchorView()->GetBoundsInScreen(); | 197 anchor_rect_ = GetAnchorView()->GetBoundsInScreen(); |
198 anchor_rect_.Inset(anchor_view_insets_); | 198 anchor_rect_.Inset(anchor_view_insets_); |
199 return anchor_rect_; | 199 return anchor_rect_; |
200 } | 200 } |
201 | 201 |
202 void BubbleDelegateView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, | 202 void BubbleDelegateView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, |
203 Widget* widget) const { | 203 Widget* widget) const { |
204 } | 204 } |
205 | 205 |
206 void BubbleDelegateView::StartFade(bool fade_in) { | 206 void BubbleDelegateView::StartFade(bool fade_in) { |
207 #if defined(USE_AURA) | |
208 // Use AURA's window layer animation instead of fading. This ensures that | |
209 // hosts which rely on the layer animation callbacks to close the window | |
210 // work correctly. | |
211 if (fade_in) | 207 if (fade_in) |
212 GetWidget()->Show(); | 208 GetWidget()->Show(); |
213 else | 209 else |
214 GetWidget()->Close(); | 210 GetWidget()->Close(); |
215 #else | |
216 fade_animation_.reset(new gfx::SlideAnimation(this)); | |
217 fade_animation_->SetSlideDuration(GetFadeDuration()); | |
218 fade_animation_->Reset(fade_in ? 0.0 : 1.0); | |
219 if (fade_in) { | |
220 original_opacity_ = 0; | |
221 GetWidget()->SetOpacity(original_opacity_); | |
222 GetWidget()->Show(); | |
223 fade_animation_->Show(); | |
224 } else { | |
225 original_opacity_ = 255; | |
226 fade_animation_->Hide(); | |
227 } | |
228 #endif | |
229 } | 211 } |
230 | 212 |
231 void BubbleDelegateView::ResetFade() { | 213 void BubbleDelegateView::ResetFade() { |
232 fade_animation_.reset(); | 214 fade_animation_.reset(); |
233 GetWidget()->SetOpacity(original_opacity_); | 215 GetWidget()->SetOpacity(original_opacity_); |
234 } | 216 } |
235 | 217 |
236 void BubbleDelegateView::SetAlignment(BubbleBorder::BubbleAlignment alignment) { | 218 void BubbleDelegateView::SetAlignment(BubbleBorder::BubbleAlignment alignment) { |
237 GetBubbleFrameView()->bubble_border()->set_alignment(alignment); | 219 GetBubbleFrameView()->bubble_border()->set_alignment(alignment); |
238 SizeToContents(); | 220 SizeToContents(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 if (widget == GetWidget() && anchor_widget() && | 330 if (widget == GetWidget() && anchor_widget() && |
349 anchor_widget()->GetTopLevelWidget()) { | 331 anchor_widget()->GetTopLevelWidget()) { |
350 if (visible) | 332 if (visible) |
351 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); | 333 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); |
352 else | 334 else |
353 anchor_widget()->GetTopLevelWidget()->EnableInactiveRendering(); | 335 anchor_widget()->GetTopLevelWidget()->EnableInactiveRendering(); |
354 } | 336 } |
355 } | 337 } |
356 | 338 |
357 } // namespace views | 339 } // namespace views |
OLD | NEW |