Skip to content

Custom note views#16

Merged
aure merged 3 commits intoAudioKit:mainfrom
txbrown:feature/custom-note-views
Mar 11, 2026
Merged

Custom note views#16
aure merged 3 commits intoAudioKit:mainfrom
txbrown:feature/custom-note-views

Conversation

@txbrown
Copy link
Copy Markdown
Contributor

@txbrown txbrown commented Mar 11, 2026

At the moment PianoRoll package does not allow for custom note views. We are stuck with the default rectangle.
Adding possibility of drawing custom note views allows for reusing the PianoRoll package in various applications and to fit different needs.

CleanShot 2026-03-11 at 20 53 14@2x

txbrown added 3 commits March 11, 2026 20:21
Move the nested PianoRoll.Layout enum to a top-level PianoRollLayout
type so it can be referenced without specifying generic parameters.
Extract the hardcoded note visuals into a reusable DefaultNoteView.
Make PianoRoll, PianoRollNoteView, and VerticalPianoRollNoteView
generic over NoteContent. Replace hardcoded note visuals with a
noteContent closure. Add a backward-compatible constrained init
that uses DefaultNoteView so existing call sites compile unchanged.
Add a second PianoRoll example with per-pitch rainbow colors, gradient
fills, glowing shadows, and scale-on-hover animation. Set a minimum
window size for the macOS demo.
PianoRollNote(start: 10, length: 1, pitch: 9, text: "A"),
PianoRollNote(start: 12, length: 3, pitch: 6, text: "F"),
PianoRollNote(start: 12, length: 1, pitch: 14, text: "F"),
PianoRollNote(start: 13, length: 2, pitch: 11, text: "C♯"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)

static let pitchColors: [Color] = [
.red, .orange, .yellow, .green, .mint, .cyan,
.blue, .indigo, .purple, .pink, .red, .orange,
.yellow, .green, .mint, .cyan,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)

/// - gridColor: Color of grid
/// - gridSize: Size of a grid cell
/// - layout: Horizontal or vertical layout
/// - noteContent: Custom view builder for note appearance. Receives the note and whether it is active (hovering/dragging).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 129 characters (line_length)

PianoRollNote(start: 10, length: 1, pitch: 9, text: "A"),
PianoRollNote(start: 12, length: 3, pitch: 6, text: "F"),
PianoRollNote(start: 12, length: 1, pitch: 14, text: "F"),
PianoRollNote(start: 13, length: 2, pitch: 11, text: "C♯"),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)

static let pitchColors: [Color] = [
.red, .orange, .yellow, .green, .mint, .cyan,
.blue, .indigo, .purple, .pink, .red, .orange,
.yellow, .green, .mint, .cyan,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma)

/// - gridColor: Color of grid
/// - gridSize: Size of a grid cell
/// - layout: Horizontal or vertical layout
/// - noteContent: Custom view builder for note appearance. Receives the note and whether it is active (hovering/dragging).
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line Length Violation: Line should be 120 characters or less: currently 129 characters (line_length)

@aure aure merged commit bc0075a into AudioKit:main Mar 11, 2026
2 checks passed
@aure
Copy link
Copy Markdown
Member

aure commented Mar 11, 2026

Good stuff!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants