]> ruin.nu Git - moosique.git/commitdiff
no message
authorEinar Pehrson <einarp@itstud.chalmers.se>
Sun, 11 May 2003 00:53:02 +0000 (00:53 +0000)
committerEinar Pehrson <einarp@itstud.chalmers.se>
Sun, 11 May 2003 00:53:02 +0000 (00:53 +0000)
MooGUI.java
MooMenu.java
MooToolbar.java
MooTrackTitle.java
MooTrackView.java
MooView.java
Moosique.java
To Do.txt

index 7bcd6dd854d103d8360c78f1396ad0c9dde62eae..97b4ad0dc431b6dca32f2a42e8f8a73ea3e5e673 100644 (file)
@@ -6,19 +6,18 @@ import java.awt.event.*;
 /**
  * Moosique's graphical user interface.
  * 
- * @author  Mikael Andreen
+ * @author  Einar Pehrson
  */
  
 public class MooGUI extends JFrame {
 
        private Sequence seq;
-
+       private MooMenu menu;
        private MooToolbar toolbar;
-       private JPanel trackPanel;
-       private MooTrackView[] trackViews;
+       private MooView view;
        private JLabel statusBar;
-
-       public static Font standardFont = new Font("Helvetica", Font.PLAIN, 10);
+       public static final Font FONT = new Font("Helvetica", Font.PLAIN, 10);
+       public static final Color bgColor = new Color(192, 224, 255);
        
        /** 
         * Creates the GUI.
@@ -30,23 +29,33 @@ public class MooGUI extends JFrame {
                
                Container pane = getContentPane();
                pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
-               
+
                // Adds menu bar.
-               setJMenuBar(new MooMenu());
+               menu = new MooMenu();
+               setJMenuBar(menu);
 
                // Adds toolbar.
                toolbar = new MooToolbar();
                pane.add(toolbar, BorderLayout.NORTH);
 
-               // Adds tracks.
-               trackPanel = new JPanel(true);
-               createTrackViews();
-               pane.add(trackPanel, BorderLayout.CENTER);
+               // Adds main view.
+               view = new MooView(seq.getTracks());
+               pane.add(view, BorderLayout.CENTER);
 
                // Adds status bar.
                statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
+               statusBar.setFont(FONT);
                pane.add(statusBar, BorderLayout.SOUTH);
 
+               // Brings on the colors!
+               setBackground(pane);
+               setBackground(menu);
+               setBackground(toolbar);
+               setBackground(view);
+               statusBar.setBackground(bgColor);
+               view.setBackground(bgColor);
+
+               // Configures window.
                addWindowListener(new MooGUICloser());
                pack();
                Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
@@ -57,6 +66,15 @@ public class MooGUI extends JFrame {
                setVisible(true);
                show();
        }
+
+       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.
@@ -64,7 +82,7 @@ public class MooGUI extends JFrame {
         */
        public void setSequence(Sequence sequence) {
                seq = sequence;
-               createTrackViews();
+               view.update(seq.getTracks());
        }
 
        /** 
@@ -75,22 +93,9 @@ public class MooGUI extends JFrame {
                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();}
+               public void windowClosing(WindowEvent e) {
+                       Moosique.quit();
+               }
        }
 }
\ No newline at end of file
index 7a0785b304fcb878d996adfc74e01eaef7b9a920..2403a373551f07828d5bc0fd2c1d76fc5552e567 100644 (file)
@@ -1,3 +1,4 @@
+import javax.sound.midi.*;
 import javax.swing.*;
 import javax.swing.filechooser.*;
 import java.awt.event.*;
@@ -120,6 +121,7 @@ public class MooMenu extends JMenuBar implements ActionListener {
 
        public void actionPerformed(ActionEvent e) {
                String command = e.getActionCommand();
+               Sequence seq;
                
                if(command == "New") {
                        Moosique.clearSequence();
@@ -171,9 +173,12 @@ public class MooMenu extends JMenuBar implements ActionListener {
                } else if (command == "Jump...") {
                
                } else if (command == "Add track...") {
-               
+                       Moosique.getSequence().createTrack();
                } else if (command == "Delete track...") {
-               
+                       /* Let the user select a track from a list.
+                       seq = Moosique.getSequence();
+                       seq.deleteTrack(seq.getTracks()[NUMBER]);
+                       */
                } else if (command == "Copy track...") {
                
                } else if (command == "Move track...") {
@@ -203,7 +208,7 @@ public class MooMenu extends JMenuBar implements ActionListener {
                        JOptionPane.showMessageDialog(null, "här kommer about att komma");
                }
        }
-       
+
        class MidiFileFilter extends javax.swing.filechooser.FileFilter {
                public boolean accept(File f) {
                        if(f != null) {
index 2a31842212b68009b1ba2838401a3bef5f6db765..c579aa84e7def844e52236a7f783bceb93d8c2ec 100644 (file)
@@ -20,22 +20,22 @@ public class MooToolbar extends JToolBar {
         */
        
        public MooToolbar() {
+               setFloatable(false);
                mouseAdapter = new MooMouseAdapter();
 
+               // Creates playback buttons
                rewind = createButton("images/rewind.gif", "Rewind");
                add(rewind);
-
                playpause = createButton("images/play.gif", "Play");
                add(playpause);
                playIcon = new ImageIcon("images/play.gif");
                pauseIcon = new ImageIcon("images/pause.gif");
-               
                stop = createButton("images/stop.gif", "Stop");
                add(stop);
-               
                fastforward = createButton("images/forward.gif", "Fast forward");
                add(fastforward);
                
+               // Creates progress indicator
                JPanel progIndPanel = new JPanel();
                progIndPanel.setBorder(BorderFactory.createLineBorder(Color.black));
                progIndPanel.setMaximumSize(new Dimension(100,22));
@@ -43,9 +43,9 @@ public class MooToolbar extends JToolBar {
                measure = createLabel("Mrs",10);
                beats = createLabel("Beat",10);
                ticks = createLabel("Tick",10);
-               measurevalue = createLabel("1", 12);
-               beatsvalue = createLabel("1",12);
-               ticksvalue = createLabel("1",12);
+               measurevalue = createLabel("1", 16);
+               beatsvalue = createLabel("1",16);
+               ticksvalue = createLabel("1",16);
                progIndPanel.add(measure);
                progIndPanel.add(beats);
                progIndPanel.add(ticks);
@@ -75,7 +75,7 @@ public class MooToolbar extends JToolBar {
         */
        private JLabel createLabel(String title, int fontSize){
                JLabel value = new JLabel(title,JLabel.CENTER);
-               value.setFont(new Font("Times New Roman", Font.BOLD, fontSize));
+               value.setFont(new Font("Times New Roman", Font.PLAIN, fontSize));
                return value;
        }
        
index 0c043372f2e836806036a20f2d85593593bcf705..b32479fd43cd0fa05ff76fd2878f45cac28834e4 100644 (file)
@@ -24,6 +24,7 @@ public class MooTrackTitle extends JPanel {
                setLayout(new GridLayout(4,1));
 
                title = new JTextField(); // JTextField(String text, int columns) 
+               title.setFont(Moosique.getGUI().FONT);
                title.addFocusListener(new TitleFocusListener());
                add(title);
 
@@ -34,7 +35,7 @@ public class MooTrackTitle extends JPanel {
                checkboxes.setLayout(new GridLayout(1,3));
 
                channel = new JComboBox();
-               channel.setFont(new Font("Helvetica", Font.PLAIN, 10));
+               channel.setFont(Moosique.getGUI().FONT);
                for (int i = 1; i <= 16; i++)
                        channel.addItem(new Integer(i));
                channel.addItemListener(new ItemListener(){
@@ -48,7 +49,7 @@ public class MooTrackTitle extends JPanel {
                
 
                mute = new JCheckBox("Mute");
-               mute.setFont(new Font("Helvetica", Font.PLAIN, 10));
+               mute.setFont(Moosique.getGUI().FONT);
                mute.addActionListener(new ActionListener(){
                                public void actionPerformed(ActionEvent event){
                                        //setMute
@@ -57,7 +58,7 @@ public class MooTrackTitle extends JPanel {
                checkboxes.add(mute);
 
                solo = new JCheckBox("Solo");
-               solo.setFont(new Font("Helvetica", Font.PLAIN, 10));
+               solo.setFont(Moosique.getGUI().FONT);
                solo.addActionListener(new ActionListener(){
                                public void actionPerformed(ActionEvent event){
                                        //setSolo
index 1e59ba4d200e507442367c89b6df4018c052365f..ccaa10553ccbe38bc546c5ff67a1aa197c8ef913 100644 (file)
@@ -12,6 +12,7 @@ import javax.sound.midi.*;
  
 public class MooTrackView extends JPanel implements ActionListener {
 
+       private Track track;
        private MooTrackTitle title;
        private NoteArea notes;
        private Rectangle box;
@@ -19,6 +20,7 @@ public class MooTrackView extends JPanel implements ActionListener {
        private JMenuItem menuItem;
        
        public MooTrackView (Track track) {
+               this.track = track;
                setPreferredSize(new Dimension(200, 200));
                setLayout(new BorderLayout());
                this.setBorder(BorderFactory.createLineBorder(Color.black));
@@ -45,6 +47,10 @@ public class MooTrackView extends JPanel implements ActionListener {
        
        public void actionPerformed(ActionEvent e) {}
     
+       public Track getTrack() {
+               return track;
+       }
+
        class NoteArea extends JPanel {
                public void RectanglePanel() {
                        setPreferredSize(new Dimension(20, 20));
index 1cdbee8c36d7462569420d62aa640c9724a6b4d7..620478ca09b8857983b2cba25d4618e1612b21c1 100644 (file)
@@ -1,18 +1,65 @@
+import javax.sound.midi.*;
 import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
 
 /**
+ * The main view, the container of the track views.
  * 
- * 
- * @author  Andersson, Andreen, Lanneskog, Pehrson
- * @version 1
+ * @author  Einar Pehrson
  */
-public class MooView {
+
+public class MooView extends JScrollPane {
+
+       private Track[] tracks;
+       private MooTrackView[] trackViews;
+       private JPanel trackPanel;
+
+       /** 
+        * Creates the main view
+        */
+       public MooView(Track[] tracks) {
+               super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED);
+
+               this.tracks = tracks;
+
+               trackPanel = new JPanel(new GridLayout(1,3), true);
+               createTrackViews();
+               setViewportView(trackPanel);
+       }
 
        /** 
-        * Creates 
+        * Fills the track panel with track views for all tracks in the current sequence.
         */
-       public MooView () {
+       private void createTrackViews() {
+               trackPanel.removeAll();
+               ((GridLayout)trackPanel.getLayout()).setColumns(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();
+       }
+
+       public void update(Track[] tracks) {
+               this.tracks = tracks;
+               createTrackViews();
+       }
 
+       /** 
+        * Creates a view for the given track and adds it to the main view.
+        * @param track         the track for which to add a view
+        */
+       public void addTrackView(Track track) {
+               
+       }
+
+       /** 
+        * Removes the view for the given track.
+        * @param track         the track for which to remove the view
+        */
+       public void removeTrackView(Track track) {
+               
        }
-}
+}
\ No newline at end of file
index 9a19a53878b1d9d6ee7787b954d9ba23c974934a..13d7ce6c650adc260db8575ccdf849399b92d130 100644 (file)
@@ -56,8 +56,12 @@ public class Moosique {
                //If a filename is given as the command-line argument, attempts to load a sequence from the file.
                if (fileArg != null) {
                        System.out.print("Loading MIDI sequence from " + fileArg + "...");
-                       if (!load(fileArg)) clearSequence();
-                       System.out.println("Done");
+                       if (!load(fileArg)) {
+                               System.out.println("Failed");
+                               clearSequence();
+                       } else {
+                               System.out.println("Done");
+                       }
                } else {
                        // Otherwise creates a new empty one.
                        clearSequence();
index 9edff84f4e4f936e49201663f2c2ac1ffb987054..187541f19fa35f3d83e873eed058aafba7dc8e9d 100644 (file)
--- a/To Do.txt
+++ b/To Do.txt
@@ -31,6 +31,22 @@ VIKTIGT! Implementera playfunktionens beteende. N
 
 \f
 x Fixa en progress indicator till filladdningen om den tänker ta så lång tid.
+x Scrollningen?!? Horisontell behövs på både MooView och MooTrackView, men vertikal bara på MooView. Hur göra?
+x Får Moosique vara statisk? Fult?
+
+\f
+MIDI Messages
+
+FF 58  Time signature: [0] / [1], [2] MIDI clocks per metronome tick, [3] / 32 per 24 MIDI clocks
+FF 51  Tempo           
+FF 03  Track Name      String name = new String(getData());
+C0     Program change  int pc = getData1();
+
+
+Sequence
+       private ShortMessage timeSignature, tempo;
+Track 
+       private ShortMessage trackName, programChange;
 
 \f
 MooMenu
@@ -72,10 +88,6 @@ MooNote / MootrackView / MooNoteElement
 \f
 MooTrackTitle
 
-       * Behöver vi verkligen ha titel för tracks?? Tycker att TrackTitle tar upp mycket plats som det är.. 
-
-       
-
        * Kanalinställning
                Hämta från det första Event i ett spår.
 
@@ -86,9 +98,6 @@ MooTrackTitle
                boolean getTrackSolo(int track)                 Obtains the current solo state for a track. 
                void setTrackMute(int track, boolean mute)      Sets the mute state for a track. 
                void setTrackSolo(int track, boolean solo)      Sets the solo state for a track. 
-
-               * För att kunna använda dessa funktioner behöver vi TrackTitle veta
-                       vilken int track den ska arbeta mot.. Skicka in som parameter till konstruktorn?
        
                När det gäller kanalerna velar jag lite. Antingen gör jag en mappningsmatris i Moosique som
                man får läsa och skriva ifrån (vilket blir FULT!), eller så tar man allt direkt genom
@@ -131,4 +140,4 @@ Moosique
 
        * getPosition och setPosition - kvar?
 
-\f
+\f
\ No newline at end of file