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/base/animation/animation_delegate.h" |
8 | 8 |
9 class ThrobbingImageViewAnimationDelegate : public ui::AnimationDelegate { | 9 class ThrobbingImageViewAnimationDelegate : public ui::AnimationDelegate { |
10 public: | 10 public: |
(...skipping 19 matching lines...) Expand all Loading... |
30 delegate_.reset(new ThrobbingImageViewAnimationDelegate(self)); | 30 delegate_.reset(new ThrobbingImageViewAnimationDelegate(self)); |
31 throbAnimation_.reset(new ui::ThrobAnimation(delegate_.get())); | 31 throbAnimation_.reset(new ui::ThrobAnimation(delegate_.get())); |
32 throbAnimation_->SetThrobDuration(durationMS); | 32 throbAnimation_->SetThrobDuration(durationMS); |
33 throbAnimation_->StartThrobbing(-1); | 33 throbAnimation_->StartThrobbing(-1); |
34 | 34 |
35 throbPosition_ = throbPosition; | 35 throbPosition_ = throbPosition; |
36 } | 36 } |
37 return self; | 37 return self; |
38 } | 38 } |
39 | 39 |
40 - (void)setTweenType:(ui::Tween::Type)type { | |
41 throbAnimation_->SetTweenType(type); | |
42 } | |
43 | |
44 - (void)dealloc { | 40 - (void)dealloc { |
45 throbAnimation_->Stop(); | 41 throbAnimation_->Stop(); |
46 [super dealloc]; | 42 [super dealloc]; |
47 } | 43 } |
48 | 44 |
49 - (void)drawRect:(NSRect)rect { | 45 - (void)drawRect:(NSRect)rect { |
50 [backgroundImage_ drawInRect:[self bounds] | 46 [backgroundImage_ drawInRect:[self bounds] |
51 fromRect:NSZeroRect | 47 fromRect:NSZeroRect |
52 operation:NSCompositeSourceOver | 48 operation:NSCompositeSourceOver |
53 fraction:1]; | 49 fraction:1]; |
54 | 50 |
55 NSRect b = [self bounds]; | 51 NSRect b = [self bounds]; |
56 NSRect throbImageBounds; | 52 NSRect throbImageBounds; |
57 if (throbPosition_ == kThrobPositionBottomRight) { | 53 if (throbPosition_ == kThrobPositionBottomRight) { |
58 NSSize throbImageSize = [throbImage_ size]; | 54 NSSize throbImageSize = [throbImage_ size]; |
59 throbImageBounds.origin = b.origin; | 55 throbImageBounds.origin = b.origin; |
60 throbImageBounds.origin.x += NSWidth(b) - throbImageSize.width; | 56 throbImageBounds.origin.x += NSWidth(b) - throbImageSize.width; |
61 throbImageBounds.size = throbImageSize; | 57 throbImageBounds.size = throbImageSize; |
62 } else { | 58 } else { |
63 throbImageBounds = b; | 59 throbImageBounds = b; |
64 } | 60 } |
65 [throbImage_ drawInRect:throbImageBounds | 61 [throbImage_ drawInRect:throbImageBounds |
66 fromRect:NSZeroRect | 62 fromRect:NSZeroRect |
67 operation:NSCompositeSourceOver | 63 operation:NSCompositeSourceOver |
68 fraction:throbAnimation_->GetCurrentValue()]; | 64 fraction:throbAnimation_->GetCurrentValue()]; |
69 } | 65 } |
70 | 66 |
71 @end | 67 @end |
OLD | NEW |