35 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
36 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
37 |
|
|
|
import java.text.NumberFormat; |
|
|
|
|
38 |
import javax.swing.Action; |
import javax.swing.Action; |
39 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
40 |
import javax.swing.Box; |
import javax.swing.Box; |
45 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
46 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
47 |
import javax.swing.JPopupMenu; |
import javax.swing.JPopupMenu; |
|
import javax.swing.JToolBar; |
|
48 |
import javax.swing.Timer; |
import javax.swing.Timer; |
49 |
|
|
50 |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
51 |
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
52 |
|
|
53 |
import net.sf.juife.Dial; |
import net.sf.juife.Dial; |
|
import net.sf.juife.InformationDialog; |
|
54 |
import net.sf.juife.JuifeUtils; |
import net.sf.juife.JuifeUtils; |
55 |
|
|
56 |
import org.jsampler.CC; |
import org.jsampler.CC; |
57 |
import org.jsampler.HF; |
import org.jsampler.HF; |
58 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
59 |
|
|
|
import org.jsampler.view.std.JSFxSendsPane; |
|
|
import org.jsampler.view.std.JSInstrumentChooser; |
|
|
import org.jsampler.view.std.JSVolumeEditorPopup; |
|
|
|
|
60 |
import org.jvnet.substance.SubstanceImageCreator; |
import org.jvnet.substance.SubstanceImageCreator; |
61 |
|
|
62 |
import org.linuxsampler.lscp.SamplerChannel; |
import org.linuxsampler.lscp.SamplerChannel; |
65 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
66 |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
67 |
import static org.jsampler.view.fantasia.FantasiaUtils.*; |
import static org.jsampler.view.fantasia.FantasiaUtils.*; |
|
import static org.jsampler.view.std.JSVolumeEditorPopup.VolumeType; |
|
68 |
|
|
69 |
/** |
/** |
70 |
* |
* |
77 |
private final EnhancedDial dialVolume = new EnhancedDial(); |
private final EnhancedDial dialVolume = new EnhancedDial(); |
78 |
private final ChannelScreen screen; |
private final ChannelScreen screen; |
79 |
|
|
80 |
private final PowerButton btnPower = new PowerButton(); |
private final Channel.PowerButton btnPower; |
81 |
private final MuteButton btnMute = new MuteButton(); |
private final MuteButton btnMute = new MuteButton(); |
82 |
private final SoloButton btnSolo = new SoloButton(); |
private final SoloButton btnSolo = new SoloButton(); |
83 |
private final OptionsButton btnOptions = new OptionsButton(); |
private final Channel.OptionsButton btnOptions; |
84 |
|
|
85 |
|
|
86 |
/** Creates a new instance of <code>NormalChannelView</code> */ |
/** Creates a new instance of <code>NormalChannelView</code> */ |
95 |
this.channel = channel; |
this.channel = channel; |
96 |
this.channelOptionsView = channelOptionsView; |
this.channelOptionsView = channelOptionsView; |
97 |
|
|
98 |
|
addMouseListener(channel.getContextMenu()); |
99 |
|
|
100 |
|
btnPower = new Channel.PowerButton(channel); |
101 |
|
btnOptions = new Channel.OptionsButton(channel); |
102 |
|
|
103 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
104 |
|
|
105 |
screen = new ChannelScreen(channel); |
screen = new ChannelScreen(channel); |
229 |
SamplerChannel sc = channel.getChannelInfo(); |
SamplerChannel sc = channel.getChannelInfo(); |
230 |
|
|
231 |
screen.updateScreenInfo(sc); |
screen.updateScreenInfo(sc); |
232 |
|
float f = sc.getVolume() * 100.0f; |
233 |
|
screen.updateVolumeInfo((int)f); |
234 |
updateMuteIcon(sc); |
updateMuteIcon(sc); |
235 |
|
|
236 |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn); |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn); |
342 |
} |
} |
343 |
|
|
344 |
|
|
|
private class PowerButton extends PixmapToggleButton implements ActionListener { |
|
|
|
|
|
PowerButton() { |
|
|
super(Res.gfxPowerOff, Res.gfxPowerOn); |
|
|
|
|
|
setSelected(true); |
|
|
addActionListener(this); |
|
|
setToolTipText(i18n.getButtonLabel("Channel.ttRemoveChannel")); |
|
|
} |
|
|
|
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
boolean b = preferences().getBoolProperty(CONFIRM_CHANNEL_REMOVAL); |
|
|
if(b) { |
|
|
String s = i18n.getMessage("Channel.remove?", channel.getChannelId()); |
|
|
if(!HF.showYesNoDialog(NormalChannelView.this, s)) { |
|
|
setSelected(true); |
|
|
return; |
|
|
} |
|
|
} |
|
|
channel.remove(); |
|
|
} |
|
|
|
|
|
public boolean |
|
|
contains(int x, int y) { return (x - 11)*(x - 11) + (y - 11)*(y - 11) < 71; } |
|
|
} |
|
|
|
|
345 |
private class MuteButton extends PixmapButton implements ActionListener { |
private class MuteButton extends PixmapButton implements ActionListener { |
346 |
MuteButton() { |
MuteButton() { |
347 |
super(Res.gfxMuteOff); |
super(Res.gfxMuteOff); |
410 |
public boolean |
public boolean |
411 |
contains(int x, int y) { return (x > 5 && x < 23) && (y > 5 && y < 16); } |
contains(int x, int y) { return (x > 5 && x < 23) && (y > 5 && y < 16); } |
412 |
} |
} |
|
|
|
|
private class OptionsButton extends PixmapToggleButton implements ActionListener { |
|
|
OptionsButton() { |
|
|
super(Res.gfxOptionsOff, Res.gfxOptionsOn); |
|
|
setRolloverIcon(Res.gfxOptionsOffRO); |
|
|
this.setRolloverSelectedIcon(Res.gfxOptionsOnRO); |
|
|
addActionListener(this); |
|
|
setToolTipText(i18n.getButtonLabel("Channel.ttShowOptions")); |
|
|
} |
|
|
|
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
channel.showOptionsPane(isSelected()); |
|
|
|
|
|
String s; |
|
|
if(isSelected()) s = i18n.getButtonLabel("Channel.ttHideOptions"); |
|
|
else s = i18n.getButtonLabel("Channel.ttShowOptions"); |
|
|
|
|
|
setToolTipText(s); |
|
|
} |
|
|
|
|
|
public boolean |
|
|
contains(int x, int y) { return super.contains(x, y) & y < 13; } |
|
|
} |
|
413 |
} |
} |
414 |
|
|
415 |
|
|
426 |
|
|
427 |
private final InstrumentPane instrumentPane; |
private final InstrumentPane instrumentPane; |
428 |
|
|
429 |
|
private final Channel.StreamVoiceCountPane streamVoiceCountPane; |
430 |
|
|
431 |
|
private final Channel.VolumePane volumePane; |
432 |
|
|
433 |
private JButton btnInstr = |
private JButton btnInstr = |
434 |
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
435 |
|
|
445 |
|
|
446 |
private final JPopupMenu menuEngines = new JPopupMenu(); |
private final JPopupMenu menuEngines = new JPopupMenu(); |
447 |
|
|
|
private final JButton btnVolume = createScreenButton(""); |
|
|
private JSVolumeEditorPopup popupVolume; |
|
|
|
|
|
private final JLabel lStreams = createScreenLabel(" --"); |
|
|
private final JLabel lVoices = createScreenLabel("-- "); |
|
|
|
|
|
private InformationDialog fxSendsDlg = null; |
|
|
|
|
448 |
private Timer timer; |
private Timer timer; |
449 |
|
|
|
private static NumberFormat numberFormat = NumberFormat.getInstance(); |
|
|
static { |
|
|
numberFormat.setMaximumFractionDigits(1); |
|
|
} |
|
|
|
|
450 |
ChannelScreen(final Channel channel) { |
ChannelScreen(final Channel channel) { |
451 |
super(Res.gfxChannelScreen); |
super(Res.gfxChannelScreen); |
452 |
setPixmapInsets(new Insets(6, 6, 6, 6)); |
setPixmapInsets(new Insets(6, 6, 6, 6)); |
453 |
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
454 |
|
|
455 |
this.channel = channel; |
this.channel = channel; |
456 |
popupVolume = new JSVolumeEditorPopup(btnVolume, VolumeType.CHANNEL); |
addMouseListener(channel.getContextMenu()); |
457 |
|
streamVoiceCountPane = new Channel.StreamVoiceCountPane(channel); |
458 |
|
volumePane = new Channel.VolumePane(channel); |
459 |
|
|
460 |
setOpaque(false); |
setOpaque(false); |
461 |
|
|
464 |
btnInstr.setAlignmentX(CENTER_ALIGNMENT); |
btnInstr.setAlignmentX(CENTER_ALIGNMENT); |
465 |
btnInstr.setRolloverEnabled(false); |
btnInstr.setRolloverEnabled(false); |
466 |
btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); |
btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); |
467 |
|
btnInstr.addMouseListener(channel.getContextMenu()); |
468 |
|
|
469 |
instrumentPane = new InstrumentPane(); |
instrumentPane = new InstrumentPane(); |
470 |
add(instrumentPane); |
add(instrumentPane); |
478 |
btnFxSends.addActionListener(new ActionListener() { |
btnFxSends.addActionListener(new ActionListener() { |
479 |
public void |
public void |
480 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
481 |
if(fxSendsDlg != null && fxSendsDlg.isVisible()) { |
channel.showFxSendsDialog(); |
|
fxSendsDlg.toFront(); |
|
|
return; |
|
|
} |
|
|
FxSendsPane p = new FxSendsPane(channel.getModel()); |
|
|
int id = channel.getModel().getChannelId(); |
|
|
fxSendsDlg = new InformationDialog(CC.getMainFrame(), p); |
|
|
fxSendsDlg.setTitle(i18n.getLabel("FxSendsDlg.title", id)); |
|
|
fxSendsDlg.setModal(false); |
|
|
fxSendsDlg.showCloseButton(false); |
|
|
fxSendsDlg.setVisible(true); |
|
482 |
} |
} |
483 |
}); |
}); |
484 |
|
|
485 |
|
btnFxSends.addMouseListener(channel.getContextMenu()); |
486 |
|
|
487 |
p.add(btnFxSends); |
p.add(btnFxSends); |
488 |
|
|
489 |
//p.add(Box.createRigidArea(new Dimension(6, 0))); |
//p.add(Box.createRigidArea(new Dimension(6, 0))); |
491 |
|
|
492 |
btnEngine.setIcon(Res.iconEngine12); |
btnEngine.setIcon(Res.iconEngine12); |
493 |
btnEngine.setIconTextGap(1); |
btnEngine.setIconTextGap(1); |
494 |
|
btnEngine.addMouseListener(channel.getContextMenu()); |
495 |
p.add(btnEngine); |
p.add(btnEngine); |
496 |
//p.add(new Label("|")); |
//p.add(new Label("|")); |
497 |
|
|
501 |
|
|
502 |
p.add(Box.createGlue()); |
p.add(Box.createGlue()); |
503 |
|
|
504 |
lStreams.setFont(Res.fontScreenMono); |
p.add(streamVoiceCountPane); |
505 |
lStreams.setHorizontalAlignment(JLabel.RIGHT); |
p.add(volumePane); |
|
lStreams.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
|
|
p.add(lStreams); |
|
|
|
|
|
JLabel l = createScreenLabel("/"); |
|
|
l.setFont(Res.fontScreenMono); |
|
|
l.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
|
|
p.add(l); |
|
|
|
|
|
lVoices.setFont(Res.fontScreenMono); |
|
|
lVoices.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
|
|
p.add(lVoices); |
|
|
|
|
|
btnVolume.setIcon(Res.iconVolume14); |
|
|
btnVolume.setIconTextGap(2); |
|
|
btnVolume.setAlignmentX(RIGHT_ALIGNMENT); |
|
|
btnVolume.setHorizontalAlignment(btnVolume.LEFT); |
|
|
updateVolumeInfo(100); |
|
|
Dimension d = btnVolume.getPreferredSize(); |
|
|
d.width = 60; |
|
|
btnVolume.setPreferredSize(d); |
|
|
btnVolume.setMinimumSize(d); |
|
506 |
|
|
|
btnVolume.addActionListener(new ActionListener() { |
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
if(popupVolume.isVisible()) { |
|
|
popupVolume.commit(); |
|
|
popupVolume.hide(); |
|
|
} else { |
|
|
float vol = channel.getModel().getChannelInfo().getVolume(); |
|
|
popupVolume.setCurrentVolume(vol); |
|
|
popupVolume.show(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
popupVolume.addActionListener(new ActionListener() { |
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
channel.getModel().setBackendVolume(popupVolume.getVolumeFactor()); |
|
|
} |
|
|
}); |
|
|
|
|
|
p.add(btnVolume); |
|
507 |
p.setPreferredSize(new Dimension(260, p.getPreferredSize().height)); |
p.setPreferredSize(new Dimension(260, p.getPreferredSize().height)); |
508 |
p.setMinimumSize(p.getPreferredSize()); |
p.setMinimumSize(p.getPreferredSize()); |
509 |
p.setMaximumSize(p.getPreferredSize()); |
p.setMaximumSize(p.getPreferredSize()); |
545 |
installListeners() { |
installListeners() { |
546 |
btnInstr.addActionListener(new ActionListener() { |
btnInstr.addActionListener(new ActionListener() { |
547 |
public void |
public void |
548 |
actionPerformed(ActionEvent e) { loadInstrument(); } |
actionPerformed(ActionEvent e) { channel.loadInstrument(); } |
549 |
}); |
}); |
550 |
|
|
551 |
btnEditInstr.addActionListener(new ActionListener() { |
btnEditInstr.addActionListener(new ActionListener() { |
580 |
timer.start(); |
timer.start(); |
581 |
} |
} |
582 |
|
|
|
private void |
|
|
loadInstrument() { |
|
|
JSInstrumentChooser dlg = FantasiaUtils.createInstrumentChooser(CC.getMainFrame()); |
|
|
dlg.setVisible(true); |
|
|
|
|
|
if(!dlg.isCancelled()) { |
|
|
SamplerChannelModel m = channel.getModel(); |
|
|
m.loadBackendInstrument(dlg.getInstrumentFile(), dlg.getInstrumentIndex()); |
|
|
} |
|
|
} |
|
|
|
|
583 |
protected void |
protected void |
584 |
updateScreenInfo(SamplerChannel sc) { |
updateScreenInfo(SamplerChannel sc) { |
585 |
int status = sc.getInstrumentStatus(); |
int status = sc.getInstrumentStatus(); |
609 |
|
|
610 |
protected void |
protected void |
611 |
updateVolumeInfo(int volume) { |
updateVolumeInfo(int volume) { |
612 |
if(CC.getViewConfig().isMeasurementUnitDecibel()) { |
volumePane.updateVolumeInfo(volume); |
|
String s = numberFormat.format(HF.percentsToDecibels(volume)); |
|
|
btnVolume.setText(s + "dB"); |
|
|
} else { |
|
|
btnVolume.setText(String.valueOf(volume) + "%"); |
|
|
} |
|
613 |
} |
} |
614 |
|
|
615 |
/** |
/** |
618 |
*/ |
*/ |
619 |
protected void |
protected void |
620 |
updateStreamCount(int count) { |
updateStreamCount(int count) { |
621 |
Dimension d = lStreams.getPreferredSize(); |
streamVoiceCountPane.updateStreamCount(count); |
|
lStreams.setText(count == 0 ? "--" : String.valueOf(count)); |
|
|
d = JuifeUtils.getUnionSize(d, lStreams.getPreferredSize()); |
|
|
lStreams.setMinimumSize(d); |
|
|
lStreams.setPreferredSize(d); |
|
|
lStreams.setMaximumSize(d); |
|
622 |
} |
} |
623 |
|
|
624 |
/** |
/** |
627 |
*/ |
*/ |
628 |
protected void |
protected void |
629 |
updateVoiceCount(int count) { |
updateVoiceCount(int count) { |
630 |
Dimension d = lVoices.getPreferredSize(); |
streamVoiceCountPane.updateVoiceCount(count); |
|
lVoices.setText(count == 0 ? "--" : String.valueOf(count)); |
|
|
d = JuifeUtils.getUnionSize(d, lVoices.getPreferredSize()); |
|
|
lVoices.setMinimumSize(d); |
|
|
lVoices.setPreferredSize(d); |
|
|
lVoices.setMaximumSize(d); |
|
631 |
} |
} |
632 |
|
|
633 |
class InstrumentPane extends JPanel { |
class InstrumentPane extends JPanel { |
683 |
} |
} |
684 |
} |
} |
685 |
|
|
|
class FxSendsPane extends JSFxSendsPane { |
|
|
FxSendsPane(SamplerChannelModel model) { |
|
|
super(model); |
|
|
|
|
|
actionAddFxSend.putValue(Action.SMALL_ICON, Res.iconNew16); |
|
|
actionRemoveFxSend.putValue(Action.SMALL_ICON, Res.iconDelete16); |
|
|
} |
|
|
|
|
|
protected JToolBar |
|
|
createToolBar() { |
|
|
JToolBar tb = new JToolBar(); |
|
|
Dimension d = new Dimension(Short.MAX_VALUE, tb.getPreferredSize().height); |
|
|
tb.setMaximumSize(d); |
|
|
tb.setFloatable(false); |
|
|
tb.setAlignmentX(JPanel.RIGHT_ALIGNMENT); |
|
|
|
|
|
tb.add(new ToolbarButton(actionAddFxSend)); |
|
|
tb.add(new ToolbarButton(actionRemoveFxSend)); |
|
|
|
|
|
return tb; |
|
|
} |
|
|
} |
|
|
|
|
686 |
static class ScreenButtonBg extends PixmapPane { |
static class ScreenButtonBg extends PixmapPane { |
687 |
ScreenButtonBg(JButton btn) { |
ScreenButtonBg(JButton btn) { |
688 |
super(Res.gfxScreenBtnBg); |
super(Res.gfxScreenBtnBg); |