| 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 #import "chrome/browser/ui/cocoa/tabs/throbbing_image_view.h" | 5 #import "chrome/browser/ui/cocoa/tabs/throbbing_image_view.h" |
| 6 | 6 |
| 7 #include "ui/base/animation/animation_delegate.h" | 7 #include "ui/gfx/animation/animation_delegate.h" |
| 8 | 8 |
| 9 class ThrobbingImageViewAnimationDelegate : public ui::AnimationDelegate { | 9 class ThrobbingImageViewAnimationDelegate : public gfx::AnimationDelegate { |
| 10 public: | 10 public: |
| 11 ThrobbingImageViewAnimationDelegate(NSView* view) : view_(view) {} | 11 ThrobbingImageViewAnimationDelegate(NSView* view) : view_(view) {} |
| 12 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE { | 12 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE { |
| 13 [view_ setNeedsDisplay:YES]; | 13 [view_ setNeedsDisplay:YES]; |
| 14 } | 14 } |
| 15 private: | 15 private: |
| 16 NSView* view_; // weak | 16 NSView* view_; // weak |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 @implementation ThrobbingImageView | 19 @implementation ThrobbingImageView |
| 20 | 20 |
| 21 - (id)initWithFrame:(NSRect)rect | 21 - (id)initWithFrame:(NSRect)rect |
| 22 backgroundImage:(NSImage*)backgroundImage | 22 backgroundImage:(NSImage*)backgroundImage |
| 23 throbImage:(NSImage*)throbImage | 23 throbImage:(NSImage*)throbImage |
| 24 durationMS:(int)durationMS | 24 durationMS:(int)durationMS |
| 25 throbPosition:(ThrobPosition)throbPosition | 25 throbPosition:(ThrobPosition)throbPosition |
| 26 animationContainer:(ui::AnimationContainer*)animationContainer { | 26 animationContainer:(gfx::AnimationContainer*)animationContainer { |
| 27 if ((self = [super initWithFrame:rect])) { | 27 if ((self = [super initWithFrame:rect])) { |
| 28 backgroundImage_.reset([backgroundImage retain]); | 28 backgroundImage_.reset([backgroundImage retain]); |
| 29 throbImage_.reset([throbImage retain]); | 29 throbImage_.reset([throbImage retain]); |
| 30 | 30 |
| 31 delegate_.reset(new ThrobbingImageViewAnimationDelegate(self)); | 31 delegate_.reset(new ThrobbingImageViewAnimationDelegate(self)); |
| 32 throbAnimation_.reset(new ui::ThrobAnimation(delegate_.get())); | 32 throbAnimation_.reset(new gfx::ThrobAnimation(delegate_.get())); |
| 33 throbAnimation_->SetContainer(animationContainer); | 33 throbAnimation_->SetContainer(animationContainer); |
| 34 throbAnimation_->SetThrobDuration(durationMS); | 34 throbAnimation_->SetThrobDuration(durationMS); |
| 35 throbAnimation_->StartThrobbing(-1); | 35 throbAnimation_->StartThrobbing(-1); |
| 36 | 36 |
| 37 throbPosition_ = throbPosition; | 37 throbPosition_ = throbPosition; |
| 38 } | 38 } |
| 39 return self; | 39 return self; |
| 40 } | 40 } |
| 41 | 41 |
| 42 - (void)dealloc { | 42 - (void)dealloc { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 60 } else { | 60 } else { |
| 61 throbImageBounds = b; | 61 throbImageBounds = b; |
| 62 } | 62 } |
| 63 [throbImage_ drawInRect:throbImageBounds | 63 [throbImage_ drawInRect:throbImageBounds |
| 64 fromRect:NSZeroRect | 64 fromRect:NSZeroRect |
| 65 operation:NSCompositeSourceOver | 65 operation:NSCompositeSourceOver |
| 66 fraction:throbAnimation_->GetCurrentValue()]; | 66 fraction:throbAnimation_->GetCurrentValue()]; |
| 67 } | 67 } |
| 68 | 68 |
| 69 @end | 69 @end |
| OLD | NEW |