aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AppKit/GTMNSAnimation+Duration.h42
-rw-r--r--AppKit/GTMNSAnimation+Duration.m55
-rw-r--r--GTM.xcodeproj/project.pbxproj8
-rw-r--r--ReleaseNotes.txt4
4 files changed, 109 insertions, 0 deletions
diff --git a/AppKit/GTMNSAnimation+Duration.h b/AppKit/GTMNSAnimation+Duration.h
new file mode 100644
index 0000000..54b3070
--- /dev/null
+++ b/AppKit/GTMNSAnimation+Duration.h
@@ -0,0 +1,42 @@
+//
+// GTMNSAnimation+Duration.h
+//
+// Copyright 2009 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <AppKit/AppKit.h>
+#import "GTMDefines.h"
+
+// A category for changing the duration of an animation based on the current
+// event. Right now it tracks the state of the shift and control keys to slow
+// down animations appropriately similar to how minimize window animations
+// occur.
+@interface NSAnimation (GTMNSAnimationDurationAdditions)
+- (void)gtm_setDuration:(NSTimeInterval)duration;
+@end
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+
+#import <QuartzCore/QuartzCore.h>
+
+// A category for changing the duration of an animation based on the current
+// event. Right now it tracks the state of the shift and control keys to slow
+// down animations appropriately similar to how minimize window animations
+// occur.
+@interface CAAnimation (GTMCAAnimationDurationAdditions)
+- (void)gtm_setDuration:(CFTimeInterval)duration;
+@end
+
+#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
diff --git a/AppKit/GTMNSAnimation+Duration.m b/AppKit/GTMNSAnimation+Duration.m
new file mode 100644
index 0000000..f8d0ced
--- /dev/null
+++ b/AppKit/GTMNSAnimation+Duration.m
@@ -0,0 +1,55 @@
+//
+// GTMNSAnimation+Duration.m
+//
+// Copyright 2009 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import "GTMNSAnimation+Duration.h"
+
+static NSTimeInterval GTMCurrentDurationMultiplier(void) {
+ NSEvent *event = [NSApp currentEvent];
+ NSUInteger modifiers = [event modifierFlags];
+ NSTimeInterval duration = 1.0;
+ if (modifiers & NSShiftKeyMask) {
+ duration *= 0.2;
+ }
+ // These are additive, so shift+control returns 0.1 * duration.
+ if (modifiers & NSControlKeyMask) {
+ duration *= 0.5;
+ }
+ return duration;
+}
+
+@implementation NSAnimation (GTMNSAnimationDurationAdditions)
+
+- (void)gtm_setDuration:(NSTimeInterval)duration {
+ duration = duration * GTMCurrentDurationMultiplier();
+ [self setDuration:duration];
+}
+
+@end
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+
+@implementation CAAnimation (GTMCAAnimationDurationAdditions)
+
+- (void)gtm_setDuration:(CFTimeInterval)duration {
+ duration = duration * GTMCurrentDurationMultiplier();
+ [self setDuration:duration];
+}
+
+@end
+
+#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
diff --git a/GTM.xcodeproj/project.pbxproj b/GTM.xcodeproj/project.pbxproj
index b236943..ae1d0e9 100644
--- a/GTM.xcodeproj/project.pbxproj
+++ b/GTM.xcodeproj/project.pbxproj
@@ -81,6 +81,8 @@
84B91B8B0EA3CC2E0087500F /* GTMUnitTestingImage.10.6.0.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 84B91B890EA3CC2E0087500F /* GTMUnitTestingImage.10.6.0.tiff */; };
84B91B8C0EA3CC2E0087500F /* GTMUnitTestingWindow.10.6.0.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 84B91B8A0EA3CC2E0087500F /* GTMUnitTestingWindow.10.6.0.tiff */; };
8B0E65510FD80D5E00461C4A /* GTMHotKeyTextField.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8B0E653F0FD80D5E00461C4A /* GTMHotKeyTextField.strings */; };
+ 8B158A9B10A8C31100C93125 /* GTMNSAnimation+Duration.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B158A6010A8BE4500C93125 /* GTMNSAnimation+Duration.m */; };
+ 8B158ADE10A8C42000C93125 /* GTMNSAnimation+Duration.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B158A5F10A8BE4500C93125 /* GTMNSAnimation+Duration.h */; settings = {ATTRIBUTES = (Public, ); }; };
8B1801A20E2533D500280961 /* GTMLargeTypeWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B1801A00E2533D500280961 /* GTMLargeTypeWindow.m */; };
8B1801A30E2533D500280961 /* GTMLargeTypeWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B1801A10E2533D500280961 /* GTMLargeTypeWindow.h */; settings = {ATTRIBUTES = (Public, ); }; };
8B1801AE0E25341B00280961 /* GTMLargeTypeWindowImageTest.gtmUTState in Resources */ = {isa = PBXBuildFile; fileRef = 8B1801A80E25341B00280961 /* GTMLargeTypeWindowImageTest.gtmUTState */; };
@@ -487,6 +489,8 @@
8B0E654E0FD80D5E00461C4A /* sv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/GTMHotKeyTextField.strings; sourceTree = "<group>"; };
8B0E654F0FD80D5E00461C4A /* zh_CN */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = zh_CN; path = zh_CN.lproj/GTMHotKeyTextField.strings; sourceTree = "<group>"; };
8B0E65500FD80D5E00461C4A /* zh_TW */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = zh_TW; path = zh_TW.lproj/GTMHotKeyTextField.strings; sourceTree = "<group>"; };
+ 8B158A5F10A8BE4500C93125 /* GTMNSAnimation+Duration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTMNSAnimation+Duration.h"; sourceTree = "<group>"; };
+ 8B158A6010A8BE4500C93125 /* GTMNSAnimation+Duration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSAnimation+Duration.m"; sourceTree = "<group>"; };
8B1801A00E2533D500280961 /* GTMLargeTypeWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMLargeTypeWindow.m; sourceTree = "<group>"; };
8B1801A10E2533D500280961 /* GTMLargeTypeWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMLargeTypeWindow.h; sourceTree = "<group>"; };
8B1801A40E2533DB00280961 /* GTMLargeTypeWindowTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMLargeTypeWindowTest.m; sourceTree = "<group>"; };
@@ -1068,6 +1072,8 @@
F43DCDCB0D4796C600959A62 /* GTMLoginItems.h */,
F43DCDCC0D4796C600959A62 /* GTMLoginItems.m */,
F43DCEC60D47BEA000959A62 /* GTMLoginItemsTest.m */,
+ 8B158A5F10A8BE4500C93125 /* GTMNSAnimation+Duration.h */,
+ 8B158A6010A8BE4500C93125 /* GTMNSAnimation+Duration.m */,
F428FEFF0D48E55E00382ED1 /* GTMNSBezierPath+CGPath.h */,
F428FF000D48E55E00382ED1 /* GTMNSBezierPath+CGPath.m */,
F428FF010D48E55E00382ED1 /* GTMNSBezierPath+CGPathTest.m */,
@@ -1408,6 +1414,7 @@
7FF768E41051B17E00D34F4B /* GTMNSImage+SearchCache.h in Headers */,
8B307FF91056B773006C4C7A /* GTMNSNumber+64Bit.h in Headers */,
F4C6248B109753960069CADD /* GTMIBArray.h in Headers */,
+ 8B158ADE10A8C42000C93125 /* GTMNSAnimation+Duration.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1961,6 +1968,7 @@
7FF768E51051B17E00D34F4B /* GTMNSImage+SearchCache.m in Sources */,
8B307FF81056B773006C4C7A /* GTMNSNumber+64Bit.m in Sources */,
F4C6248C109753960069CADD /* GTMIBArray.m in Sources */,
+ 8B158A9B10A8C31100C93125 /* GTMNSAnimation+Duration.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index e447726..a1bdfa2 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -346,6 +346,10 @@ Changes since 1.5.1
compile time. See BuildScripts/SDEFCompiler.sh for details on how to set it
up. If you work with SDEFs at all, this one is worth checking out.
+- GTMNSAnimation+Duration.m adds support for checking for control and shift
+ keys when trying to decide how to calculate durations for animations.
+
+
Release 1.5.1
Changes since 1.5.0
16-June-2008