Muvicado HD
Loading...
Searching...
No Matches
Pad Class Reference

A drawable element backed by NSBezierPath with color, text, and MIDI attributes. More...

#include <Pad.h>

Inheritance diagram for Pad:
Collaboration diagram for Pad:

Instance Methods

(NSString *) - text
(void) - setText:
(Boolean) - hasAction
(id) - initWithRect:
(id) - initWithPad:
(id) - initWithBezierPath:
(void) - formatSvgToFile:withIndentLevel:
(void) - translateX:Y:
(BOOL) - containsPoint:
(void) - transformUsingAffineTransform:
(void) - draw
(id) - copyWithZone: [implementation]
(void) - setFillColor: [implementation]
(void) - setLineColor: [implementation]
(void) - setTransparency: [implementation]
(id) - init [implementation]
(void) - dealloc [implementation]
(void) - encodeWithCoder: [implementation]
(id) - initWithCoder: [implementation]
(void) - drawNubs: [implementation]

Protected Types

enum  {
  PadAction_NONE = 0 , PadActionResetMode = 1 , PadActionRestMode , PadActionDrawFreehandPadMode ,
  PadActionDrawPolygonPadMode , PadActionMovePadMode , PadActionToggleGrid , PadActionSelectAll ,
  PadActionDeselectAll , PadActionMakeTransparent , PadActionMakeOpaque , PadActionDuplicate ,
  PadActionPlayMode , PadActionNudgeRight , PadActionNudgeLeft , PadActionNudgeUp ,
  PadActionNudgeDown , PadActionRotateRight , PadActionRotateLeft , PadActionFlipVertical ,
  PadActionScale2xHorizontal , PadActionScale2xVertical , PadActionScale3xHorizontal , PadActionScale3xVertical ,
  PadActionScale1_2xHorizontal , PadActionScale1_2xVertical , PadActionScale1_3xHorizontal , PadActionScale1_3xVertical
}
typedef NSInteger PadActionID

Protected Attributes

NSBezierPath * path
 ! Primary geometry of the pad.
NSBezierPath * tracePath
 ! Optional secondary path (e.g., trace/preview).
NSMutableArray * elementBag
 ! Optional container for child elements.
NSString * text
 ! Label drawn at the pad's center.
NSColor * fillColor
 ! Fill color.
NSColor * lineColor
 ! Stroke color.
int layer
 ! Layer index this pad belongs to (0 means all).
int targetLayer
 ! Target layer used when the pad acts as an action.
int port
 ! Reserved for MIDI port (if used).
int channel
 ! MIDI channel (0–15).
int note
 ! MIDI note number (0–127).
int velocity
 ! Default MIDI velocity (0–127).
int actionID
 ! Optional UI action identifier (PadActionID).
CGFloat lineWidth
 ! Stroke width used when drawing the path.
BOOL hilight
 ! Temporary highlight state for playback feedback.
BOOL selected

Properties

CGFloat transparency
 ! Convenience access to fill alpha component.
NSColor * altFillColor
 ! Alternate fill color for highlight.

Detailed Description

A drawable element backed by NSBezierPath with color, text, and MIDI attributes.

Concrete implementation of Pad behaviors.

Pads are the primary interactive shapes in the canvas. They support selection, drawing, hit-testing, affine transforms, and persistence. Pads can be exported to SVG path data and used to trigger MIDI notes when interacted with.

Definition at line 24 of file Pad.h.

Member Typedef Documentation

◆ PadActionID

- (typedef NSInteger) PadActionID
protected

Definition at line 80 of file Pad.h.

Member Enumeration Documentation

◆ anonymous enum

- (anonymous) enum
protected
Enumerator
PadAction_NONE 
PadActionResetMode 
PadActionRestMode 
PadActionDrawFreehandPadMode 
PadActionDrawPolygonPadMode 
PadActionMovePadMode 
PadActionToggleGrid 
PadActionSelectAll 
PadActionDeselectAll 
PadActionMakeTransparent 
PadActionMakeOpaque 
PadActionDuplicate 
PadActionPlayMode 
PadActionNudgeRight 
PadActionNudgeLeft 
PadActionNudgeUp 
PadActionNudgeDown 
PadActionRotateRight 
PadActionRotateLeft 
PadActionFlipVertical 
PadActionScale2xHorizontal 
PadActionScale2xVertical 
PadActionScale3xHorizontal 
PadActionScale3xVertical 
PadActionScale1_2xHorizontal 
PadActionScale1_2xVertical 
PadActionScale1_3xHorizontal 
PadActionScale1_3xVertical 

Definition at line 49 of file Pad.h.

Method Documentation

◆ containsPoint:

- (BOOL) containsPoint: (NSPoint) p

Tests whether a point lies within the pad's filled area.

Parameters
pA point in the same coordinate space as the path.
Returns
YES if the point is inside; otherwise NO.

Hit-tests a point against the pad's filled area.

Definition at line 394 of file Pad.m.

◆ copyWithZone:

- (id) copyWithZone: (NSZone *) zone
implementation

Creates a deep copy of the pad, duplicating geometry, colors, and attributes.

Parameters
zoneAllocation zone (unused).
Returns
A newly allocated Pad copy.

Definition at line 39 of file Pad.m.

Here is the call graph for this function:

◆ dealloc

- (void) dealloc
implementation

Releases owned objects.

Reimplemented from Element.

Definition at line 206 of file Pad.m.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw

- (void) draw

Draws the pad's fill, stroke, optional text, and selection handles.

Renders the pad: fill, stroke, centered text label, and selection handles.

fudge...

Definition at line 485 of file Pad.m.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawNubs:

- (void) drawNubs: (NSBezierPath *) bez
implementation

Draws small square handles (nubs) at key points of a path.

Definition at line 416 of file Pad.m.

Here is the caller graph for this function:

◆ encodeWithCoder:

- (void) encodeWithCoder: (NSCoder *) aCoder
implementation

Encodes the pad for archiving.

Reimplemented from Element.

Definition at line 217 of file Pad.m.

◆ formatSvgToFile:withIndentLevel:

- (void) formatSvgToFile: (FILE *) outfile
withIndentLevel: (int) level 

Serializes the pad as an SVG <path> element.

Parameters
outfileDestination C FILE*.
levelIndentation level for pretty-printing.

Writes an SVG <path> with style, d attribute, and id metadata. Converts NSBezierPath elements to SVG commands (M, L, C, Z).

Definition at line 264 of file Pad.m.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasAction

- (Boolean) hasAction

Indicates whether this pad has an assigned UI action.

Returns
YES if actionID != PadAction_NONE; otherwise NO.

Indicates whether this pad has an assigned action.

Definition at line 140 of file Pad.m.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init

- (id) init
implementation

Designated initializer: sets defaults, creates a path, and assigns colors.

Reimplemented from Element.

Definition at line 147 of file Pad.m.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initWithBezierPath:

- (id) initWithBezierPath: (NSBezierPath *) bp

Initializes a pad with an existing Bezier path.

Parameters
bpBezier path to adopt (retained).

Initializes with an existing Bezier path instance.

Definition at line 187 of file Pad.m.

Here is the call graph for this function:

◆ initWithCoder:

- (id) initWithCoder: (NSCoder *) aDecoder
implementation

Decodes the pad from an archive.

Reimplemented from Element.

Definition at line 234 of file Pad.m.

Here is the call graph for this function:

◆ initWithPad:

- (id) initWithPad: (Pad *) pad

Initializes a pad by copying properties from another pad.

Parameters
padSource pad.

Placeholder initializer to copy from another pad (currently unused).

Definition at line 196 of file Pad.m.

Here is the call graph for this function:

◆ initWithRect:

- (id) initWithRect: (NSRect) rect

Initializes a rectangular pad path.

Parameters
rectRectangle to outline.

Initializes a rectangular path and closes it.

Definition at line 166 of file Pad.m.

Here is the call graph for this function:

◆ setFillColor:

- (void) setFillColor: (NSColor *) x
implementation

Sets and retains the fill color.

Definition at line 67 of file Pad.m.

Here is the caller graph for this function:

◆ setLineColor:

- (void) setLineColor: (NSColor *) x
implementation

Sets the stroke color (disabled retain to avoid crash noted in comments).

Definition at line 107 of file Pad.m.

Here is the caller graph for this function:

◆ setText:

- (void) setText: (NSString *) t

Sets the pad's text label.

Parameters
tNew text value (retained).

Sets and retains the pad's text label.

Definition at line 132 of file Pad.m.

Here is the caller graph for this function:

◆ setTransparency:

- (void) setTransparency: (CGFloat) x
implementation

Sets the alpha component of the fill color while preserving RGB.

Definition at line 117 of file Pad.m.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ text

- (NSString *) text

Returns the pad's text label.

Here is the call graph for this function:

◆ transformUsingAffineTransform:

- (void) transformUsingAffineTransform: (NSAffineTransform *) transform

Applies an affine transform to the pad's path (and tracePath if present).

Parameters
transformAffine transform to apply.

Applies an affine transform to path and tracePath.

Definition at line 405 of file Pad.m.

Here is the caller graph for this function:

◆ translateX:Y:

- (void) translateX: (CGFloat) deltaX
Y: (CGFloat) deltaY 

Translates the pad geometry by the specified deltas.

Parameters
deltaXTranslation along X.
deltaYTranslation along Y.

Translates the pad's geometry by deltaX and deltaY.

Definition at line 386 of file Pad.m.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ actionID

- (int) actionID
readwriteprotected

! Optional UI action identifier (PadActionID).

Definition at line 38 of file Pad.h.

◆ channel

- (int) channel
readwriteprotected

! MIDI channel (0–15).

Definition at line 35 of file Pad.h.

◆ elementBag

- (NSMutableArray *) elementBag
readwriteretainprotected

! Optional container for child elements.

Definition at line 28 of file Pad.h.

◆ fillColor

- (NSColor *) fillColor
readwriteretainprotected

! Fill color.

Returns the current fill color.

Definition at line 63 of file Pad.m.

◆ hilight

- (BOOL) hilight
readwriteprotected

! Temporary highlight state for playback feedback.

Definition at line 41 of file Pad.h.

◆ layer

- (int) layer
readwriteprotected

! Layer index this pad belongs to (0 means all).

Definition at line 32 of file Pad.h.

◆ lineColor

- (NSColor *) lineColor
readwriteretainprotected

! Stroke color.

For the colors... assign ng (crash) retain ok copy ok (but leaks, I think)

Returns the current stroke color.

Definition at line 102 of file Pad.m.

◆ lineWidth

- (CGFloat) lineWidth
readwriteprotected

! Stroke width used when drawing the path.

Definition at line 39 of file Pad.h.

◆ note

- (int) note
readwriteprotected

! MIDI note number (0–127).

Definition at line 36 of file Pad.h.

◆ path

- (NSBezierPath *) path
readwriteretainprotected

! Primary geometry of the pad.

Definition at line 26 of file Pad.h.

◆ port

- (int) port
readwriteprotected

! Reserved for MIDI port (if used).

Definition at line 34 of file Pad.h.

◆ selected

- (BOOL) selected
readwriteprotected

! Selection state in the editor.

Definition at line 42 of file Pad.h.

◆ targetLayer

- (int) targetLayer
readwriteprotected

! Target layer used when the pad acts as an action.

Definition at line 33 of file Pad.h.

◆ text

- (NSString *) text
readwriteretainprotected

! Label drawn at the pad's center.

Returns the pad's text label.

Definition at line 128 of file Pad.m.

◆ tracePath

- (NSBezierPath *) tracePath
readwriteretainprotected

! Optional secondary path (e.g., trace/preview).

Definition at line 27 of file Pad.h.

◆ velocity

- (int) velocity
readwriteprotected

! Default MIDI velocity (0–127).

Definition at line 37 of file Pad.h.

Property Documentation

◆ altFillColor

- (NSColor *) altFillColor
readatomicassign

! Alternate fill color for highlight.

Computes an alternate fill color (lighter or darker) used for highlighting.

Returns
A derived NSColor based on the primary fillColor.

Definition at line 78 of file Pad.m.

◆ transparency

- (CGFloat) transparency
readwriteatomic

! Convenience access to fill alpha component.

Gets the alpha component of the fill color.

Definition at line 113 of file Pad.m.


The documentation for this class was generated from the following files: