MIDITimeTableView

@MainActor
open class MIDITimeTableView : UIScrollView, MIDITimeTableCellViewDelegate, MIDITimeTablePlayheadViewDelegate

Draws time table with multiple rows and editable cells. Heavily customisable.

  • Property to show measure bar. Defaults true.

    Declaration

    Swift

    @MainActor
    public var showsMeasure: Bool
  • Property to show header cells in each row. Defaults true.

    Declaration

    Swift

    @MainActor
    public var showsHeaders: Bool
  • Property to show grid. Defaults true.

    Declaration

    Swift

    @MainActor
    public var showsGrid: Bool
  • Property to show playhead. Defaults true.

    Declaration

    Swift

    @MainActor
    public var showsPlayhead: Bool
  • Property to show range head that sets the playable are on the timetable. Defaults true.

    Declaration

    Swift

    @MainActor
    public var showsRangeHead: Bool
  • When true, the range head automatically moves forward to stay at or after the end of the furthest cell, so it never gets left behind as cells are added or extended. It never moves backwards on its own; dragging it manually still works as before. Defaults true.

    Declaration

    Swift

    @MainActor
    public var autoExtendsRangeHead: Bool
  • Speed of zooming by pinch gesture.

    Declaration

    Swift

    @MainActor
    public var zoomSpeed: CGFloat
  • Maximum width of a measure bar after zooming in. Defaults 500.

    Declaration

    Swift

    @MainActor
    public var maxMeasureWidth: CGFloat
  • Minimum width of a measure bar after zooming out. Defaults 100.

    Declaration

    Swift

    @MainActor
    public var minMeasureWidth: CGFloat
  • Initial width of a measure bar. Defaults 200.

    Declaration

    Swift

    @MainActor
    public var measureWidth: CGFloat { get set }
  • Grid layer to set its customisable properties like drawing rules, colors or line widths.

    Declaration

    Swift

    @MainActor
    public private(set) var gridLayer: MIDITimeTableGridLayer { get }
  • Measure view that draws measure bars on it. You can customise its style.

    Declaration

    Swift

    @MainActor
    public private(set) var measureView: MIDITimeTableMeasureView { get }
  • Playhead view that shows the current position in timetable. You can set is hidden or movable status as well as its position.

    Declaration

    Swift

    @MainActor
    public private(set) var playheadView: MIDITimeTablePlayheadView { get }
  • Rangehead view that shows or adjusts the playable area on the timetable.

    Declaration

    Swift

    @MainActor
    public private(set) var rangeheadView: MIDITimeTablePlayheadView { get }
  • All row header cell views currently displaying.

    Declaration

    Swift

    @MainActor
    public private(set) var rowHeaderCellViews: [MIDITimeTableHeaderCellView] { get }
  • Cell views currently realized: on screen (plus a small overscan margin, see virtualizationOverscanMultiplier) or pinned because their cell is selected. Renamed from the old, fully-dense cellViews — a cell being absent here doesn’t mean it doesn’t exist in the data source, only that it isn’t currently rendered as a view. Kept in sync by the windowing pass in layoutSubviews.

    Declaration

    Swift

    @MainActor
    public private(set) var visibleCells: [MIDITimeTableCellView] { get }
  • Multiplier applied to the current viewport size to compute the overscan margin used to decide which cells/grid lines/measure bars to realize. Defaults 1, i.e. content within one extra screen’s worth of scrolling in every direction is realized ahead of time, so fast scrolling doesn’t show a pop-in edge.

    Declaration

    Swift

    @MainActor
    public var virtualizationOverscanMultiplier: CGFloat
  • Data source object of the time table to populate its data.

    Declaration

    Swift

    @MainActor
    public weak var dataSource: MIDITimeTableViewDataSource?
  • Delegate object of the time table to inform about changes and customise sizing.

    Declaration

    Swift

    @MainActor
    public weak var timeTableDelegate: MIDITimeTableViewDelegate?

Init

  • Undocumented

    Declaration

    Swift

    @MainActor
    public override init(frame: CGRect)
  • Undocumented

    Declaration

    Swift

    @MainActor
    public required init?(coder aDecoder: NSCoder)

Lifecycle

  • Undocumented

    Declaration

    Swift

    @MainActor
    open override func layoutSubviews()
  • Populates row and cell layout data from its data source and redraws time table.

    Declaration

    Swift

    @MainActor
    public func reloadData()
  • Applies an edit result to the time table’s own row data and cell views incrementally: only cells actually touched by result (updated, removed, or newly inserted) get their view moved, removed, or created. Every other cell keeps its existing view instance and stays in the hierarchy exactly as it was, instead of the whole table being torn down and rebuilt the way reloadData() would.

    User-driven changes already call this for you after first giving your delegate a chance to apply the same result to your backing data source. If you call this directly with insertions, update your data source first so newly dequeued cell views can be configured from the inserted models.

    Declaration

    Swift

    @MainActor
    public func applyEditResult(_ result: MIDITimeTableCellEditResult)

    Parameters

    result

    The edit result to apply.

  • Removes the given cells by publishing a normal change result. The delegate receives MIDITimeTableCellEditResult(removals:) first, then the time table removes the cells from its internal layout snapshot.

    Declaration

    Swift

    @MainActor
    public func removeCells(at indices: [MIDITimeTableCellIndex])

    Parameters

    indices

    Row/index pairs of the cells to remove.

  • Returns a cell’s currently realized view, if any. nil if the cell exists in the data but isn’t currently realized — off-screen and unselected, see visibleCells.

    Declaration

    Swift

    @MainActor
    public func cellView(for id: MIDITimeTableCellID) -> MIDITimeTableCellView?

    Parameters

    id

    Stable id of the cell to look up.

    Return Value

    The cell’s realized view, or nil.

  • Gets the row and column index of the cell view in the data source.

    Declaration

    Swift

    @MainActor
    public func cellIndex(of cell: MIDITimeTableCellView) -> MIDITimeTableCellIndex?

    Parameters

    cell

    The cell you want to get row and column info.

    Return Value

    Returns a row and column index Int pair in a tuple.

  • Returns a reusable cell view with identifier, if one is available.

    Declaration

    Swift

    @MainActor
    public func dequeueReusableCellView(withIdentifier identifier: String) -> MIDITimeTableCellView?
  • Returns a reusable header view with identifier, if one is available.

    Declaration

    Swift

    @MainActor
    public func dequeueReusableHeaderCellView(withIdentifier identifier: String) -> MIDITimeTableHeaderCellView?

Drag to select multiple cells

  • Makes all cells unselected. A selected cell is always realized (see visibleCells), so this reaches every selected cell in the whole document, not just the ones on screen.

    Declaration

    Swift

    @MainActor
    public func unselectAllCells()

MIDITimeTableCellViewDelegate

MIDITimeTablePlayheadViewDelegate