]> ruin.nu Git - moosique.git/commitdiff
global keylistener..
authorMichael Andreen <harv@ruin.nu>
Sun, 11 May 2003 19:21:54 +0000 (19:21 +0000)
committerMichael Andreen <harv@ruin.nu>
Sun, 11 May 2003 19:21:54 +0000 (19:21 +0000)
MooGUI.java
Moosique.java
To Do.txt

index 7019828a67abbe19af427caa1432fb6b8d369c98..146ca6daa8483350c78cbc2fcea6557d67a05121 100644 (file)
@@ -55,6 +55,19 @@ public class MooGUI extends JFrame {
                statusBar.setBackground(bgColor);
                view.setBackground(bgColor);
 
+               ActionMap am = getRootPane().getActionMap();
+
+               Action playAction = new AbstractAction() {
+                       public void actionPerformed(ActionEvent ae) {
+                               Moosique.resumepause();
+                       }};
+               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();
@@ -74,7 +87,7 @@ public class MooGUI extends JFrame {
                        comps[i].setBackground(bgColor);
                }
        }
-       
+
        /** 
         * Changes the sequence of the GUI.
         * @param sequence      the MIDI sequence to visualize
@@ -100,7 +113,7 @@ public class MooGUI extends JFrame {
                // Calls on the toolbar to update the progress indicator.
                //toolbar.updateProgInd();
        }
-       
+
        class MooGUICloser extends WindowAdapter {
                public void windowClosing(WindowEvent e) {
                        Moosique.quit();
index 13d7ce6c650adc260db8575ccdf849399b92d130..5ee3bccea394dd8819cba008c3627d8e7139972e 100644 (file)
@@ -22,6 +22,7 @@ public class Moosique {
        private static String filename, fileArg;
        private static long position;
        private static boolean makeGUI = true;
+       private static boolean playing = false;
 
        /** 
         * Starts the application.
@@ -146,6 +147,7 @@ public class Moosique {
         * Starts playback of the current sequence.
         */
        public static void play() {
+               playing = true;
                sequencer.setTickPosition(position);
                sequencer.start();
        }
@@ -154,6 +156,7 @@ public class Moosique {
         * Pauses playback of the current sequence.
         */
        public static void pause() {
+               playing = false;
                sequencer.stop();
        }
 
@@ -161,6 +164,7 @@ public class Moosique {
         * Resumes playback of the current sequence.
         */
        public static void resume() {
+               playing = true;
                sequencer.start();
        }
 
@@ -168,10 +172,22 @@ public class Moosique {
         * Stops playback of the current sequence.
         */
        public static void stop() {
+               playing = false;
                sequencer.stop();
                sequencer.setTickPosition(position);
        }
 
+       /**
+        * Pauses if playing and resumes if stopped.
+        */
+       public static void resumepause()
+       {
+               if (playing)
+                       pause();
+               else
+                       resume();
+       }
+
        /** 
         * Rewinds the current sequence the given number of measures.
         * @param measures      the number of measures to rewind
@@ -288,4 +304,4 @@ public class Moosique {
                if (synthesizer.isOpen()) synthesizer.close();
                System.exit(0);
        }
-}
\ No newline at end of file
+}
index 73c80d98d9bf6b54dbd3d3ad5443d03e81114d5d..1e1528c9b49a6152db167e7b36dbb2180c356913 100644 (file)
--- a/To Do.txt
+++ b/To Do.txt
@@ -131,6 +131,7 @@ MooGUI
                        InputMap im = rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
                        KeyStroke helpKey = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0);
                        im.put(helpKey, "help");
+
        
        * Globala kommandon
        
@@ -138,7 +139,8 @@ MooGUI
                        Mappa F9-F12 till MooKeyboard.setOctave(n) där n = {2, 4, 6, 8}
        
                * Play / Stop
-                       Mappa till blanksteg.
+                       Mappa till blanksteg. <-- Detta fungerar inte.. blanksteget
+                       används av vår toolbar.
 
 \f
 Moosique