| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "chrome/browser/ui/cocoa/tabs/media_indicator_view.h" | 5 #import "chrome/browser/ui/cocoa/tabs/media_indicator_view.h" |
| 6 | 6 |
| 7 #include "ui/gfx/animation/animation.h" | 7 #include "ui/gfx/animation/animation.h" |
| 8 #include "ui/gfx/animation/animation_delegate.h" | 8 #include "ui/gfx/animation/animation_delegate.h" |
| 9 #include "ui/gfx/image/image.h" | 9 #include "ui/gfx/image/image.h" |
| 10 | 10 |
| 11 class MediaIndicatorViewAnimationDelegate : public gfx::AnimationDelegate { | 11 class MediaIndicatorViewAnimationDelegate : public gfx::AnimationDelegate { |
| 12 public: | 12 public: |
| 13 MediaIndicatorViewAnimationDelegate(NSView* view, | 13 MediaIndicatorViewAnimationDelegate(NSView* view, |
| 14 TabMediaState* mediaState, | 14 TabMediaState* mediaState, |
| 15 TabMediaState* animatingMediaState) | 15 TabMediaState* animatingMediaState) |
| 16 : view_(view), mediaState_(mediaState), | 16 : view_(view), mediaState_(mediaState), |
| 17 animatingMediaState_(animatingMediaState), | 17 animatingMediaState_(animatingMediaState), |
| 18 doneCallbackObject_(nil), doneCallbackSelector_(nil) {} | 18 doneCallbackObject_(nil), doneCallbackSelector_(nil) {} |
| 19 virtual ~MediaIndicatorViewAnimationDelegate() {} | 19 virtual ~MediaIndicatorViewAnimationDelegate() {} |
| 20 | 20 |
| 21 void SetAnimationDoneCallback(id anObject, SEL selector) { | 21 void SetAnimationDoneCallback(id anObject, SEL selector) { |
| 22 doneCallbackObject_ = anObject; | 22 doneCallbackObject_ = anObject; |
| 23 doneCallbackSelector_ = selector; | 23 doneCallbackSelector_ = selector; |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE { | 26 virtual void AnimationEnded(const gfx::Animation* animation) override { |
| 27 *animatingMediaState_ = *mediaState_; | 27 *animatingMediaState_ = *mediaState_; |
| 28 [view_ setNeedsDisplay:YES]; | 28 [view_ setNeedsDisplay:YES]; |
| 29 [doneCallbackObject_ performSelector:doneCallbackSelector_]; | 29 [doneCallbackObject_ performSelector:doneCallbackSelector_]; |
| 30 } | 30 } |
| 31 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE { | 31 virtual void AnimationProgressed(const gfx::Animation* animation) override { |
| 32 [view_ setNeedsDisplay:YES]; | 32 [view_ setNeedsDisplay:YES]; |
| 33 } | 33 } |
| 34 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE { | 34 virtual void AnimationCanceled(const gfx::Animation* animation) override { |
| 35 AnimationEnded(animation); | 35 AnimationEnded(animation); |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 NSView* const view_; | 39 NSView* const view_; |
| 40 TabMediaState* const mediaState_; | 40 TabMediaState* const mediaState_; |
| 41 TabMediaState* const animatingMediaState_; | 41 TabMediaState* const animatingMediaState_; |
| 42 | 42 |
| 43 id doneCallbackObject_; | 43 id doneCallbackObject_; |
| 44 SEL doneCallbackSelector_; | 44 SEL doneCallbackSelector_; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 fromRect:NSZeroRect | 105 fromRect:NSZeroRect |
| 106 operation:NSCompositeSourceOver | 106 operation:NSCompositeSourceOver |
| 107 fraction:opaqueness]; | 107 fraction:opaqueness]; |
| 108 } | 108 } |
| 109 | 109 |
| 110 - (void)disableAnimations { | 110 - (void)disableAnimations { |
| 111 delegate_.reset(); | 111 delegate_.reset(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 @end | 114 @end |
| OLD | NEW |