GSShape Class Reference
Inherits from | NSObject |
Conforms to | GSSelectableElementProtocol NSCopying |
Declared in | GSShape.h |
Tasks
Other Methods
– initWithDict:format:
position
positionPrecise
– setPositionFast:
– moveWithPoint:
– undoManager
– saveToFile:format:error:
– propertyListValueFormat:
Attributes
Properties
attributes
Place to store data.
@property (strong, nonatomic, nullable) NSDictionary
*attributes
Discussion
Here it is possible to store something. Please use a unique key. The objects should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).
positionPrecise
The unrounded position of the element.
@property (nonatomic, readonly) NSPoint
positionPrecise
Discussion
This is used for consecutiv operations to avoid rounding errors
Instance Methods
attributeForKey:
convenience accessor to get to the content of the attributes dict
- (NSObject *_Nullable)attributeForKey:(NSString
*)key
Parameters
- key
-
the key
Return Value
the data stored with key
initWithDict:format:
initialises a shape with a dictionary loaded from a pList.
- (instancetype)initWithDict:(NSDictionary *)dict
format:(GSFormatVersion)formatVersion
Parameters
- dict
-
A dictionary
moveWithPoint:
Moves the path by the offset.
- (void)moveWithPoint:(NSPoint)offset
Parameters
- offset
-
A NSPoint
propertyListValueFormat:
Returns the content of the object to store it in pList.
- (nullable NSDictionary
*)propertyListValueFormat:(GSFormatVersion)format
Parameters
- format
-
the version of the dict
Discussion
This is used to store the data in the .glyphs file.
removeAttributeForKey:
Removed the object with this key.
- (void)removeAttributeForKey:(NSString *)key
Parameters
- key
-
The key to remove
saveToFile:format:error:
writes that shape to file
- (BOOL)saveToFile:(FILE *)file
format:(GSFormatVersion)formatVersion error:(NSError
**)error
Parameters
- file
-
Nullable for testing purposes.
- formatVersion
-
formatVersion
- error
-
error
Return Value
return value description
setAttribute:forKey:
Adds something to the fonts attributes.
- (void)setAttribute:(nullable id)value
forKey:(nonnull NSString *)key
Parameters
- value
-
The object should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).
- key
-
Please use an uniqe key that gives some indecation who put it there (e.g. prefix it with your name or project).
Discussion
This also triggers undo/document dirty state.
setPositionFast:
Sets the position without notifying the path and no undo.
- (void)setPositionFast:(NSPoint)position
Parameters
- position
-
The new position
Discussion
This is mostly used to build a new element list that is later
added to the layer. Otherwise you need to make sure to anounce the
changes. e.g. by calling [GSLayer
elementDidChange:]
.