Conversation
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♯"), |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
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♯"), |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
Line Length Violation: Line should be 120 characters or less: currently 129 characters (line_length)
|
Good stuff! |
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.