X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=blobdiff_plain;f=MooNoteElement.java;h=7ea74227d0be3a456226583adfa3fe9a8bed560f;hp=67555fcf5ccc80c45c85c7512b7ae69f1928ccd3;hb=6154ba318198471a2b94391df6aab6f2b6cd9b29;hpb=a8b0b5e27d120df964c5b6d8554a6207951b00d0 diff --git a/MooNoteElement.java b/MooNoteElement.java index 67555fc..7ea7422 100644 --- a/MooNoteElement.java +++ b/MooNoteElement.java @@ -87,6 +87,15 @@ public class MooNoteElement extends JPanel { repaint(); } + /** + * Transposes the current note element the given number of halftones. + * @param halftones the number of halftones to transpose - positive for up, negative for down + */ + public void transpose(int halftones) { + note.transpose(halftones); + update(); + } + /** * Draws the string that shows the note's properties. * @param g The Graphics object used to draw the strings. @@ -155,16 +164,24 @@ public class MooNoteElement extends JPanel { } /** - * layout this changed elemnt + * Layout this changed elemnt. */ protected void newLayout(){ mtv.layoutElement(this,true); } + /** * Listener that checks the mouse actions on this element. */ class MAdapter extends MouseAdapter { + /** + * Selects the note if + */ + public void mouseEntered(MouseEvent e) { + if (mtv.isLeftMouseButtonPressed()) select(); + } + /** * If left mouse button is clicked, selects the note and plays it. */ @@ -232,11 +249,9 @@ public class MooNoteElement extends JPanel { } else if (source == popupRemove) { remove(); } else if (source == popupTranspOctUp) { - note.transpose(12); - update(); + transpose(12); } else if (source == popupTranspOctDown) { - note.transpose(-12); - update(); + transpose(-12); } } }