]> ruin.nu Git - moosique.git/blobdiff - MooTrackView.java
menu for elements..
[moosique.git] / MooTrackView.java
index a9a41d9f127a9c6a8871b5b8515c46cfcd9d1aea..cba92728796318289308ea79601c293a6989fdf0 100644 (file)
@@ -18,6 +18,7 @@ public class MooTrackView extends JPanel implements ActionListener {
        private NoteArea notes;
        private Rectangle box;
        private JPopupMenu popup;
+       private JPopupMenu notePopup;
        private JMenuItem menuItem;
        protected static int viewLength = 0;
        
@@ -41,9 +42,12 @@ public class MooTrackView extends JPanel implements ActionListener {
                menuItem = new JMenuItem("Add...");
                menuItem.addActionListener(this);
                popup.add(menuItem);
+
+
+               notePopup = new JPopupMenu();
                menuItem = new JMenuItem("Preferences...");
                menuItem.addActionListener(this);
-               popup.add(menuItem);
+               notePopup.add(menuItem);
 
                notes.addMouseListener(new PopupListener());
                add(notes, BorderLayout.CENTER);
@@ -59,7 +63,7 @@ public class MooTrackView extends JPanel implements ActionListener {
        /** 
         * Updates the track view.
         */
-       public void update() {
+       public void update(long tickPosition) {
                repaint();
        }
 
@@ -89,7 +93,7 @@ public class MooTrackView extends JPanel implements ActionListener {
                                if (note instanceof MooNote) {
                                        // Adds the note element to the note area.
                                        MooNote mn = (MooNote)note;
-                                       elem = new MooNoteElement(mn, mn.getDuration() / 24);
+                                       elem = new MooNoteElement(mn);
                                        add(elem);
 
                                        // Moves the note element to the appropriate place.
@@ -143,7 +147,10 @@ public class MooTrackView extends JPanel implements ActionListener {
 
                private void maybeShowPopup(MouseEvent e) {
                        if (e.isPopupTrigger()) {
-                               popup.show(e.getComponent(), e.getX(), e.getY());
+                               if (findComponentAt(e.getX(), e.getY()) instanceof MooNoteElement)
+                                       notePopup.show(e.getComponent(), e.getX(), e.getY());
+                               else
+                                       popup.show(e.getComponent(), e.getX(), e.getY());
                        }
                }
        }