/core/externals/google-toolbox-for-mac/AppKit/GTMNSAnimation+Duration.h

http://macfuse.googlecode.com/ · C++ Header · 83 lines · 23 code · 14 blank · 46 comment · 0 complexity · b47127fc312146e55fab1b8337721780 MD5 · raw file

  1. //
  2. // GTMNSAnimation+Duration.h
  3. //
  4. // Copyright 2009 Google Inc.
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7. // use this file except in compliance with the License. You may obtain a copy
  8. // of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  14. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  15. // License for the specific language governing permissions and limitations under
  16. // the License.
  17. //
  18. #import <AppKit/AppKit.h>
  19. #import "GTMDefines.h"
  20. // Given a "normal" duration for an animation, return what it should be based
  21. // on the current system state. For example, holding down the shift and/or
  22. // control keys modifies the normal duration for an animation making it slower.
  23. // Currently only modifies the duration if the current event is masked by
  24. // eventMask and only the control and/or shift modifiers are down.
  25. // The shift modifier is ignored if it is applied to a Tab key down.
  26. // Tab and shift-tab are often used for navigating around UI elements,
  27. // and in the majority of cases slowing down the animations while navigating
  28. // around UI elements is not desired.
  29. NSTimeInterval GTMModifyDurationBasedOnCurrentState(NSTimeInterval duration,
  30. NSUInteger eventMask);
  31. // The standard eventmask that you want for the methods in this file. Some apps
  32. // (eg Chrome) may not want to have animations fire on key strokes, so will use
  33. // just NSLeftMouseUpMask instead.
  34. extern const NSUInteger kGTMLeftMouseUpAndKeyDownMask;
  35. // Categories for changing the duration of an animation based on the current
  36. // event. Right now they track the state of the shift and control keys to slow
  37. // down animations similar to how minimize window animations occur.
  38. @interface NSAnimation (GTMNSAnimationDurationAdditions)
  39. // Note that using this initializer will set the duration of the animation
  40. // based on the current event when the animation is created. If the animation
  41. // is to be reused, the duration for the event should be reset with
  42. // gtm_setDuration each time the animation is started.
  43. // See notes for GTMModifyDurationBasedOnCurrentState for more info.
  44. - (id)gtm_initWithDuration:(NSTimeInterval)duration
  45. eventMask:(NSUInteger)eventMask
  46. animationCurve:(NSAnimationCurve)animationCurve;
  47. // Sets the duration by taking the duration passed in and calling
  48. // GTMModifyDurationBasedOnCurrentState to calculate the real duration.
  49. // See notes for GTMModifyDurationBasedOnCurrentState for more info.
  50. - (void)gtm_setDuration:(NSTimeInterval)duration
  51. eventMask:(NSUInteger)eventMask;
  52. @end
  53. #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
  54. #import <QuartzCore/QuartzCore.h>
  55. @interface NSAnimationContext (GTMNSAnimationDurationAdditions)
  56. // Sets the duration by taking the duration passed in and calling
  57. // GTMModifyDurationBasedOnCurrentState to calculate the real duration.
  58. // See notes for GTMModifyDurationBasedOnCurrentState for more info.
  59. - (void)gtm_setDuration:(NSTimeInterval)duration
  60. eventMask:(NSUInteger)eventMask;
  61. @end
  62. @interface CAAnimation (GTMCAAnimationDurationAdditions)
  63. // Sets the duration by taking the duration passed in and calling
  64. // GTMModifyDurationBasedOnCurrentState to calculate the real duration.
  65. // See notes for GTMModifyDurationBasedOnCurrentState for more info.
  66. - (void)gtm_setDuration:(CFTimeInterval)duration
  67. eventMask:(NSUInteger)events;
  68. @end
  69. #endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5