+
+ public MooToolbar() {
+ // setAlignmentX(LEFT_ALIGNMENT);
+ setFloatable(false);
+ mouseAdapter = new MAdapter();
+
+ // Creates playback buttons
+ rewind = createButton("images/rewind.gif", "Rewind");
+ playpause = createButton("images/play.gif", "Play");
+ stop = createButton("images/stop.gif", "Stop");
+ fastforward = createButton("images/forward.gif", "Fast forward");
+ playIcon = new ImageIcon("images/play.gif");
+ pauseIcon = new ImageIcon("images/pause.gif");
+
+ // Adds playback buttons
+ add(rewind);
+ add(playpause);
+ add(stop);
+ add(fastforward);
+
+ // Creates progress indicator
+ measure = createLabel("Msr", 10);
+ beats = createLabel("Beat", 10);
+ ticks = createLabel("Tick", 10);
+ measuresValue = 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();
+ spacesouth.setBackground(bgColor);
+
+ // Creates progress indicator panel and adds components
+ progIndPanel = new JPanel();
+ progIndPanel.setMaximumSize(new Dimension(120,27));
+ progIndPanel.setLayout(new GridLayout(2,4));
+ progIndPanel.add(spacenorth);
+ progIndPanel.add(measure);
+ progIndPanel.add(beats);
+ progIndPanel.add(ticks);
+ progIndPanel.add(spacesouth);
+ progIndPanel.add(measuresValue);
+ progIndPanel.add(beatsValue);
+ progIndPanel.add(ticksValue);
+ add(progIndPanel);
+ }
+
+ /**
+ * Updates the progress indicator.
+ * @param tickPosition the tick position to visualize
+ */
+ public void updateProgInd(long tickPosition) {
+ ticksPerBeat = Moosique.getSequence().getResolution();
+ if (tickPosition == 0) {
+ resetProgInd();
+ } else {
+ // Otherwise, calculates the current song position in measures, beats and ticks.
+ long measures = tickPosition / (beatsPerMeasure * ticksPerBeat);
+ long beats = (tickPosition - measures * beatsPerMeasure * ticksPerBeat) / ticksPerBeat;
+ long ticks = tickPosition - measures * beatsPerMeasure * ticksPerBeat - beats * ticksPerBeat;
+ measuresValue.setText(Long.toString(1 + measures));
+ beatsValue.setText(Long.toString(1 + beats));
+ ticksValue.setText(Long.toString(1 + ticks));
+ }
+ }