From 867eb267809ea85e6f983b93e5f63ca86150d7bc Mon Sep 17 00:00:00 2001 From: Einar Pehrson Date: Fri, 16 May 2003 14:50:36 +0000 Subject: [PATCH] *** empty log message *** --- MooMenu.java | 3 +++ MooTrackTitle.java | 8 ++++++++ MooTrackView.java | 24 ++++++++++++++++++++---- MooView.java | 2 -- Moosique.java | 8 +------- To Do.txt | 2 -- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/MooMenu.java b/MooMenu.java index ee3c0d4..5d8dd36 100644 --- a/MooMenu.java +++ b/MooMenu.java @@ -37,6 +37,7 @@ public class MooMenu extends JMenuBar implements ActionListener { 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); @@ -54,8 +55,10 @@ public class MooMenu extends JMenuBar implements ActionListener { 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..."); diff --git a/MooTrackTitle.java b/MooTrackTitle.java index 258e9d4..545681d 100644 --- a/MooTrackTitle.java +++ b/MooTrackTitle.java @@ -120,6 +120,14 @@ public class MooTrackTitle extends JPanel { 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. diff --git a/MooTrackView.java b/MooTrackView.java index 8827f31..513792d 100644 --- a/MooTrackView.java +++ b/MooTrackView.java @@ -20,6 +20,8 @@ public class MooTrackView extends JPanel { 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; @@ -28,6 +30,7 @@ public class MooTrackView extends JPanel { super(true); this.track = track; this.title = title; + insets = getInsets(); // Configures panel setBackground(Color.white); @@ -82,9 +85,8 @@ public class MooTrackView extends JPanel { } // 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. @@ -140,6 +142,12 @@ public class MooTrackView extends JPanel { 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; @@ -153,8 +161,16 @@ public class MooTrackView extends JPanel { } 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()); } } @@ -169,9 +185,9 @@ public class MooTrackView extends JPanel { 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 diff --git a/MooView.java b/MooView.java index ee2880b..c16699c 100644 --- a/MooView.java +++ b/MooView.java @@ -70,13 +70,11 @@ public class MooView extends JScrollPane { 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); } diff --git a/Moosique.java b/Moosique.java index 91cf4ff..0a148b6 100644 --- a/Moosique.java +++ b/Moosique.java @@ -380,13 +380,7 @@ public class Moosique { } 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() { diff --git a/To Do.txt b/To Do.txt index b598436..93b5d13 100644 --- a/To Do.txt +++ b/To Do.txt @@ -2,8 +2,6 @@ Diverse -x VIKTIGT!!! HUR LÄGGA TILL NOTER?!? - x Spara konfiguration? Arbetskatalog Fem senast öppnade filerna -- 2.39.2