addItem(edit, "Paste", KeyEvent.VK_V, ActionEvent.CTRL_MASK);
addItem(edit, "Select all", KeyEvent.VK_E, ActionEvent.CTRL_MASK);
addItem(edit, "Invert selection", KeyEvent.VK_I, ActionEvent.CTRL_MASK);
+ edit.addSeparator();
addItem(edit, "Preferences...", KeyEvent.VK_P, ActionEvent.CTRL_MASK);
playback = createMenu("Playback", KeyEvent.VK_P);
addItem(music, "Delete track...", KeyEvent.VK_D, ActionEvent.CTRL_MASK);
addItem(music, "Copy track...", KeyEvent.VK_Y, ActionEvent.CTRL_MASK);
addItem(music, "Move track...", KeyEvent.VK_M, ActionEvent.CTRL_MASK);
+ edit.addSeparator();
addItem(music, "Insert measure...");
addItem(music, "Delete measure...");
+ edit.addSeparator();
addItem(music, "Set time signature...");
addItem(music, "Set tempo...");
addItem(music, "Scale velocity...");
checkboxes.add(solo);
add(checkboxes);
}
+
+ /**
+ * Returns the channel of the track that the view is visualising.
+ * @return the chanel of the visualised track
+ */
+ public int getChannel() {
+ return channel;
+ }
/**
* Checks if the focus is lost.
private JPopupMenu popup;
private JMenuItem popupAdd;
private ArrayList rects;
+ private Insets insets;
+ private int ticksPerSixteenth, popupY = 0;
protected static int viewLength = 0;
protected static int extraHeight = 0;
public static final int NOTE_HEIGHT = 10, NOTE_WIDTH = 40, VIEW_WIDTH = 200;
super(true);
this.track = track;
this.title = title;
+ insets = getInsets();
// Configures panel
setBackground(Color.white);
}
// Creates temporary variables.
- int ticksPerSixteenth = Moosique.getSequence().getResolution() / 4;
+ ticksPerSixteenth = Moosique.getSequence().getResolution() / 4;
MooNote mn = elem.getNote();
- Insets insets = getInsets();
int x, y, height;
// Calculates coordinates.
repaint();
}
+ private void addStandardNote() {
+ long timestamp = (long)(ticksPerSixteenth * (popupY - insets.top) / NOTE_HEIGHT);
+ System.out.println(ticksPerSixteenth + ", " + popupY + ", " + insets.top + ", " + timestamp);
+ addNote(new MooNote(title.getChannel(), 60, 100, timestamp, Moosique.getSequence().getResolution() / 4));
+ }
+
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
}
class MAdapter extends MouseAdapter {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
+ popupY = e.getY();
+ addStandardNote();
+ }
+ }
+
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
+ popupY = e.getY();
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == popupAdd) {
- //addNote(new MooNote());
- // int channel, int pitch, int velocity, long timestamp, int duration
+ addStandardNote();
}
+ // new MooNote(int channel, int pitch, int velocity, long timestamp, int duration)
}
}
}
\ No newline at end of file
trackPanel.setLayout(gL);
for (int i = 1; i < tracks.length; i++) {
if (Moosique.shouldBeDrawn(tracks[i])) {
- System.out.println("Draws track " + i);
MooTrackTitle title = new MooTrackTitle(tracks[i]);
titlePanel.add(title);
trackPanel.add(new MooTrackView(tracks[i], title));
progressBar.setValue(i);
} else {
- System.out.println("Doesn't draw track " + i);
gL.setColumns(--numberOfTracks);
trackPanel.setLayout(gL);
}
}
noteOns.trimToSize();
noteOffs.trimToSize();
- boolean isEmpty = (noteOns.size() == 0);
- String text = "Track " + i + " has " + noteOns.size() + "/" + noteOffs.size() + "/" + tracks[i].size();
- if (isEmpty) {
- text += " and will be removed.";
- emptyTracks.add(tracks[i]);
- }
- System.out.println(text);
+ if (noteOns.size() == 0) emptyTracks.add(tracks[i]);
// Sorts the note lists by tick position.
Comparator c = new Comparator() {
\f
Diverse
-x VIKTIGT!!! HUR LÄGGA TILL NOTER?!?
-
x Spara konfiguration?
Arbetskatalog
Fem senast öppnade filerna