/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/NormalChannelView.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/fantasia/NormalChannelView.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1730 by iliev, Wed Apr 30 23:31:08 2008 UTC revision 1767 by iliev, Mon Sep 8 00:19:27 2008 UTC
# Line 31  import java.awt.event.HierarchyEvent; Line 31  import java.awt.event.HierarchyEvent;
31  import java.awt.event.HierarchyListener;  import java.awt.event.HierarchyListener;
32  import java.awt.event.MouseAdapter;  import java.awt.event.MouseAdapter;
33  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
34    import java.awt.event.MouseListener;
35    
36  import java.beans.PropertyChangeEvent;  import java.beans.PropertyChangeEvent;
37  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
38    
39  import java.text.NumberFormat;  import java.util.Vector;
40    
41  import javax.swing.Action;  import javax.swing.Action;
42  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
# Line 47  import javax.swing.JLabel; Line 48  import javax.swing.JLabel;
48  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
49  import javax.swing.JPanel;  import javax.swing.JPanel;
50  import javax.swing.JPopupMenu;  import javax.swing.JPopupMenu;
 import javax.swing.JToolBar;  
 import javax.swing.Timer;  
51    
52  import javax.swing.event.ChangeEvent;  import javax.swing.event.ChangeEvent;
53  import javax.swing.event.ChangeListener;  import javax.swing.event.ChangeListener;
54    
55  import net.sf.juife.Dial;  import net.sf.juife.Dial;
 import net.sf.juife.InformationDialog;  
 import net.sf.juife.JuifeUtils;  
56    
57  import org.jsampler.CC;  import org.jsampler.CC;
 import org.jsampler.HF;  
 import org.jsampler.SamplerChannelModel;  
58    
59  import org.jsampler.view.std.JSFxSendsPane;  import org.jvnet.substance.utils.SubstanceImageCreator;
 import org.jsampler.view.std.JSInstrumentChooser;  
 import org.jsampler.view.std.JSVolumeEditorPopup;  
   
 import org.jvnet.substance.SubstanceImageCreator;  
60    
61  import org.linuxsampler.lscp.SamplerChannel;  import org.linuxsampler.lscp.SamplerChannel;
62  import org.linuxsampler.lscp.SamplerEngine;  import org.linuxsampler.lscp.SamplerEngine;
# Line 73  import org.linuxsampler.lscp.SamplerEngi Line 64  import org.linuxsampler.lscp.SamplerEngi
64  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;  import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
65  import static org.jsampler.view.fantasia.FantasiaPrefs.*;  import static org.jsampler.view.fantasia.FantasiaPrefs.*;
66  import static org.jsampler.view.fantasia.FantasiaUtils.*;  import static org.jsampler.view.fantasia.FantasiaUtils.*;
 import static org.jsampler.view.std.JSVolumeEditorPopup.VolumeType;  
67    
68  /**  /**
69   *   *
70   * @author Grigor Iliev   * @author Grigor Iliev
71   */   */
72  public class NormalChannelView extends JPanel implements ChannelView {  public class NormalChannelView extends PixmapPane implements ChannelView {
73          private final Channel channel;          private final Channel channel;
74          private final ChannelOptionsView channelOptionsView;          private ChannelOptionsView channelOptionsView = null;
75                    
76          private final EnhancedDial dialVolume = new EnhancedDial();          private final EnhancedDial dialVolume = new EnhancedDial();
77          private final ChannelScreen screen;          private final ChannelScreen screen;
78                    
79          private final PowerButton btnPower = new PowerButton();          private final Channel.PowerButton btnPower;
80          private final MuteButton btnMute = new MuteButton();          private final MuteButton btnMute = new MuteButton();
81          private final SoloButton btnSolo = new SoloButton();          private final SoloButton btnSolo = new SoloButton();
82          private final OptionsButton btnOptions = new OptionsButton();          private final Channel.OptionsButton btnOptions;
83                    
84            private final Vector<JComponent> components = new Vector<JComponent>();
85                    
         /** Creates a new instance of <code>NormalChannelView</code> */  
         public  
         NormalChannelView(Channel channel) {  
                 this(channel, new NormalChannelOptionsView(channel));  
         }  
86                    
87          /** Creates a new instance of <code>NormalChannelView</code> */          /** Creates a new instance of <code>NormalChannelView</code> */
88          public          public
89          NormalChannelView(Channel channel, ChannelOptionsView channelOptionsView) {          NormalChannelView(Channel channel) {
90                    super(Res.gfxChannel);
91                    setPixmapInsets(new Insets(3, 3, 3, 3));
92                    
93                    components.add(this);
94                    
95                  this.channel = channel;                  this.channel = channel;
                 this.channelOptionsView = channelOptionsView;  
96                                    
97                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));                  btnPower = new Channel.PowerButton(channel);
98                    components.add(btnPower);
99                    btnOptions = new Channel.OptionsButton(channel);
100                    components.add(btnOptions);
101                                    
102                  screen = new ChannelScreen(channel);                  screen = new ChannelScreen(channel);
103                  ChannelPane p = new ChannelPane();                  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
                 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));  
                   
                 //p.add(Box.createRigidArea(new Dimension(3, 0)));  
104                                    
105                  btnPower.setAlignmentY(JPanel.TOP_ALIGNMENT);                  btnPower.setAlignmentY(JPanel.TOP_ALIGNMENT);
106                                    
107                  JPanel tb = new JPanel();                  JPanel tb = new JPanel();
108                    components.add(tb);
109                  tb.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 4));                  tb.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 4));
110                  tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));                  tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
111                  tb.setOpaque(false);                  tb.setOpaque(false);
# Line 123  public class NormalChannelView extends J Line 114  public class NormalChannelView extends J
114                  tb.setPreferredSize(new Dimension(tb.getPreferredSize().width, 58));                  tb.setPreferredSize(new Dimension(tb.getPreferredSize().width, 58));
115                  tb.setMinimumSize(tb.getPreferredSize());                  tb.setMinimumSize(tb.getPreferredSize());
116                  tb.setMaximumSize(tb.getPreferredSize());                  tb.setMaximumSize(tb.getPreferredSize());
117                  p.add(tb);                  add(tb);
118                                    
119                  //p.add(Box.createRigidArea(new Dimension(4, 0)));                  //p.add(Box.createRigidArea(new Dimension(4, 0)));
120                                    
121                  p.add(createVSeparator());                  add(createVSeparator());
122                                    
123                  //p.add(Box.createRigidArea(new Dimension(3, 0)));                  //p.add(Box.createRigidArea(new Dimension(3, 0)));
124                                    
125                  JPanel p2 = new JPanel();                  JPanel p2 = new JPanel();
126                    components.add(p2);
127                  p2.setOpaque(false);                  p2.setOpaque(false);
128                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
129                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
130                  p2.setBorder(BorderFactory.createEmptyBorder(5, 3, 0, 2));                  p2.setBorder(BorderFactory.createEmptyBorder(5, 3, 0, 2));
131                  p2.add(screen);                  p2.add(screen);
132                  p.add(p2);                  add(p2);
133                                    
134                  p.add(createVSeparator());                  add(createVSeparator());
135                                    
136                  p2 = new JPanel();                  p2 = new JPanel();
137                    components.add(p2);
138                  p2.setOpaque(false);                  p2.setOpaque(false);
139                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
140                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
141                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
142                  p2.add(new JLabel(Res.gfxMuteTitle));                  
143                    JLabel l = new JLabel(Res.gfxMuteTitle);
144                    components.add(l);
145                    p2.add(l);
146                    components.add(btnMute);
147                  p2.add(btnMute);                  p2.add(btnMute);
148                  p2.add(new JLabel(Res.gfxSoloTitle));                  
149                    l = new JLabel(Res.gfxSoloTitle);
150                    components.add(l);
151                    p2.add(l);
152                    
153                    components.add(btnSolo);
154                  p2.add(btnSolo);                  p2.add(btnSolo);
155                                    
156                  p.add(p2);                  add(p2);
157                                    
158                  p.add(createVSeparator());                  add(createVSeparator());
159                                    
160                  p2 = new JPanel();                  p2 = new JPanel();
161                    components.add(p2);
162                  p2.setOpaque(false);                  p2.setOpaque(false);
163                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
164                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
165                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));                  p2.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
166                  JLabel l = new JLabel(Res.gfxVolumeTitle);                  l = new JLabel(Res.gfxVolumeTitle);
167                    components.add(l);
168                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);
169                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
170                  p2.add(l);                  p2.add(l);
171                    
172                    components.add(dialVolume);
173                  dialVolume.setDialPixmap(Res.gfxVolumeDial, 30, 330);                  dialVolume.setDialPixmap(Res.gfxVolumeDial, 30, 330);
174                  dialVolume.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  dialVolume.setAlignmentX(JPanel.CENTER_ALIGNMENT);
175                  p2.add(dialVolume);                  p2.add(dialVolume);
176                  p.add(p2);                  add(p2);
177                                    
178                  p.add(createVSeparator());                  add(createVSeparator());
179                                    
180                  p2 = new JPanel();                  p2 = new JPanel();
181                    components.add(p2);
182                  p2.setOpaque(false);                  p2.setOpaque(false);
183                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));                  p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
184                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);                  p2.setAlignmentY(JPanel.TOP_ALIGNMENT);
185                  p2.setBorder(BorderFactory.createEmptyBorder(27, 0, 0, 0));                  p2.setBorder(BorderFactory.createEmptyBorder(27, 0, 0, 0));
186                  l = new JLabel(Res.gfxOptionsTitle);                  l = new JLabel(Res.gfxOptionsTitle);
187                    components.add(l);
188                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  l.setAlignmentX(JPanel.CENTER_ALIGNMENT);
189                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));                  l.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
190                  p2.add(l);                  p2.add(l);
# Line 185  public class NormalChannelView extends J Line 193  public class NormalChannelView extends J
193                                    
194                  btnOptions.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  btnOptions.setAlignmentX(JPanel.CENTER_ALIGNMENT);
195                  p2.add(btnOptions);                  p2.add(btnOptions);
196                  p.add(p2);                  add(p2);
197                                    
198                                    
199                  p.setPreferredSize(new Dimension(420, 60));                  setPreferredSize(new Dimension(420, 60));
200                  p.setMinimumSize(p.getPreferredSize());                  setMinimumSize(getPreferredSize());
201                  p.setMaximumSize(p.getPreferredSize());                  setMaximumSize(getPreferredSize());
202                  //p.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));                  //p.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
203    
204                  p.setAlignmentX(JPanel.CENTER_ALIGNMENT);                  setAlignmentX(JPanel.CENTER_ALIGNMENT);
                   
                 add(p);  
205                                    
206                  installView();                  installView();
207          }          }
# Line 204  public class NormalChannelView extends J Line 210  public class NormalChannelView extends J
210          // Implementation of the ChannelView interface          // Implementation of the ChannelView interface
211          //////////////////////////////////////////////          //////////////////////////////////////////////
212                    
213            public Type
214            getType() { return Type.NORMAL; }
215            
216          public JComponent          public JComponent
217          getComponent() { return this; }          getComponent() { return this; }
218                    
# Line 218  public class NormalChannelView extends J Line 227  public class NormalChannelView extends J
227                                  screen.updateVolumeInfo(dialVolume.getValue());                                  screen.updateVolumeInfo(dialVolume.getValue());
228                          }                          }
229                  });                  });
230                    
231                    screen.installListeners();
232                    
233                    addEnhancedMouseListener(channel.getContextMenu());
234          }          }
235                    
236          public void          public void
237          uninstallView() {          uninstallView() {
238                  screen.onDestroy();                  screen.onDestroy();
239                    btnOptions.onDestroy();
240                    uninstallChannelOptionsView();
241                    //removeEnhancedMouseListener(channel.getContextMenu());
242            }
243            
244            public void
245            installChannelOptionsView() {
246                    if(channelOptionsView != null) return;
247                    
248                    channelOptionsView = new NormalChannelOptionsView(channel);
249                    channelOptionsView.installView();
250                    
251            }
252            
253            public void
254            uninstallChannelOptionsView() {
255                    if(channelOptionsView == null) return;
256                    channelOptionsView.uninstallView();
257                    channelOptionsView = null;
258          }          }
259                    
260          public ChannelOptionsView          public ChannelOptionsView
# Line 233  public class NormalChannelView extends J Line 265  public class NormalChannelView extends J
265                  SamplerChannel sc = channel.getChannelInfo();                  SamplerChannel sc = channel.getChannelInfo();
266                                    
267                  screen.updateScreenInfo(sc);                  screen.updateScreenInfo(sc);
268                    float f = sc.getVolume() * 100.0f;
269                    screen.updateVolumeInfo((int)f);
270                  updateMuteIcon(sc);                  updateMuteIcon(sc);
271                                    
272                  if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn);                  if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn);
# Line 243  public class NormalChannelView extends J Line 277  public class NormalChannelView extends J
277                  dialVolume.setEnabled(b);                  dialVolume.setEnabled(b);
278                  btnSolo.setEnabled(b);                  btnSolo.setEnabled(b);
279                  btnMute.setEnabled(b);                  btnMute.setEnabled(b);
280                    
281                    if(getChannelOptionsView() != null) getChannelOptionsView().updateChannelInfo();
282          }          }
283                    
284          public void          public void
# Line 257  public class NormalChannelView extends J Line 293  public class NormalChannelView extends J
293                  btnOptions.doClick();                  btnOptions.doClick();
294          }          }
295                    
296            public boolean
297            isOptionsButtonSelected() { return btnOptions.isSelected(); }
298            
299            public void
300            setOptionsButtonSelected(boolean b) {
301                    btnOptions.setSelected(b);
302            }
303            
304            public void
305            addEnhancedMouseListener(MouseListener l) {
306                    removeEnhancedMouseListener(l);
307                    
308                    for(JComponent c : components) c.addMouseListener(l);
309                    screen.addEnhancedMouseListener(l);
310            }
311            
312            public void
313            removeEnhancedMouseListener(MouseListener l) {
314                    for(JComponent c : components) c.removeMouseListener(l);
315                    screen.removeEnhancedMouseListener(l);
316            }
317            
318          //////////////////////////////////////////////          //////////////////////////////////////////////
319                    
320                    
# Line 344  public class NormalChannelView extends J Line 402  public class NormalChannelView extends J
402          }          }
403                    
404                    
         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; }  
         }  
           
405          private class MuteButton extends PixmapButton implements ActionListener {          private class MuteButton extends PixmapButton implements ActionListener {
406                  MuteButton() {                  MuteButton() {
407                          super(Res.gfxMuteOff);                          super(Res.gfxMuteOff);
# Line 439  public class NormalChannelView extends J Line 470  public class NormalChannelView extends J
470                  public boolean                  public boolean
471                  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); }
472          }          }
           
         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; }  
         }  
473  }  }
474    
475    
   
 class ChannelPane extends PixmapPane {  
         ChannelPane() {  
                 super(Res.gfxChannel);  
                 setPixmapInsets(new Insets(3, 3, 3, 3));  
         }  
 }  
   
476  class ChannelScreen extends PixmapPane {  class ChannelScreen extends PixmapPane {
477          private final Channel channel;          private final Channel channel;
478                    
479          private final InstrumentPane instrumentPane;          private final InstrumentPane instrumentPane;
480                    
481            private final Channel.StreamVoiceCountPane streamVoiceCountPane;
482            
483            private final Channel.VolumePane volumePane;
484            
485          private JButton btnInstr =          private JButton btnInstr =
486                  createScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr"));                  createScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr"));
487                    
# Line 494  class ChannelScreen extends PixmapPane { Line 497  class ChannelScreen extends PixmapPane {
497                    
498          private final JPopupMenu menuEngines = new JPopupMenu();          private final JPopupMenu menuEngines = new JPopupMenu();
499                    
500          private final JButton btnVolume = createScreenButton("");          private final ActionListener guiListener;
         private JSVolumeEditorPopup popupVolume;  
           
         private final JLabel lStreams = createScreenLabel(" --");  
         private final JLabel lVoices = createScreenLabel("-- ");  
501                    
502          private InformationDialog fxSendsDlg = null;          private final Vector<JComponent> components = new Vector<JComponent>();
           
         private Timer timer;  
           
         private static NumberFormat numberFormat = NumberFormat.getInstance();  
         static {  
                 numberFormat.setMaximumFractionDigits(1);  
         }  
503                    
504          ChannelScreen(final Channel channel) {          ChannelScreen(final Channel channel) {
505                  super(Res.gfxChannelScreen);                  super(Res.gfxChannelScreen);
506                  setPixmapInsets(new Insets(6, 6, 6, 6));                  setPixmapInsets(new Insets(6, 6, 6, 6));
507                  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));                  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
508                                    
509                    components.add(this);
510                    
511                  this.channel = channel;                  this.channel = channel;
512                  popupVolume = new JSVolumeEditorPopup(btnVolume, VolumeType.CHANNEL);                  
513                    streamVoiceCountPane = new Channel.StreamVoiceCountPane(channel);
514                    components.add(streamVoiceCountPane);
515                    
516                    volumePane = new Channel.VolumePane(channel);
517                    components.add(volumePane);
518                                    
519                  setOpaque(false);                  setOpaque(false);
520                                    
# Line 524  class ChannelScreen extends PixmapPane { Line 523  class ChannelScreen extends PixmapPane {
523                  btnInstr.setAlignmentX(CENTER_ALIGNMENT);                  btnInstr.setAlignmentX(CENTER_ALIGNMENT);
524                  btnInstr.setRolloverEnabled(false);                  btnInstr.setRolloverEnabled(false);
525                  btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));                  btnInstr.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
526                    components.add(btnInstr);
527                                    
528                  instrumentPane = new InstrumentPane();                  instrumentPane = new InstrumentPane();
529                    components.add(instrumentPane);
530                  add(instrumentPane);                  add(instrumentPane);
531                                    
532                    add(Box.createRigidArea(new Dimension(0, 3)));
533                    
534                  JPanel p = new JPanel();                  JPanel p = new JPanel();
535                    components.add(p);
536                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));                  p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
537                  p.setAlignmentX(CENTER_ALIGNMENT);                  p.setAlignmentX(CENTER_ALIGNMENT);
538                  p.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0));                  p.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0));
539                                    
540                    components.add(btnFxSends);
541                  btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt"));                  btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt"));
542                  btnFxSends.addActionListener(new ActionListener() {                  btnFxSends.addActionListener(new ActionListener() {
543                          public void                          public void
544                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
545                                  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);  
546                          }                          }
547                  });                  });
548                                    
# Line 556  class ChannelScreen extends PixmapPane { Line 551  class ChannelScreen extends PixmapPane {
551                  //p.add(Box.createRigidArea(new Dimension(6, 0)));                  //p.add(Box.createRigidArea(new Dimension(6, 0)));
552                  p.add(Box.createGlue());                  p.add(Box.createGlue());
553                                    
554                    components.add(btnEngine);
555                  btnEngine.setIcon(Res.iconEngine12);                  btnEngine.setIcon(Res.iconEngine12);
556                  btnEngine.setIconTextGap(1);                  btnEngine.setIconTextGap(1);
557                  p.add(btnEngine);                  p.add(btnEngine);
# Line 567  class ChannelScreen extends PixmapPane { Line 563  class ChannelScreen extends PixmapPane {
563                                    
564                  p.add(Box.createGlue());                  p.add(Box.createGlue());
565                                    
566                  lStreams.setFont(Res.fontScreenMono);                  p.add(streamVoiceCountPane);
567                  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);  
                   
                 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());  
                         }  
                 });  
568                                    
                 p.add(btnVolume);  
569                  p.setPreferredSize(new Dimension(260, p.getPreferredSize().height));                  p.setPreferredSize(new Dimension(260, p.getPreferredSize().height));
570                  p.setMinimumSize(p.getPreferredSize());                  p.setMinimumSize(p.getPreferredSize());
571                  p.setMaximumSize(p.getPreferredSize());                  p.setMaximumSize(p.getPreferredSize());
# Line 627  class ChannelScreen extends PixmapPane { Line 580  class ChannelScreen extends PixmapPane {
580                  setMaximumSize(getPreferredSize());                  setMaximumSize(getPreferredSize());
581                                    
582                  createEngineMenu();                  createEngineMenu();
583                  installListeners();                  
584                    guiListener = new ActionListener() {
585                            public void
586                            actionPerformed(ActionEvent e) {
587                                    if(getMousePosition(true) != null) {
588                                            getHandler().mouseEntered(null);
589                                    } else {
590                                            getHandler().mouseExited(null);
591                                    }
592                            }
593                    };
594            }
595            
596            public void
597            addEnhancedMouseListener(MouseListener l) {
598                    removeEnhancedMouseListener(l);
599                    for(JComponent c : components) c.addMouseListener(l);
600            }
601            
602            public void
603            removeEnhancedMouseListener(MouseListener l) {
604                    for(JComponent c : components) c.removeMouseListener(l);
605          }          }
606                    
607          protected void          protected void
608          onDestroy() { timer.stop(); }          onDestroy() { uninstallListeners(); }
609                    
610          private void          private void
611          createEngineMenu() {          createEngineMenu() {
# Line 650  class ChannelScreen extends PixmapPane { Line 624  class ChannelScreen extends PixmapPane {
624                  }                  }
625          }          }
626                    
627          private void          protected void
628          installListeners() {          installListeners() {
629                  btnInstr.addActionListener(new ActionListener() {                  btnInstr.addActionListener(new ActionListener() {
630                          public void                          public void
631                          actionPerformed(ActionEvent e) { loadInstrument(); }                          actionPerformed(ActionEvent e) { channel.loadInstrument(); }
632                  });                  });
633                                    
634                  btnEditInstr.addActionListener(new ActionListener() {                  btnEditInstr.addActionListener(new ActionListener() {
# Line 675  class ChannelScreen extends PixmapPane { Line 649  class ChannelScreen extends PixmapPane {
649                  addMouseListener(getHandler());                  addMouseListener(getHandler());
650                  addHierarchyListener(getHandler());                  addHierarchyListener(getHandler());
651                                    
652                  ActionListener l = new ActionListener() {                  ((MainFrame)CC.getMainFrame()).getGuiTimer().addActionListener(guiListener);
                         public void  
                         actionPerformed(ActionEvent e) {  
                                 if(getMousePosition(true) != null) {  
                                         getHandler().mouseEntered(null);  
                                 } else {  
                                         getHandler().mouseExited(null);  
                                 }  
                         }  
                 };  
                 timer = new Timer(1000, l);  
                 timer.start();  
653          }          }
654                    
655          private void          private void
656          loadInstrument() {          uninstallListeners() {
657                  JSInstrumentChooser dlg = FantasiaUtils.createInstrumentChooser(CC.getMainFrame());                  ((MainFrame)CC.getMainFrame()).getGuiTimer().removeActionListener(guiListener);
                 dlg.setVisible(true);  
                   
                 if(!dlg.isCancelled()) {  
                         SamplerChannelModel m = channel.getModel();  
                         m.loadBackendInstrument(dlg.getInstrumentFile(), dlg.getInstrumentIndex());  
                 }  
658          }          }
659                    
660          protected void          protected void
661          updateScreenInfo(SamplerChannel sc) {          updateScreenInfo(SamplerChannel sc) {
662                    String s = btnInstr.getToolTipText();
663                    
664                  int status = sc.getInstrumentStatus();                  int status = sc.getInstrumentStatus();
665                  if(status >= 0 && status < 100) {                  if(status >= 0 && status < 100) {
666                          btnInstr.setText(i18n.getLabel("ChannelScreen.loadingInstrument", status));                          btnInstr.setText(i18n.getLabel("ChannelScreen.loadingInstrument", status));
667                            if(s != null) btnInstr.setToolTipText(null);
668                  } else if(status == -1) {                  } else if(status == -1) {
669                          btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr"));                          btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr"));
670                            if(s != null) btnInstr.setToolTipText(null);
671                  } else if(status < -1) {                  } else if(status < -1) {
672                           btnInstr.setText(i18n.getLabel("ChannelScreen.errorLoadingInstrument"));                           btnInstr.setText(i18n.getLabel("ChannelScreen.errorLoadingInstrument"));
673                             if(s != null) btnInstr.setToolTipText(null);
674                  } else {                  } else {
675                          if(sc.getInstrumentName() != null) btnInstr.setText(sc.getInstrumentName());                          if(sc.getInstrumentName() != null) btnInstr.setText(sc.getInstrumentName());
676                          else btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr"));                          else btnInstr.setText(i18n.getButtonLabel("ChannelScreen.btnInstr"));
677                            
678                            btnInstr.setToolTipText(sc.getInstrumentName());
679                  }                  }
680                                    
681                  instrumentPane.update();                  instrumentPane.update();
682                    
683                  if(sc.getEngine() != null) {                  if(sc.getEngine() != null) {
684                          String s = sc.getEngine().getName();                          s = sc.getEngine().getName();
685                          s += " engine";                          s += " engine";
686                          if(!s.equals(btnEngine.getText())) {                          if(!s.equals(btnEngine.getText())) {
687                                  btnEngine.setText(s);                                  btnEngine.setText(s);
# Line 729  class ChannelScreen extends PixmapPane { Line 693  class ChannelScreen extends PixmapPane {
693                    
694          protected void          protected void
695          updateVolumeInfo(int volume) {          updateVolumeInfo(int volume) {
696                  if(CC.getViewConfig().isMeasurementUnitDecibel()) {                  volumePane.updateVolumeInfo(volume);
                         String s = numberFormat.format(HF.percentsToDecibels(volume));  
                         btnVolume.setText(s + "dB");  
                 } else {  
                         btnVolume.setText(String.valueOf(volume) + "%");  
                 }  
697          }          }
698                    
699          /**          /**
# Line 743  class ChannelScreen extends PixmapPane { Line 702  class ChannelScreen extends PixmapPane {
702           */           */
703          protected void          protected void
704          updateStreamCount(int count) {          updateStreamCount(int count) {
705                  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);  
706          }          }
707                    
708          /**          /**
# Line 757  class ChannelScreen extends PixmapPane { Line 711  class ChannelScreen extends PixmapPane {
711           */           */
712          protected void          protected void
713          updateVoiceCount(int count) {          updateVoiceCount(int count) {
714                  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);  
715          }          }
716                    
717          class InstrumentPane extends JPanel {          class InstrumentPane extends JPanel {
# Line 818  class ChannelScreen extends PixmapPane { Line 767  class ChannelScreen extends PixmapPane {
767                  }                  }
768          }          }
769                    
         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;  
                 }  
         }  
           
770          static class ScreenButtonBg extends PixmapPane {          static class ScreenButtonBg extends PixmapPane {
771                  ScreenButtonBg(JButton btn) {                  ScreenButtonBg(JButton btn) {
772                          super(Res.gfxScreenBtnBg);                          super(Res.gfxScreenBtnBg);

Legend:
Removed from v.1730  
changed lines
  Added in v.1767

  ViewVC Help
Powered by ViewVC