| 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/history_overlay_controller.h" | 5 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 NSRect frame = NSMakeRect(0, 0, kShieldWidth, kShieldHeight); | 55 NSRect frame = NSMakeRect(0, 0, kShieldWidth, kShieldHeight); |
| 56 if ((self = [super initWithFrame:frame])) { | 56 if ((self = [super initWithFrame:frame])) { |
| 57 mode_ = mode; | 57 mode_ = mode; |
| 58 | 58 |
| 59 // If going backward, the arrow needs to be in the right half of the circle, | 59 // If going backward, the arrow needs to be in the right half of the circle, |
| 60 // so offset the X position. | 60 // so offset the X position. |
| 61 CGFloat offset = mode_ == kHistoryOverlayModeBack ? kShieldRadius : 0; | 61 CGFloat offset = mode_ == kHistoryOverlayModeBack ? kShieldRadius : 0; |
| 62 NSRect arrowRect = NSMakeRect(offset, 0, kShieldRadius, kShieldHeight); | 62 NSRect arrowRect = NSMakeRect(offset, 0, kShieldRadius, kShieldHeight); |
| 63 arrowRect = NSInsetRect(arrowRect, 10, 0); // Give a little padding. | 63 arrowRect = NSInsetRect(arrowRect, 10, 0); // Give a little padding. |
| 64 | 64 |
| 65 scoped_nsobject<NSImageView> imageView( | 65 base::scoped_nsobject<NSImageView> imageView( |
| 66 [[NSImageView alloc] initWithFrame:arrowRect]); | 66 [[NSImageView alloc] initWithFrame:arrowRect]); |
| 67 [imageView setImage:image]; | 67 [imageView setImage:image]; |
| 68 [imageView setAutoresizingMask:NSViewMinYMargin | NSViewMaxYMargin]; | 68 [imageView setAutoresizingMask:NSViewMinYMargin | NSViewMaxYMargin]; |
| 69 [self addSubview:imageView]; | 69 [self addSubview:imageView]; |
| 70 } | 70 } |
| 71 return self; | 71 return self; |
| 72 } | 72 } |
| 73 | 73 |
| 74 - (void)drawRect:(NSRect)dirtyRect { | 74 - (void)drawRect:(NSRect)dirtyRect { |
| 75 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:self.bounds]; | 75 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:self.bounds]; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 relativeTo:parent_]; | 155 relativeTo:parent_]; |
| 156 [[BrowserWindowController | 156 [[BrowserWindowController |
| 157 browserWindowControllerForView:[self view]] onHistoryOverlayShown]; | 157 browserWindowControllerForView:[self view]] onHistoryOverlayShown]; |
| 158 } | 158 } |
| 159 | 159 |
| 160 - (void)dismiss { | 160 - (void)dismiss { |
| 161 const CGFloat kFadeOutDurationSeconds = 0.4; | 161 const CGFloat kFadeOutDurationSeconds = 0.4; |
| 162 | 162 |
| 163 NSView* overlay = self.view; | 163 NSView* overlay = self.view; |
| 164 | 164 |
| 165 scoped_nsobject<CAAnimation> animation( | 165 base::scoped_nsobject<CAAnimation> animation( |
| 166 [[overlay animationForKey:@"alphaValue"] copy]); | 166 [[overlay animationForKey:@"alphaValue"] copy]); |
| 167 [animation setDelegate:self]; | 167 [animation setDelegate:self]; |
| 168 [animation setDuration:kFadeOutDurationSeconds]; | 168 [animation setDuration:kFadeOutDurationSeconds]; |
| 169 NSMutableDictionary* dictionary = | 169 NSMutableDictionary* dictionary = |
| 170 [NSMutableDictionary dictionaryWithCapacity:1]; | 170 [NSMutableDictionary dictionaryWithCapacity:1]; |
| 171 [dictionary setObject:animation forKey:@"alphaValue"]; | 171 [dictionary setObject:animation forKey:@"alphaValue"]; |
| 172 [overlay setAnimations:dictionary]; | 172 [overlay setAnimations:dictionary]; |
| 173 [[overlay animator] setAlphaValue:0.0]; | 173 [[overlay animator] setAlphaValue:0.0]; |
| 174 } | 174 } |
| 175 | 175 |
| 176 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { | 176 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { |
| 177 // Destroy the CAAnimation and its strong reference to its delegate (this | 177 // Destroy the CAAnimation and its strong reference to its delegate (this |
| 178 // class). | 178 // class). |
| 179 [self.view setAnimations:nil]; | 179 [self.view setAnimations:nil]; |
| 180 } | 180 } |
| 181 | 181 |
| 182 @end | 182 @end |
| OLD | NEW |