]> ruin.nu Git - moosique.git/commitdiff
no message
authorEinar Pehrson <einarp@itstud.chalmers.se>
Mon, 12 May 2003 20:18:44 +0000 (20:18 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Mon, 12 May 2003 20:18:44 +0000 (20:18 +0000)
MooToolbar.java
MooTrackView.java
MooView.java

index c7aee25aeea2f9c6344dc90365241bdd4905af09..a9ec10bd09b9a79d53e33b6689fb8c0d80cd93de 100644 (file)
@@ -44,8 +44,11 @@ public class MooToolbar extends JToolBar {
                beats = createLabel("Beat", 10);
                ticks = createLabel("Tick", 10);
                measureValue = createLabel("1", 16);
+               measureValue.setBorder(BorderFactory.createLineBorder(Color.black));
                beatsValue = createLabel("1", 16);
+               beatsValue.setBorder(BorderFactory.createLineBorder(Color.black));
                ticksValue = createLabel("1", 16);
+               ticksValue.setBorder(BorderFactory.createLineBorder(Color.black));
                JPanel spacenorth = new JPanel();
                spacenorth.setBackground(bgColor);
                JPanel spacesouth = new JPanel();
@@ -103,7 +106,6 @@ public class MooToolbar extends JToolBar {
        private JLabel createLabel(String title, int fontSize){
                JLabel label = new JLabel(title,JLabel.CENTER);
                label.setFont(new Font("Times New Roman", Font.PLAIN, fontSize));
-               label.setBorder(BorderFactory.createLineBorder(Color.black));
                return label;
        }
 
@@ -113,6 +115,9 @@ public class MooToolbar extends JToolBar {
                                        Moosique.play();
                                        playpause.setIcon(pauseIcon);
                                        playpause.setToolTipText("Pause");
+                                       while(Moosique.getSequencer().isRunning()) {
+                                               Moosique.getGUI().update();
+                                       }
                        } else if (((JButton)e.getSource()).getToolTipText() == "Pause") {
                                        Moosique.pause();
                                        playpause.setIcon(playIcon);
@@ -121,6 +126,9 @@ public class MooToolbar extends JToolBar {
                                        Moosique.resume();
                                        playpause.setIcon(pauseIcon);
                                        playpause.setToolTipText("Pause");
+                                       while(Moosique.getSequencer().isRunning()) {
+                                               Moosique.getGUI().update();
+                                       }
                        } else if (((JButton)e.getSource()).getToolTipText() == "Stop") {
                                Moosique.stop();
                                playpause.setIcon(playIcon);
index 0bc564cf1dadf74190bb588ed540b972d558d41a..c94657b6314ed33d18f62d7c506bcb345f7a639d 100644 (file)
@@ -57,16 +57,18 @@ public class MooTrackView extends JPanel implements ActionListener {
         * Updates the track view.
         */
        public void update() {
-       
+               repaint();
        }
 
        class NoteArea extends JPanel {
-               public static final int NOTE_SIZE = 25;
+               public static final int NOTE_HEIGHT = 10;
+               public static final int NOTE_WIDTH = 40;
                private int trackLength;
 
                public NoteArea(Track track) {
+                       System.out.println("Creating track view...");
                        setLayout(null);
-                       trackLength = 60;
+                       trackLength = 140;
                        MidiEvent note;
                        MooNoteElement elem;
                        boolean isOccupied;
@@ -82,23 +84,24 @@ public class MooTrackView extends JPanel implements ActionListener {
 
                                        // Places the note element in the appropriate place.
                                        x = insets.left;
-                                       y = insets.top + (int)(mn.getTick() / 24) * NOTE_SIZE;
-                                       height = NOTE_SIZE;
-                                       // height = (mn.getDuration() / 24) * NOTE_SIZE;
-                                       System.out.println("Comp at: " + x + ", " + y + " is: " + findComponentAt(x + 10, y + 10));
+                                       y = insets.top + (int)(mn.getTick() / 24) * NOTE_HEIGHT;
+                                       height = NOTE_HEIGHT;
+                                       // height = (mn.getDuration() / 24) * NOTE_HEIGHT;
+                                       // System.out.println("Comp at: " + x + ", " + y + " is: " + findComponentAt(x + 10, y + 10));
                                        while(findComponentAt(x, y) instanceof MooNoteElement ||
-                                             findComponentAt(x, y + height - 1) instanceof MooNoteElement) x += NOTE_SIZE;
-                                       elem.setBounds(x, y, NOTE_SIZE, height);
+                                             findComponentAt(x, y + height - 1) instanceof MooNoteElement) x += NOTE_WIDTH;
+                                       elem.setBounds(x, y, NOTE_WIDTH, height);
                                }
                        }
+                       validate();
                }
 
                public void paintComponent(Graphics g) {
                        super.paintComponent(g);
                        Graphics2D g2 = (Graphics2D)g;
-                       for (int c = 0; c < (trackLength*NOTE_SIZE); c += NOTE_SIZE) {
-                               for (int r = 0; r < (10*NOTE_SIZE); r += NOTE_SIZE) {
-                                       box = new Rectangle(r, c, NOTE_SIZE, NOTE_SIZE);
+                       for (int c = 0; c < (trackLength*NOTE_HEIGHT); c += NOTE_HEIGHT) {
+                               for (int r = 0; r < (10*NOTE_WIDTH); r += NOTE_WIDTH) {
+                                       box = new Rectangle(r, c, NOTE_WIDTH, NOTE_HEIGHT);
                                        g2.setColor(Color.gray);
                                        g2.draw(box);
                                }
index 5f8c15ea598acc356224cbd0b61897f1a197b6c1..b21cf29058850c885a58e89f33216dcc63cae30a 100644 (file)
@@ -12,12 +12,14 @@ import java.awt.event.*;
 public class MooView extends JScrollPane {
 
        private JPanel trackPanel;
+       private int numberOfTracks;
 
        /** 
         * Creates the main view
         */
        public MooView(Track[] tracks) {
                super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED);
+               numberOfTracks = tracks.length;
                trackPanel = new JPanel(new GridLayout(1,3), true);
                setTracks(tracks);
                setViewportView(trackPanel);
@@ -29,12 +31,11 @@ public class MooView extends JScrollPane {
         */
        public void setTracks(Track[] tracks) {
                trackPanel.removeAll();
-               ((GridLayout)trackPanel.getLayout()).setColumns(tracks.length);
+               trackPanel.setLayout(new GridLayout(1,tracks.length));
                for (int i = 0; i < tracks.length; i++) {
                        trackPanel.add(new MooTrackView(tracks[i]));
                }
                trackPanel.validate();
-               validate();
        }
 
        /** 
@@ -43,7 +44,7 @@ public class MooView extends JScrollPane {
        public void update() {
                Component[] comps = getComponents();
                for (int i = 0; i < comps.length; i++) {
-                       ((MooTrackView)comps[i]).update();
+                       if(comps[i] instanceof MooTrackView) ((MooTrackView)comps[i]).update();
                }
        }
 
@@ -53,7 +54,8 @@ public class MooView extends JScrollPane {
         * @param index         the index at which to insert the view
         */
        public void addTrackView(Track track, int index) {
-               add(new MooTrackView(track), index);
+               ((GridLayout)trackPanel.getLayout()).setColumns(++numberOfTracks);
+               trackPanel.add(new MooTrackView(track), index);
                validate();
        }
 
@@ -63,6 +65,7 @@ public class MooView extends JScrollPane {
         */
        public void removeTrackView(int index) {
                remove(index);
+               ((GridLayout)trackPanel.getLayout()).setColumns(--numberOfTracks);
                validate();
        }
 }
\ No newline at end of file