| 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/hover_close_button.h" | 5 #import "chrome/browser/ui/cocoa/hover_close_button.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 imageID = IDR_CLOSE_1_H; | 169 imageID = IDR_CLOSE_1_H; |
| 170 break; | 170 break; |
| 171 case kHoverStateMouseDown: | 171 case kHoverStateMouseDown: |
| 172 imageID = IDR_CLOSE_1_P; | 172 imageID = IDR_CLOSE_1_P; |
| 173 break; | 173 break; |
| 174 } | 174 } |
| 175 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 175 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 176 return bundle.GetNativeImageNamed(imageID).ToNSImage(); | 176 return bundle.GetNativeImageNamed(imageID).ToNSImage(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 - (void)setHoverState:(HoverState)state { | 179 - (void)mouseExited:(NSEvent*)event { |
| 180 if (state != self.hoverState) { | 180 previousState_ = self.hoverState; |
| 181 previousState_ = self.hoverState; | 181 [super mouseExited:event]; |
| 182 [super setHoverState:state]; | 182 |
| 183 // Only animate the HoverStateNone case. | 183 // Only animate the HoverStateNone case. |
| 184 if (state == kHoverStateNone) { | 184 if (self.hoverState == kHoverStateNone) { |
| 185 DCHECK(fadeOutAnimation_ == nil); | 185 DCHECK(fadeOutAnimation_ == nil); |
| 186 fadeOutAnimation_ = | 186 fadeOutAnimation_ = |
| 187 [[GTMKeyValueAnimation alloc] initWithTarget:self | 187 [[GTMKeyValueAnimation alloc] initWithTarget:self |
| 188 keyPath:kFadeOutValueKeyPath]; | 188 keyPath:kFadeOutValueKeyPath]; |
| 189 [fadeOutAnimation_ setDuration:kCloseAnimationDuration]; | 189 [fadeOutAnimation_ setDuration:kCloseAnimationDuration]; |
| 190 [fadeOutAnimation_ setFrameRate:kFramesPerSecond]; | 190 [fadeOutAnimation_ setFrameRate:kFramesPerSecond]; |
| 191 [fadeOutAnimation_ setDelegate:self]; | 191 [fadeOutAnimation_ setDelegate:self]; |
| 192 [fadeOutAnimation_ startAnimation]; | 192 [fadeOutAnimation_ startAnimation]; |
| 193 } else { | 193 } else { |
| 194 // -stopAnimation will call the animationDidStop: delegate method | 194 // -stopAnimation will call the animationDidStop: delegate method |
| 195 // which will clean up the animation. | 195 // which will clean up the animation. |
| 196 [fadeOutAnimation_ stopAnimation]; | 196 [fadeOutAnimation_ stopAnimation]; |
| 197 } | |
| 198 } | 197 } |
| 199 } | 198 } |
| 200 | 199 |
| 201 - (void)commonInit { | 200 - (void)commonInit { |
| 202 // Set accessibility description. | 201 // Set accessibility description. |
| 203 NSCell* cell = [self cell]; | 202 NSCell* cell = [self cell]; |
| 204 [cell accessibilitySetOverrideValue:gDescription | 203 [cell accessibilitySetOverrideValue:gDescription |
| 205 forAttribute:NSAccessibilityDescriptionAttribute]; | 204 forAttribute:NSAccessibilityDescriptionAttribute]; |
| 206 | 205 |
| 207 // Add a tooltip. Using 'owner:self' means that | 206 // Add a tooltip. Using 'owner:self' means that |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 break; | 245 break; |
| 247 case kHoverStateMouseDown: | 246 case kHoverStateMouseDown: |
| 248 imageID = IDR_CLOSE_DIALOG_P; | 247 imageID = IDR_CLOSE_DIALOG_P; |
| 249 break; | 248 break; |
| 250 } | 249 } |
| 251 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 250 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 252 return bundle.GetNativeImageNamed(imageID).ToNSImage(); | 251 return bundle.GetNativeImageNamed(imageID).ToNSImage(); |
| 253 } | 252 } |
| 254 | 253 |
| 255 @end | 254 @end |
| OLD | NEW |