Abhishek Banthia
8 years ago
113 changed files with 2809 additions and 24 deletions
Binary file not shown.
@ -0,0 +1 @@ |
|||||||
|
Versions/Current/Resources |
@ -0,0 +1,31 @@ |
|||||||
|
//
|
||||||
|
// PTHotKey+ShortcutRecorder.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Created by Ilya Kulakov on 27.02.11.
|
||||||
|
// Copyright 2011 Wireload. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
#import "PTHotKey.h" |
||||||
|
|
||||||
|
|
||||||
|
@interface PTHotKey (ShortcutRecorder) |
||||||
|
|
||||||
|
+ (PTHotKey *)hotKeyWithIdentifier:(id)anIdentifier |
||||||
|
keyCombo:(NSDictionary *)aKeyCombo |
||||||
|
target:(id)aTarget |
||||||
|
action:(SEL)anAction; |
||||||
|
|
||||||
|
+ (PTHotKey *)hotKeyWithIdentifier:(id)anIdentifier |
||||||
|
keyCombo:(NSDictionary *)aKeyCombo |
||||||
|
target:(id)aTarget |
||||||
|
action:(SEL)anAction |
||||||
|
keyUpAction:(SEL)aKeyUpAction; |
||||||
|
|
||||||
|
+ (PTHotKey *)hotKeyWithIdentifier:(id)anIdentifier |
||||||
|
keyCombo:(NSDictionary *)aKeyCombo |
||||||
|
target:(id)aTarget |
||||||
|
action:(SEL)anAction |
||||||
|
withObject:(id)anObject; |
||||||
|
@end |
@ -0,0 +1,60 @@ |
|||||||
|
//
|
||||||
|
// PTHotKey.h
|
||||||
|
// Protein
|
||||||
|
//
|
||||||
|
// Created by Quentin Carnicelli on Sat Aug 02 2003.
|
||||||
|
// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// Andy Kim
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h> |
||||||
|
#import <Carbon/Carbon.h> |
||||||
|
#import "PTKeyCombo.h" |
||||||
|
|
||||||
|
@interface PTHotKey : NSObject |
||||||
|
{ |
||||||
|
NSString* mIdentifier; |
||||||
|
NSString* mName; |
||||||
|
PTKeyCombo* mKeyCombo; |
||||||
|
id mTarget; |
||||||
|
id mObject; |
||||||
|
SEL mAction; |
||||||
|
SEL mKeyUpAction; |
||||||
|
|
||||||
|
UInt32 mCarbonHotKeyID; |
||||||
|
EventHotKeyRef mCarbonEventHotKeyRef; |
||||||
|
} |
||||||
|
|
||||||
|
- (id)initWithIdentifier: (id)identifier keyCombo: (PTKeyCombo*)combo; |
||||||
|
- (id)initWithIdentifier: (id)identifier keyCombo: (PTKeyCombo*)combo withObject: (id)object; |
||||||
|
- (id)init; |
||||||
|
|
||||||
|
- (void)setIdentifier: (id)ident; |
||||||
|
- (id)identifier; |
||||||
|
|
||||||
|
- (void)setName: (NSString*)name; |
||||||
|
- (NSString*)name; |
||||||
|
|
||||||
|
- (void)setKeyCombo: (PTKeyCombo*)combo; |
||||||
|
- (PTKeyCombo*)keyCombo; |
||||||
|
|
||||||
|
- (void)setTarget: (id)target; |
||||||
|
- (id)target; |
||||||
|
- (void)setObject: (id)object; |
||||||
|
- (id)object; |
||||||
|
- (void)setAction: (SEL)action; |
||||||
|
- (SEL)action; |
||||||
|
- (void)setKeyUpAction: (SEL)action; |
||||||
|
- (SEL)keyUpAction; |
||||||
|
|
||||||
|
- (UInt32)carbonHotKeyID; |
||||||
|
- (void)setCarbonHotKeyID: (UInt32)hotKeyID; |
||||||
|
|
||||||
|
- (EventHotKeyRef)carbonEventHotKeyRef; |
||||||
|
- (void)setCarbonEventHotKeyRef:(EventHotKeyRef)hotKeyRef; |
||||||
|
|
||||||
|
- (void)invoke; |
||||||
|
- (void)uninvoke; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,44 @@ |
|||||||
|
//
|
||||||
|
// PTHotKeyCenter.h
|
||||||
|
// Protein
|
||||||
|
//
|
||||||
|
// Created by Quentin Carnicelli on Sat Aug 02 2003.
|
||||||
|
// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// Quentin D. Carnicelli
|
||||||
|
// Finlay Dobbie
|
||||||
|
// Vincent Pottier
|
||||||
|
// Andy Kim
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
#import <Carbon/Carbon.h> |
||||||
|
|
||||||
|
@class PTHotKey; |
||||||
|
|
||||||
|
@interface PTHotKeyCenter : NSObject |
||||||
|
{ |
||||||
|
NSMutableDictionary* mHotKeys; //Keys are carbon hot key IDs
|
||||||
|
BOOL mEventHandlerInstalled; |
||||||
|
UInt32 mHotKeyCount; // Used to assign new hot key ID
|
||||||
|
BOOL mIsPaused; |
||||||
|
EventHandlerRef mEventHandler; |
||||||
|
} |
||||||
|
|
||||||
|
+ (PTHotKeyCenter *)sharedCenter; |
||||||
|
|
||||||
|
- (BOOL)registerHotKey: (PTHotKey*)hotKey; |
||||||
|
- (void)unregisterHotKey: (PTHotKey*)hotKey; |
||||||
|
|
||||||
|
- (NSArray*)allHotKeys; |
||||||
|
- (PTHotKey*)hotKeyWithIdentifier: (id)ident; |
||||||
|
|
||||||
|
- (void)sendEvent: (NSEvent*)event; |
||||||
|
|
||||||
|
- (void)pause; |
||||||
|
|
||||||
|
- (void)resume; |
||||||
|
|
||||||
|
- (BOOL)isPaused; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,26 @@ |
|||||||
|
//
|
||||||
|
// PTKeyCodeTranslator.h
|
||||||
|
// Chercher
|
||||||
|
//
|
||||||
|
// Created by Finlay Dobbie on Sat Oct 11 2003.
|
||||||
|
// Copyright (c) 2003 Cliché Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Carbon/Carbon.h> |
||||||
|
|
||||||
|
@interface PTKeyCodeTranslator : NSObject |
||||||
|
{ |
||||||
|
TISInputSourceRef keyboardLayout; |
||||||
|
const UCKeyboardLayout *uchrData; |
||||||
|
UInt32 keyTranslateState; |
||||||
|
UInt32 deadKeyState; |
||||||
|
} |
||||||
|
|
||||||
|
+ (id)currentTranslator; |
||||||
|
|
||||||
|
- (id)initWithKeyboardLayout:(TISInputSourceRef)aLayout; |
||||||
|
- (NSString *)translateKeyCode:(short)keyCode; |
||||||
|
|
||||||
|
- (TISInputSourceRef)keyboardLayout; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,38 @@ |
|||||||
|
//
|
||||||
|
// PTKeyCombo.h
|
||||||
|
// Protein
|
||||||
|
//
|
||||||
|
// Created by Quentin Carnicelli on Sat Aug 02 2003.
|
||||||
|
// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
|
||||||
|
@interface PTKeyCombo : NSObject <NSCopying> |
||||||
|
{ |
||||||
|
NSInteger mKeyCode; |
||||||
|
NSUInteger mModifiers; |
||||||
|
} |
||||||
|
|
||||||
|
+ (id)clearKeyCombo; |
||||||
|
+ (id)keyComboWithKeyCode: (NSInteger)keyCode modifiers: (NSUInteger)modifiers; |
||||||
|
- (id)initWithKeyCode: (NSInteger)keyCode modifiers: (NSUInteger)modifiers; |
||||||
|
|
||||||
|
- (id)initWithPlistRepresentation: (id)plist; |
||||||
|
- (id)plistRepresentation; |
||||||
|
|
||||||
|
- (BOOL)isEqual: (PTKeyCombo*)combo; |
||||||
|
|
||||||
|
- (NSInteger)keyCode; |
||||||
|
- (NSUInteger)modifiers; |
||||||
|
|
||||||
|
- (BOOL)isClearCombo; |
||||||
|
- (BOOL)isValidHotKeyCombo; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
|
||||||
|
@interface PTKeyCombo (UserDisplayAdditions) |
||||||
|
- (NSString*)keyCodeString; |
||||||
|
- (NSUInteger)modifierMask; |
||||||
|
@end |
Binary file not shown.
@ -0,0 +1,42 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||||
|
<plist version="1.0"> |
||||||
|
<dict> |
||||||
|
<key>BuildMachineOSBuild</key> |
||||||
|
<string>16B2555</string> |
||||||
|
<key>CFBundleDevelopmentRegion</key> |
||||||
|
<string>English</string> |
||||||
|
<key>CFBundleExecutable</key> |
||||||
|
<string>PTHotKey</string> |
||||||
|
<key>CFBundleIdentifier</key> |
||||||
|
<string>com.kulakov.PTHotKey</string> |
||||||
|
<key>CFBundleInfoDictionaryVersion</key> |
||||||
|
<string>6.0</string> |
||||||
|
<key>CFBundlePackageType</key> |
||||||
|
<string>FMWK</string> |
||||||
|
<key>CFBundleShortVersionString</key> |
||||||
|
<string>1.5</string> |
||||||
|
<key>CFBundleSignature</key> |
||||||
|
<string>????</string> |
||||||
|
<key>CFBundleSupportedPlatforms</key> |
||||||
|
<array> |
||||||
|
<string>MacOSX</string> |
||||||
|
</array> |
||||||
|
<key>CFBundleVersion</key> |
||||||
|
<string>1.5</string> |
||||||
|
<key>DTCompiler</key> |
||||||
|
<string>com.apple.compilers.llvm.clang.1_0</string> |
||||||
|
<key>DTPlatformBuild</key> |
||||||
|
<string>8B62</string> |
||||||
|
<key>DTPlatformVersion</key> |
||||||
|
<string>GM</string> |
||||||
|
<key>DTSDKBuild</key> |
||||||
|
<string>16B2649</string> |
||||||
|
<key>DTSDKName</key> |
||||||
|
<string>macosx10.12</string> |
||||||
|
<key>DTXcode</key> |
||||||
|
<string>0810</string> |
||||||
|
<key>DTXcodeBuild</key> |
||||||
|
<string>8B62</string> |
||||||
|
</dict> |
||||||
|
</plist> |
@ -0,0 +1 @@ |
|||||||
|
Versions/Current/Headers |
@ -0,0 +1 @@ |
|||||||
|
Versions/Current/Resources |
@ -0,0 +1 @@ |
|||||||
|
Versions/Current/ShortcutRecorder |
@ -0,0 +1,116 @@ |
|||||||
|
//
|
||||||
|
// SRCommon.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Copyright 2006-2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// David Dauer
|
||||||
|
// Jesper
|
||||||
|
// Jamie Kirkpatrick
|
||||||
|
// Andy Kim
|
||||||
|
// Ilya Kulakov
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
#import <Carbon/Carbon.h> |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Mask representing subset of Cocoa modifier flags suitable for shortcuts. |
||||||
|
*/ |
||||||
|
static const NSEventModifierFlags SRCocoaModifierFlagsMask = NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Mask representing subset of Carbon modifier flags suitable for shortcuts. |
||||||
|
*/ |
||||||
|
static const NSUInteger SRCarbonModifierFlagsMask = cmdKey | optionKey | shiftKey | controlKey; |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Converts carbon modifier flags to cocoa. |
||||||
|
*/ |
||||||
|
FOUNDATION_STATIC_INLINE NSEventModifierFlags SRCarbonToCocoaFlags(UInt32 aCarbonFlags) |
||||||
|
{ |
||||||
|
NSEventModifierFlags cocoaFlags = 0; |
||||||
|
|
||||||
|
if (aCarbonFlags & cmdKey) |
||||||
|
cocoaFlags |= NSCommandKeyMask; |
||||||
|
|
||||||
|
if (aCarbonFlags & optionKey) |
||||||
|
cocoaFlags |= NSAlternateKeyMask; |
||||||
|
|
||||||
|
if (aCarbonFlags & controlKey) |
||||||
|
cocoaFlags |= NSControlKeyMask; |
||||||
|
|
||||||
|
if (aCarbonFlags & shiftKey) |
||||||
|
cocoaFlags |= NSShiftKeyMask; |
||||||
|
|
||||||
|
return cocoaFlags; |
||||||
|
} |
||||||
|
|
||||||
|
/*!
|
||||||
|
Converts cocoa modifier flags to carbon. |
||||||
|
*/ |
||||||
|
FOUNDATION_STATIC_INLINE UInt32 SRCocoaToCarbonFlags(NSEventModifierFlags aCocoaFlags) |
||||||
|
{ |
||||||
|
UInt32 carbonFlags = 0; |
||||||
|
|
||||||
|
if (aCocoaFlags & NSCommandKeyMask) |
||||||
|
carbonFlags |= cmdKey; |
||||||
|
|
||||||
|
if (aCocoaFlags & NSAlternateKeyMask) |
||||||
|
carbonFlags |= optionKey; |
||||||
|
|
||||||
|
if (aCocoaFlags & NSControlKeyMask) |
||||||
|
carbonFlags |= controlKey; |
||||||
|
|
||||||
|
if (aCocoaFlags & NSShiftKeyMask) |
||||||
|
carbonFlags |= shiftKey; |
||||||
|
|
||||||
|
return carbonFlags; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Return Bundle where resources can be found. |
||||||
|
|
||||||
|
@discussion Throws NSInternalInconsistencyException if bundle cannot be found. |
||||||
|
*/ |
||||||
|
NSBundle *SRBundle(); |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Convenient method to get localized string from the framework bundle. |
||||||
|
*/ |
||||||
|
NSString *SRLoc(NSString *aKey); |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Convenient method to get image from the framework bundle. |
||||||
|
*/ |
||||||
|
NSImage *SRImage(NSString *anImageName); |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns string representation of shortcut with modifier flags replaced with their localized |
||||||
|
readable equivalents (e.g. ? -> Option). |
||||||
|
*/ |
||||||
|
NSString *SRReadableStringForCocoaModifierFlagsAndKeyCode(NSEventModifierFlags aModifierFlags, unsigned short aKeyCode); |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns string representation of shortcut with modifier flags replaced with their localized |
||||||
|
readable equivalents (e.g. ? -> Option) and ASCII character for key code. |
||||||
|
*/ |
||||||
|
NSString *SRReadableASCIIStringForCocoaModifierFlagsAndKeyCode(NSEventModifierFlags aModifierFlags, unsigned short aKeyCode); |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines if given key code with flags is equal to key equivalent and flags |
||||||
|
(usually taken from NSButton or NSMenu). |
||||||
|
|
||||||
|
@discussion On Mac OS X some key combinations can have "alternates". E.g. option-A can be represented both as option-A and as Œ. |
||||||
|
*/ |
||||||
|
BOOL SRKeyCodeWithFlagsEqualToKeyEquivalentWithFlags(unsigned short aKeyCode, |
||||||
|
NSEventModifierFlags aKeyCodeFlags, |
||||||
|
NSString *aKeyEquivalent, |
||||||
|
NSEventModifierFlags aKeyEquivalentModifierFlags); |
@ -0,0 +1,139 @@ |
|||||||
|
//
|
||||||
|
// SRKeyCodeTransformer.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Copyright 2006-2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// David Dauer
|
||||||
|
// Jesper
|
||||||
|
// Jamie Kirkpatrick
|
||||||
|
// Ilya Kulakov
|
||||||
|
// Silvio Rizzi
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
#import <Carbon/Carbon.h> |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Transforms key code into unicode character or plain string. |
||||||
|
*/ |
||||||
|
@interface SRKeyCodeTransformer : NSValueTransformer |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns initialized key code transformer. |
||||||
|
|
||||||
|
@param aUsesASCII Determines whether transformer uses only ASCII capable keyboard input source. |
||||||
|
|
||||||
|
@param aUsesPlainStrings Determines whether key codes without readable glyphs (e.g. F1...F19) are transformed to |
||||||
|
to unicode characters (NSF1FunctionKey...NSF19FunctionKey) suitable for setting key equivalents |
||||||
|
of Cocoa controls or to plain strings (@"F1"...@"F19") suitable for drawing, logging and accessibility. |
||||||
|
|
||||||
|
@discussion This method is the designated initializer for SRKeyCodeTransformer. |
||||||
|
*/ |
||||||
|
- (instancetype)initWithASCIICapableKeyboardInputSource:(BOOL)aUsesASCII plainStrings:(BOOL)aUsesPlainStrings; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether transformer uses ASCII capable keyboard input source. |
||||||
|
*/ |
||||||
|
@property (readonly) BOOL usesASCIICapableKeyboardInputSource; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether key codes without readable glyphs are transformed to unicode characters |
||||||
|
suitable for setting keqEquivalents or to plain strings suitable for drawing, logging and accessibility. |
||||||
|
*/ |
||||||
|
@property (readonly) BOOL usesPlainStrings; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the shared transformer. |
||||||
|
*/ |
||||||
|
+ (instancetype)sharedTransformer; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the shared transformer configured to use only ASCII capable keyboard input source. |
||||||
|
*/ |
||||||
|
+ (instancetype)sharedASCIITransformer; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the shared transformer configured to transform key codes to plain strings. |
||||||
|
*/ |
||||||
|
+ (SRKeyCodeTransformer *)sharedPlainTransformer; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the shared transformer configured to use only ASCII capable keyboard input source |
||||||
|
and to transform key codes to plain strings. |
||||||
|
*/ |
||||||
|
+ (SRKeyCodeTransformer *)sharedPlainASCIITransformer; |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns mapping from special key codes to unicode characters. |
||||||
|
*/ |
||||||
|
+ (NSDictionary *)specialKeyCodesToUnicodeCharactersMapping; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns mapping from special key codes to plain strings. |
||||||
|
*/ |
||||||
|
+ (NSDictionary *)specialKeyCodesToPlainStringsMapping; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether key code is special. |
||||||
|
|
||||||
|
@param aKeyCode Key code to be checked. |
||||||
|
*/ |
||||||
|
- (BOOL)isKeyCodeSpecial:(unsigned short)aKeyCode; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Transforms given special key code into unicode character by taking into account modifier flags. |
||||||
|
|
||||||
|
@discussion E.g. the key code 0x30 is transformed to ⇥. But if shift is pressed, it is transformed to ⇤. |
||||||
|
|
||||||
|
@result Unicode character or plain string. nil if not a special key code. |
||||||
|
*/ |
||||||
|
- (NSString *)transformedSpecialKeyCode:(NSNumber *)aKeyCode withExplicitModifierFlags:(NSNumber *)aModifierFlags; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Shorcut to [self transformedValue:aValue withImplicitModifierFlags:aModifierFlags explicitModifierFlags:0] |
||||||
|
*/ |
||||||
|
- (NSString *)transformedValue:(NSNumber *)aValue withModifierFlags:(NSNumber *)aModifierFlags; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Transfroms given key code into unicode character by taking into account modifier flags. |
||||||
|
|
||||||
|
@param aValue An instance of NSNumber (unsigned short) that represents key code. |
||||||
|
|
||||||
|
@param anImplicitModifierFlags An instance of NSNumber (NSEventModifierFlags) that represents implicit modifier flags like opt in å. |
||||||
|
|
||||||
|
@param anExplicitModifierFlags An instance of NSNumber (NSEventModifierFlags) that represents explicit modifier flags like shift in shift-⇤. |
||||||
|
*/ |
||||||
|
- (NSString *)transformedValue:(NSNumber *)aValue withImplicitModifierFlags:(NSNumber *)anImplicitModifierFlags explicitModifierFlags:(NSNumber *)anExplicitModifierFlags; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
These constants represents drawable unicode characters for key codes that do not have |
||||||
|
appropriate constants in Carbon and Cocoa. |
||||||
|
*/ |
||||||
|
typedef NS_ENUM(unichar, SRKeyCodeGlyph) |
||||||
|
{ |
||||||
|
SRKeyCodeGlyphTabRight = 0x21E5, // ⇥
|
||||||
|
SRKeyCodeGlyphTabLeft = 0x21E4, // ⇤
|
||||||
|
SRKeyCodeGlyphReturn = 0x2305, // ⌅
|
||||||
|
SRKeyCodeGlyphReturnR2L = 0x21A9, // ↩
|
||||||
|
SRKeyCodeGlyphDeleteLeft = 0x232B, // ⌫
|
||||||
|
SRKeyCodeGlyphDeleteRight = 0x2326, // ⌦
|
||||||
|
SRKeyCodeGlyphPadClear = 0x2327, // ⌧
|
||||||
|
SRKeyCodeGlyphLeftArrow = 0x2190, // ←
|
||||||
|
SRKeyCodeGlyphRightArrow = 0x2192, // →
|
||||||
|
SRKeyCodeGlyphUpArrow = 0x2191, // ↑
|
||||||
|
SRKeyCodeGlyphDownArrow = 0x2193, // ↓
|
||||||
|
SRKeyCodeGlyphPageDown = 0x21DF, // ⇟
|
||||||
|
SRKeyCodeGlyphPageUp = 0x21DE, // ⇞
|
||||||
|
SRKeyCodeGlyphNorthwestArrow = 0x2196, // ↖
|
||||||
|
SRKeyCodeGlyphSoutheastArrow = 0x2198, // ↘
|
||||||
|
SRKeyCodeGlyphEscape = 0x238B, // ⎋
|
||||||
|
SRKeyCodeGlyphSpace = 0x0020, // ' '
|
||||||
|
}; |
@ -0,0 +1,21 @@ |
|||||||
|
//
|
||||||
|
// SRKeyEquivalentModifierMaskTransformer.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Copyright 2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors to this file:
|
||||||
|
// Ilya Kulakov
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h> |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Transform dictionary representation of shortcut into string suitable |
||||||
|
for -setKeyEquivalentModifierMask: of NSButton and NSMenuItem. |
||||||
|
*/ |
||||||
|
@interface SRKeyEquivalentModifierMaskTransformer : NSValueTransformer |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,21 @@ |
|||||||
|
//
|
||||||
|
// SRKeyEquivalentTransformer.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Copyright 2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors to this file:
|
||||||
|
// Ilya Kulakov
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h> |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Transform dictionary representation of shortcut into string suitable |
||||||
|
for -setKeyEquivalent: of NSButton and NSMenuItem. |
||||||
|
*/ |
||||||
|
@interface SRKeyEquivalentTransformer : NSValueTransformer |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,37 @@ |
|||||||
|
//
|
||||||
|
// SRModifierFlagsTransformer.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Copyright 2006-2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// Ilya Kulakov
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Transforms mask of Cocoa modifier flags to string of unicode characters. |
||||||
|
*/ |
||||||
|
@interface SRModifierFlagsTransformer : NSValueTransformer |
||||||
|
|
||||||
|
- (instancetype)initWithPlainStrings:(BOOL)aUsesPlainStrings; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether modifier flags are transformed to unicode characters or to plain strings. |
||||||
|
*/ |
||||||
|
@property (readonly) BOOL usesPlainStrings; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the shared transformer. |
||||||
|
*/ |
||||||
|
+ (instancetype)sharedTransformer; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the shared plain transformer. |
||||||
|
*/ |
||||||
|
+ (instancetype)sharedPlainTransformer; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,436 @@ |
|||||||
|
//
|
||||||
|
// SRRecorderControl.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Copyright 2006-2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// David Dauer
|
||||||
|
// Jesper
|
||||||
|
// Jamie Kirkpatrick
|
||||||
|
// Ilya Kulakov
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
#import <ShortcutRecorder/SRCommon.h> |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Key code. |
||||||
|
|
||||||
|
@discussion NSNumber representation of unsigned short. |
||||||
|
Required key of SRRecorderControl's objectValue. |
||||||
|
*/ |
||||||
|
extern NSString *const SRShortcutKeyCode; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Modifier flags. |
||||||
|
|
||||||
|
@discussion NSNumber representation of NSEventModifierFlags. |
||||||
|
Optional key of SRRecorderControl's objectValue. |
||||||
|
*/ |
||||||
|
extern NSString *const SRShortcutModifierFlagsKey; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Interpretation of key code and modifier flags depending on system locale and input source |
||||||
|
used when shortcut was taken. |
||||||
|
|
||||||
|
@discussion NSString. |
||||||
|
Optional key of SRRecorderControl's objectValue. |
||||||
|
*/ |
||||||
|
extern NSString *const SRShortcutCharacters; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Interpretation of key code without modifier flags depending on system locale and input source |
||||||
|
used when shortcut was taken. |
||||||
|
|
||||||
|
@discussion NSString. |
||||||
|
Optional key of SRRecorderControl's objectValue. |
||||||
|
*/ |
||||||
|
extern NSString *const SRShortcutCharactersIgnoringModifiers; |
||||||
|
|
||||||
|
|
||||||
|
@protocol SRRecorderControlDelegate; |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
An SRRecorderControl object is a control (but not a subclass of NSControl) that allows you to record shortcuts. |
||||||
|
|
||||||
|
@discussion In addition to NSView bindings, exposes: |
||||||
|
NSValueBinding. This binding supports 2 options: |
||||||
|
- NSValueTransformerBindingOption |
||||||
|
- NSValueTransformerNameBindingOption |
||||||
|
NSEnabledBinding. This binding supports 2 options: |
||||||
|
- NSValueTransformerBindingOption |
||||||
|
- NSValueTransformerNameBindingOption |
||||||
|
Note that at that moment, this binding _is not_ multivalue. |
||||||
|
|
||||||
|
Required height: 25 points |
||||||
|
Recommended min width: 100 points |
||||||
|
*/ |
||||||
|
IB_DESIGNABLE |
||||||
|
@interface SRRecorderControl : NSView /* <NSAccessibility, NSKeyValueBindingCreation, NSToolTipOwner, NSNibAwaking> */ |
||||||
|
|
||||||
|
/*!
|
||||||
|
The receiver’s delegate. |
||||||
|
|
||||||
|
@discussion A recorder control delegate responds to editing-related messages. You can use to to prevent editing |
||||||
|
in some cases or to validate typed shortcuts. |
||||||
|
*/ |
||||||
|
@property (assign) IBOutlet NSObject<SRRecorderControlDelegate> *delegate; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns an integer bit field indicating allowed modifier flags. |
||||||
|
|
||||||
|
@discussion Defaults to SRCocoaModifierFlagsMask. |
||||||
|
*/ |
||||||
|
@property (readonly) IBInspectable NSEventModifierFlags allowedModifierFlags; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns an integer bit field indicating required modifier flags. |
||||||
|
|
||||||
|
@discussion Defaults to 0. |
||||||
|
*/ |
||||||
|
@property (readonly) IBInspectable NSEventModifierFlags requiredModifierFlags; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether shortcuts without modifier flags are allowed. |
||||||
|
|
||||||
|
@discussion Defaults to NO. |
||||||
|
*/ |
||||||
|
@property (readonly) IBInspectable BOOL allowsEmptyModifierFlags; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether the control reinterpret key code and modifier flags |
||||||
|
using ASCII capable input source. |
||||||
|
|
||||||
|
@discussion Defaults to YES. |
||||||
|
If not set, the same key code may be draw differently depending on current input source. |
||||||
|
E.g. with US English input source key code 0x0 is interpreted as "a", |
||||||
|
however with Russian input source, it's interpreted as "ф". |
||||||
|
*/ |
||||||
|
@property IBInspectable BOOL drawsASCIIEquivalentOfShortcut; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether Escape is used to cancel recording. |
||||||
|
|
||||||
|
@discussion Defaults to YES. |
||||||
|
If set, Escape without modifier flags cannot be recorded as shortcut. |
||||||
|
*/ |
||||||
|
@property IBInspectable BOOL allowsEscapeToCancelRecording; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether delete (or forward delete) is used to remove current shortcut and end recording. |
||||||
|
|
||||||
|
@discussion Defaults to YES. |
||||||
|
If set, neither Delete nor Forward Delete without modifier flags can be recorded as shortcut. |
||||||
|
*/ |
||||||
|
@property IBInspectable BOOL allowsDeleteToClearShortcutAndEndRecording; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether control enabled and can be edited or not. |
||||||
|
|
||||||
|
@discussion Defaults to YES. |
||||||
|
*/ |
||||||
|
@property (nonatomic, getter=isEnabled) IBInspectable BOOL enabled; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether recording is in process. |
||||||
|
*/ |
||||||
|
@property (nonatomic, readonly) BOOL isRecording; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns dictionary representation of receiver's shortcut. |
||||||
|
*/ |
||||||
|
@property (nonatomic, copy) NSDictionary *objectValue; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Configures recording behavior of the control. |
||||||
|
|
||||||
|
@param newAllowedModifierFlags New allowed modifier flags. |
||||||
|
|
||||||
|
@param newRequiredModifierFlags New required modifier flags. |
||||||
|
|
||||||
|
@param newAllowsEmptyModifierFlags Determines whether empty modifier flags are allowed. |
||||||
|
|
||||||
|
@discussion Flags are filtered using SRCocoaModifierFlagsMask. Flags does not affect object values set manually. |
||||||
|
|
||||||
|
These restrictions can be ignored if delegate implements shortcutRecorder:shouldUnconditionallyAllowModifierFlags:forKeyCode: and returns YES for given modifier flags and key code. |
||||||
|
|
||||||
|
Throws NSInvalidArgumentException if either required flags are not allowed |
||||||
|
or required flags are not empty and no modifier flags are allowed. |
||||||
|
|
||||||
|
@see SRRecorderControlDelegate |
||||||
|
*/ |
||||||
|
- (void)setAllowedModifierFlags:(NSEventModifierFlags)newAllowedModifierFlags |
||||||
|
requiredModifierFlags:(NSEventModifierFlags)newRequiredModifierFlags |
||||||
|
allowsEmptyModifierFlags:(BOOL)newAllowsEmptyModifierFlags; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Called to initialize internal state after either initWithFrame or awakeFromNib is called. |
||||||
|
*/ |
||||||
|
- (void)_initInternalState; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Turns on the recording mode. |
||||||
|
|
||||||
|
@discussion You SHOULD not call this method directly. |
||||||
|
*/ |
||||||
|
- (BOOL)beginRecording; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Turns off the recording mode. Current object value is preserved. |
||||||
|
|
||||||
|
@discussion You SHOULD not call this method directly. |
||||||
|
*/ |
||||||
|
- (void)endRecording; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Clears object value and turns off the recording mode. |
||||||
|
|
||||||
|
@discussion You SHOULD not call this method directly. |
||||||
|
*/ |
||||||
|
- (void)clearAndEndRecording; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Designated method to end recording. Sets a given object value, updates bindings and turns off the recording mode. |
||||||
|
|
||||||
|
@discussion You SHOULD not call this method directly. |
||||||
|
*/ |
||||||
|
- (void)endRecordingWithObjectValue:(NSDictionary *)anObjectValue; |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns shape of the control. |
||||||
|
|
||||||
|
@discussion Primarily used to draw appropriate focus ring. |
||||||
|
*/ |
||||||
|
- (NSBezierPath *)controlShape; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns rect for label with given attributes. |
||||||
|
|
||||||
|
@param aLabel Label for drawing. |
||||||
|
|
||||||
|
@param anAttributes A dictionary of NSAttributedString text attributes to be applied to the string. |
||||||
|
*/ |
||||||
|
- (NSRect)rectForLabel:(NSString *)aLabel withAttributes:(NSDictionary *)anAttributes; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns rect of the snap back button in the receiver coordinates. |
||||||
|
*/ |
||||||
|
- (NSRect)snapBackButtonRect; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns rect of the clear button in the receiver coordinates. |
||||||
|
|
||||||
|
@discussion Returned rect will have empty width (other values will be valid) if button should not be drawn. |
||||||
|
*/ |
||||||
|
- (NSRect)clearButtonRect; |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns label to be displayed by the receiver. |
||||||
|
|
||||||
|
@discussion Returned value depends on isRecording state objectValue and currenlty pressed keys and modifier flags. |
||||||
|
*/ |
||||||
|
- (NSString *)label; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns label for accessibility. |
||||||
|
|
||||||
|
@discussion Returned value depends on isRecording state objectValue and currenlty pressed keys and modifier flags. |
||||||
|
*/ |
||||||
|
- (NSString *)accessibilityLabel; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns string representation of object value. |
||||||
|
*/ |
||||||
|
- (NSString *)stringValue; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns string representation of object value for accessibility. |
||||||
|
*/ |
||||||
|
- (NSString *)accessibilityStringValue; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns attirbutes of label to be displayed by the receiver according to current state. |
||||||
|
|
||||||
|
@see normalLabelAttributes |
||||||
|
|
||||||
|
@see recordingLabelAttributes |
||||||
|
|
||||||
|
@see disabledLabelAttributes |
||||||
|
*/ |
||||||
|
- (NSDictionary *)labelAttributes; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns attributes of label to be displayed by the receiver in normal mode. |
||||||
|
*/ |
||||||
|
- (NSDictionary *)normalLabelAttributes; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns attributes of label to be displayed by the receiver in recording mode. |
||||||
|
*/ |
||||||
|
- (NSDictionary *)recordingLabelAttributes; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns attributes of label to be displayed by the receiver in disabled mode. |
||||||
|
*/ |
||||||
|
- (NSDictionary *)disabledLabelAttributes; |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Draws background of the receiver into current graphics context. |
||||||
|
*/ |
||||||
|
- (void)drawBackground:(NSRect)aDirtyRect; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Draws interior of the receiver into current graphics context. |
||||||
|
*/ |
||||||
|
- (void)drawInterior:(NSRect)aDirtyRect; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Draws label of the receiver into current graphics context. |
||||||
|
*/ |
||||||
|
- (void)drawLabel:(NSRect)aDirtyRect; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Draws snap back button of the receiver into current graphics context. |
||||||
|
*/ |
||||||
|
- (void)drawSnapBackButton:(NSRect)aDirtyRect; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Draws clear button of the receiver into current graphics context. |
||||||
|
*/ |
||||||
|
- (void)drawClearButton:(NSRect)aDirtyRect; |
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether main button (representation of the receiver in normal mode) is highlighted. |
||||||
|
*/ |
||||||
|
- (BOOL)isMainButtonHighlighted; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether snap back button is highlighted. |
||||||
|
*/ |
||||||
|
- (BOOL)isSnapBackButtonHighlighted; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whetehr clear button is highlighted. |
||||||
|
*/ |
||||||
|
- (BOOL)isClearButtonHighlighted; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether modifier flags are valid for key code according to the receiver settings. |
||||||
|
|
||||||
|
@param aModifierFlags Proposed modifier flags. |
||||||
|
|
||||||
|
@param aKeyCode Code of the pressed key. |
||||||
|
|
||||||
|
@see allowedModifierFlags |
||||||
|
|
||||||
|
@see allowsEmptyModifierFlags |
||||||
|
|
||||||
|
@see requiredModifierFlags |
||||||
|
*/ |
||||||
|
- (BOOL)areModifierFlagsValid:(NSEventModifierFlags)aModifierFlags forKeyCode:(unsigned short)aKeyCode; |
||||||
|
|
||||||
|
/*!
|
||||||
|
A helper method to propagate view-driven changes back to model. |
||||||
|
|
||||||
|
@discussion This method makes it easier to propagate changes from a view |
||||||
|
back to the model without overriding bind:toObject:withKeyPath:options: |
||||||
|
|
||||||
|
@see http://tomdalling.com/blog/cocoa/implementing-your-own-cocoa-bindings/
|
||||||
|
*/ |
||||||
|
- (void)propagateValue:(id)aValue forBinding:(NSString *)aBinding; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
|
||||||
|
@protocol SRRecorderControlDelegate <NSObject> |
||||||
|
|
||||||
|
@optional |
||||||
|
|
||||||
|
/*!
|
||||||
|
Asks the delegate if editing should begin in the specified shortcut recorder. |
||||||
|
|
||||||
|
@param aRecorder The shortcut recorder which editing is about to begin. |
||||||
|
|
||||||
|
@result YES if an editing session should be initiated; otherwise, NO to disallow editing. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. If it is not present, editing proceeds as if this method had returned YES. |
||||||
|
*/ |
||||||
|
- (BOOL)shortcutRecorderShouldBeginRecording:(SRRecorderControl *)aRecorder; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Gives a delegate opportunity to bypass rules specified by allowed and required modifier flags. |
||||||
|
|
||||||
|
@param aRecorder The shortcut recorder for which editing ended. |
||||||
|
|
||||||
|
@param aModifierFlags Proposed modifier flags. |
||||||
|
|
||||||
|
@param aKeyCode Code of the pressed key. |
||||||
|
|
||||||
|
@result YES if recorder should bypass key code with given modifier flags despite settings like required modifier flags, allowed modifier flags. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. |
||||||
|
Normally, you wouldn't allow a user to record shourcut without modifier flags set: disallow 'a', but allow cmd-'a'. |
||||||
|
However, some keys were designed to be key shortcuts by itself. E.g. Functional keys. By implementing this method a delegate can allow |
||||||
|
these special keys to be set without modifier flags even when the control is configured to disallow empty modifier flags. |
||||||
|
|
||||||
|
@see allowedModifierFlags |
||||||
|
|
||||||
|
@see allowsEmptyModifierFlags |
||||||
|
|
||||||
|
@see requiredModifierFlags |
||||||
|
*/ |
||||||
|
- (BOOL)shortcutRecorder:(SRRecorderControl *)aRecorder shouldUnconditionallyAllowModifierFlags:(NSEventModifierFlags)aModifierFlags forKeyCode:(unsigned short)aKeyCode; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Asks the delegate if the shortcut can be set by the specified shortcut recorder. |
||||||
|
|
||||||
|
@param aRecorder The shortcut recorder which shortcut is beign to be recordered. |
||||||
|
|
||||||
|
@param aShortcut The Shortcut user typed. |
||||||
|
|
||||||
|
@result YES if shortcut can be recordered. Otherwise NO. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. If it is not present, shortcut is recordered as if this method had returned YES. |
||||||
|
You may implement this method to filter shortcuts that were already set by other recorders. |
||||||
|
|
||||||
|
@see SRValidator |
||||||
|
*/ |
||||||
|
- (BOOL)shortcutRecorder:(SRRecorderControl *)aRecorder canRecordShortcut:(NSDictionary *)aShortcut; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Tells the delegate that editing stopped for the specified shortcut recorder. |
||||||
|
|
||||||
|
@param aRecorder The shortcut recorder for which editing ended. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. |
||||||
|
*/ |
||||||
|
- (void)shortcutRecorderDidEndRecording:(SRRecorderControl *)aRecorder; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
|
||||||
|
FOUNDATION_STATIC_INLINE BOOL SRShortcutEqualToShortcut(NSDictionary *a, NSDictionary *b) |
||||||
|
{ |
||||||
|
if (a == b) |
||||||
|
return YES; |
||||||
|
else if (a && !b) |
||||||
|
return NO; |
||||||
|
else if (!a && b) |
||||||
|
return NO; |
||||||
|
else |
||||||
|
return ([a[SRShortcutKeyCode] isEqual:b[SRShortcutKeyCode]] && [a[SRShortcutModifierFlagsKey] isEqual:b[SRShortcutModifierFlagsKey]]); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
FOUNDATION_STATIC_INLINE NSDictionary *SRShortcutWithCocoaModifierFlagsAndKeyCode(NSEventModifierFlags aModifierFlags, unsigned short aKeyCode) |
||||||
|
{ |
||||||
|
return @{SRShortcutKeyCode: @(aKeyCode), SRShortcutModifierFlagsKey: @(aModifierFlags)}; |
||||||
|
} |
@ -0,0 +1,131 @@ |
|||||||
|
//
|
||||||
|
// SRValidator.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
//
|
||||||
|
// Copyright 2006-2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors:
|
||||||
|
// David Dauer
|
||||||
|
// Jesper
|
||||||
|
// Jamie Kirkpatrick
|
||||||
|
// Andy Kim
|
||||||
|
// Silvio Rizzi
|
||||||
|
// Ilya Kulakov
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
|
||||||
|
|
||||||
|
@protocol SRValidatorDelegate; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Implements logic to check whether shortcut is taken by other parts of the application and system. |
||||||
|
*/ |
||||||
|
@interface SRValidator : NSObject |
||||||
|
|
||||||
|
@property (assign) NSObject<SRValidatorDelegate> *delegate; |
||||||
|
|
||||||
|
- (instancetype)initWithDelegate:(NSObject<SRValidatorDelegate> *)aDelegate; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether shortcut is taken. |
||||||
|
|
||||||
|
@discussion Key is checked in the following order: |
||||||
|
1. If delegate implements shortcutValidator:isKeyCode:andFlagsTaken:reason: |
||||||
|
2. If delegate allows system-wide shortcuts are checked |
||||||
|
3. If delegate allows application menu it checked |
||||||
|
|
||||||
|
@see SRValidatorDelegate |
||||||
|
*/ |
||||||
|
- (BOOL)isKeyCode:(unsigned short)aKeyCode andFlagsTaken:(NSEventModifierFlags)aFlags error:(NSError **)outError; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether shortcut is taken in delegate. |
||||||
|
|
||||||
|
@discussion If delegate does not implement appropriate method, returns immediately. |
||||||
|
*/ |
||||||
|
- (BOOL)isKeyCode:(unsigned short)aKeyCode andFlagTakenInDelegate:(NSEventModifierFlags)aFlags error:(NSError **)outError; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether shortcut is taken by system-wide shortcuts. |
||||||
|
|
||||||
|
@discussion Does not check whether delegate allows or disallows checking in system shortcuts. |
||||||
|
*/ |
||||||
|
- (BOOL)isKeyCode:(unsigned short)aKeyCode andFlagsTakenInSystemShortcuts:(NSEventModifierFlags)aFlags error:(NSError **)outError; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Determines whether shortcut is taken by application menu item. |
||||||
|
|
||||||
|
@discussion Does not check whether delegate allows or disallows checking in application menu. |
||||||
|
*/ |
||||||
|
- (BOOL)isKeyCode:(unsigned short)aKeyCode andFlags:(NSEventModifierFlags)aFlags takenInMenu:(NSMenu *)aMenu error:(NSError **)outError; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
|
||||||
|
@protocol SRValidatorDelegate |
||||||
|
|
||||||
|
@optional |
||||||
|
|
||||||
|
/*!
|
||||||
|
Asks the delegate if aKeyCode and aFlags are valid. |
||||||
|
|
||||||
|
@param aValidator The validator that validates key code and flags. |
||||||
|
|
||||||
|
@param aKeyCode Key code to validate. |
||||||
|
|
||||||
|
@param aFlags Flags to validate. |
||||||
|
|
||||||
|
@param outReason If delegate decides that shortcut is invalid, it may pass here an error message. |
||||||
|
|
||||||
|
@result YES if shortcut is valid. Otherwise NO. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. If it is not present, checking proceeds as if this method had returned YES. |
||||||
|
*/ |
||||||
|
- (BOOL)shortcutValidator:(SRValidator *)aValidator isKeyCode:(unsigned short)aKeyCode andFlagsTaken:(NSEventModifierFlags)aFlags reason:(NSString **)outReason; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Asks the delegate whether validator should check key equivalents of app's menu items. |
||||||
|
|
||||||
|
@param aValidator The validator that going to check app's menu items. |
||||||
|
|
||||||
|
@result YES if validator should check key equivalents of app's menu items. Otherwise NO. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. If it is not present, checking proceeds as if this method had returned YES. |
||||||
|
*/ |
||||||
|
- (BOOL)shortcutValidatorShouldCheckMenu:(SRValidator *)aValidator; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Asks the delegate whether it should check system shortcuts. |
||||||
|
|
||||||
|
@param aValidator The validator that going to check system shortcuts. |
||||||
|
|
||||||
|
@result YES if validator should check system shortcuts. Otherwise NO. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. If it is not present, checking proceeds as if this method had returned YES. |
||||||
|
*/ |
||||||
|
- (BOOL)shortcutValidatorShouldCheckSystemShortcuts:(SRValidator *)aValidator; |
||||||
|
|
||||||
|
/*!
|
||||||
|
Asks the delegate whether it should use ASCII representation of key code when making error messages. |
||||||
|
|
||||||
|
@param aValidator The validator that is about to make an error message. |
||||||
|
|
||||||
|
@result YES if validator should use ASCII representation. Otherwise NO. |
||||||
|
|
||||||
|
@discussion Implementation of this method by the delegate is optional. If it is not present, ASCII representation of key code is used. |
||||||
|
*/ |
||||||
|
- (BOOL)shortcutValidatorShouldUseASCIIStringForKeyCodes:(SRValidator *)aValidator; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
|
||||||
|
@interface NSMenuItem (SRValidator) |
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns full path to the menu item. E.g. "Window ➝ Zoom" |
||||||
|
*/ |
||||||
|
- (NSString *)SR_path; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,54 @@ |
|||||||
|
//
|
||||||
|
// ShortcutRecorder.h
|
||||||
|
// ShortcutRecorder
|
||||||
|
// Copyright 2012 Contributors. All rights reserved.
|
||||||
|
//
|
||||||
|
// License: BSD
|
||||||
|
//
|
||||||
|
// Contributors to this file:
|
||||||
|
// Jesper
|
||||||
|
// Ilya Kulakov
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h> |
||||||
|
#import <ShortcutRecorder/SRCommon.h> |
||||||
|
#import <ShortcutRecorder/SRKeyCodeTransformer.h> |
||||||
|
#import <ShortcutRecorder/SRModifierFlagsTransformer.h> |
||||||
|
#import <ShortcutRecorder/SRKeyEquivalentTransformer.h> |
||||||
|
#import <ShortcutRecorder/SRKeyEquivalentModifierMaskTransformer.h> |
||||||
|
#import <ShortcutRecorder/SRValidator.h> |
||||||
|
#import <ShortcutRecorder/SRRecorderControl.h> |
||||||
|
|
||||||
|
|
||||||
|
#ifndef IBInspectable |
||||||
|
#define IBInspectable |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef IB_DESIGNABLE |
||||||
|
#define IB_DESIGNABLE |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef NSAppKitVersionNumber10_6 |
||||||
|
#define NSAppKitVersionNumber10_6 1038 |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef NSAppKitVersionNumber10_9 |
||||||
|
#define NSAppKitVersionNumber10_9 1265 |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef NSEDGEINSETS_DEFINED |
||||||
|
typedef struct NSEdgeInsets { |
||||||
|
CGFloat top; |
||||||
|
CGFloat left; |
||||||
|
CGFloat bottom; |
||||||
|
CGFloat right; |
||||||
|
} NSEdgeInsets; |
||||||
|
|
||||||
|
NS_INLINE NSEdgeInsets NSEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) { |
||||||
|
NSEdgeInsets e; |
||||||
|
e.top = top; |
||||||
|
e.left = left; |
||||||
|
e.bottom = bottom; |
||||||
|
e.right = right; |
||||||
|
return e; |
||||||
|
} |
||||||
|
#endif |
@ -0,0 +1,42 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||||
|
<plist version="1.0"> |
||||||
|
<dict> |
||||||
|
<key>BuildMachineOSBuild</key> |
||||||
|
<string>16B2555</string> |
||||||
|
<key>CFBundleDevelopmentRegion</key> |
||||||
|
<string>English</string> |
||||||
|
<key>CFBundleExecutable</key> |
||||||
|
<string>ShortcutRecorder</string> |
||||||
|
<key>CFBundleIdentifier</key> |
||||||
|
<string>com.kulakov.ShortcutRecorder</string> |
||||||
|
<key>CFBundleInfoDictionaryVersion</key> |
||||||
|
<string>6.0</string> |
||||||
|
<key>CFBundlePackageType</key> |
||||||
|
<string>FMWK</string> |
||||||
|
<key>CFBundleShortVersionString</key> |
||||||
|
<string>2.17</string> |
||||||
|
<key>CFBundleSignature</key> |
||||||
|
<string>????</string> |
||||||
|
<key>CFBundleSupportedPlatforms</key> |
||||||
|
<array> |
||||||
|
<string>MacOSX</string> |
||||||
|
</array> |
||||||
|
<key>CFBundleVersion</key> |
||||||
|
<string>2.17</string> |
||||||
|
<key>DTCompiler</key> |
||||||
|
<string>com.apple.compilers.llvm.clang.1_0</string> |
||||||
|
<key>DTPlatformBuild</key> |
||||||
|
<string>8B62</string> |
||||||
|
<key>DTPlatformVersion</key> |
||||||
|
<string>GM</string> |
||||||
|
<key>DTSDKBuild</key> |
||||||
|
<string>16B2649</string> |
||||||
|
<key>DTSDKName</key> |
||||||
|
<string>macosx10.12</string> |
||||||
|
<key>DTXcode</key> |
||||||
|
<string>0810</string> |
||||||
|
<key>DTXcodeBuild</key> |
||||||
|
<string>8B62</string> |
||||||
|
</dict> |
||||||
|
</plist> |
@ -0,0 +1,40 @@ |
|||||||
|
Copyright (c) 2006, contributors to ShortcutRecorder. (See the contributors listed in detail later in the file, or see <http://wafflesoftware.net/shortcut/contributors/>.) |
||||||
|
|
||||||
|
All rights reserved. |
||||||
|
Redistribution and use in source and binary forms, with or without |
||||||
|
modification, are permitted provided that the following conditions are met: |
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright |
||||||
|
notice, this list of conditions and the following disclaimer. |
||||||
|
* Redistributions in binary form must reproduce the above copyright |
||||||
|
notice, this list of conditions and the following disclaimer in the |
||||||
|
documentation and/or other materials provided with the distribution. |
||||||
|
* The name of the contributors may not be used to endorse or promote |
||||||
|
products derived from this software without specific prior written |
||||||
|
permission. |
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS "AS IS" AND ANY |
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
===================================================================== |
||||||
|
|
||||||
|
Contributors to Shortcut Recorder, in no order in particular: |
||||||
|
Jesper, waffle software, <wootest+shortcutrecorder@gmail.com>. Initial idea and concept, first shot at implementation using NSView. |
||||||
|
David Dauer, <david@daviddauer.de>. Refinement, cleaner reimplementation, documentation, IB Palette. |
||||||
|
Jamie Kirkpatrick, Kirk Consulting Ltd, <jkp@kirkconsulting.co.uk>. Further modularisation and re-factoring, and general bug fixes. |
||||||
|
Ilya Kulakov, <kulakov.ilya@gmail.com>. ShortcutRecorder 2.0 and further support. |
||||||
|
Alexander Ljungberg, <aljungberg@wireload.net>. Graphics for ShortcutRecorder 2.0 |
||||||
|
|
||||||
|
===================================================================== |
||||||
|
|
||||||
|
Some rights reserved: <http://creativecommons.org/licenses/by/3.0/> |
||||||
|
|
||||||
|
For more information, visit <http://blog.oofn.net/projects/misc/> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,29 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef POP_POP_H |
||||||
|
#define POP_POP_H |
||||||
|
|
||||||
|
#import <pop/POPDefines.h> |
||||||
|
|
||||||
|
#import <pop/POPAnimatableProperty.h> |
||||||
|
#import <pop/POPAnimation.h> |
||||||
|
#import <pop/POPAnimationEvent.h> |
||||||
|
#import <pop/POPAnimationExtras.h> |
||||||
|
#import <pop/POPAnimationTracer.h> |
||||||
|
#import <pop/POPAnimator.h> |
||||||
|
#import <pop/POPBasicAnimation.h> |
||||||
|
#import <pop/POPCustomAnimation.h> |
||||||
|
#import <pop/POPDecayAnimation.h> |
||||||
|
#import <pop/POPGeometry.h> |
||||||
|
#import <pop/POPLayerExtras.h> |
||||||
|
#import <pop/POPPropertyAnimation.h> |
||||||
|
#import <pop/POPSpringAnimation.h> |
||||||
|
|
||||||
|
#endif /* POP_POP_H */ |
@ -0,0 +1,251 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <CoreGraphics/CoreGraphics.h> |
||||||
|
|
||||||
|
#import <Foundation/NSObject.h> |
||||||
|
|
||||||
|
#import <pop/POPDefines.h> |
||||||
|
|
||||||
|
@class POPMutableAnimatableProperty; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Describes an animatable property. |
||||||
|
*/ |
||||||
|
@interface POPAnimatableProperty : NSObject <NSCopying, NSMutableCopying> |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Property accessor. |
||||||
|
@param name The name of the property. |
||||||
|
@return The animatable property with that name or nil if it does not exist. |
||||||
|
@discussion Common animatable properties are included by default. Use the provided constants to reference. |
||||||
|
*/ |
||||||
|
+ (id)propertyWithName:(NSString *)name; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The designated initializer. |
||||||
|
@param name The name of the property. |
||||||
|
@param block The block used to configure the property on creation. |
||||||
|
@return The animatable property with name if it exists, otherwise a newly created instance configured by block. |
||||||
|
@discussion Custom properties should use reverse-DNS naming. A newly created instance is only mutable in the scope of block. Once constructed, a property becomes immutable. |
||||||
|
*/ |
||||||
|
+ (id)propertyWithName:(NSString *)name initializer:(void (^)(POPMutableAnimatableProperty *prop))block; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The name of the property. |
||||||
|
@discussion Used to uniquely identify an animatable property. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, copy) NSString *name; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Block used to read values from a property into an array of floats. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, copy) void (^readBlock)(id obj, CGFloat values[]); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Block used to write values from an array of floats into a property. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, copy) void (^writeBlock)(id obj, const CGFloat values[]); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The threshold value used when determining completion of dynamics simulations. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, assign) CGFloat threshold; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract A mutable animatable property intended for configuration. |
||||||
|
*/ |
||||||
|
@interface POPMutableAnimatableProperty : POPAnimatableProperty |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract A read-write version of POPAnimatableProperty name property. |
||||||
|
*/ |
||||||
|
@property (readwrite, nonatomic, copy) NSString *name; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract A read-write version of POPAnimatableProperty readBlock property. |
||||||
|
*/ |
||||||
|
@property (readwrite, nonatomic, copy) void (^readBlock)(id obj, CGFloat values[]); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract A read-write version of POPAnimatableProperty writeBlock property. |
||||||
|
*/ |
||||||
|
@property (readwrite, nonatomic, copy) void (^writeBlock)(id obj, const CGFloat values[]); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract A read-write version of POPAnimatableProperty threshold property. |
||||||
|
*/ |
||||||
|
@property (readwrite, nonatomic, assign) CGFloat threshold; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
/**
|
||||||
|
Common CALayer property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPLayerBackgroundColor; |
||||||
|
extern NSString * const kPOPLayerBounds; |
||||||
|
extern NSString * const kPOPLayerCornerRadius; |
||||||
|
extern NSString * const kPOPLayerBorderWidth; |
||||||
|
extern NSString * const kPOPLayerBorderColor; |
||||||
|
extern NSString * const kPOPLayerOpacity; |
||||||
|
extern NSString * const kPOPLayerPosition; |
||||||
|
extern NSString * const kPOPLayerPositionX; |
||||||
|
extern NSString * const kPOPLayerPositionY; |
||||||
|
extern NSString * const kPOPLayerRotation; |
||||||
|
extern NSString * const kPOPLayerRotationX; |
||||||
|
extern NSString * const kPOPLayerRotationY; |
||||||
|
extern NSString * const kPOPLayerScaleX; |
||||||
|
extern NSString * const kPOPLayerScaleXY; |
||||||
|
extern NSString * const kPOPLayerScaleY; |
||||||
|
extern NSString * const kPOPLayerSize; |
||||||
|
extern NSString * const kPOPLayerSubscaleXY; |
||||||
|
extern NSString * const kPOPLayerSubtranslationX; |
||||||
|
extern NSString * const kPOPLayerSubtranslationXY; |
||||||
|
extern NSString * const kPOPLayerSubtranslationY; |
||||||
|
extern NSString * const kPOPLayerSubtranslationZ; |
||||||
|
extern NSString * const kPOPLayerTranslationX; |
||||||
|
extern NSString * const kPOPLayerTranslationXY; |
||||||
|
extern NSString * const kPOPLayerTranslationY; |
||||||
|
extern NSString * const kPOPLayerTranslationZ; |
||||||
|
extern NSString * const kPOPLayerZPosition; |
||||||
|
extern NSString * const kPOPLayerShadowColor; |
||||||
|
extern NSString * const kPOPLayerShadowOffset; |
||||||
|
extern NSString * const kPOPLayerShadowOpacity; |
||||||
|
extern NSString * const kPOPLayerShadowRadius; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common CAShapeLayer property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPShapeLayerStrokeStart; |
||||||
|
extern NSString * const kPOPShapeLayerStrokeEnd; |
||||||
|
extern NSString * const kPOPShapeLayerStrokeColor; |
||||||
|
extern NSString * const kPOPShapeLayerFillColor; |
||||||
|
extern NSString * const kPOPShapeLayerLineWidth; |
||||||
|
extern NSString * const kPOPShapeLayerLineDashPhase; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common NSLayoutConstraint property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPLayoutConstraintConstant; |
||||||
|
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UIView property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPViewAlpha; |
||||||
|
extern NSString * const kPOPViewBackgroundColor; |
||||||
|
extern NSString * const kPOPViewBounds; |
||||||
|
extern NSString * const kPOPViewCenter; |
||||||
|
extern NSString * const kPOPViewFrame; |
||||||
|
extern NSString * const kPOPViewScaleX; |
||||||
|
extern NSString * const kPOPViewScaleXY; |
||||||
|
extern NSString * const kPOPViewScaleY; |
||||||
|
extern NSString * const kPOPViewSize; |
||||||
|
extern NSString * const kPOPViewTintColor; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UIScrollView property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPScrollViewContentOffset; |
||||||
|
extern NSString * const kPOPScrollViewContentSize; |
||||||
|
extern NSString * const kPOPScrollViewZoomScale; |
||||||
|
extern NSString * const kPOPScrollViewContentInset; |
||||||
|
extern NSString * const kPOPScrollViewScrollIndicatorInsets; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UITableView property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPTableViewContentOffset; |
||||||
|
extern NSString * const kPOPTableViewContentSize; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UICollectionView property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPCollectionViewContentOffset; |
||||||
|
extern NSString * const kPOPCollectionViewContentSize; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UINavigationBar property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPNavigationBarBarTintColor; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UIToolbar property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPToolbarBarTintColor; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UITabBar property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPTabBarBarTintColor; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common UILabel property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPLabelTextColor; |
||||||
|
|
||||||
|
#else |
||||||
|
|
||||||
|
/**
|
||||||
|
Common NSView property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPViewFrame; |
||||||
|
extern NSString * const kPOPViewBounds; |
||||||
|
extern NSString * const kPOPViewAlphaValue; |
||||||
|
extern NSString * const kPOPViewFrameRotation; |
||||||
|
extern NSString * const kPOPViewFrameCenterRotation; |
||||||
|
extern NSString * const kPOPViewBoundsRotation; |
||||||
|
|
||||||
|
/**
|
||||||
|
Common NSWindow property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPWindowFrame; |
||||||
|
extern NSString * const kPOPWindowAlphaValue; |
||||||
|
extern NSString * const kPOPWindowBackgroundColor; |
||||||
|
|
||||||
|
#endif |
||||||
|
|
||||||
|
#if SCENEKIT_SDK_AVAILABLE |
||||||
|
|
||||||
|
/**
|
||||||
|
Common SceneKit property names. |
||||||
|
*/ |
||||||
|
extern NSString * const kPOPSCNNodePosition; |
||||||
|
extern NSString * const kPOPSCNNodePositionX; |
||||||
|
extern NSString * const kPOPSCNNodePositionY; |
||||||
|
extern NSString * const kPOPSCNNodePositionZ; |
||||||
|
extern NSString * const kPOPSCNNodeTranslation; |
||||||
|
extern NSString * const kPOPSCNNodeTranslationX; |
||||||
|
extern NSString * const kPOPSCNNodeTranslationY; |
||||||
|
extern NSString * const kPOPSCNNodeTranslationZ; |
||||||
|
extern NSString * const kPOPSCNNodeRotation; |
||||||
|
extern NSString * const kPOPSCNNodeRotationX; |
||||||
|
extern NSString * const kPOPSCNNodeRotationY; |
||||||
|
extern NSString * const kPOPSCNNodeRotationZ; |
||||||
|
extern NSString * const kPOPSCNNodeRotationW; |
||||||
|
extern NSString * const kPOPSCNNodeEulerAngles; |
||||||
|
extern NSString * const kPOPSCNNodeEulerAnglesX; |
||||||
|
extern NSString * const kPOPSCNNodeEulerAnglesY; |
||||||
|
extern NSString * const kPOPSCNNodeEulerAnglesZ; |
||||||
|
extern NSString * const kPOPSCNNodeOrientation; |
||||||
|
extern NSString * const kPOPSCNNodeOrientationX; |
||||||
|
extern NSString * const kPOPSCNNodeOrientationY; |
||||||
|
extern NSString * const kPOPSCNNodeOrientationZ; |
||||||
|
extern NSString * const kPOPSCNNodeOrientationW; |
||||||
|
extern NSString * const kPOPSCNNodeScale; |
||||||
|
extern NSString * const kPOPSCNNodeScaleX; |
||||||
|
extern NSString * const kPOPSCNNodeScaleY; |
||||||
|
extern NSString * const kPOPSCNNodeScaleZ; |
||||||
|
extern NSString * const kPOPSCNNodeScaleXY; |
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,188 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <Foundation/NSObject.h> |
||||||
|
|
||||||
|
#import <pop/POPAnimationTracer.h> |
||||||
|
#import <pop/POPGeometry.h> |
||||||
|
|
||||||
|
@class CAMediaTimingFunction; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The abstract animation base class. |
||||||
|
@discussion Instantiate and use one of the concrete animation subclasses. |
||||||
|
*/ |
||||||
|
@interface POPAnimation : NSObject |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The name of the animation. |
||||||
|
@discussion Optional property to help identify the animation. |
||||||
|
*/ |
||||||
|
@property (copy, nonatomic) NSString *name; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The beginTime of the animation in media time. |
||||||
|
@discussion Defaults to 0 and starts immediately. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic) CFTimeInterval beginTime; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The animation delegate. |
||||||
|
@discussion See {@ref POPAnimationDelegate} for details. |
||||||
|
*/ |
||||||
|
@property (weak, nonatomic) id delegate; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The animation tracer. |
||||||
|
@discussion Returns the existing tracer, creating one if needed. Call start/stop on the tracer to toggle event collection. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic) POPAnimationTracer *tracer; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Optional block called on animation start. |
||||||
|
*/ |
||||||
|
@property (copy, nonatomic) void (^animationDidStartBlock)(POPAnimation *anim); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Optional block called when value meets or exceeds to value. |
||||||
|
*/ |
||||||
|
@property (copy, nonatomic) void (^animationDidReachToValueBlock)(POPAnimation *anim); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Optional block called on animation completion. |
||||||
|
*/ |
||||||
|
@property (copy, nonatomic) void (^completionBlock)(POPAnimation *anim, BOOL finished); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Optional block called each frame animation is applied. |
||||||
|
*/ |
||||||
|
@property (copy, nonatomic) void (^animationDidApplyBlock)(POPAnimation *anim); |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Flag indicating whether animation should be removed on completion. |
||||||
|
@discussion Setting to NO can facilitate animation reuse. Defaults to YES. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic) BOOL removedOnCompletion; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Flag indicating whether animation is paused. |
||||||
|
@discussion A paused animation is excluded from the list of active animations. On initial creation, defaults to YES. On animation addition, the animation is implicity unpaused. On animation completion, the animation is implicity paused including for animations with removedOnCompletion set to NO. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic, getter = isPaused) BOOL paused; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Flag indicating whether animation autoreverses. |
||||||
|
@discussion An animation that autoreverses will have twice the duration before it is considered finished. It will animate to the toValue, stop, then animate back to the original fromValue. The delegate methods are called as follows: |
||||||
|
|
||||||
|
1) animationDidStart: is called at the beginning, as usual, and then after each toValue is reached and the autoreverse is going to start. |
||||||
|
2) animationDidReachToValue: is called every time the toValue is reached. The toValue is swapped with the fromValue at the end of each animation segment. This means that with autoreverses set to YES, the animationDidReachToValue: delegate method will be called a minimum of twice. |
||||||
|
3) animationDidStop:finished: is called every time the toValue is reached, the finished argument will be NO if the autoreverse is not yet complete. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic) BOOL autoreverses; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The number of times to repeat the animation. |
||||||
|
@discussion A repeatCount of 0 or 1 means that the animation will not repeat, just like Core Animation. A repeatCount of 2 or greater means that the animation will run that many times before stopping. The delegate methods are called as follows: |
||||||
|
|
||||||
|
1) animationDidStart: is called at the beginning of each animation repeat. |
||||||
|
2) animationDidReachToValue: is called every time the toValue is reached. |
||||||
|
3) animationDidStop:finished: is called every time the toValue is reached, the finished argument will be NO if the autoreverse is not yet complete. |
||||||
|
|
||||||
|
When combined with the autoreverses property, a singular animation is effectively twice as long. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic) NSInteger repeatCount; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Repeat the animation forever. |
||||||
|
@discussion This property will make the animation repeat forever. The value of the repeatCount property is undefined when this property is set. The finished parameter of the delegate callback animationDidStop:finished: will always be NO. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic) BOOL repeatForever; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The animation delegate. |
||||||
|
*/ |
||||||
|
@protocol POPAnimationDelegate <NSObject> |
||||||
|
@optional |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Called on animation start. |
||||||
|
@param anim The relevant animation. |
||||||
|
*/ |
||||||
|
- (void)pop_animationDidStart:(POPAnimation *)anim; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Called when value meets or exceeds to value. |
||||||
|
@param anim The relevant animation. |
||||||
|
*/ |
||||||
|
- (void)pop_animationDidReachToValue:(POPAnimation *)anim; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Called on animation stop. |
||||||
|
@param anim The relevant animation. |
||||||
|
@param finished Flag indicating finished state. Flag is true if the animation reached completion before being removed. |
||||||
|
*/ |
||||||
|
- (void)pop_animationDidStop:(POPAnimation *)anim finished:(BOOL)finished; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Called each frame animation is applied. |
||||||
|
@param anim The relevant animation. |
||||||
|
*/ |
||||||
|
- (void)pop_animationDidApply:(POPAnimation *)anim; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
|
||||||
|
@interface NSObject (POP) |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Add an animation to the reciver. |
||||||
|
@param anim The animation to add. |
||||||
|
@param key The key used to identify the animation. |
||||||
|
@discussion The 'key' may be any string such that only one animation per unique key is added per object. |
||||||
|
*/ |
||||||
|
- (void)pop_addAnimation:(POPAnimation *)anim forKey:(NSString *)key; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Remove all animations attached to the receiver. |
||||||
|
*/ |
||||||
|
- (void)pop_removeAllAnimations; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Remove any animation attached to the receiver for 'key'. |
||||||
|
@param key The key used to identify the animation. |
||||||
|
*/ |
||||||
|
- (void)pop_removeAnimationForKey:(NSString *)key; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Returns an array containing the keys of all animations currently attached to the receiver. |
||||||
|
@param The order of keys reflects the order in which animations will be applied. |
||||||
|
*/ |
||||||
|
- (NSArray *)pop_animationKeys; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Returns any animation attached to the receiver. |
||||||
|
@param key The key used to identify the animation. |
||||||
|
@returns The animation currently attached, or nil if no such animation exists. |
||||||
|
*/ |
||||||
|
- (id)pop_animationForKey:(NSString *)key; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
/**
|
||||||
|
* This implementation of NSCopying does not do any copying of animation's state, but only configuration. |
||||||
|
* i.e. you cannot copy an animation and expect to apply it to a view and have the copied animation pick up where the original left off. |
||||||
|
* Two common uses of copying animations: |
||||||
|
* * you need to apply the same animation to multiple different views. |
||||||
|
* * you need to absolutely ensure that the the caller of your function cannot mutate the animation once it's been passed in. |
||||||
|
*/ |
||||||
|
@interface POPAnimation (NSCopying) <NSCopying> |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,69 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <Foundation/Foundation.h> |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Enumeraton of animation event types. |
||||||
|
*/ |
||||||
|
typedef NS_ENUM(NSUInteger, POPAnimationEventType) { |
||||||
|
kPOPAnimationEventPropertyRead = 0, |
||||||
|
kPOPAnimationEventPropertyWrite, |
||||||
|
kPOPAnimationEventToValueUpdate, |
||||||
|
kPOPAnimationEventFromValueUpdate, |
||||||
|
kPOPAnimationEventVelocityUpdate, |
||||||
|
kPOPAnimationEventBouncinessUpdate, |
||||||
|
kPOPAnimationEventSpeedUpdate, |
||||||
|
kPOPAnimationEventFrictionUpdate, |
||||||
|
kPOPAnimationEventMassUpdate, |
||||||
|
kPOPAnimationEventTensionUpdate, |
||||||
|
kPOPAnimationEventDidStart, |
||||||
|
kPOPAnimationEventDidStop, |
||||||
|
kPOPAnimationEventDidReachToValue, |
||||||
|
kPOPAnimationEventAutoreversed |
||||||
|
}; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The base animation event class. |
||||||
|
*/ |
||||||
|
@interface POPAnimationEvent : NSObject |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The event type. See {@ref POPAnimationEventType} for possible values. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, assign) POPAnimationEventType type; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The time of event. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, assign) CFTimeInterval time; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Optional string describing the animation at time of event. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, copy) NSString *animationDescription; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract An animation event subclass for recording value and velocity. |
||||||
|
*/ |
||||||
|
@interface POPAnimationValueEvent : POPAnimationEvent |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The value recorded. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, strong) id value; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The velocity recorded, if any. |
||||||
|
*/ |
||||||
|
@property (readonly, nonatomic, strong) id velocity; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,43 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <QuartzCore/CAAnimation.h> |
||||||
|
|
||||||
|
#import <pop/POPDefines.h> |
||||||
|
#import <pop/POPSpringAnimation.h> |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The current drag coefficient. |
||||||
|
@discussion A value greater than 1.0 indicates Simulator slow-motion animations are enabled. Defaults to 1.0. |
||||||
|
*/ |
||||||
|
extern CGFloat POPAnimationDragCoefficient(); |
||||||
|
|
||||||
|
@interface CAAnimation (POPAnimationExtras) |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Apply the current drag coefficient to animation speed. |
||||||
|
@discussion Convenience utility to respect Simulator slow-motion animation settings. |
||||||
|
*/ |
||||||
|
- (void)pop_applyDragCoefficient; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
@interface POPSpringAnimation (POPAnimationExtras) |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Converts from spring bounciness and speed to tension, friction and mass dynamics values. |
||||||
|
*/ |
||||||
|
+ (void)convertBounciness:(CGFloat)bounciness speed:(CGFloat)speed toTension:(CGFloat *)outTension friction:(CGFloat *)outFriction mass:(CGFloat *)outMass; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Converts from dynamics tension, friction and mass to spring bounciness and speed values. |
||||||
|
*/ |
||||||
|
+ (void)convertTension:(CGFloat)tension friction:(CGFloat)friction toBounciness:(CGFloat *)outBounciness speed:(CGFloat *)outSpeed; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,16 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <pop/POPAnimation.h> |
||||||
|
|
||||||
|
#define POP_ANIMATION_FRICTION_FOR_QC_FRICTION(qcFriction) (25.0 + (((qcFriction - 8.0) / 2.0) * (25.0 - 19.0))) |
||||||
|
#define POP_ANIMATION_TENSION_FOR_QC_TENSION(qcTension) (194.0 + (((qcTension - 30.0) / 50.0) * (375.0 - 194.0))) |
||||||
|
|
||||||
|
#define QC_FRICTION_FOR_POP_ANIMATION_FRICTION(fbFriction) (8.0 + 2.0 * ((fbFriction - 25.0)/(25.0 - 19.0))) |
||||||
|
#define QC_TENSION_FOR_POP_ANIMATION_TENSION(fbTension) (30.0 + 50.0 * ((fbTension - 194.0)/(375.0 - 194.0))) |
@ -0,0 +1,60 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <Foundation/Foundation.h> |
||||||
|
|
||||||
|
#import <pop/POPAnimationEvent.h> |
||||||
|
|
||||||
|
@class POPAnimation; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Tracer of animation events to facilitate unit testing & debugging. |
||||||
|
*/ |
||||||
|
@interface POPAnimationTracer : NSObject |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Start recording events. |
||||||
|
*/ |
||||||
|
- (void)start; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Stop recording events. |
||||||
|
*/ |
||||||
|
- (void)stop; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Resets any recoded events. Continues recording events if already started. |
||||||
|
*/ |
||||||
|
- (void)reset; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Property representing all recorded events. |
||||||
|
@discussion Events are returned in order of occurrence. |
||||||
|
*/ |
||||||
|
@property (nonatomic, assign, readonly) NSArray *allEvents; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Property representing all recorded write events for convenience. |
||||||
|
@discussion Events are returned in order of occurrence. |
||||||
|
*/ |
||||||
|
@property (nonatomic, assign, readonly) NSArray *writeEvents; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Queries for events of specified type. |
||||||
|
@param type The type of event to return. |
||||||
|
@returns An array of events of specified type in order of occurrence. |
||||||
|
*/ |
||||||
|
- (NSArray *)eventsWithType:(POPAnimationEventType)type; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Property indicating whether tracer should automatically log events and reset collection on animation completion. |
||||||
|
*/ |
||||||
|
@property (nonatomic, assign) BOOL shouldLogAndResetOnCompletion; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,47 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <Foundation/Foundation.h> |
||||||
|
|
||||||
|
@protocol POPAnimatorDelegate; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The animator class renders animations. |
||||||
|
*/ |
||||||
|
@interface POPAnimator : NSObject |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The shared animator instance. |
||||||
|
@discussion Consumers should generally use the shared instance in lieu of creating new instances. |
||||||
|
*/ |
||||||
|
+ (instancetype)sharedAnimator; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The optional animator delegate. |
||||||
|
*/ |
||||||
|
@property (weak, nonatomic) id<POPAnimatorDelegate> delegate; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract The animator delegate. |
||||||
|
*/ |
||||||
|
@protocol POPAnimatorDelegate <NSObject> |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Called on each frame before animation application. |
||||||
|
*/ |
||||||
|
- (void)animatorWillAnimate:(POPAnimator *)animator; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Called on each frame after animation application. |
||||||
|
*/ |
||||||
|
- (void)animatorDidAnimate:(POPAnimator *)animator; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,68 @@ |
|||||||
|
/**
|
||||||
|
Copyright (c) 2014-present, Facebook, Inc. |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
This source code is licensed under the BSD-style license found in the |
||||||
|
LICENSE file in the root directory of this source tree. An additional grant |
||||||
|
of patent rights can be found in the PATENTS file in the same directory. |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <pop/POPAnimator.h> |
||||||
|
|
||||||
|
@class POPAnimation; |
||||||
|
|
||||||
|
@protocol POPAnimatorObserving <NSObject> |
||||||
|
@required |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Called on each observer after animator has advanced. Core Animation actions are disabled by default. |
||||||
|
*/ |
||||||
|
- (void)animatorDidAnimate:(POPAnimator *)animator; |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
@interface POPAnimator () |
||||||
|
|
||||||
|
#if !TARGET_OS_IPHONE |
||||||
|
/**
|
||||||
|
Determines whether or not to use a high priority background thread for animation updates. Using a background thread can result in faster, more responsive updates, but may be less compatible. Defaults to YES. |
||||||
|
*/ |
||||||
|
+ (BOOL)disableBackgroundThread; |
||||||
|
+ (void)setDisableBackgroundThread:(BOOL)flag; |
||||||
|
#endif |
||||||
|
|
||||||
|
/**
|
||||||
|
Used for externally driven animator instances. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic) BOOL disableDisplayLink; |
||||||
|
|
||||||
|
/**
|
||||||
|
Time used when starting animations. Defaults to 0 meaning current media time is used. Exposed for unit testing. |
||||||
|
*/ |
||||||
|
@property (assign, nonatomic) CFTimeInterval beginTime; |
||||||
|
|
||||||
|
/**
|
||||||
|
Exposed for unit testing. |
||||||
|
*/ |
||||||
|
- (void)renderTime:(CFTimeInterval)time; |
||||||
|
|
||||||
|
/**
|
||||||
|
Funnel methods for category additions. |
||||||
|
*/ |
||||||
|
- (void)addAnimation:(POPAnimation *)anim forObject:(id)obj key:(NSString *)key; |
||||||
|
- (void)removeAllAnimationsForObject:(id)obj; |
||||||
|
- (void)removeAnimationForObject:(id)obj key:(NSString *)key; |
||||||
|
- (NSArray *)animationKeysForObject:(id)obj; |
||||||
|
- (POPAnimation *)animationForObject:(id)obj key:(NSString *)key; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Add an animator observer. Observer will be notified of each subsequent animator advance until removal. |
||||||
|
*/ |
||||||
|
- (void)addObserver:(id<POPAnimatorObserving>)observer; |
||||||
|
|
||||||
|
/**
|
||||||
|
@abstract Remove an animator observer. |
||||||
|
*/ |
||||||
|
- (void)removeObserver:(id<POPAnimatorObserving>)observer; |
||||||
|
|
||||||
|
@end |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue