File file = chooser.getSelectedFile();
if(returnVal == JFileChooser.APPROVE_OPTION && isMidiFile(file)) {
directory = chooser.getSelectedFile().getParentFile();
- Moosique.load(chooser.getSelectedFile().getAbsolutePath());
+ if (!Moosique.promptOnUnsavedChanges())
+ Moosique.load(chooser.getSelectedFile().getAbsolutePath());
}
} else if (command == "Save") {
if (!Moosique.save()) showSaveAsDialog();
private ArrayList coords, selection, copyBuffer;
private Insets insets;
private int ticksPerSixteenth, popupY = 0;
+ private boolean leftMouseButtonPressed = false;
protected static int viewLength = 0;
protected static int extraHeight = 0;
public static final int NOTE_HEIGHT = 10, NOTE_WIDTH = 40, VIEW_WIDTH = 200;
}
}
+ /**
+ * Returns whether the left mouse button is currently pressed or not.
+ * @return true if the left mosue button is currently pressed
+ */
+ public boolean isLeftMouseButtonPressed() {
+ return leftMouseButtonPressed;
+ }
+
/**
* The adapter used to listen on mouse actions
*/
}
public void mousePressed(MouseEvent e) {
+ if (SwingUtilities.isLeftMouseButton(e)) leftMouseButtonPressed = true;
maybeShowPopup(e);
}
public void mouseReleased(MouseEvent e) {
+ if (SwingUtilities.isLeftMouseButton(e)) leftMouseButtonPressed = false;
maybeShowPopup(e);
}
* Grabs the focus when the mouse has entered.
*/
public void mouseEntered(MouseEvent e) {
- // Moosique.setActiveChannel(track.getChannel());
+ Moosique.setActiveChannel(title.getChannel());
grabFocus();
}
}
private static MidiChannel[] channels;
private static MidiChannel activeChannel;
private static MidiEvent[] timeSignatures, tempoChanges;
+
private static ArrayList emptyTracks;
private static Map trackMute = new HashMap();
private static Map trackSolo = new HashMap();
-
+ private static Thread player;
private static String filename;
private static long editPosition;
- private static boolean makeGUI = true, initSound = true, isEdited = false, drawEmptyTracks = false;
- private static Thread player;
+ private static boolean makeGUI = true, initSound = true, edited = false, drawEmptyTracks = false;
public static final int DEFAULT_RESOLUTION = 96, DEFAULT_TRACKS = 4;
/**
* @return the tick position
*/
public static boolean isEdited() {
- return isEdited;
+ return edited;
}
/**
* Sets the current sequence as edited, which implies prompts when loading a new sequence.
*/
public static void setEdited() {
- isEdited = true;
+ edited = true;
}
/**
} catch (IOException e) {
return false;
}
- isEdited = false;
+ edited = false;
Track[] tracks = seq.getTracks();
emptyTracks = new ArrayList();
* Prompts the user .
*/
public static boolean promptOnUnsavedChanges() {
- if (!isEdited) return false;
+ if (!edited) return false;
int exitOption = JOptionPane.showConfirmDialog(gui,
"The current sequence has been edited, but not saved.\nDo you wish to continue anyway?",
"File not saved - continue?",
try {
MidiSystem.write(seq, 1, new File(file));
filename = file;
- isEdited = false;
+ edited = false;
gui.setStatus("Saved " + file);
return true;
} catch (IOException e) {