33import SwiftUI
44
55public struct MIDITrackViewModel {
6- public init ( midiNotes: [ CGRect ] , length: CGFloat , height: CGFloat , playPos: Double , zoomLevel: Double , minimumZoom: Double , maximumZoom: Double ) {
7- self . midiNotes = midiNotes
6+ /// The model which holds data for the MIDITrackView
7+ /// - Parameters:
8+ /// - noteRects: the note rectangles rendered in the view
9+ /// - length: the length of the longest track
10+ /// - height: the height of the MIDI track
11+ /// - playhead: the playhead of the MIDI track
12+ /// - zoomLevel: the zoom level of the MIDI track
13+ /// - minimumZoom: the minimum zoom level for the MIDI track
14+ /// - maximumZoom: the maximum zoom level for the MIDI track
15+ public init ( noteRects: [ CGRect ] ,
16+ length: CGFloat ,
17+ height: CGFloat ,
18+ playhead: Double ,
19+ zoomLevel: Double ,
20+ minimumZoom: Double ,
21+ maximumZoom: Double ) {
22+ self . noteRects = noteRects
823 self . length = length
924 self . height = height
10- self . playPos = playPos
25+ self . playhead = playhead
1126 self . zoomLevel = zoomLevel
1227 self . minimumZoom = minimumZoom
1328 self . maximumZoom = maximumZoom
@@ -24,25 +39,23 @@ public struct MIDITrackViewModel {
2439 zoomLevel = max ( min ( newScale, maximumZoom) , minimumZoom)
2540 }
2641 public mutating func zoomLevelGestureEnded( ) { lastZoomLevel = 1.0 }
27- public mutating func updatePlayPos( newPos: Double ) { playPos = newPos }
42+ public mutating func updatePlayPos( newPos: Double ) { playhead = newPos }
43+ /// Get the zoom level of all the tracks in the view
2844 public func getZoomLevel( ) -> Double { return zoomLevel }
45+ /// Get the length of the longest track.
2946 public func getLength( ) -> CGFloat { return length }
47+ /// Get the height of all the tracks in the view.
3048 public func getHeight( ) -> CGFloat { return height }
31- public func getPlayPos ( ) -> Double { return playPos }
32- public func getMIDINotes ( ) -> [ CGRect ] { return midiNotes }
33- /// The notes rendered in the view.
34- private let midiNotes : [ CGRect ]
35- /// The length of the longest track.
49+ /// The view's current play position (also the position which the playhead displays)
50+ public func getPlayhead ( ) -> Double { return playhead }
51+ /// Get the note rectangles rendered in the view.
52+ public func getNoteRects ( ) -> [ CGRect ] { return noteRects }
53+ private let noteRects : [ CGRect ]
3654 private let length : CGFloat
37- /// The height of all the tracks in the view.
3855 private let height : CGFloat
39- /// The view's current play position (also the position which the playhead displays)
40- private var playPos : Double
41- /// The zoom level of all the tracks in the view
56+ private var playhead : Double
4257 private var zoomLevel : Double
43- /// The minimum zoom level.
4458 private let minimumZoom : Double
45- /// The maximum zoom level.
4659 private let maximumZoom : Double
4760 private var lastZoomLevel : Double = 1.0
4861}
0 commit comments