X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=blobdiff_plain;f=MooView.java;h=0215b829054c51c50fb6e9f6bb273b6239025db7;hp=5e25e02b46d046e6fa655f7eafb2a1a181c86abd;hb=d564984e345995ca352c4f5eee3296c6e02010de;hpb=83ec11f99e143607d057db2a68c262ca9672e524 diff --git a/MooView.java b/MooView.java index 5e25e02..0215b82 100644 --- a/MooView.java +++ b/MooView.java @@ -24,6 +24,7 @@ public class MooView extends JScrollPane { super(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); trackPanel = new JPanel(new GridLayout(1,3), true); setViewportView(trackPanel); + getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); titlePanel = new JPanel(new GridLayout(1,3),true); JViewport columnHeader = new JViewport(); @@ -50,8 +51,9 @@ public class MooView extends JScrollPane { if (numberOfTracks == 1) { // If MIDI file is of type 0, creates a view for the track. trackPanel.setLayout(new FlowLayout()); - trackPanel.add(new MooTrackView(tracks[0])); - titlePanel.add(new MooTrackTitle(tracks[0],0)); + MooTrackTitle title = new MooTrackTitle(tracks[0]); + titlePanel.add(title); + trackPanel.add(new MooTrackView(tracks[0], title)); } else { // Creates dialog for progress bar. JDialog progressDialog = new JDialog(Moosique.getGUI(), "Visualizing...", false); @@ -64,11 +66,18 @@ public class MooView extends JScrollPane { progressDialog.setVisible(true); // Starts filling the track panel with track views, while updating the progress bar. - trackPanel.setLayout(new GridLayout(1,numberOfTracks)); + GridLayout gL = new GridLayout(1,numberOfTracks); + trackPanel.setLayout(gL); for (int i = 1; i < tracks.length; i++) { - trackPanel.add(new MooTrackView(tracks[i])); - titlePanel.add(new MooTrackTitle(tracks[i],i)); - progressBar.setValue(i); + if (Moosique.shouldBeDrawn(tracks[i])) { + MooTrackTitle title = new MooTrackTitle(tracks[i]); + titlePanel.add(title); + trackPanel.add(new MooTrackView(tracks[i], title)); + progressBar.setValue(i); + } else { + gL.setColumns(--numberOfTracks); + trackPanel.setLayout(gL); + } } progressDialog.dispose(); } @@ -91,10 +100,6 @@ public class MooView extends JScrollPane { */ public void update(long tickPosition) { getViewport().setViewPosition(new Point((int)getViewport().getViewPosition().getX(), (int)(tickPosition / (Moosique.getSequence().getResolution() / 4)) * MooTrackView.NOTE_HEIGHT)); - Component[] comps = getComponents(); - for (int i = 0; i < comps.length; i++) { - if(comps[i] instanceof MooTrackView) ((MooTrackView)comps[i]).update(tickPosition); - } } /** @@ -105,8 +110,9 @@ public class MooView extends JScrollPane { public void addTrackView(Track track, int index) { ((GridLayout)trackPanel.getLayout()).setColumns(++numberOfTracks); ((GridLayout)titlePanel.getLayout()).setColumns(++numberOfTracks); - trackPanel.add(new MooTrackView(track), index); - titlePanel.add(new MooTrackTitle(track,index), index); + MooTrackTitle title = new MooTrackTitle(track); + titlePanel.add(title, index); + trackPanel.add(new MooTrackView(track, title), index); validate(); }