]> ruin.nu Git - moosique.git/blobdiff - MooTrackView.java
setting mute and solo on channel instead..
[moosique.git] / MooTrackView.java
index 854cfec806308b0680360ea5a0f41c1999b4301a..8827f3187b89a6ef299f29aa11339ed4d189a651 100644 (file)
@@ -14,18 +14,20 @@ import java.util.*;
 public class MooTrackView extends JPanel {
 
        private Track track;
+       private MooTrackTitle title;
        private Rectangle box;
 
        private JPopupMenu popup;
-       private JMenuItem menuItem;
+       private JMenuItem popupAdd;
        private ArrayList rects;
        protected static int viewLength = 0;
        protected static int extraHeight = 0;
        public static final int NOTE_HEIGHT = 10, NOTE_WIDTH = 40, VIEW_WIDTH = 200;
 
-       public MooTrackView (Track track) {
+       public MooTrackView (Track track, MooTrackTitle title) {
                super(true);
                this.track = track;
+               this.title = title;
 
                // Configures panel
                setBackground(Color.white);
@@ -52,13 +54,13 @@ public class MooTrackView extends JPanel {
                        setPreferredSize(new Dimension(VIEW_WIDTH, viewLength + extraHeight));
 
                }
-               validate();
 
                // Creates pop-up menu.
                popup = new JPopupMenu();
-               menuItem = new JMenuItem("Add note...");
-               // menuItem.addActionListener();
-               popup.add(menuItem);
+               PopupListener pList = new PopupListener();
+               popupAdd = new JMenuItem("Add note...");
+               popupAdd.addActionListener(pList);
+               popup.add(popupAdd);
 
                // Adds listeners for popup menu and keyboard synthesizer.
                addMouseListener(new MAdapter());
@@ -100,7 +102,6 @@ public class MooTrackView extends JPanel {
                        viewLength = y + height;
                        if(old)setPreferredSize(new Dimension(VIEW_WIDTH, viewLength + extraHeight));
                }
-
        }
 
        public Track getTrack() {
@@ -123,10 +124,19 @@ public class MooTrackView extends JPanel {
                return false;
        }
        
-       public void remove(MooNoteElement elem) {
-               remove((Component)elem);
+       public void addNote(MooNote mn) {
+               mn.addTo(track);
+               MooNoteElement elem = new MooNoteElement(this, mn);
+               add(elem);
+               layoutElement(elem, false);
+               setPreferredSize(new Dimension(VIEW_WIDTH, viewLength + extraHeight));
+               repaint();
+       }
+
+       public void removeNote(MooNoteElement elem, MooNote mn) {
+               mn.removeFrom(track);
+               remove(elem);
                elem.getNote().removeFrom(track);
-               validate();
                repaint();
        }
 
@@ -151,6 +161,17 @@ public class MooTrackView extends JPanel {
 
                public void mouseEntered(MouseEvent e) {
                        // Moosique.setActiveChannel(track.getChannel());
+                       grabFocus();
+               }
+       }
+
+       class PopupListener implements ActionListener {
+               public void actionPerformed(ActionEvent e) {
+                       Object source = e.getSource();
+                       if  (source == popupAdd) {
+                               //addNote(new MooNote());
+                               // int channel, int pitch, int velocity, long timestamp, int duration
+                       }
                }
        }
-}
+}
\ No newline at end of file