]> ruin.nu Git - moosique.git/commitdiff
*** empty log message ***
authorEinar Pehrson <einarp@itstud.chalmers.se>
Fri, 16 May 2003 14:50:36 +0000 (14:50 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Fri, 16 May 2003 14:50:36 +0000 (14:50 +0000)
MooMenu.java
MooTrackTitle.java
MooTrackView.java
MooView.java
Moosique.java
To Do.txt

index ee3c0d47c746a3e4afaaecb3752ff89429d31a4c..5d8dd36c6f7e0dd78b6e24d6130563ef73daaf3b 100644 (file)
@@ -37,6 +37,7 @@ public class MooMenu extends JMenuBar implements ActionListener {
                addItem(edit, "Paste", KeyEvent.VK_V, ActionEvent.CTRL_MASK);
                addItem(edit, "Select all", KeyEvent.VK_E, ActionEvent.CTRL_MASK);
                addItem(edit, "Invert selection", KeyEvent.VK_I, ActionEvent.CTRL_MASK);
+               edit.addSeparator();
                addItem(edit, "Preferences...", KeyEvent.VK_P, ActionEvent.CTRL_MASK);
                
                playback = createMenu("Playback", KeyEvent.VK_P);
@@ -54,8 +55,10 @@ public class MooMenu extends JMenuBar implements ActionListener {
                addItem(music, "Delete track...", KeyEvent.VK_D, ActionEvent.CTRL_MASK);
                addItem(music, "Copy track...", KeyEvent.VK_Y, ActionEvent.CTRL_MASK);
                addItem(music, "Move track...", KeyEvent.VK_M, ActionEvent.CTRL_MASK);
+               edit.addSeparator();
                addItem(music, "Insert measure...");
                addItem(music, "Delete measure...");
+               edit.addSeparator();
                addItem(music, "Set time signature...");
                addItem(music, "Set tempo...");
                addItem(music, "Scale velocity...");
index 258e9d45deda3e58cbb44fb9fa0a88ae90fd25e8..545681d89d53e529cb3053627aed33e7be193264 100644 (file)
@@ -120,6 +120,14 @@ public class MooTrackTitle extends JPanel {
                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.
index 8827f3187b89a6ef299f29aa11339ed4d189a651..513792de17c09597de455aa3600e081bfd84cb07 100644 (file)
@@ -20,6 +20,8 @@ public class MooTrackView extends JPanel {
        private JPopupMenu popup;
        private JMenuItem popupAdd;
        private ArrayList rects;
+       private Insets insets;
+       private int ticksPerSixteenth, popupY = 0;
        protected static int viewLength = 0;
        protected static int extraHeight = 0;
        public static final int NOTE_HEIGHT = 10, NOTE_WIDTH = 40, VIEW_WIDTH = 200;
@@ -28,6 +30,7 @@ public class MooTrackView extends JPanel {
                super(true);
                this.track = track;
                this.title = title;
+               insets = getInsets();
 
                // Configures panel
                setBackground(Color.white);
@@ -82,9 +85,8 @@ public class MooTrackView extends JPanel {
                }
 
                // Creates temporary variables.
-               int ticksPerSixteenth = Moosique.getSequence().getResolution() / 4;
+               ticksPerSixteenth = Moosique.getSequence().getResolution() / 4;
                MooNote mn = elem.getNote();
-               Insets insets = getInsets();
                int x, y, height;
 
                // Calculates coordinates.
@@ -140,6 +142,12 @@ public class MooTrackView extends JPanel {
                repaint();
        }
 
+       private void addStandardNote() {
+               long timestamp = (long)(ticksPerSixteenth * (popupY - insets.top) / NOTE_HEIGHT);
+               System.out.println(ticksPerSixteenth + ", " + popupY + ", " + insets.top + ", " + timestamp);
+               addNote(new MooNote(title.getChannel(), 60, 100, timestamp, Moosique.getSequence().getResolution() / 4));
+       }
+
        public void paintComponent(Graphics g) {
                super.paintComponent(g);
                Graphics2D g2 = (Graphics2D)g;
@@ -153,8 +161,16 @@ public class MooTrackView extends JPanel {
        }
 
        class MAdapter extends MouseAdapter {
+               public void mouseClicked(MouseEvent e) {
+                       if (e.getClickCount() == 2) {
+                               popupY = e.getY();
+                               addStandardNote();
+                       }
+               }
+       
                public void mousePressed(MouseEvent e) {
                        if (e.isPopupTrigger()) {
+                               popupY = e.getY();
                                popup.show(e.getComponent(), e.getX(), e.getY());
                        }
                }
@@ -169,9 +185,9 @@ public class MooTrackView extends JPanel {
                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
+                               addStandardNote();
                        }
+                       // new MooNote(int channel, int pitch, int velocity, long timestamp, int duration)
                }
        }
 }
\ No newline at end of file
index ee2880ba01cd1df96b7749445ab7c5f32fbdd7c2..c16699cbdbf3e473194e97ddece5ef9fd0286d41 100644 (file)
@@ -70,13 +70,11 @@ public class MooView extends JScrollPane {
                        trackPanel.setLayout(gL);
                        for (int i = 1; i < tracks.length; i++) {
                                if (Moosique.shouldBeDrawn(tracks[i])) {
-                                       System.out.println("Draws track " + i);
                                        MooTrackTitle title = new MooTrackTitle(tracks[i]);
                                        titlePanel.add(title);
                                        trackPanel.add(new MooTrackView(tracks[i], title));
                                        progressBar.setValue(i);
                                } else {
-                                       System.out.println("Doesn't draw track " + i);
                                        gL.setColumns(--numberOfTracks);
                                        trackPanel.setLayout(gL);
                                }
index 91cf4ff7ddc117a62e7109224e9c66add37ef474..0a148b60a3acf0ae2422d98f902f22947cb3b26d 100644 (file)
@@ -380,13 +380,7 @@ public class Moosique {
                        }
                        noteOns.trimToSize();
                        noteOffs.trimToSize();
-                       boolean isEmpty = (noteOns.size() == 0);
-                       String text = "Track " + i + " has " + noteOns.size() + "/" + noteOffs.size() + "/" + tracks[i].size();
-                       if (isEmpty) {
-                               text += " and will be removed.";
-                               emptyTracks.add(tracks[i]);
-                       }
-                       System.out.println(text);
+                       if (noteOns.size() == 0) emptyTracks.add(tracks[i]);
                        
                        // Sorts the note lists by tick position.
                        Comparator c = new Comparator() {
index b5984369394ffe6a565920385b39e2ab32df12fb..93b5d1365159829369080550d64db7c7997adf75 100644 (file)
--- a/To Do.txt
+++ b/To Do.txt
@@ -2,8 +2,6 @@
 \f
 Diverse
 
-x VIKTIGT!!! HUR LÄGGA TILL NOTER?!? 
-
 x Spara konfiguration?
        Arbetskatalog
        Fem senast öppnade filerna