From: Einar Pehrson Date: Mon, 12 May 2003 20:18:44 +0000 (+0000) Subject: no message X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=commitdiff_plain;h=9f708407a52d8d0864e238cb37c0c30a5a783dc0 no message --- diff --git a/MooToolbar.java b/MooToolbar.java index c7aee25..a9ec10b 100644 --- a/MooToolbar.java +++ b/MooToolbar.java @@ -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); diff --git a/MooTrackView.java b/MooTrackView.java index 0bc564c..c94657b 100644 --- a/MooTrackView.java +++ b/MooTrackView.java @@ -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); } diff --git a/MooView.java b/MooView.java index 5f8c15e..b21cf29 100644 --- a/MooView.java +++ b/MooView.java @@ -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