OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/popup_blocked_animation.h" | 5 #include "chrome/browser/popup_blocked_animation.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #import <QuartzCore/QuartzCore.h> | 8 #import <QuartzCore/QuartzCore.h> |
9 | 9 |
10 #import "base/nsimage_cache_mac.h" | 10 #import "base/nsimage_cache_mac.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 CGFloat dY = NSHeight(animationFrame) / 2 - imageHeight / 2; | 101 CGFloat dY = NSHeight(animationFrame) / 2 - imageHeight / 2; |
102 animationFrame.origin.x += dX; | 102 animationFrame.origin.x += dX; |
103 animationFrame.origin.y += dY; | 103 animationFrame.origin.y += dY; |
104 animationFrame.size.width -= dX; | 104 animationFrame.size.width -= dX; |
105 animationFrame.size.height -= dY; | 105 animationFrame.size.height -= dY; |
106 animation_ = [[AnimatableImage alloc] initWithImage:image | 106 animation_ = [[AnimatableImage alloc] initWithImage:image |
107 animationFrame:animationFrame]; | 107 animationFrame:animationFrame]; |
108 [parentWindow addChildWindow:animation_ ordered:NSWindowAbove]; | 108 [parentWindow addChildWindow:animation_ ordered:NSWindowAbove]; |
109 | 109 |
110 // Start the animation from the center of the window. | 110 // Start the animation from the center of the window. |
111 NSRect contentFrame = [[animation_ contentView] frame]; | |
112 [animation_ setStartFrame:CGRectMake(0, | 111 [animation_ setStartFrame:CGRectMake(0, |
113 imageHeight / 2, | 112 imageHeight / 2, |
114 imageWidth, | 113 imageWidth, |
115 imageHeight)]; | 114 imageHeight)]; |
116 | 115 |
117 // Set the end frame to be small (a la the actual blocked icon) and inset | 116 // Set the end frame to be small (a la the actual blocked icon) and inset |
118 // slightly to the Omnibox. While the geometry won't align perfectly, it's | 117 // slightly to the Omnibox. While the geometry won't align perfectly, it's |
119 // close enough for the user to take note of the new icon. These numbers | 118 // close enough for the user to take note of the new icon. These numbers |
120 // come from measuring the Omnibox without any page actions. | 119 // come from measuring the Omnibox without any page actions. |
121 CGRect endFrame = CGRectMake(animationFrame.size.width - 115, | 120 CGRect endFrame = CGRectMake(animationFrame.size.width - 115, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 [[animation_ parentWindow] removeChildWindow:animation_]; | 171 [[animation_ parentWindow] removeChildWindow:animation_]; |
173 [self release]; | 172 [self release]; |
174 } | 173 } |
175 | 174 |
176 @end | 175 @end |
177 | 176 |
178 void PopupBlockedAnimation::Show(TabContents* tab_contents) { | 177 void PopupBlockedAnimation::Show(TabContents* tab_contents) { |
179 // The object will clean up itself at the end of the animation. | 178 // The object will clean up itself at the end of the animation. |
180 [[PopupBlockedAnimationMac alloc] initWithTabContents:tab_contents]; | 179 [[PopupBlockedAnimationMac alloc] initWithTabContents:tab_contents]; |
181 } | 180 } |
OLD | NEW |