de.sciss.mellite.gui.impl.document.EnsembleViewImpl.scala Maven / Gradle / Ivy
/*
* EnsembleViewImpl.scala
* (Mellite)
*
* Copyright (c) 2012-2016 Hanns Holger Rutz. All rights reserved.
*
* This software is published under the GNU General Public License v3+
*
*
* For further information, please contact Hanns Holger Rutz at
* [email protected]
*/
package de.sciss.mellite
package gui
package impl
package document
import de.sciss.desktop.UndoManager
import de.sciss.icons.raphael
import de.sciss.lucre.stm
import de.sciss.lucre.swing.{BooleanCheckBoxView, View, deferTx}
import de.sciss.lucre.swing.impl.ComponentHolder
import de.sciss.lucre.synth.Sys
import de.sciss.swingplus.Separator
import de.sciss.synth.proc.{SoundProcesses, Transport, Ensemble}
import scala.swing.event.ButtonClicked
import scala.swing.{Swing, Label, ToggleButton, Orientation, BoxPanel, Component}
import Swing._
object EnsembleViewImpl {
def apply[S <: Sys[S]](ensObj: Ensemble[S])(implicit tx: S#Tx, workspace: Workspace[S],
cursor: stm.Cursor[S], undoManager: UndoManager): Impl[S] = {
val ens = ensObj
val folder = FolderView(ens.folder)
val folder1 = new FolderFrameImpl.ViewImpl[S](folder)
folder1.init()
val playing = BooleanCheckBoxView(ens.playing, "Playing State")
val transport = Transport[S](Mellite.auralSystem)
transport.addObject(ensObj)
val res = new Impl(tx.newHandle(ensObj), transport, folder1, playing)
deferTx {
res.guiInit()
}
res
}
final class Impl[S <: Sys[S]](ensembleH: stm.Source[S#Tx, Ensemble[S]], transport: Transport[S],
val view: FolderFrameImpl.ViewImpl[S], playing: View[S])
(implicit val undoManager: UndoManager, val workspace: Workspace[S],
val cursor: stm.Cursor[S])
extends ComponentHolder[Component] with EnsembleView[S] { impl =>
def ensemble(implicit tx: S#Tx): Ensemble[S] = ensembleH()
def folderView = view.peer
def guiInit(): Unit = {
val ggPower = new ToggleButton {
listenTo(this)
reactions += {
case ButtonClicked(_) =>
val sel = selected
SoundProcesses.atomic[S, Unit] { implicit tx =>
transport.stop()
transport.seek(0L)
if (sel) transport.play()
} (impl.cursor)
}
}
val shpPower = raphael.Shapes.Power _
ggPower.icon = GUI.iconNormal (shpPower)
ggPower.disabledIcon = GUI.iconDisabled(shpPower)
ggPower.tooltip = "Toggle DSP"
component = new BoxPanel(Orientation.Vertical) {
contents += view.component
contents += Separator()
contents += VStrut(2)
contents += new BoxPanel(Orientation.Horizontal) {
contents += ggPower
contents += HStrut(16)
contents += new Label("Playing:")
contents += HStrut(4)
contents += playing.component
}
contents += VStrut(2)
}
}
def dispose()(implicit tx: S#Tx): Unit = {
transport .dispose()
view .dispose()
playing .dispose()
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy