Declared in GSGlyphEditViewProtocol.h

Overview

This protocol defines the API for the graphicView

Tasks

Properties

activeIndex

The index of the character of the active layer in the string

@property (nonatomic) NSUInteger activeIndex

activeLayer

The active layer

@property (nonatomic, nullable, strong) GSLayer *activeLayer

Discussion

If only one layer is selected it retunes it, otherwise it retunes nil.

In the editview, this is the layer that has a gray info box.

activePosition

The position of the activeLayer

@property (nonatomic) NSPoint activePosition

Discussion

This is in scaled view coordinates.

See Also

cachedLayerCount

number of layers in the view.

@property (nonatomic, readonly) NSUInteger cachedLayerCount

Discussion

This might be difference than the number of characters in the string after the features are applied

cachedLayerSelectionRange

The layer selection range after features have been applied.

@property (nonatomic, readonly) NSRange cachedLayerSelectionRange

Discussion

Note: This should now return the contents of the new selectedLayerRange property.

cursor

the currently active cursor

@property (nonatomic, retain, nullable) NSCursor *cursor

doKerning

Set if kerning is active

@property (nonatomic, assign) BOOL doKerning

doSpacing

Set if spacing is active

@property (nonatomic, assign) BOOL doSpacing

layoutManager

The layout manager

@property (strong, nonatomic, nonnull) GSLayoutManager *layoutManager

scale

The scale of the view

@property (nonatomic) CGFloat scale

selectedLayerRange

The layer selection range after features have been applied.

@property (nonatomic) NSRange selectedLayerRange

Discussion

When setting this property, the selectedRange property should also be set to the corresponding converted character range. When setting the selectedRange property (except in the case above), this property should be set to {NSNotFound, 0}. When getting this property, the actual ivar should only be returned if it is not {NSNotFound, 0}. Otherwise, the corresponding converted character range should be returned.

Note: Setting this property should implicitly set selectionAnchorLayerIndex if its length is 0.

selectedRange

the selection range in characters as in the original string

@property (nonatomic) NSRange selectedRange

selectionAnchorLayerIndex

Marks the starting point of selection.

@property (nonatomic) NSUInteger selectionAnchorLayerIndex

Discussion

Note: This property should be set implicitly when selectedLayerRange is set and its length is 0.

textStorage

the text storage

@property (strong, nonatomic, nonnull) GSTextStorage *textStorage

Instance Methods

cachedGlyphAtIndex:

Returns the cached layer at index

- (GSLayer *_Nullable)cachedGlyphAtIndex:(NSUInteger)index

Parameters

index

The cached index

Return Value

The layer

cachedPositionAtIndex:

Returns the cached position at a layer index

- (NSPoint)cachedPositionAtIndex:(NSUInteger)index

Parameters

index

The cached index

Return Value

the position

characterIndexForPoint:

Should pass the given graphical position to layerIndexForPoint: and convert the layer index to a character index.

- (NSUInteger)characterIndexForPoint:(NSPoint)point

Parameters

point

The graphical position to check, in view coordinates.

Return Value

The index of the character whose bounding box contains the point.

Discussion

Note: This may not be the desired index if a character is comprised of multiple glyphs. Instead, use layerIndexForPoint: directly and set the selectedLayerRange property.

getActiveLocation:

Translates the view coordinate from the event into glyph coordinates of the active layer

- (NSPoint)getActiveLocation:(NSEvent *_Nullable)theEvent

Parameters

theEvent

a mouse down even

Return Value

The coordinates

layerIndexForPoint:

Converts the given graphical position to a layer index.

- (NSUInteger)layerIndexForPoint:(NSPoint)point

Parameters

point

The graphical position to check, in view coordinates.

Return Value

The index of the layer whose bounding box contains the point.