]> ruin.nu Git - moosique.git/blob - MooTrackTitle.java
changes to instrument and channel combos..
[moosique.git] / MooTrackTitle.java
1 import javax.swing.*;
2 import java.awt.*;
3 import java.awt.event.*;
4 import javax.sound.midi.*;
5
6 /**
7  * The title bar for each track with track name, channel, instrument etc.
8  * 
9  * @author  Andersson, Andreen, Lanneskog, Pehrson
10  * @version 1
11  */
12  
13 public class MooTrackTitle extends JPanel {
14
15         private JTextField title;
16         private MooInstrumentList instruments;
17         private JComboBox channel;
18         private JCheckBox mute;
19         private JCheckBox solo;
20         private Track track;
21         /** 
22          * Creates the title bar.
23          */
24         public MooTrackTitle (Track aTrack) {
25                 track = aTrack;
26                 setLayout(new GridLayout(4,1));
27                 setBorder(BorderFactory.createLineBorder(Color.black));
28
29                 setPreferredSize(new Dimension(MooTrackView.VIEW_WIDTH,70));
30                 title = new JTextField(); // JTextField(String text, int columns) 
31                 title.setFont(Moosique.getGUI().FONT);
32                 title.addFocusListener(new TitleFocusListener());
33                 add(title);
34
35
36                 JPanel checkboxes = new JPanel();
37                 checkboxes.setLayout(new GridLayout(1,3));
38
39                 channel = new JComboBox();
40                 channel.setFont(Moosique.getGUI().FONT);
41                 for (int i = 1; i <= 16; i++)
42                         channel.addItem(new Integer(i));
43
44                 for (int j = 0; j < track.size(); j++) {
45                         MidiEvent me = track.get(j);
46                 if (me instanceof MooNote){
47                                 MooNote mn = (MooNote)me;
48                                 channel.setSelectedIndex(mn.getChannel());
49                                 break;
50                         }
51         }
52
53                 instruments = new MooInstrumentList(channel.getSelectedIndex());
54
55                 channel.addActionListener(new ActionListener(){
56                                 public void actionPerformed(ActionEvent e){
57                                         int chan = channel.getSelectedIndex();
58                                         MidiEvent me;
59                                         MooNote mn;
60                                         instruments.setChannel(channel.getSelectedIndex());
61                                         for (int j = 0; j < track.size(); j++) {
62                                                 me = track.get(j);
63                                             if (me instanceof MooNote){
64                                                         mn = (MooNote)me;
65                                                         mn.setChannel(chan);
66                                                 }
67                                 }
68                                 }});
69
70                 
71
72                 mute = new JCheckBox("Mute");
73                 mute.setFont(Moosique.getGUI().FONT);
74                 mute.addActionListener(new ActionListener(){
75                                 public void actionPerformed(ActionEvent event){
76                                         //setMute
77                                         solo.setSelected(false);
78                                 }});
79                 checkboxes.add(mute);
80
81                 solo = new JCheckBox("Solo");
82                 solo.setFont(Moosique.getGUI().FONT);
83                 solo.addActionListener(new ActionListener(){
84                                 public void actionPerformed(ActionEvent event){
85                                         //setSolo
86                                         mute.setSelected(false);
87                                 }});
88                 checkboxes.add(solo);
89
90                 add(instruments);
91                 add(channel);
92                 add(checkboxes);
93         }
94
95         class TitleFocusListener extends FocusAdapter {
96                 public void focusLost(FocusEvent e) {
97                         // Update the MidiEvent containing the title of this track
98                 }
99         }
100 }