]> ruin.nu Git - moosique.git/blobdiff - MooToolbar.java
no message
[moosique.git] / MooToolbar.java
index c1244f575e81b717e8db764427727b2d0362fd06..eb8ca43f304215539548383b8bd1466e36969405 100644 (file)
@@ -43,9 +43,9 @@ public class MooToolbar extends JToolBar {
                measure = createLabel("Msr", 10);
                beats = createLabel("Beat", 10);
                ticks = createLabel("Tick", 10);
-               measureValue = createLabel("1", 16);
-               beatsValue = createLabel("1", 16);
-               ticksValue = createLabel("1", 16);
+               measureValue = formatProgInd(createLabel("1", 16));
+               beatsValue = formatProgInd(createLabel("1", 16));
+               ticksValue = formatProgInd(createLabel("1", 16));
                JPanel spacenorth = new JPanel();
                spacenorth.setBackground(bgColor);
                JPanel spacesouth = new JPanel();
@@ -71,19 +71,19 @@ public class MooToolbar extends JToolBar {
         * Updates the progress indicator.
         */
        public void updateProgInd() {
-               int pos = Moosique.getSequencer().getTickPosition();
-               int ticksPerBeat = Moosique.getSequencer().getResolution();
+               long pos = Moosique.getSequencer().getTickPosition();
+               int ticksPerBeat = Moosique.getSequence().getResolution();
                int beatsPerMeasure = 4;
-               measureValue.setText(pos / (beatsPerMeasure * ticksPerBeat));
-               beatsValue.setText((pos - measures * beatsPerMeasure * ticksPerBeat) / ticksPerBeat);
-               ticksValue.setText(pos - measures * beatsPerMeasure * ticksPerBeat - beats * ticksPerBeat);
+               long measures = pos / (beatsPerMeasure * ticksPerBeat);
+               long beats = (pos - measures * beatsPerMeasure * ticksPerBeat) / ticksPerBeat;
+               long ticks = pos - measures * beatsPerMeasure * ticksPerBeat - beats * ticksPerBeat;
+               measureValue.setText(Long.toString(measures));
+               beatsValue.setText(Long.toString(beats));
+               ticksValue.setText(Long.toString(ticks));
        }
 
-       /**
+       /*
         * Creates a button with the specified image and tooltip.
-        * @param imagelocation         the imagelacation of the the image displayed in the button
-        * @param tooltip               the tooltip associated with this button
-        * @return button               the button to be attached to the toolbar
         */
        private JButton createButton(String imagelocation, String tooltip) {
                JButton button = new JButton (new ImageIcon(imagelocation));
@@ -92,15 +92,21 @@ public class MooToolbar extends JToolBar {
                return button;
        }
        
-       /**
+       /*
         * Creates labels with the specified text and font size. 
-        * @param title         the titel displayed on the label
-        * @param fontsize      the fontzise of the text displayed on the label
         */
        private JLabel createLabel(String title, int fontSize){
                JLabel label = new JLabel(title,JLabel.CENTER);
                label.setFont(new Font("Times New Roman", Font.PLAIN, fontSize));
+               return label;
+       }
+
+       /*
+        * Formats the given label for the progress indicator.
+        */
+       private JLabel formatProgInd(JLabel label){
                label.setBorder(BorderFactory.createLineBorder(Color.black));
+               label.setBackground(Color.white);
                return label;
        }
 
@@ -110,6 +116,9 @@ public class MooToolbar extends JToolBar {
                                        Moosique.play();
                                        playpause.setIcon(pauseIcon);
                                        playpause.setToolTipText("Pause");
+                                       while(Moosique.getSequencer().isRunning()) {
+                                               Moosique.getGUI().update();
+                                       }
                        } else if (((JButton)e.getSource()).getToolTipText() == "Pause") {
                                        Moosique.pause();
                                        playpause.setIcon(playIcon);
@@ -118,6 +127,9 @@ public class MooToolbar extends JToolBar {
                                        Moosique.resume();
                                        playpause.setIcon(pauseIcon);
                                        playpause.setToolTipText("Pause");
+                                       while(Moosique.getSequencer().isRunning()) {
+                                               Moosique.getGUI().update();
+                                       }
                        } else if (((JButton)e.getSource()).getToolTipText() == "Stop") {
                                Moosique.stop();
                                playpause.setIcon(playIcon);