22 |
|
|
23 |
package org.jsampler.view.fantasia; |
package org.jsampler.view.fantasia; |
24 |
|
|
25 |
import java.awt.Cursor; |
import java.awt.Container; |
26 |
import java.awt.Dimension; |
import java.awt.Dimension; |
27 |
import java.awt.Graphics; |
import java.awt.Graphics; |
28 |
|
import java.awt.Graphics2D; |
29 |
import java.awt.Insets; |
import java.awt.Insets; |
30 |
|
import java.awt.Rectangle; |
31 |
|
|
32 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
34 |
|
import java.awt.event.HierarchyEvent; |
35 |
|
import java.awt.event.HierarchyListener; |
36 |
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseAdapter; |
37 |
import java.awt.event.MouseEvent; |
import java.awt.event.MouseEvent; |
38 |
|
|
39 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
40 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
41 |
|
|
42 |
|
import java.text.NumberFormat; |
43 |
|
|
44 |
import java.util.logging.Level; |
import java.util.logging.Level; |
45 |
|
|
46 |
import javax.swing.Action; |
import javax.swing.Action; |
50 |
import javax.swing.DefaultListCellRenderer; |
import javax.swing.DefaultListCellRenderer; |
51 |
import javax.swing.JButton; |
import javax.swing.JButton; |
52 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
53 |
|
import javax.swing.JComponent; |
54 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
55 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
56 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
57 |
import javax.swing.JPopupMenu; |
import javax.swing.JPopupMenu; |
58 |
|
import javax.swing.JScrollPane; |
59 |
import javax.swing.JToggleButton; |
import javax.swing.JToggleButton; |
60 |
import javax.swing.JToolBar; |
import javax.swing.JToolBar; |
61 |
import javax.swing.SwingConstants; |
import javax.swing.SwingConstants; |
62 |
|
import javax.swing.Timer; |
63 |
|
|
64 |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
65 |
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
73 |
|
|
74 |
import org.jsampler.AudioDeviceModel; |
import org.jsampler.AudioDeviceModel; |
75 |
import org.jsampler.CC; |
import org.jsampler.CC; |
76 |
|
import org.jsampler.HF; |
77 |
import org.jsampler.MidiDeviceModel; |
import org.jsampler.MidiDeviceModel; |
78 |
import org.jsampler.MidiInstrumentMap; |
import org.jsampler.MidiInstrumentMap; |
79 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
97 |
import org.jsampler.view.std.JSChannelOutputRoutingDlg; |
import org.jsampler.view.std.JSChannelOutputRoutingDlg; |
98 |
import org.jsampler.view.std.JSFxSendsPane; |
import org.jsampler.view.std.JSFxSendsPane; |
99 |
import org.jsampler.view.std.JSInstrumentChooser; |
import org.jsampler.view.std.JSInstrumentChooser; |
100 |
|
import org.jsampler.view.std.JSVolumeEditorPopup; |
|
import org.jvnet.lafwidget.animation.FadeConfigurationManager; |
|
|
import org.jvnet.lafwidget.animation.FadeKind; |
|
101 |
|
|
102 |
import org.jvnet.substance.SubstanceImageCreator; |
import org.jvnet.substance.SubstanceImageCreator; |
|
import org.jvnet.substance.SubstanceLookAndFeel; |
|
103 |
|
|
104 |
import org.linuxsampler.lscp.AudioOutputDevice; |
import org.linuxsampler.lscp.AudioOutputDevice; |
105 |
import org.linuxsampler.lscp.MidiInputDevice; |
import org.linuxsampler.lscp.MidiInputDevice; |
109 |
|
|
110 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
111 |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
112 |
|
import static org.jsampler.view.fantasia.FantasiaUtils.*; |
113 |
|
import static org.jsampler.view.std.JSVolumeEditorPopup.VolumeType; |
114 |
|
|
115 |
|
|
116 |
/** |
/** |
254 |
|
|
255 |
setOpaque(false); |
setOpaque(false); |
256 |
|
|
257 |
|
int i = preferences().getIntProperty(MAXIMUM_CHANNEL_VOLUME); |
258 |
|
dialVolume.setMaximum(i); |
259 |
|
String mcv = MAXIMUM_CHANNEL_VOLUME; |
260 |
|
preferences().addPropertyChangeListener(mcv, new PropertyChangeListener() { |
261 |
|
public void |
262 |
|
propertyChange(PropertyChangeEvent e) { |
263 |
|
int j = preferences().getIntProperty(MAXIMUM_CHANNEL_VOLUME); |
264 |
|
dialVolume.setMaximum(j); |
265 |
|
} |
266 |
|
}); |
267 |
|
|
268 |
|
String vmud = VOL_MEASUREMENT_UNIT_DECIBEL; |
269 |
|
preferences().addPropertyChangeListener(vmud, new PropertyChangeListener() { |
270 |
|
public void |
271 |
|
propertyChange(PropertyChangeEvent e) { |
272 |
|
boolean b; |
273 |
|
b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL); |
274 |
|
screen.updateVolumeInfo(dialVolume.getValue()); |
275 |
|
} |
276 |
|
}); |
277 |
|
|
278 |
getModel().addSamplerChannelListener(getHandler()); |
getModel().addSamplerChannelListener(getHandler()); |
279 |
|
|
280 |
updateChannelInfo(); |
updateChannelInfo(); |
287 |
public void |
public void |
288 |
propertyChange(PropertyChangeEvent e) { |
propertyChange(PropertyChangeEvent e) { |
289 |
if(e.getNewValue() == "expanded") { |
if(e.getNewValue() == "expanded") { |
290 |
|
// TODO: this should be done regardles the listener != null? |
291 |
mainPane.removePropertyChangeListener(s, this); |
mainPane.removePropertyChangeListener(s, this); |
292 |
|
/////// |
293 |
listener.actionPerformed(null); |
listener.actionPerformed(null); |
294 |
|
ensureChannelIsVisible(); |
295 |
|
} else if(e.getNewValue() == "expanding/collapsing") { |
296 |
|
ensureChannelIsVisible(); |
297 |
} |
} |
298 |
} |
} |
299 |
}); |
}); |
317 |
run() { listener.actionPerformed(null); } |
run() { listener.actionPerformed(null); } |
318 |
}); |
}); |
319 |
} |
} |
320 |
|
|
321 |
|
CC.getSamplerModel().addSamplerChannelListListener(getHandler()); |
322 |
|
} |
323 |
|
|
324 |
|
private void |
325 |
|
ensureChannelIsVisible() { |
326 |
|
Container p = getParent(); |
327 |
|
JScrollPane sp = null; |
328 |
|
while(p != null) { |
329 |
|
if(p instanceof JScrollPane) { |
330 |
|
sp = (JScrollPane)p; |
331 |
|
break; |
332 |
|
} |
333 |
|
p = p.getParent(); |
334 |
|
} |
335 |
|
if(sp == null) return; |
336 |
|
int h = sp.getViewport().getView().getHeight(); |
337 |
|
sp.getViewport().scrollRectToVisible(new Rectangle(0, h - 2, 1, 1)); |
338 |
} |
} |
339 |
|
|
340 |
private JPanel |
private JPanel |
392 |
|
|
393 |
if(vol == dialVolume.getValue()) return; |
if(vol == dialVolume.getValue()) return; |
394 |
|
|
|
|
|
395 |
/* |
/* |
396 |
* If the model's volume is not equal to the dial knob |
* If the model's volume is not equal to the dial knob |
397 |
* value we assume that the change is due to user input. |
* value we assume that the change is due to user input. |
415 |
|
|
416 |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn); |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn); |
417 |
else btnSolo.setIcon(Res.gfxSoloOff); |
else btnSolo.setIcon(Res.gfxSoloOff); |
|
|
|
418 |
dialVolume.setValue((int)(sc.getVolume() * 100)); |
dialVolume.setValue((int)(sc.getVolume() * 100)); |
419 |
|
|
420 |
boolean b = sc.getEngine() != null; |
boolean b = sc.getEngine() != null; |
464 |
} |
} |
465 |
} |
} |
466 |
|
|
467 |
|
protected void |
468 |
|
onDestroy() { |
469 |
|
CC.getSamplerModel().removeSamplerChannelListListener(getHandler()); |
470 |
|
|
471 |
|
screen.onDestroy(); |
472 |
|
optionsPane.onDestroy(); |
473 |
|
} |
474 |
|
|
475 |
private final EventHandler eventHandler = new EventHandler(); |
private final EventHandler eventHandler = new EventHandler(); |
476 |
|
|
477 |
private EventHandler |
private EventHandler |
478 |
getHandler() { return eventHandler; } |
getHandler() { return eventHandler; } |
479 |
|
|
480 |
private class EventHandler implements SamplerChannelListener { |
private class EventHandler implements SamplerChannelListener, SamplerChannelListListener { |
481 |
/** |
/** |
482 |
* Invoked when changes are made to a sampler channel. |
* Invoked when changes are made to a sampler channel. |
483 |
* @param e A <code>SamplerChannelEvent</code> instance |
* @param e A <code>SamplerChannelEvent</code> instance |
505 |
voiceCountChanged(SamplerChannelEvent e) { |
voiceCountChanged(SamplerChannelEvent e) { |
506 |
screen.updateVoiceCount(getModel().getVoiceCount()); |
screen.updateVoiceCount(getModel().getVoiceCount()); |
507 |
} |
} |
508 |
|
|
509 |
|
/** |
510 |
|
* Invoked when a new sampler channel is created. |
511 |
|
* @param e A <code>SamplerChannelListEvent</code> |
512 |
|
* instance providing the event information. |
513 |
|
*/ |
514 |
|
public void |
515 |
|
channelAdded(SamplerChannelListEvent e) { } |
516 |
|
|
517 |
|
/** |
518 |
|
* Invoked when a sampler channel is removed. |
519 |
|
* @param e A <code>SamplerChannelListEvent</code> |
520 |
|
* instance providing the event information. |
521 |
|
*/ |
522 |
|
public void |
523 |
|
channelRemoved(SamplerChannelListEvent e) { |
524 |
|
// Some cleanup when the channel is removed. |
525 |
|
if(e.getChannelModel().getChannelId() == getChannelId()) { |
526 |
|
onDestroy(); |
527 |
|
} |
528 |
|
} |
529 |
} |
} |
530 |
|
|
531 |
|
|
669 |
|
|
670 |
class ChannelScreen extends PixmapPane { |
class ChannelScreen extends PixmapPane { |
671 |
private final Channel channel; |
private final Channel channel; |
672 |
private JButton btnInstr = new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
|
673 |
|
private final InstrumentPane instrumentPane; |
674 |
|
|
675 |
|
private JButton btnInstr = |
676 |
|
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
677 |
|
|
678 |
|
private final JButton btnEditInstr = |
679 |
|
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnEditInstr")); |
680 |
|
private final ScreenButtonBg sbbEditInstr = new ScreenButtonBg(btnEditInstr); |
681 |
|
|
682 |
private final JButton btnFxSends = |
private final JButton btnFxSends = |
683 |
new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnFxSends")); |
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnFxSends")); |
684 |
|
|
685 |
private final JButton btnEngine |
private final JButton btnEngine |
686 |
= new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnEngine")); |
= createScreenButton(i18n.getButtonLabel("ChannelScreen.btnEngine")); |
687 |
|
|
688 |
private final JPopupMenu menuEngines = new JPopupMenu(); |
private final JPopupMenu menuEngines = new JPopupMenu(); |
689 |
|
|
690 |
private final JLabel lVolume = new Label(); |
private final JButton btnVolume = createScreenButton(""); |
691 |
private final JLabel lStreams = new Label("--"); |
private JSVolumeEditorPopup popupVolume; |
692 |
private final JLabel lVoices = new Label("--"); |
|
693 |
|
private final JLabel lStreams = createScreenLabel(" --"); |
694 |
|
private final JLabel lVoices = createScreenLabel("-- "); |
695 |
|
|
696 |
private InformationDialog fxSendsDlg = null; |
private InformationDialog fxSendsDlg = null; |
697 |
|
|
698 |
private Dimension dimVolume; |
private Timer timer; |
699 |
|
|
700 |
class Label extends JLabel { |
private static NumberFormat numberFormat = NumberFormat.getInstance(); |
701 |
Label() { this(""); } |
static { |
702 |
|
numberFormat.setMaximumFractionDigits(1); |
|
Label(String s) { |
|
|
super(s); |
|
|
setFont(Res.fontScreen); |
|
|
setForeground(new java.awt.Color(0xFFA300)); |
|
|
} |
|
703 |
} |
} |
704 |
|
|
705 |
ChannelScreen(final Channel channel) { |
ChannelScreen(final Channel channel) { |
708 |
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
709 |
|
|
710 |
this.channel = channel; |
this.channel = channel; |
711 |
|
popupVolume = new JSVolumeEditorPopup(btnVolume, VolumeType.CHANNEL); |
712 |
|
|
713 |
setOpaque(false); |
setOpaque(false); |
714 |
|
|
718 |
btnInstr.setRolloverEnabled(false); |
btnInstr.setRolloverEnabled(false); |
719 |
btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); |
btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); |
720 |
|
|
721 |
add(btnInstr); |
instrumentPane = new InstrumentPane(); |
722 |
|
add(instrumentPane); |
723 |
|
|
724 |
JPanel p = new JPanel(); |
JPanel p = new JPanel(); |
725 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
726 |
p.setAlignmentX(CENTER_ALIGNMENT); |
p.setAlignmentX(CENTER_ALIGNMENT); |
727 |
p.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
p.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0)); |
728 |
|
|
729 |
btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt")); |
btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt")); |
730 |
btnFxSends.addActionListener(new ActionListener() { |
btnFxSends.addActionListener(new ActionListener() { |
746 |
|
|
747 |
p.add(btnFxSends); |
p.add(btnFxSends); |
748 |
|
|
749 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
//p.add(Box.createRigidArea(new Dimension(6, 0))); |
750 |
|
p.add(Box.createGlue()); |
751 |
|
|
752 |
btnEngine.setIcon(Res.iconEngine12); |
btnEngine.setIcon(Res.iconEngine12); |
753 |
|
btnEngine.setIconTextGap(1); |
754 |
p.add(btnEngine); |
p.add(btnEngine); |
755 |
//p.add(new Label("|")); |
//p.add(new Label("|")); |
756 |
|
|
760 |
|
|
761 |
p.add(Box.createGlue()); |
p.add(Box.createGlue()); |
762 |
|
|
763 |
|
lStreams.setFont(Res.fontScreenMono); |
764 |
|
lStreams.setHorizontalAlignment(JLabel.RIGHT); |
765 |
|
lStreams.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
766 |
p.add(lStreams); |
p.add(lStreams); |
|
p.add(new Label("/")); |
|
|
p.add(lVoices); |
|
767 |
|
|
768 |
p.add(Box.createRigidArea(new Dimension(12, 0))); |
JLabel l = createScreenLabel("/"); |
769 |
|
l.setFont(Res.fontScreenMono); |
770 |
|
l.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
771 |
|
p.add(l); |
772 |
|
|
773 |
|
lVoices.setFont(Res.fontScreenMono); |
774 |
|
lVoices.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
775 |
|
p.add(lVoices); |
776 |
|
|
777 |
lVolume.setIcon(Res.iconVolume14); |
btnVolume.setIcon(Res.iconVolume14); |
778 |
lVolume.setAlignmentX(RIGHT_ALIGNMENT); |
btnVolume.setIconTextGap(2); |
779 |
|
btnVolume.setAlignmentX(RIGHT_ALIGNMENT); |
780 |
|
btnVolume.setHorizontalAlignment(btnVolume.LEFT); |
781 |
updateVolumeInfo(100); |
updateVolumeInfo(100); |
782 |
dimVolume = lVolume.getPreferredSize(); |
Dimension d = btnVolume.getPreferredSize(); |
783 |
p.add(lVolume); |
d.width = 60; |
784 |
p.setPreferredSize(new Dimension(250, p.getPreferredSize().height)); |
btnVolume.setPreferredSize(d); |
785 |
|
btnVolume.setMinimumSize(d); |
786 |
|
|
787 |
|
btnVolume.addActionListener(new ActionListener() { |
788 |
|
public void |
789 |
|
actionPerformed(ActionEvent e) { |
790 |
|
if(popupVolume.isVisible()) { |
791 |
|
popupVolume.commit(); |
792 |
|
popupVolume.hide(); |
793 |
|
} else { |
794 |
|
float vol = channel.getModel().getChannelInfo().getVolume(); |
795 |
|
popupVolume.setCurrentVolume(vol); |
796 |
|
popupVolume.show(); |
797 |
|
} |
798 |
|
} |
799 |
|
}); |
800 |
|
|
801 |
|
popupVolume.addActionListener(new ActionListener() { |
802 |
|
public void |
803 |
|
actionPerformed(ActionEvent e) { |
804 |
|
channel.getModel().setBackendVolume(popupVolume.getVolumeFactor()); |
805 |
|
} |
806 |
|
}); |
807 |
|
|
808 |
|
p.add(btnVolume); |
809 |
|
p.setPreferredSize(new Dimension(260, p.getPreferredSize().height)); |
810 |
p.setMinimumSize(p.getPreferredSize()); |
p.setMinimumSize(p.getPreferredSize()); |
811 |
p.setMaximumSize(p.getPreferredSize()); |
p.setMaximumSize(p.getPreferredSize()); |
812 |
|
|
823 |
installListeners(); |
installListeners(); |
824 |
} |
} |
825 |
|
|
826 |
|
protected void |
827 |
|
onDestroy() { timer.stop(); } |
828 |
|
|
829 |
private void |
private void |
830 |
createEngineMenu() { |
createEngineMenu() { |
831 |
for(final SamplerEngine engine : CC.getSamplerModel().getEngines()) { |
for(final SamplerEngine engine : CC.getSamplerModel().getEngines()) { |
832 |
JMenuItem mi = new JMenuItem(engine.getDescription()); |
JMenuItem mi = new JMenuItem(engine.getName() + " engine"); |
833 |
|
mi.setToolTipText(engine.getDescription()); |
834 |
|
|
835 |
mi.addActionListener(new ActionListener() { |
mi.addActionListener(new ActionListener() { |
836 |
public void |
public void |
850 |
actionPerformed(ActionEvent e) { loadInstrument(); } |
actionPerformed(ActionEvent e) { loadInstrument(); } |
851 |
}); |
}); |
852 |
|
|
853 |
|
btnEditInstr.addActionListener(new ActionListener() { |
854 |
|
public void |
855 |
|
actionPerformed(ActionEvent e) { |
856 |
|
CC.getSamplerModel().editBackendInstrument(channel.getChannelId()); |
857 |
|
} |
858 |
|
}); |
859 |
|
|
860 |
btnEngine.addActionListener(new ActionListener() { |
btnEngine.addActionListener(new ActionListener() { |
861 |
public void |
public void |
862 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
864 |
menuEngines.show(btnEngine, 0, y); |
menuEngines.show(btnEngine, 0, y); |
865 |
} |
} |
866 |
}); |
}); |
867 |
|
|
868 |
|
addMouseListener(getHandler()); |
869 |
|
addHierarchyListener(getHandler()); |
870 |
|
|
871 |
|
ActionListener l = new ActionListener() { |
872 |
|
public void |
873 |
|
actionPerformed(ActionEvent e) { |
874 |
|
if(getMousePosition(true) != null) { |
875 |
|
getHandler().mouseEntered(null); |
876 |
|
} else { |
877 |
|
getHandler().mouseExited(null); |
878 |
|
} |
879 |
|
} |
880 |
|
}; |
881 |
|
timer = new Timer(1000, l); |
882 |
|
timer.start(); |
883 |
} |
} |
884 |
|
|
885 |
private void |
private void |
886 |
loadInstrument() { |
loadInstrument() { |
887 |
JSInstrumentChooser dlg = new JSInstrumentChooser(CC.getMainFrame()); |
JSInstrumentChooser dlg = FantasiaUtils.createInstrumentChooser(CC.getMainFrame()); |
888 |
dlg.setVisible(true); |
dlg.setVisible(true); |
889 |
|
|
890 |
if(!dlg.isCancelled()) { |
if(!dlg.isCancelled()) { |
906 |
if(sc.getInstrumentName() != null) btnInstr.setText(sc.getInstrumentName()); |
if(sc.getInstrumentName() != null) btnInstr.setText(sc.getInstrumentName()); |
907 |
else btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
else btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
908 |
} |
} |
909 |
|
|
910 |
|
instrumentPane.update(); |
911 |
|
|
912 |
if(sc.getEngine() != null) { |
if(sc.getEngine() != null) { |
913 |
String s = sc.getEngine().getDescription(); |
String s = sc.getEngine().getName(); |
914 |
if(!s.equals(btnEngine.getText())) btnEngine.setText(s); |
s += " engine"; |
915 |
|
if(!s.equals(btnEngine.getText())) { |
916 |
|
btnEngine.setText(s); |
917 |
|
btnEngine.setToolTipText(sc.getEngine().getDescription()); |
918 |
|
} |
919 |
} |
} |
920 |
|
|
921 |
} |
} |
922 |
|
|
923 |
protected void |
protected void |
924 |
updateVolumeInfo(int volume) { |
updateVolumeInfo(int volume) { |
925 |
lVolume.setText(i18n.getLabel("ChannelScreen.volume", volume)); |
if(CC.getViewConfig().isMeasurementUnitDecibel()) { |
926 |
lVolume.setMinimumSize(dimVolume); |
String s = numberFormat.format(HF.percentsToDecibels(volume)); |
927 |
lVolume.setPreferredSize(dimVolume); |
btnVolume.setText(s + "dB"); |
928 |
|
} else { |
929 |
|
btnVolume.setText(String.valueOf(volume) + "%"); |
930 |
|
} |
931 |
} |
} |
932 |
|
|
933 |
/** |
/** |
958 |
lVoices.setMaximumSize(d); |
lVoices.setMaximumSize(d); |
959 |
} |
} |
960 |
|
|
961 |
|
class InstrumentPane extends JPanel { |
962 |
|
private final JPanel leftPane = new JPanel(); |
963 |
|
private final JPanel rightPane = new JPanel(); |
964 |
|
|
965 |
|
InstrumentPane() { |
966 |
|
setOpaque(false); |
967 |
|
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); |
968 |
|
add(leftPane); |
969 |
|
add(btnInstr); |
970 |
|
add(rightPane); |
971 |
|
add(sbbEditInstr); |
972 |
|
btnEditInstr.setToolTipText(i18n.getLabel("ChannelScreen.btnEditInstr.tt")); |
973 |
|
sbbEditInstr.setVisible(false); |
974 |
|
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 6)); |
975 |
|
|
976 |
|
update(); |
977 |
|
} |
978 |
|
|
979 |
|
public void |
980 |
|
update() { |
981 |
|
int a = btnInstr.getMinimumSize().width; |
982 |
|
int b = 0; |
983 |
|
if(sbbEditInstr.isVisible()) b = sbbEditInstr.getPreferredSize().width; |
984 |
|
|
985 |
|
int max = 254 - b; |
986 |
|
if(a > max) a = max; |
987 |
|
|
988 |
|
int h = btnInstr.getPreferredSize().height; |
989 |
|
btnInstr.setPreferredSize(new Dimension(a, h)); |
990 |
|
h = btnInstr.getMaximumSize().height; |
991 |
|
btnInstr.setMaximumSize(new Dimension(a, h)); |
992 |
|
|
993 |
|
|
994 |
|
int i = (254 - btnInstr.getPreferredSize().width) / 2; |
995 |
|
|
996 |
|
int j = i; |
997 |
|
if(sbbEditInstr.isVisible()) j -= sbbEditInstr.getPreferredSize().width; |
998 |
|
if(i < 0 || j < 0) i = j = 0; |
999 |
|
|
1000 |
|
Dimension d = new Dimension(i, 1); |
1001 |
|
leftPane.setMinimumSize(d); |
1002 |
|
leftPane.setPreferredSize(d); |
1003 |
|
leftPane.setMaximumSize(d); |
1004 |
|
|
1005 |
|
d = new Dimension(j, 1); |
1006 |
|
rightPane.setMinimumSize(d); |
1007 |
|
rightPane.setPreferredSize(d); |
1008 |
|
rightPane.setMaximumSize(d); |
1009 |
|
|
1010 |
|
validate(); |
1011 |
|
} |
1012 |
|
} |
1013 |
|
|
1014 |
class FxSendsPane extends JSFxSendsPane { |
class FxSendsPane extends JSFxSendsPane { |
1015 |
FxSendsPane(SamplerChannelModel model) { |
FxSendsPane(SamplerChannelModel model) { |
1016 |
super(model); |
super(model); |
1034 |
} |
} |
1035 |
} |
} |
1036 |
|
|
1037 |
static class ScreenButton extends JButton { |
static class ScreenButtonBg extends PixmapPane { |
1038 |
ScreenButton(String s) { |
ScreenButtonBg(JButton btn) { |
1039 |
super(s); |
super(Res.gfxScreenBtnBg); |
1040 |
setContentAreaFilled(false); |
setPixmapInsets(new Insets(4, 4, 4, 4)); |
1041 |
setFocusPainted(false); |
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); |
1042 |
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 7)); |
1043 |
setMargin(new Insets(0, 0, 0, 0)); |
add(btn); |
1044 |
|
setPreferredSize(new Dimension(getPreferredSize().width, 13)); |
1045 |
putClientProperty ( |
} |
1046 |
SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE |
|
1047 |
); |
public Dimension |
1048 |
|
getPreferredSize() { |
1049 |
putClientProperty ( |
return new Dimension(super.getPreferredSize().width, 13); |
1050 |
SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE |
} |
1051 |
); |
} |
1052 |
|
|
1053 |
putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); |
|
1054 |
|
private final EventHandler eventHandler = new EventHandler(); |
1055 |
FadeConfigurationManager.getInstance().disallowFades(FadeKind.ROLLOVER, this); |
|
1056 |
|
private EventHandler |
1057 |
|
getHandler() { return eventHandler; } |
1058 |
|
|
1059 |
|
private class EventHandler extends MouseAdapter implements HierarchyListener { |
1060 |
|
public void |
1061 |
|
mouseEntered(MouseEvent e) { |
1062 |
|
if(channel.getChannelInfo().getInstrumentStatus() != 100) return; |
1063 |
|
|
1064 |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
if(!sbbEditInstr.isVisible()) { |
1065 |
setFont(Res.fontScreen); |
sbbEditInstr.setVisible(true); |
1066 |
setForeground(new java.awt.Color(0xFFA300)); |
instrumentPane.update(); |
1067 |
|
} |
1068 |
|
} |
1069 |
|
|
1070 |
|
public void |
1071 |
|
mouseExited(MouseEvent e) { |
1072 |
|
if(getMousePosition(true) != null) return; |
1073 |
|
if(sbbEditInstr.isVisible()) { |
1074 |
|
sbbEditInstr.setVisible(false); |
1075 |
|
instrumentPane.update(); |
1076 |
|
} |
1077 |
|
} |
1078 |
|
|
1079 |
|
/** Called when the hierarchy has been changed. */ |
1080 |
|
public void |
1081 |
|
hierarchyChanged(HierarchyEvent e) { |
1082 |
|
if((e.getChangeFlags() & e.SHOWING_CHANGED) == e.SHOWING_CHANGED) { |
1083 |
|
if(getMousePosition() == null) mouseExited(null); |
1084 |
|
else mouseEntered(null); |
1085 |
|
} |
1086 |
} |
} |
1087 |
} |
} |
1088 |
} |
} |
1318 |
actionPerformed(ActionEvent e) { updateInstrumentMap(); } |
actionPerformed(ActionEvent e) { updateInstrumentMap(); } |
1319 |
}); |
}); |
1320 |
|
|
|
CC.getSamplerModel().addSamplerChannelListListener(getHandler()); |
|
1321 |
CC.getSamplerModel().addMidiInstrumentMapListListener(mapListListener); |
CC.getSamplerModel().addMidiInstrumentMapListListener(mapListListener); |
1322 |
|
|
1323 |
cbAudioDevice.addActionListener(new ActionListener() { |
cbAudioDevice.addActionListener(new ActionListener() { |
1551 |
private void |
private void |
1552 |
setUpdate(boolean b) { update = b; } |
setUpdate(boolean b) { update = b; } |
1553 |
|
|
1554 |
|
protected void |
1555 |
|
onDestroy() { |
1556 |
|
SamplerModel sm = CC.getSamplerModel(); |
1557 |
|
|
1558 |
|
sm.removeMidiDeviceListListener(getHandler()); |
1559 |
|
sm.removeAudioDeviceListListener(getHandler()); |
1560 |
|
sm.removeMidiInstrumentMapListListener(mapListListener); |
1561 |
|
sm.removeSamplerListener(samplerListener); |
1562 |
|
|
1563 |
|
if(midiDevice != null) { |
1564 |
|
midiDevice.removeMidiDeviceListener(getHandler()); |
1565 |
|
} |
1566 |
|
} |
1567 |
|
|
1568 |
private final Handler handler = new Handler(); |
private final Handler handler = new Handler(); |
1569 |
|
|
1570 |
private Handler |
private Handler |
1571 |
getHandler() { return handler; } |
getHandler() { return handler; } |
1572 |
|
|
1573 |
private class Handler implements MidiDeviceListListener, ListListener<AudioDeviceModel>, |
private class Handler implements MidiDeviceListListener, ListListener<AudioDeviceModel>, |
1574 |
SamplerChannelListListener, MidiDeviceListener { |
MidiDeviceListener { |
1575 |
/** |
/** |
1576 |
* Invoked when a new MIDI device is created. |
* Invoked when a new MIDI device is created. |
1577 |
* @param e A <code>MidiDeviceListEvent</code> |
* @param e A <code>MidiDeviceListEvent</code> |
1612 |
cbAudioDevice.removeItem(e.getEntry().getDeviceInfo()); |
cbAudioDevice.removeItem(e.getEntry().getDeviceInfo()); |
1613 |
} |
} |
1614 |
|
|
|
/** |
|
|
* Invoked when a new sampler channel is created. |
|
|
* @param e A <code>SamplerChannelListEvent</code> |
|
|
* instance providing the event information. |
|
|
*/ |
|
|
public void |
|
|
channelAdded(SamplerChannelListEvent e) { } |
|
|
|
|
|
/** |
|
|
* Invoked when a sampler channel is removed. |
|
|
* @param e A <code>SamplerChannelListEvent</code> |
|
|
* instance providing the event information. |
|
|
*/ |
|
|
public void |
|
|
channelRemoved(SamplerChannelListEvent e) { |
|
|
// Some cleanup when the channel is removed. |
|
|
if(e.getChannelModel().getChannelId() == channel.getChannelId()) { |
|
|
SamplerModel sm = CC.getSamplerModel(); |
|
|
|
|
|
sm.removeMidiDeviceListListener(getHandler()); |
|
|
sm.removeAudioDeviceListListener(getHandler()); |
|
|
sm.removeMidiInstrumentMapListListener(mapListListener); |
|
|
sm.removeSamplerListener(samplerListener); |
|
|
sm.removeSamplerChannelListListener(getHandler()); |
|
|
|
|
|
if(midiDevice != null) { |
|
|
midiDevice.removeMidiDeviceListener(getHandler()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
1615 |
public void |
public void |
1616 |
settingsChanged(MidiDeviceEvent e) { |
settingsChanged(MidiDeviceEvent e) { |
1617 |
if(isUpdate()) { |
if(isUpdate()) { |