]> ruin.nu Git - moosique.git/blobdiff - MooGUI.java
minor updates..
[moosique.git] / MooGUI.java
index 1ab280f9bc97e6608900df269cab5d9236c5e876..7bcd6dd854d103d8360c78f1396ad0c9dde62eae 100644 (file)
@@ -9,11 +9,16 @@ import java.awt.event.*;
  * @author  Mikael Andreen
  */
  
-public class MooGUI extends JFrame implements WindowListener {
+public class MooGUI extends JFrame {
 
        private Sequence seq;
+
+       private MooToolbar toolbar;
+       private JPanel trackPanel;
+       private MooTrackView[] trackViews;
        private JLabel statusBar;
-       private // MooView view;
+
+       public static Font standardFont = new Font("Helvetica", Font.PLAIN, 10);
        
        /** 
         * Creates the GUI.
@@ -21,30 +26,36 @@ public class MooGUI extends JFrame implements WindowListener {
        public MooGUI(Sequence seq) {
                super("Moosique");
 
+               this.seq = seq;
+               
+               Container pane = getContentPane();
+               pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
+               
                // Adds menu bar.
                setJMenuBar(new MooMenu());
 
                // Adds toolbar.
-               getContentPane().add(new MooToolbar(), BorderLayout.NORTH);
-               addWindowListener(this);
-               
-               // Adds main view.
-               // view = new MooView();
+               toolbar = new MooToolbar();
+               pane.add(toolbar, BorderLayout.NORTH);
+
+               // Adds tracks.
+               trackPanel = new JPanel(true);
+               createTrackViews();
+               pane.add(trackPanel, BorderLayout.CENTER);
 
                // Adds status bar.
-               statusBar = new JLabel("Welcome to Moosique!", Label.CENTER);
+               statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
+               pane.add(statusBar, BorderLayout.SOUTH);
 
-               MooInstrumentList m = new MooInstrumentList();
-               getContentPane().add(m, BorderLayout.CENTER);
-               m.addKeyListener(new MooKeyboard());
+               addWindowListener(new MooGUICloser());
                pack();
-
-               // Dimension bounds = new Dimension(300,70);
-               // setSize(bounds.width,bounds.height);
-               // setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (bounds.width / 2), (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (bounds.height / 2));
+               Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
+               setSize(bounds.width,bounds.height - 40);
+               setLocation(0, 0);
                // setResizable(false);
-               // setBackground(Color.white);
+               setBackground(Color.white);
                setVisible(true);
+               show();
        }
        
        /** 
@@ -53,6 +64,7 @@ public class MooGUI extends JFrame implements WindowListener {
         */
        public void setSequence(Sequence sequence) {
                seq = sequence;
+               createTrackViews();
        }
 
        /** 
@@ -62,12 +74,23 @@ public class MooGUI extends JFrame implements WindowListener {
        public void setStatus(String text) {
                statusBar.setText(text);
        }
-
-       public void windowOpened(WindowEvent e) {}
-       public void windowClosing(WindowEvent e) {Moosique.quit();}
-       public void windowClosed(WindowEvent e) {}
-       public void windowIconified(WindowEvent e) {}
-       public void windowDeiconified(WindowEvent e) {}
-       public void windowActivated(WindowEvent e) {}
-       public void windowDeactivated(WindowEvent e) {}
-}
+       
+       /** 
+        * Fills the track panel with track views for all tracks in the current sequence.
+        */
+       private void createTrackViews() {
+               trackPanel.removeAll();
+               Track[] tracks = seq.getTracks();
+               trackPanel.setLayout(new GridLayout(1, tracks.length));
+               trackViews = new MooTrackView[tracks.length];
+               for (int i = 0; i < tracks.length; i++) {
+                       trackViews[i] = new MooTrackView(tracks[i]);
+                       trackPanel.add(new MooTrackView(tracks[i]));
+               }
+               trackPanel.validate();
+       }
+       
+       class MooGUICloser extends WindowAdapter {
+               public void windowClosing(WindowEvent e) {Moosique.quit();}
+       }
+}
\ No newline at end of file