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

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

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

revision 1734 by iliev, Sun May 4 18:40:13 2008 UTC revision 1785 by iliev, Tue Oct 7 00:07:14 2008 UTC
# Line 40  import javax.swing.AbstractAction; Line 40  import javax.swing.AbstractAction;
40  import javax.swing.Action;  import javax.swing.Action;
41  import javax.swing.BoxLayout;  import javax.swing.BoxLayout;
42  import javax.swing.ButtonGroup;  import javax.swing.ButtonGroup;
 import javax.swing.DefaultListCellRenderer;  
43  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
44  import javax.swing.JButton;  import javax.swing.JButton;
45  import javax.swing.JComponent;  import javax.swing.JComponent;
# Line 50  import javax.swing.JPanel; Line 49  import javax.swing.JPanel;
49  import javax.swing.JPopupMenu;  import javax.swing.JPopupMenu;
50  import javax.swing.JRadioButtonMenuItem;  import javax.swing.JRadioButtonMenuItem;
51  import javax.swing.JScrollPane;  import javax.swing.JScrollPane;
 import javax.swing.JToggleButton;  
52  import javax.swing.JToolBar;  import javax.swing.JToolBar;
53    
 import net.sf.juife.InformationDialog;  
 import net.sf.juife.TitleBar;  
   
54  import org.jdesktop.swingx.JXCollapsiblePane;  import org.jdesktop.swingx.JXCollapsiblePane;
55    
56  import org.jsampler.CC;  import org.jsampler.CC;
# Line 68  import org.jsampler.event.SamplerChannel Line 63  import org.jsampler.event.SamplerChannel
63  import org.jsampler.event.SamplerChannelListener;  import org.jsampler.event.SamplerChannelListener;
64    
65  import org.jsampler.view.JSChannel;  import org.jsampler.view.JSChannel;
66    import org.jsampler.view.JSChannelsPane;
67    
68    import org.jsampler.view.fantasia.basic.PixmapToggleButton;
69    
70  import org.jsampler.view.std.JSChannelOutputRoutingDlg;  import org.jsampler.view.std.JSChannelOutputRoutingDlg;
71    import org.jsampler.view.std.JSFxSendsDlg;
72  import org.jsampler.view.std.JSFxSendsPane;  import org.jsampler.view.std.JSFxSendsPane;
73  import org.jsampler.view.std.JSInstrumentChooser;  import org.jsampler.view.std.JSInstrumentChooser;
74  import org.jsampler.view.std.JSVolumeEditorPopup;  import org.jsampler.view.std.JSVolumeEditorPopup;
# Line 88  import static org.jsampler.view.std.JSVo Line 87  import static org.jsampler.view.std.JSVo
87   */   */
88  public class Channel extends JSChannel {  public class Channel extends JSChannel {
89          private final JXCollapsiblePane mainPane;          private final JXCollapsiblePane mainPane;
         private ChannelOptionsView channelOptionsView;  
90          private final ChannelOptionsPane optionsPane = new ChannelOptionsPane();          private final ChannelOptionsPane optionsPane = new ChannelOptionsPane();
91                    
92          private final ViewTracker viewTracker;          private final ViewTracker viewTracker;
93                    
94          private InformationDialog fxSendsDlg = null;          private JSFxSendsDlg fxSendsDlg = null;
95                    
96          private final ContextMenu contextMenu = new ContextMenu();          private final ContextMenu contextMenu;
97                    
98          private boolean selected = false;          private boolean selected = false;
99                    
# Line 108  public class Channel extends JSChannel { Line 106  public class Channel extends JSChannel {
106                  }                  }
107          }          }
108                    
109            ////////////////////////////////
110            // ******* Mouse tracker *******
111            ////////////////////////////////
112            private static int mouseOverChannelId = -1;
113            private static boolean mousePressed = false;
114            
115            private static ActionListener guiListener = null;
116            
117            private static Channel oldMouseOverChannel = null;
118            private static Channel newMouseOverChannel = null;
119            
120            
121            private static void
122            mouseMoved() {
123                    //TODO: do this for all channels panes
124                    JSChannelsPane cp = CC.getMainFrame().getChannelsPane(0);
125                    for(int i = 0; i < cp.getChannelCount(); i++) {
126                            mouseMoved((Channel)cp.getChannel(i));
127                    }
128                    
129                    if(oldMouseOverChannel == newMouseOverChannel) return;
130                    
131                    if(oldMouseOverChannel != null) oldMouseOverChannel.mouseExited();
132                    
133                    if(newMouseOverChannel != null) {
134                            mouseOverChannelId = newMouseOverChannel.getChannelId();
135                            newMouseOverChannel.mouseEntered();
136                    }
137                    
138                    oldMouseOverChannel = newMouseOverChannel = null;
139            }
140            
141            private static void
142            mouseMoved(Channel c) {
143                    int id = c.getChannelId();
144                    if(c.mainPane.getMousePosition(true) != null) {
145                            newMouseOverChannel = c;
146                    } else if(id == mouseOverChannelId) {
147                            oldMouseOverChannel = c;
148                    }
149            }
150            
151            ////////////////////////////////
152            
153            
154          /**          /**
155           * Creates a new instance of <code>Channel</code> using the specified           * Creates a new instance of <code>Channel</code> using the specified
156           * non-<code>null</code> channel model.           * non-<code>null</code> channel model.
# Line 136  public class Channel extends JSChannel { Line 179  public class Channel extends JSChannel {
179                                    
180                  mainPane = new JXCollapsiblePane();                  mainPane = new JXCollapsiblePane();
181                  viewTracker = new ViewTracker();                  viewTracker = new ViewTracker();
182                    contextMenu = new ContextMenu();
183                                    
184                  mainPane.getContentPane().setLayout (                  mainPane.getContentPane().setLayout (
185                          new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS)                          new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS)
# Line 143  public class Channel extends JSChannel { Line 187  public class Channel extends JSChannel {
187                                    
188                  int viewIdx = preferences().getIntProperty(DEFAULT_CHANNEL_VIEW);                  int viewIdx = preferences().getIntProperty(DEFAULT_CHANNEL_VIEW);
189                  if(viewIdx == 0) {                  if(viewIdx == 0) {
190                          contextMenu.rbmiSmallView.doClick(0);                          viewTracker.setView(new SmallChannelView(Channel.this));
191                  } else if(viewIdx == 1) {                  } else if(viewIdx == 1) {
192                          contextMenu.rbmiNormalView.doClick(0);                          viewTracker.setView(new NormalChannelView(Channel.this));
193                  } else {                  } else {
194                          contextMenu.rbmiNormalView.doClick(0);                          viewTracker.setView(new NormalChannelView(Channel.this));
195                  }                  }
196                                    
197                  setOpaque(false);                  setOpaque(false);
# Line 191  public class Channel extends JSChannel { Line 235  public class Channel extends JSChannel {
235                  }                  }
236                                    
237                  CC.getSamplerModel().addSamplerChannelListListener(getHandler());                  CC.getSamplerModel().addSamplerChannelListListener(getHandler());
238                    
239                    installGuiListener();
240            }
241            
242            private static void
243            installGuiListener() {
244                    if(guiListener != null) return;
245                    
246                    guiListener = new ActionListener() {
247                            public void
248                            actionPerformed(ActionEvent e) {
249                                    mouseMoved();
250                            }
251                    };
252                    
253                    ((MainFrame)CC.getMainFrame()).getGuiTimer().addActionListener(guiListener);
254            }
255            
256            private void
257            mouseEntered() {
258                    viewTracker.mouseEntered();
259            }
260            
261            private void
262            mouseExited() {
263                    viewTracker.mouseExited();
264          }          }
265                    
266          private void          private void
# Line 213  public class Channel extends JSChannel { Line 283  public class Channel extends JSChannel {
283           * Determines whether the channel is selected.           * Determines whether the channel is selected.
284           * @return <code>true</code> if the channel is selected, <code>false</code> otherwise.           * @return <code>true</code> if the channel is selected, <code>false</code> otherwise.
285           */           */
286          public boolean isSelected() { return selected; }          @Override
287            public boolean
288            isSelected() { return selected; }
289                    
290          /**          /**
291           * Sets the selection state of this channel.           * Sets the selection state of this channel.
# Line 221  public class Channel extends JSChannel { Line 293  public class Channel extends JSChannel {
293           * @param select Specifies the new selection state of this channel;           * @param select Specifies the new selection state of this channel;
294           * <code>true</code> to select the channel, <code>false</code> otherwise.           * <code>true</code> to select the channel, <code>false</code> otherwise.
295           */           */
296            @Override
297          public void          public void
298          setSelected(boolean select) {          setSelected(boolean select) {
299                                    
# Line 247  public class Channel extends JSChannel { Line 320  public class Channel extends JSChannel {
320          private void          private void
321          updateChannelInfo() {          updateChannelInfo() {
322                  viewTracker.getCurrentView().updateChannelInfo();                  viewTracker.getCurrentView().updateChannelInfo();
                 viewTracker.getCurrentView().getChannelOptionsView().updateChannelInfo();  
323          }          }
324                    
325          public void          public void
# Line 275  public class Channel extends JSChannel { Line 347  public class Channel extends JSChannel {
347          onDestroy() {          onDestroy() {
348                  CC.getSamplerModel().removeSamplerChannelListListener(getHandler());                  CC.getSamplerModel().removeSamplerChannelListListener(getHandler());
349                  preferences().removePropertyChangeListener(ANIMATED, animatedPorpetyListener);                  preferences().removePropertyChangeListener(ANIMATED, animatedPorpetyListener);
350                                    if(fxSendsDlg != null) fxSendsDlg.dispose();
351                  viewTracker.onDestroy();                  viewTracker.onDestroy();
352          }          }
353                                    
# Line 300  public class Channel extends JSChannel { Line 372  public class Channel extends JSChannel {
372                          fxSendsDlg.toFront();                          fxSendsDlg.toFront();
373                          return;                          return;
374                  }                  }
375                  FxSendsPane p = new FxSendsPane(getModel());                  
376                  int id = getModel().getChannelId();                  fxSendsDlg = new JSFxSendsDlg(new FxSendsPane(getModel()));
                 fxSendsDlg = new InformationDialog(CC.getMainFrame(), p);  
                 fxSendsDlg.setTitle(i18n.getLabel("FxSendsDlg.title", id));  
                 fxSendsDlg.setModal(false);  
                 fxSendsDlg.showCloseButton(false);  
377                  fxSendsDlg.setVisible(true);                  fxSendsDlg.setVisible(true);
378          }          }
379                    
# Line 321  public class Channel extends JSChannel { Line 389  public class Channel extends JSChannel {
389                   * @param e A <code>SamplerChannelEvent</code> instance                   * @param e A <code>SamplerChannelEvent</code> instance
390                   * containing event information.                   * containing event information.
391                   */                   */
392                    @Override
393                  public void                  public void
394                  channelChanged(SamplerChannelEvent e) { updateChannelInfo(); }                  channelChanged(SamplerChannelEvent e) { updateChannelInfo(); }
395                    
# Line 329  public class Channel extends JSChannel { Line 398  public class Channel extends JSChannel {
398                   * @param e A <code>SamplerChannelEvent</code> instance                   * @param e A <code>SamplerChannelEvent</code> instance
399                   * containing event information.                   * containing event information.
400                   */                   */
401                    @Override
402                  public void                  public void
403                  streamCountChanged(SamplerChannelEvent e) {                  streamCountChanged(SamplerChannelEvent e) {
404                          viewTracker.getCurrentView().updateStreamCount(getModel().getStreamCount());                          viewTracker.getCurrentView().updateStreamCount(getModel().getStreamCount());
# Line 339  public class Channel extends JSChannel { Line 409  public class Channel extends JSChannel {
409                   * @param e A <code>SamplerChannelEvent</code> instance                   * @param e A <code>SamplerChannelEvent</code> instance
410                   * containing event information.                   * containing event information.
411                   */                   */
412                    @Override
413                  public void                  public void
414                  voiceCountChanged(SamplerChannelEvent e) {                  voiceCountChanged(SamplerChannelEvent e) {
415                          viewTracker.getCurrentView().updateVoiceCount(getModel().getVoiceCount());                          viewTracker.getCurrentView().updateVoiceCount(getModel().getVoiceCount());
# Line 349  public class Channel extends JSChannel { Line 420  public class Channel extends JSChannel {
420                   * @param e A <code>SamplerChannelListEvent</code>                   * @param e A <code>SamplerChannelListEvent</code>
421                   * instance providing the event information.                   * instance providing the event information.
422                   */                   */
423                    @Override
424                  public void                  public void
425                  channelAdded(SamplerChannelListEvent e) { }                  channelAdded(SamplerChannelListEvent e) { }
426                    
# Line 357  public class Channel extends JSChannel { Line 429  public class Channel extends JSChannel {
429                   * @param e A <code>SamplerChannelListEvent</code>                   * @param e A <code>SamplerChannelListEvent</code>
430                   * instance providing the event information.                   * instance providing the event information.
431                   */                   */
432                    @Override
433                  public void                  public void
434                  channelRemoved(SamplerChannelListEvent e) {                  channelRemoved(SamplerChannelListEvent e) {
435                          // Some cleanup when the channel is removed.                          // Some cleanup when the channel is removed.
# Line 365  public class Channel extends JSChannel { Line 438  public class Channel extends JSChannel {
438                          }                          }
439                  }                  }
440                                    
441                    @Override
442                  public void                  public void
443                  propertyChange(PropertyChangeEvent e) {                  propertyChange(PropertyChangeEvent e) {
444                          if(e.getNewValue() == "collapsed") {                          if(e.getNewValue() == "collapsed") {
# Line 373  public class Channel extends JSChannel { Line 447  public class Channel extends JSChannel {
447                  }                  }
448          }          }
449                    
450          private static boolean viewTrackerMousePressed = false;          public ViewTracker
451            getViewTracker() { return viewTracker; }
452                    
453          class ViewTracker extends MouseAdapter implements PropertyChangeListener {          class ViewTracker extends MouseAdapter implements PropertyChangeListener {
454                  private ChannelView originalView;                  private ChannelView originalView;
455                  private ChannelView mouseOverView;                  private ChannelView mouseOverView;
456                  private ChannelView currentView;                  private ChannelView currentView;
457                                    
458                                    private ChannelView.Type mouseOverViewType = null;
                 private boolean mouseOver = false;  
                   
                 private final ActionListener guiListener;  
459                                    
460                  ViewTracker() {                  ViewTracker() {
461                          guiListener = new ActionListener() {                          
                                 public void  
                                 actionPerformed(ActionEvent e) {  
                                         if(viewTrackerMousePressed) return;  
                                           
                                         if(mainPane.getMousePosition(true) != null) {  
                                                 mouseEntered(null);  
                                         } else {  
                                                 mouseExited(null);  
                                         }  
                                 }  
                         };  
462                                                    
463                          updateMouseOverViewType();                          updateMouseOverViewType();
464                                                    
# Line 415  public class Channel extends JSChannel { Line 476  public class Channel extends JSChannel {
476                                    
477                  private void                  private void
478                  installListeners() {                  installListeners() {
479                          ((MainFrame)CC.getMainFrame()).getGuiTimer().addActionListener(guiListener);                          
480                  }                  }
481                                    
482                  private void                  private void
483                  uninstallListeners() {                  uninstallListeners() {
484                          ((MainFrame)CC.getMainFrame()).getGuiTimer().removeActionListener(guiListener);                          
485                  }                  }
486                                    
487                  private void                  private void
# Line 429  public class Channel extends JSChannel { Line 490  public class Channel extends JSChannel {
490                                  mouseOverView.removeEnhancedMouseListener(this);                                  mouseOverView.removeEnhancedMouseListener(this);
491                          }                          }
492                                                    
493                            mouseOverView = null;
494                            
495                          boolean b;                          boolean b;
496                          b = preferences().getBoolProperty(DIFFERENT_CHANNEL_VIEW_ON_MOUSE_OVER);                          b = preferences().getBoolProperty(DIFFERENT_CHANNEL_VIEW_ON_MOUSE_OVER);
497                          if(!b) {                          if(!b) {
498                                  mouseOverView = null;                                  mouseOverViewType = null;
499                                  uninstallListeners();                                  uninstallListeners();
500                                  return;                                  return;
501                          }                          }
502                                                    
                         Channel channel = Channel.this;  
503                          int i = preferences().getIntProperty(CHANNEL_VIEW_ON_MOUSE_OVER);                          int i = preferences().getIntProperty(CHANNEL_VIEW_ON_MOUSE_OVER);
504                                                    
505                          switch(i) {                          switch(i) {
506                                  case 0: mouseOverView = new SmallChannelView(channel); break;                                  case 0: mouseOverViewType = ChannelView.Type.SMALL; break;
507                                  case 1: mouseOverView = new NormalChannelView(channel); break;                                  case 1: mouseOverViewType = ChannelView.Type.NORMAL; break;
508                                  default:mouseOverView = null;                                  default:mouseOverViewType = null;
509                          }                          }
510                                                    
511                          if(mouseOverView != null) {                          if(mouseOverViewType != null) {
512                                  installListeners();                                  installListeners();
513                            }
514                    }
515                    
516                    public ChannelView
517                    getMouseOverView() {
518                            if(mouseOverViewType == null) return null;
519                            
520                            if(mouseOverView == null) {
521                                    Channel channel = Channel.this;
522                                    
523                                    switch(mouseOverViewType) {
524                                    case SMALL: mouseOverView = new SmallChannelView(channel); break;
525                                    case NORMAL: mouseOverView = new NormalChannelView(channel); break;
526                                    default: mouseOverView = new NormalChannelView(channel);
527                                    }
528                                    
529                                  mouseOverView.addEnhancedMouseListener(this);                                  mouseOverView.addEnhancedMouseListener(this);
530                          }                          }
531                            
532                            return mouseOverView;
533                  }                  }
534                                    
535                  public ChannelView                  public ChannelView
536                  getCurrentView() { return currentView; }                  getCurrentView() { return currentView; }
537                                    
538                    public ChannelView
539                    getOriginalView() { return originalView; }
540                    
541                  public void                  public void
542                  setView(ChannelView view) {                  setView(ChannelView view) {
543                          setView(view, true);                          setView(view, true);
# Line 500  public class Channel extends JSChannel { Line 583  public class Channel extends JSChannel {
583                                    
584                  private void                  private void
585                  updateView() {                  updateView() {
586                          JComponent c = getCurrentView().getChannelOptionsView().getComponent();                          ChannelOptionsView view = getCurrentView().getChannelOptionsView();
587                          optionsPane.setContentPane(c);                          if(view != null) optionsPane.setContentPane(view.getComponent());
588                                                    
589                          updateChannelInfo();                          updateChannelInfo();
590                                    
# Line 553  public class Channel extends JSChannel { Line 636  public class Channel extends JSChannel {
636                          if(view == null) return;                          if(view == null) return;
637                                                    
638                          view.uninstallView();                          view.uninstallView();
                         view.getChannelOptionsView().uninstallView();  
639                                                    
640                          view = null;                          view = null;
641                  }                  }
642                                    
643                    public boolean
644                    isMouseOverEnabled() { return mouseOverViewType != null; }
645                    
646                  private void                  private void
647                  mouseEntered() {                  mouseEntered() {
648                          if(mouseOverView == null) return;                          if(!isMouseOverEnabled()) return;
649                          if(getCurrentView().getType() == mouseOverView.getType()) return;                          if(getCurrentView().getType() == getMouseOverView().getType()) return;
650                                                    
651                          JSChannel[] channels = CC.getMainFrame().getChannelsPane(0).getChannels();                          JSChannel[] channels = CC.getMainFrame().getChannelsPane(0).getChannels();
652                          for(JSChannel c : channels) {                          for(JSChannel c : channels) {
# Line 571  public class Channel extends JSChannel { Line 656  public class Channel extends JSChannel {
656                                  if(!(chn).isUsingOriginalView()) chn.fallbackToOriginalView();                                  if(!(chn).isUsingOriginalView()) chn.fallbackToOriginalView();
657                          }                          }
658                                                    
659                          setView(mouseOverView, false);                          setView(getMouseOverView(), false);
660                  }                  }
661                                    
662                  private void                  private void
663                  mouseExited() {                  mouseExited() {
664                          if(mouseOverView == null) return;                          if(!isMouseOverEnabled()) return;
665                          if(getCurrentView().getType() == originalView.getType()) return;                          if(getCurrentView().getType() == originalView.getType()) return;
666                                                    
667                          fallbackToOriginalView();                          fallbackToOriginalView();
668                  }                  }
669                                    
670                    @Override
671                  public void                  public void
672                  mouseEntered(MouseEvent e) {                  mouseEntered(MouseEvent e) {
673                          if(viewTrackerMousePressed) return;                          guiListener.actionPerformed(null);
                           
                         if(mouseOver) return;  
                         mouseOver = true;  
                         mouseEntered();  
674                  }                  }
675                                    
676                    @Override
677                  public void                  public void
678                  mouseExited(MouseEvent e) {                  mouseExited(MouseEvent e) {
679                          if(viewTrackerMousePressed) return;                          guiListener.actionPerformed(null);
                           
                         if(mainPane.getMousePosition(true) != null) return;  
                         if(!mouseOver) return;  
                         mouseOver = false;  
                         mouseExited();  
680                  }                  }
681                                    
682                    @Override
683                  public void                  public void
684                  mousePressed(MouseEvent e) {                  mousePressed(MouseEvent e) {
685                          viewTrackerMousePressed = true;                          mousePressed = true;
686                  }                  }
687                                    
688                    @Override
689                  public void                  public void
690                  mouseReleased(MouseEvent e) {                  mouseReleased(MouseEvent e) {
691                          viewTrackerMousePressed = false;                          mousePressed = false;
692                  }                  }
693                                    
694                  public void                  public void
# Line 633  public class Channel extends JSChannel { Line 713  public class Channel extends JSChannel {
713                          preferences().removePropertyChangeListener(s, this);                          preferences().removePropertyChangeListener(s, this);
714                  }                  }
715                                    
716                    @Override
717                  public void                  public void
718                  propertyChange(PropertyChangeEvent e) {                  propertyChange(PropertyChangeEvent e) {
719                          updateMouseOverViewType();                          updateMouseOverViewType();
# Line 646  public class Channel extends JSChannel { Line 727  public class Channel extends JSChannel {
727                          getModel().addSamplerChannelListener(this);                          getModel().addSamplerChannelListener(this);
728                  }                  }
729                                    
730                    @Override
731                  public void                  public void
732                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
733                          CC.getSamplerModel().editBackendInstrument(getChannelId());                          CC.getSamplerModel().editBackendInstrument(getChannelId());
734                  }                  }
735                                    
736                    @Override
737                  public void                  public void
738                  channelChanged(SamplerChannelEvent e) {                  channelChanged(SamplerChannelEvent e) {
739                          boolean b = getChannelInfo().getInstrumentStatus() == 100;                          boolean b = getChannelInfo().getInstrumentStatus() == 100;
740                          setEnabled(b);                          setEnabled(b);
741                  }                  }
742                                    
743                    @Override
744                  public void                  public void
745                  streamCountChanged(SamplerChannelEvent e) { }                  streamCountChanged(SamplerChannelEvent e) { }
746                                    
747                    @Override
748                  public void                  public void
749                  voiceCountChanged(SamplerChannelEvent e) { }                  voiceCountChanged(SamplerChannelEvent e) { }
750          }          }
# Line 669  public class Channel extends JSChannel { Line 754  public class Channel extends JSChannel {
754                          super(i18n.getMenuLabel("channels.fxSends"));                          super(i18n.getMenuLabel("channels.fxSends"));
755                  }                  }
756                                    
757                    @Override
758                  public void                  public void
759                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
760                          showFxSendsDialog();                          showFxSendsDialog();
# Line 682  public class Channel extends JSChannel { Line 768  public class Channel extends JSChannel {
768                          getModel().addSamplerChannelListener(this);                          getModel().addSamplerChannelListener(this);
769                  }                  }
770                                    
771                    @Override
772                  public void                  public void
773                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
774                          SamplerChannel c = getChannelInfo();                          SamplerChannel c = getChannelInfo();
775                          new JSChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true);                          new JSChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true);
776                  }                  }
777                                    
778                    @Override
779                  public void                  public void
780                  channelChanged(SamplerChannelEvent e) {                  channelChanged(SamplerChannelEvent e) {
781                          boolean b = getChannelInfo().getAudioOutputDevice() != -1;                          boolean b = getChannelInfo().getAudioOutputDevice() != -1;
782                          setEnabled(b);                          setEnabled(b);
783                  }                  }
784                                    
785                    @Override
786                  public void                  public void
787                  streamCountChanged(SamplerChannelEvent e) { }                  streamCountChanged(SamplerChannelEvent e) { }
788                                    
789                    @Override
790                  public void                  public void
791                  voiceCountChanged(SamplerChannelEvent e) { }                  voiceCountChanged(SamplerChannelEvent e) { }
792          }          }
# Line 706  public class Channel extends JSChannel { Line 796  public class Channel extends JSChannel {
796                          super(i18n.getMenuLabel("channels.smallView"));                          super(i18n.getMenuLabel("channels.smallView"));
797                  }                  }
798                                    
799                    @Override
800                  public void                  public void
801                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
802                          viewTracker.setView(new SmallChannelView(Channel.this));                          viewTracker.setView(new SmallChannelView(Channel.this));
# Line 717  public class Channel extends JSChannel { Line 808  public class Channel extends JSChannel {
808                          super(i18n.getMenuLabel("channels.normalView"));                          super(i18n.getMenuLabel("channels.normalView"));
809                  }                  }
810                                    
811                    @Override
812                  public void                  public void
813                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
814                          viewTracker.setView(new NormalChannelView(Channel.this));                          viewTracker.setView(new NormalChannelView(Channel.this));
# Line 727  public class Channel extends JSChannel { Line 819  public class Channel extends JSChannel {
819          getContextMenu() { return contextMenu; }          getContextMenu() { return contextMenu; }
820                    
821          class ContextMenu extends MouseAdapter {          class ContextMenu extends MouseAdapter {
822                  private final JPopupMenu menu = new JPopupMenu();                  private JPopupMenu menu = null;
823                                    
824                  protected final JRadioButtonMenuItem rbmiSmallView;                  protected JRadioButtonMenuItem rbmiSmallView;
825                  protected final JRadioButtonMenuItem rbmiNormalView;                  protected JRadioButtonMenuItem rbmiNormalView;
826                                    
827                  ContextMenu() {                  ContextMenu() {
828                            
829                    }
830                    
831                    private void
832                    createMenu() {
833                            menu = new JPopupMenu();
834                          menu.add(new JMenuItem(new EditInstrumentAction()));                          menu.add(new JMenuItem(new EditInstrumentAction()));
835                          menu.addSeparator();                          menu.addSeparator();
836                                                    
837                          rbmiSmallView = new JRadioButtonMenuItem(new SetSmallViewAction());                          rbmiSmallView = new JRadioButtonMenuItem(new SetSmallViewAction());
838                          rbmiNormalView = new JRadioButtonMenuItem(new SetNormalViewAction());                          rbmiNormalView = new JRadioButtonMenuItem(new SetNormalViewAction());
839                            if(viewTracker.getOriginalView() instanceof SmallChannelView) {
840                                    rbmiSmallView.setSelected(true);
841                            } else if(viewTracker.getOriginalView() instanceof NormalChannelView) {
842                                    rbmiNormalView.setSelected(true);
843                            }
844                                                    
845                          ButtonGroup group = new ButtonGroup();                          ButtonGroup group = new ButtonGroup();
846                          group.add(rbmiSmallView);                          group.add(rbmiSmallView);
# Line 751  public class Channel extends JSChannel { Line 854  public class Channel extends JSChannel {
854                          menu.add(new JMenuItem(new ChannelRoutingAction()));                          menu.add(new JMenuItem(new ChannelRoutingAction()));
855                  }                  }
856                                    
857                    private JPopupMenu
858                    getMenu() {
859                            if(menu == null) createMenu();
860                            return menu;
861                    }
862                    
863                    @Override
864                  public void                  public void
865                  mousePressed(MouseEvent e) {                  mousePressed(MouseEvent e) {
866                          if(e.isPopupTrigger()) show(e);                          if(e.isPopupTrigger()) show(e);
867                  }                  }
868                    
869                    @Override
870                  public void                  public void
871                  mouseReleased(MouseEvent e) {                  mouseReleased(MouseEvent e) {
872                          if(e.isPopupTrigger()) show(e);                          if(e.isPopupTrigger()) show(e);
# Line 763  public class Channel extends JSChannel { Line 874  public class Channel extends JSChannel {
874                    
875                  void                  void
876                  show(MouseEvent e) {                  show(MouseEvent e) {
877                          menu.show(e.getComponent(), e.getX(), e.getY());                          getMenu().show(e.getComponent(), e.getX(), e.getY());
878                  }                  }
879          }          }
880                    
# Line 775  public class Channel extends JSChannel { Line 886  public class Channel extends JSChannel {
886                          actionRemoveFxSend.putValue(Action.SMALL_ICON, Res.iconDelete16);                          actionRemoveFxSend.putValue(Action.SMALL_ICON, Res.iconDelete16);
887                  }                  }
888                                    
889                    @Override
890                  protected JToolBar                  protected JToolBar
891                  createToolBar() {                  createToolBar() {
892                          JToolBar tb = new JToolBar();                          JToolBar tb = new JToolBar();
# Line 922  public class Channel extends JSChannel { Line 1034  public class Channel extends JSChannel {
1034                          setToolTipText(i18n.getButtonLabel("Channel.ttRemoveChannel"));                          setToolTipText(i18n.getButtonLabel("Channel.ttRemoveChannel"));
1035                  }                  }
1036                                    
1037                    @Override
1038                  public void                  public void
1039                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
1040                          boolean b = preferences().getBoolProperty(CONFIRM_CHANNEL_REMOVAL);                          boolean b = preferences().getBoolProperty(CONFIRM_CHANNEL_REMOVAL);
# Line 935  public class Channel extends JSChannel { Line 1048  public class Channel extends JSChannel {
1048                          channel.remove();                          channel.remove();
1049                  }                  }
1050                                    
1051                    @Override
1052                  public boolean                  public boolean
1053                  contains(int x, int y) { return (x - 11)*(x - 11) + (y - 11)*(y - 11) < 71; }                  contains(int x, int y) { return (x - 11)*(x - 11) + (y - 11)*(y - 11) < 71; }
1054          }          }
1055                    
1056          public static class OptionsButton extends PixmapToggleButton implements ActionListener {          public static class OptionsButton extends PixmapToggleButton
1057                                            implements ActionListener, PropertyChangeListener {
1058                    
1059                  private final Channel channel;                  private final Channel channel;
1060                                    
1061                  OptionsButton(Channel channel) {                  OptionsButton(Channel channel) {
# Line 953  public class Channel extends JSChannel { Line 1069  public class Channel extends JSChannel {
1069                          setToolTipText(i18n.getButtonLabel("Channel.ttShowOptions"));                          setToolTipText(i18n.getButtonLabel("Channel.ttShowOptions"));
1070                  }                  }
1071                                    
1072                    @Override
1073                  public void                  public void
1074                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
1075                            ChannelView view = channel.viewTracker.getCurrentView();
1076                            
1077                            if(isSelected() && view.getChannelOptionsView() == null) {
1078                                    view.installChannelOptionsView();
1079                                    JComponent c = view.getChannelOptionsView().getComponent();
1080                                    channel.optionsPane.setContentPane(c);
1081                            }
1082                            
1083                          channel.showOptionsPane(isSelected());                          channel.showOptionsPane(isSelected());
1084                                                    
1085                          String s;                          String s;
# Line 962  public class Channel extends JSChannel { Line 1087  public class Channel extends JSChannel {
1087                          else s = i18n.getButtonLabel("Channel.ttShowOptions");                          else s = i18n.getButtonLabel("Channel.ttShowOptions");
1088                                                    
1089                          setToolTipText(s);                          setToolTipText(s);
1090                            
1091                            s = JXCollapsiblePane.ANIMATION_STATE_KEY;
1092                            channel.optionsPane.addPropertyChangeListener(s, this);
1093                    }
1094                    
1095                    @Override
1096                    public void
1097                    propertyChange(PropertyChangeEvent e) {
1098                            if(e.getNewValue() == "collapsed") {
1099                                    ChannelView view = channel.viewTracker.getCurrentView();
1100                                    view.uninstallChannelOptionsView();
1101                                    channel.optionsPane.setContentPane(new JPanel());
1102                            }
1103                    }
1104                    
1105                    public void
1106                    onDestroy() {
1107                            String s = JXCollapsiblePane.ANIMATION_STATE_KEY;
1108                            channel.optionsPane.removePropertyChangeListener(s, this);
1109                  }                  }
1110                                    
1111                    @Override
1112                  public boolean                  public boolean
1113                  contains(int x, int y) { return super.contains(x, y) & y < 13; }                  contains(int x, int y) { return super.contains(x, y) & y < 13; }
1114          }          }

Legend:
Removed from v.1734  
changed lines
  Added in v.1785

  ViewVC Help
Powered by ViewVC