]> ruin.nu Git - moosique.git/blobdiff - MooTrackTitle.java
some changes..
[moosique.git] / MooTrackTitle.java
index d5876c1485718a34f6ae3ef940152182d5f2974c..dbf70a1e6cba0884d8ed2c6ec5282971070ee8c2 100644 (file)
@@ -27,6 +27,7 @@ public class MooTrackTitle extends JPanel {
 
        /** 
         * Creates the title bar.
+        * @param aTrack the track that this tracktitle is operating on.
         */
        public MooTrackTitle (Track aTrack) {
                setDoubleBuffered(true);
@@ -59,8 +60,11 @@ public class MooTrackTitle extends JPanel {
                title.addFocusListener(new TitleFocusListener());
                add(title);
 
-               instruments = new MooInstrumentList(channel);
-               // instruments = new MooInstrumentList(channel, programChangeMessage);
+               int type;
+               if (channel == 9) type = MooInstrumentList.DRUMS;
+               else type = MooInstrumentList.INSTRUMENTS;
+               instruments = new MooInstrumentList(channel, type);
+               // instruments = new MooInstrumentList(channel, type, programChangeMessage);
                add(instruments);
 
                channelBox = new JComboBox();
@@ -72,15 +76,15 @@ public class MooTrackTitle extends JPanel {
 
                channelBox.addActionListener(new ActionListener(){
                                public void actionPerformed(ActionEvent e){
-                                       int chan = channelBox.getSelectedIndex();
+                                       channel = channelBox.getSelectedIndex();
                                        MidiEvent me;
                                        MooNote mn;
-                                       instruments.setChannel(channelBox.getSelectedIndex());
+                                       instruments.setChannel(channel);
                                        for (int j = 0; j < track.size(); j++) {
                                                me = track.get(j);
                                            if (me instanceof MooNote){
                                                        mn = (MooNote)me;
-                                                       mn.setChannel(chan);
+                                                       mn.setChannel(channel);
                                                }
                                }}});
                add(channelBox);
@@ -89,37 +93,60 @@ public class MooTrackTitle extends JPanel {
                checkboxes.setLayout(new GridLayout(1,3));
 
                mute = new JCheckBox("Mute");
-               mute.setSelected(Moosique.getChannel(channel).getMute());
+               mute.setSelected(Moosique.getSequencer().getTrackMute(getTrackNum()));
                mute.setFont(Moosique.getGUI().FONT);
                mute.addActionListener(new ActionListener(){
                                public void actionPerformed(ActionEvent event){
                                        boolean selected = mute.isSelected();
+                                       int trackNum = getTrackNum();
                                        if (selected){
                                                solo.setSelected(false);
-                                               Moosique.getChannel(channel).setSolo(false);
+                                               Moosique.getSequencer().setTrackSolo(trackNum, false);
                                        }
-                                       Moosique.getChannel(channel).setMute(selected);
+                                       Moosique.getSequencer().setTrackMute(trackNum, selected);
 
                                }});
                checkboxes.add(mute);
 
                solo = new JCheckBox("Solo");
-               solo.setSelected(Moosique.getChannel(channel).getSolo());
+               solo.setSelected(Moosique.getSequencer().getTrackSolo(getTrackNum()));
                solo.setFont(Moosique.getGUI().FONT);
                solo.addActionListener(new ActionListener(){
                                public void actionPerformed(ActionEvent event){
                                        //setSolo
                                        boolean selected = solo.isSelected();
+                                       int trackNum = getTrackNum();
                                        if (selected){
                                                mute.setSelected(false);
-                                               Moosique.getChannel(channel).setMute(false);
+                                               Moosique.getSequencer().setTrackMute(trackNum, false);
                                        }
-                                       Moosique.getChannel(channel).setSolo(selected);
+                                       Moosique.getSequencer().setTrackSolo(trackNum, selected);
                                }});
                checkboxes.add(solo);
                add(checkboxes);
        }
+       
+       /** 
+        * Returns the channel of the track that the view is visualising.
+        * @return the chanel of the visualised track
+        */
+       public int getChannel() {
+               return channel;
+       }
+
+       protected int getTrackNum() {
+               Track[] tracks = Moosique.getSequence().getTracks();
 
+               for (int i = 0; i < tracks.length; i++) {
+                       if (tracks[i] == track)
+                               return i;
+               }
+               System.out.println("Couldn't find track");
+               return 0;
+       }
+       /**
+        * Checks if the focus is lost.
+        */
        class TitleFocusListener extends FocusAdapter {
                public void focusLost(FocusEvent e) {
                        // Update the MidiEvent containing the title of this track