]> ruin.nu Git - moosique.git/blobdiff - MooGUI.java
Fixed some bugs
[moosique.git] / MooGUI.java
index 97b4ad0dc431b6dca32f2a42e8f8a73ea3e5e673..32285ac5191375271ec0ba593f2dddfb8cb45ac6 100644 (file)
@@ -55,6 +55,23 @@ public class MooGUI extends JFrame {
                statusBar.setBackground(bgColor);
                view.setBackground(bgColor);
 
+               // Sets up global key listener
+               ActionMap am = getRootPane().getActionMap();
+
+               Action playAction = new AbstractAction() {
+                       public void actionPerformed(ActionEvent ae) {
+                               if (!Moosique.getSequencer().isRunning()) {
+                                       Moosique.play();
+                               } else {
+                                       Moosique.stop();
+                               }
+                       }};
+               am.put("Play", playAction);
+
+               InputMap im = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+               KeyStroke playKey = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0);
+               im.put(playKey, "Play");
+
                // Configures window.
                addWindowListener(new MooGUICloser());
                pack();
@@ -70,19 +87,18 @@ public class MooGUI extends JFrame {
        private void setBackground(Container c) {
                c.setBackground(bgColor);
                Component[] comps = c.getComponents();
-               System.out.println(comps.length);
                for (int i = 0; i < comps.length; i++) {
                        comps[i].setBackground(bgColor);
                }
        }
-       
+
        /** 
         * Changes the sequence of the GUI.
         * @param sequence      the MIDI sequence to visualize
         */
        public void setSequence(Sequence sequence) {
                seq = sequence;
-               view.update(seq.getTracks());
+               view.setTracks(seq.getTracks());
        }
 
        /** 
@@ -92,10 +108,19 @@ public class MooGUI extends JFrame {
        public void setStatus(String text) {
                statusBar.setText(text);
        }
-       
+
+       /**
+        * Calls on the main view to update the track views,
+        * and on the toolbar to update the progress indicator.
+        */
+       public void update(){
+               view.update();
+               toolbar.updateProgInd();
+       }
+
        class MooGUICloser extends WindowAdapter {
                public void windowClosing(WindowEvent e) {
                        Moosique.quit();
                }
        }
-}
\ No newline at end of file
+}