]> ruin.nu Git - moosique.git/blobdiff - MooGUI.java
minor updates..
[moosique.git] / MooGUI.java
index b7031d8b1f78fdd1660fb5430ae1943f42dba897..7bcd6dd854d103d8360c78f1396ad0c9dde62eae 100644 (file)
@@ -9,27 +9,53 @@ import java.awt.event.*;
  * @author  Mikael Andreen
  */
  
-public class MooGUI extends JFrame implements WindowListener {
+public class MooGUI extends JFrame {
 
-       Sequence seq;
+       private Sequence seq;
+
+       private MooToolbar toolbar;
+       private JPanel trackPanel;
+       private MooTrackView[] trackViews;
+       private JLabel statusBar;
+
+       public static Font standardFont = new Font("Helvetica", Font.PLAIN, 10);
        
        /** 
         * Creates the GUI.
         */
        public MooGUI(Sequence seq) {
                super("Moosique");
-               addWindowListener(this);
-               MooInstrumentList m = new MooInstrumentList();
-               getContentPane().add(m);
-               m.addKeyListener(new MooKeyboard());
-               pack();
-               Dimension bounds = new Dimension(300,70);
+
+               this.seq = seq;
+               
+               Container pane = getContentPane();
+               pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
+               
+               // Adds menu bar.
                setJMenuBar(new MooMenu());
-//             setSize(bounds.width,bounds.height);
-               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (bounds.width / 2), (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (bounds.height / 2));
-//             setResizable(false);
+
+               // Adds toolbar.
+               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!", JLabel.CENTER);
+               pane.add(statusBar, BorderLayout.SOUTH);
+
+               addWindowListener(new MooGUICloser());
+               pack();
+               Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
+               setSize(bounds.width,bounds.height - 40);
+               setLocation(0, 0);
+               // setResizable(false);
                setBackground(Color.white);
                setVisible(true);
+               show();
        }
        
        /** 
@@ -38,13 +64,33 @@ public class MooGUI extends JFrame implements WindowListener {
         */
        public void setSequence(Sequence sequence) {
                seq = sequence;
+               createTrackViews();
        }
 
-       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) {}
-}
+       /** 
+        * Shows the given message in the status bar.
+        * @param text  the message to show
+        */
+       public void setStatus(String text) {
+               statusBar.setText(text);
+       }
+       
+       /** 
+        * 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