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

de.sciss.mellite.impl.objview.TimelineObjView.scala Maven / Gradle / Ivy

/*
 *  TimelineObjViewFactory.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.objview

import de.sciss.lucre.swing.Window
import de.sciss.lucre.synth.Txn
import de.sciss.lucre.{Obj, Source, Txn => LTxn}
import de.sciss.mellite.impl.objview.ObjViewImpl.raphaelIcon
import de.sciss.mellite.{ObjListView, ObjView, Shapes, TimelineFrame, UniverseHandler}
import de.sciss.proc.Implicits._
import de.sciss.proc.Timeline

import javax.swing.Icon

object TimelineObjView extends NoArgsListObjViewFactory {
  type E[T <: LTxn[T]] = Timeline[T]
  val icon          : Icon      = raphaelIcon(Shapes.Timeline)
  val prefix        : String    = "Timeline"
  def humanName     : String    = prefix
  def tpe           : Obj.Type  = Timeline
  def category      : String    = ObjView.categComposition

  def mkListView[T <: Txn[T]](obj: Timeline[T])(implicit tx: T): ObjListView[T] =
    new Impl(tx.newHandle(obj)).initAttrs(obj)

  def makeObj[T <: Txn[T]](name: String)(implicit tx: T): List[Obj[T]] = {
    val obj = Timeline[T]() // .Modifiable[T]
    if (name.nonEmpty) obj.name = name
    obj :: Nil
  }

  trait Basic[T <: Txn[T]]
    extends ObjViewImpl.Impl[T]
      with TimelineObjView[T] {

    def factory: ObjView.Factory = TimelineObjView

    override def isViewable = true

    override def openView(parent: Option[Window[T]])
                (implicit tx: T, handler: UniverseHandler[T]): Option[Window[T]] = {
      val frame = TimelineFrame[T](objH())
      Some(frame)
    }
  }

  private final class Impl[T <: Txn[T]](val objH: Source[T, Timeline[T]])
    extends Basic[T]
      with ObjListViewImpl.EmptyRenderer[T]
      with ObjListViewImpl.NonEditable[T] {
  }
}
trait TimelineObjView[T <: LTxn[T]] extends ObjView[T] {
  type Repr = Timeline[T]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy