All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.sciss.mellite.impl.timeline.tool.CollectionImpl.scala Maven / Gradle / Ivy

/*
 *  CollectionImpl.scala
 *  (Mellite)
 *
 *  Copyright (c) 2012-2023 Hanns Holger Rutz. All rights reserved.
 *
 *  This software is published under the GNU Affero General Public License v3+
 *
 *
 *  For further information, please contact Hanns Holger Rutz at
 *  [email protected]
 */

package de.sciss.mellite.impl.timeline.tool

import de.sciss.lucre.edit.UndoManager
import de.sciss.lucre.synth.Txn
import de.sciss.lucre.{Obj, SpanLikeObj}
import de.sciss.mellite.impl.tool.BasicCollectionTool
import de.sciss.mellite.{ObjTimelineView, TimelineTool, TimelineTrackCanvas}
import de.sciss.proc.Timeline

/** A more complete implementation for timeline tools that process selected regions.
  * It implements `commit` by aggregating individual region based
  * commits performed in the abstract method `commitObj`.
  */
trait CollectionImpl[T <: Txn[T], A] extends BasicCollectionTool[T, A, Int, ObjTimelineView[T]]
  with TimelineTool[T, A] {

  override protected def canvas: TimelineTrackCanvas[T]

  override def commit(drag: A)(implicit tx: T, undoManager: UndoManager[T]): Boolean = {
    lazy val tl = canvas.timeline
    var edited = false
    undoManager.capture(name) {
      canvas.selectionModel.iterator.foreach { pv =>
        val span = pv.span
        val proc = pv.obj
        edited |= commitObj(drag)(span, proc, tl)
      }
    }
    edited
  }

  protected def commitObj(drag: A)(span: SpanLikeObj[T], obj: Obj[T], timeline: Timeline[T])
                         (implicit tx: T, undoManager: UndoManager[T]): Boolean
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy