X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooMenu.java;h=8d1caeaa11ec4a2e5a5b8413841401b0b60c5f7d;hb=8183d3bd4989dc30165b8f3a4656819ce086fbef;hp=2403a373551f07828d5bc0fd2c1d76fc5552e567;hpb=cd7d6166d73969c1c811ac7153cc6eee59a6a685;p=moosique.git diff --git a/MooMenu.java b/MooMenu.java index 2403a37..8d1caea 100644 --- a/MooMenu.java +++ b/MooMenu.java @@ -3,6 +3,7 @@ import javax.swing.*; import javax.swing.filechooser.*; import java.awt.event.*; import java.io.*; +import java.awt.*; /** * Moosiques GUI representing a menubar, menus and menuitems @@ -12,6 +13,8 @@ import java.io.*; public class MooMenu extends JMenuBar implements ActionListener { private JMenu file, edit, playback, music, help; + private JFileChooser chooser; + private File directory; /** * Creates the menu bar. @@ -106,6 +109,14 @@ public class MooMenu extends JMenuBar implements ActionListener { return item; } + /** + * creates a JDialog popupmenu, containing diffrent choices + * @param title the title of the dialog + * @return trackframe the JDialog....ffaaaaaaaaaaaaaaaan! + */ + //private JDialog makeDialog(String title){ + // + //} /** * checks if the fileformat is compatible with our program * @param f the file to check @@ -126,22 +137,39 @@ public class MooMenu extends JMenuBar implements ActionListener { if(command == "New") { Moosique.clearSequence(); } else if (command == "Open...") { - JFileChooser chooser = new JFileChooser(); + // Shows a file chooser. If shown previously, starts in the current directory. + if (directory != null) { + chooser = new JFileChooser(directory); + } else { + chooser = new JFileChooser(); + } chooser.addChoosableFileFilter(new MidiFileFilter()); int returnVal = chooser.showOpenDialog(this); - if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(chooser.getSelectedFile())) { + + // Stores the current directory and loads the selected file. + File file = chooser.getSelectedFile(); + if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) { + directory = chooser.getSelectedFile().getParentFile(); Moosique.load(chooser.getSelectedFile().getAbsolutePath()); } } else if (command == "Save") { Moosique.save(); } else if (command == "Save as...") { - JFileChooser chooser = new JFileChooser(); + // Shows a file chooser. If shown previously, starts in the current directory. + if (directory != null) { + chooser = new JFileChooser(directory); + } else { + chooser = new JFileChooser(); + } chooser.addChoosableFileFilter(new MidiFileFilter()); int returnVal = chooser.showSaveDialog(this); - if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(chooser.getSelectedFile())) { - Moosique.saveAs(chooser.getSelectedFile().getAbsolutePath()); + + // Stores the current directory and loads the selected file. + File file = chooser.getSelectedFile(); + if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) { + directory = file.getParentFile(); + Moosique.saveAs(file.getAbsolutePath()); } - } else if (command == "Exit") { Moosique.quit(); } else if (command == "Copy") { @@ -157,32 +185,35 @@ public class MooMenu extends JMenuBar implements ActionListener { } else if (command == "Preferences...") { } else if (command == "Play") { - if (Moosique.getSequencer().isRunning()) { - Moosique.pause(); - } else { - Moosique.play(); - } + if (!Moosique.getSequencer().isRunning()) Moosique.play(); } else if (command == "Pause") { - if (Moosique.getSequencer().isRunning()) { - Moosique.resume(); - } else { - Moosique.pause(); - } + if (Moosique.getSequencer().isRunning()) Moosique.pause(); } else if (command == "Stop") { Moosique.stop(); } else if (command == "Jump...") { - + } else if (command == "Add track...") { + + MooDialog what = new MooDialog(MooDialog.ADD_TRACK); + Moosique.getSequence().createTrack(); + } else if (command == "Delete track...") { + + MooDialog what = new MooDialog(MooDialog.DELETE_TRACK); + /* Let the user select a track from a list. seq = Moosique.getSequence(); seq.deleteTrack(seq.getTracks()[NUMBER]); */ } else if (command == "Copy track...") { + MooDialog what = new MooDialog(MooDialog.COPY_TRACK); + } else if (command == "Move track...") { + MooDialog what = new MooDialog(MooDialog.MOVE_TRACK); + } else if (command == "Insert measure...") { } else if (command == "Delete measure...") { @@ -225,4 +256,6 @@ public class MooMenu extends JMenuBar implements ActionListener { return "MIDI files"; } } -} \ No newline at end of file + + +}