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/gfx/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/gfx/rect.h" |
10 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
11 #include "ui/views/bubble/bubble_frame_view.h" | 11 #include "ui/views/bubble/bubble_frame_view.h" |
12 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
13 #include "ui/views/widget/widget_observer.h" | 13 #include "ui/views/widget/widget_observer.h" |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
16 #include "ui/base/win/shell.h" | 16 #include "ui/base/win/shell.h" |
17 #endif | 17 #endif |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 void BubbleDelegateView::StartFade(bool fade_in) { | 263 void BubbleDelegateView::StartFade(bool fade_in) { |
264 #if defined(USE_AURA) | 264 #if defined(USE_AURA) |
265 // Use AURA's window layer animation instead of fading. This ensures that | 265 // Use AURA's window layer animation instead of fading. This ensures that |
266 // hosts which rely on the layer animation callbacks to close the window | 266 // hosts which rely on the layer animation callbacks to close the window |
267 // work correctly. | 267 // work correctly. |
268 if (fade_in) | 268 if (fade_in) |
269 GetWidget()->Show(); | 269 GetWidget()->Show(); |
270 else | 270 else |
271 GetWidget()->Close(); | 271 GetWidget()->Close(); |
272 #else | 272 #else |
273 fade_animation_.reset(new ui::SlideAnimation(this)); | 273 fade_animation_.reset(new gfx::SlideAnimation(this)); |
274 fade_animation_->SetSlideDuration(GetFadeDuration()); | 274 fade_animation_->SetSlideDuration(GetFadeDuration()); |
275 fade_animation_->Reset(fade_in ? 0.0 : 1.0); | 275 fade_animation_->Reset(fade_in ? 0.0 : 1.0); |
276 if (fade_in) { | 276 if (fade_in) { |
277 original_opacity_ = 0; | 277 original_opacity_ = 0; |
278 if (border_widget_) | 278 if (border_widget_) |
279 border_widget_->SetOpacity(original_opacity_); | 279 border_widget_->SetOpacity(original_opacity_); |
280 GetWidget()->SetOpacity(original_opacity_); | 280 GetWidget()->SetOpacity(original_opacity_); |
281 GetWidget()->Show(); | 281 GetWidget()->Show(); |
282 fade_animation_->Show(); | 282 fade_animation_->Show(); |
283 } else { | 283 } else { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (fade_animation_.get()) | 316 if (fade_animation_.get()) |
317 fade_animation_->Reset(); | 317 fade_animation_->Reset(); |
318 GetWidget()->Close(); | 318 GetWidget()->Close(); |
319 return true; | 319 return true; |
320 } | 320 } |
321 | 321 |
322 void BubbleDelegateView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 322 void BubbleDelegateView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
323 UpdateColorsFromTheme(theme); | 323 UpdateColorsFromTheme(theme); |
324 } | 324 } |
325 | 325 |
326 void BubbleDelegateView::AnimationEnded(const ui::Animation* animation) { | 326 void BubbleDelegateView::AnimationEnded(const gfx::Animation* animation) { |
327 if (animation != fade_animation_.get()) | 327 if (animation != fade_animation_.get()) |
328 return; | 328 return; |
329 bool closed = fade_animation_->GetCurrentValue() == 0; | 329 bool closed = fade_animation_->GetCurrentValue() == 0; |
330 fade_animation_->Reset(); | 330 fade_animation_->Reset(); |
331 if (closed) | 331 if (closed) |
332 GetWidget()->Close(); | 332 GetWidget()->Close(); |
333 } | 333 } |
334 | 334 |
335 void BubbleDelegateView::AnimationProgressed(const ui::Animation* animation) { | 335 void BubbleDelegateView::AnimationProgressed(const gfx::Animation* animation) { |
336 if (animation != fade_animation_.get()) | 336 if (animation != fade_animation_.get()) |
337 return; | 337 return; |
338 DCHECK(fade_animation_->is_animating()); | 338 DCHECK(fade_animation_->is_animating()); |
339 unsigned char opacity = fade_animation_->GetCurrentValue() * 255; | 339 unsigned char opacity = fade_animation_->GetCurrentValue() * 255; |
340 #if defined(OS_WIN) && !defined(USE_AURA) | 340 #if defined(OS_WIN) && !defined(USE_AURA) |
341 // Explicitly set the content Widget's layered style and set transparency via | 341 // Explicitly set the content Widget's layered style and set transparency via |
342 // SetLayeredWindowAttributes. This is done because initializing the Widget as | 342 // SetLayeredWindowAttributes. This is done because initializing the Widget as |
343 // transparent and setting opacity via UpdateLayeredWindow doesn't support | 343 // transparent and setting opacity via UpdateLayeredWindow doesn't support |
344 // hosting child native Windows controls. | 344 // hosting child native Windows controls. |
345 const HWND hwnd = GetWidget()->GetNativeView(); | 345 const HWND hwnd = GetWidget()->GetNativeView(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 border_widget_->ShowInactive(); | 416 border_widget_->ShowInactive(); |
417 if (anchor_widget() && anchor_widget()->GetTopLevelWidget()) | 417 if (anchor_widget() && anchor_widget()->GetTopLevelWidget()) |
418 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); | 418 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); |
419 } else { | 419 } else { |
420 if (border_widget_) | 420 if (border_widget_) |
421 border_widget_->Hide(); | 421 border_widget_->Hide(); |
422 } | 422 } |
423 } | 423 } |
424 | 424 |
425 } // namespace views | 425 } // namespace views |
OLD | NEW |