Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: chrome/browser/ui/cocoa/tabs/throbbing_image_view.mm

Issue 13867007: Tab audio indicator: Use animation container on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:
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 ui::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 if ((self = [super initWithFrame:rect])) { 27 if ((self = [super initWithFrame:rect])) {
27 backgroundImage_.reset([backgroundImage retain]); 28 backgroundImage_.reset([backgroundImage retain]);
28 throbImage_.reset([throbImage retain]); 29 throbImage_.reset([throbImage retain]);
29 30
30 delegate_.reset(new ThrobbingImageViewAnimationDelegate(self)); 31 delegate_.reset(new ThrobbingImageViewAnimationDelegate(self));
31 throbAnimation_.reset(new ui::ThrobAnimation(delegate_.get())); 32 throbAnimation_.reset(new ui::ThrobAnimation(delegate_.get()));
33 throbAnimation_->SetContainer(animationContainer);
32 throbAnimation_->SetThrobDuration(durationMS); 34 throbAnimation_->SetThrobDuration(durationMS);
33 throbAnimation_->StartThrobbing(-1); 35 throbAnimation_->StartThrobbing(-1);
34 36
35 throbPosition_ = throbPosition; 37 throbPosition_ = throbPosition;
36 } 38 }
37 return self; 39 return self;
38 } 40 }
39 41
40 - (void)dealloc { 42 - (void)dealloc {
41 throbAnimation_->Stop(); 43 throbAnimation_->Stop();
(...skipping 16 matching lines...) Expand all
58 } else { 60 } else {
59 throbImageBounds = b; 61 throbImageBounds = b;
60 } 62 }
61 [throbImage_ drawInRect:throbImageBounds 63 [throbImage_ drawInRect:throbImageBounds
62 fromRect:NSZeroRect 64 fromRect:NSZeroRect
63 operation:NSCompositeSourceOver 65 operation:NSCompositeSourceOver
64 fraction:throbAnimation_->GetCurrentValue()]; 66 fraction:throbAnimation_->GetCurrentValue()];
65 } 67 }
66 68
67 @end 69 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/throbbing_image_view.h ('k') | chrome/browser/ui/cocoa/tabs/throbbing_image_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698