X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooTrackTitle.java;h=979aed2139208e234f4124871b34b955fe536aef;hb=4526e51b70110f7272b0c2a3a5f207657d690029;hp=d5876c1485718a34f6ae3ef940152182d5f2974c;hpb=ce9a16d679f2058454af367e972888ba8e2c34c0;p=moosique.git diff --git a/MooTrackTitle.java b/MooTrackTitle.java index d5876c1..979aed2 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -25,8 +25,19 @@ public class MooTrackTitle extends JPanel { private String trackName = ""; private int channel = 0; + /** + * Creates the title bar for an empty track, and therefore an initial channel is required. + * @param aTrack the track that this tracktitle is operating on. + * @param chan the initial channel + */ + public MooTrackTitle (Track aTrack, int chan) { + this(aTrack); + channel = chan; + } + /** * Creates the title bar. + * @param aTrack the track that this tracktitle is operating on. */ public MooTrackTitle (Track aTrack) { setDoubleBuffered(true); @@ -59,8 +70,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 +86,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,22 +103,24 @@ public class MooTrackTitle extends JPanel { checkboxes.setLayout(new GridLayout(1,3)); mute = new JCheckBox("Mute"); - mute.setSelected(Moosique.getChannel(channel).getMute()); + mute.setSelected(false); + Moosique.setTrackMute(track, false); mute.setFont(Moosique.getGUI().FONT); mute.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ boolean selected = mute.isSelected(); if (selected){ solo.setSelected(false); - Moosique.getChannel(channel).setSolo(false); + Moosique.setTrackSolo(track, false); } - Moosique.getChannel(channel).setMute(selected); + Moosique.setTrackMute(track, selected); }}); checkboxes.add(mute); solo = new JCheckBox("Solo"); - solo.setSelected(Moosique.getChannel(channel).getSolo()); + solo.setSelected(false); + Moosique.setTrackSolo(track, false); solo.setFont(Moosique.getGUI().FONT); solo.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent event){ @@ -112,14 +128,25 @@ public class MooTrackTitle extends JPanel { boolean selected = solo.isSelected(); if (selected){ mute.setSelected(false); - Moosique.getChannel(channel).setMute(false); + Moosique.setTrackMute(track, false); } - Moosique.getChannel(channel).setSolo(selected); + Moosique.setTrackSolo(track, 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; + } + /** + * Checks if the focus is lost. + */ class TitleFocusListener extends FocusAdapter { public void focusLost(FocusEvent e) { // Update the MidiEvent containing the title of this track