diff --git a/build.xml b/build.xml index 74d65a1b..f9c16796 100644 --- a/build.xml +++ b/build.xml @@ -51,6 +51,11 @@ + + + + + diff --git a/src/fourthline/mabiicco/ui/IMMLManager.java b/src/fourthline/mabiicco/ui/IMMLManager.java index 1ad24b78..9f39462b 100644 --- a/src/fourthline/mabiicco/ui/IMMLManager.java +++ b/src/fourthline/mabiicco/ui/IMMLManager.java @@ -17,4 +17,5 @@ public interface IMMLManager { public void updateActivePart(); public void updateActiveTrackProgram(int program, int songProgram); public int getActivePartProgram(); + public boolean selectTrackOnExistNote(int note, int tickOffset); } diff --git a/src/fourthline/mabiicco/ui/MMLSeqView.java b/src/fourthline/mabiicco/ui/MMLSeqView.java index 8522d9c1..321a21c0 100644 --- a/src/fourthline/mabiicco/ui/MMLSeqView.java +++ b/src/fourthline/mabiicco/ui/MMLSeqView.java @@ -22,6 +22,7 @@ import fourthline.mabiicco.ui.editor.MMLEditor; import fourthline.mabiicco.ui.editor.MMLScoreUndoEdit; import fourthline.mmlTools.MMLEventList; +import fourthline.mmlTools.MMLNoteEvent; import fourthline.mmlTools.MMLScore; import fourthline.mmlTools.MMLTempoEvent; import fourthline.mmlTools.MMLTrack; @@ -541,6 +542,28 @@ public void updateActiveTrackProgram(int program, int songProgram) { undoEdit.saveState(); } + @Override + public boolean selectTrackOnExistNote(int note, int tickOffset) { + int trackIndex = 0; + for (MMLTrack track : mmlScore.getTrackList()) { + int partIndex = 0; + for (MMLEventList eventList : track.getMMLEventList()) { + MMLNoteEvent noteEvent = eventList.searchOnTickOffset(tickOffset); + if ( (noteEvent != null) && (note == noteEvent.getNote()) ) { + tabbedPane.setSelectedIndex(trackIndex); + MMLTrackView view = (MMLTrackView) tabbedPane.getSelectedComponent(); + view.setSelectMMLPartOfIndex(partIndex); + updateSelectedTrackAndMMLPart(); + return true; + } + partIndex++; + } + trackIndex++; + } + + return false; + } + public void setTimeView(JLabel timeView) { this.timeView = timeView; } diff --git a/src/fourthline/mabiicco/ui/editor/EditMode.java b/src/fourthline/mabiicco/ui/editor/EditMode.java index d96d8868..09586dc2 100644 --- a/src/fourthline/mabiicco/ui/editor/EditMode.java +++ b/src/fourthline/mabiicco/ui/editor/EditMode.java @@ -20,13 +20,13 @@ enum EditMode { public void pressEvent(IEditContext context, MouseEvent e) { startPoint = e.getPoint(); if (SwingUtilities.isRightMouseButton(e)) { - if (context.onExistNote(startPoint)) { + if (context.onExistNote(startPoint, false)) { context.showPopupMenu(startPoint); } else { context.changeState(AREA).executeEvent(context, e); } } else if (SwingUtilities.isLeftMouseButton(e)) { - if (context.onExistNote(startPoint)) { + if (context.onExistNote(startPoint, true)) { // ノート上であれば、ノートを選択状態にする. 複数選択判定も. context.selectNoteByPoint(startPoint, e.getModifiers()); if (context.isEditLengthPosition(startPoint)) { @@ -43,7 +43,8 @@ public void pressEvent(IEditContext context, MouseEvent e) { public void executeEvent(IEditContext context, MouseEvent e) { int cursorType = Cursor.DEFAULT_CURSOR; Point p = e.getPoint(); - if (context.onExistNote(p)) { + boolean onAlt = (e.getModifiers() & ActionEvent.ALT_MASK) != 0; + if (context.onExistNote(p, onAlt)) { if (context.isEditLengthPosition(p)) { cursorType = Cursor.E_RESIZE_CURSOR; } else { diff --git a/src/fourthline/mabiicco/ui/editor/IEditContext.java b/src/fourthline/mabiicco/ui/editor/IEditContext.java index 016d9156..e64f8d4c 100644 --- a/src/fourthline/mabiicco/ui/editor/IEditContext.java +++ b/src/fourthline/mabiicco/ui/editor/IEditContext.java @@ -11,7 +11,7 @@ * EditModeから使用するContext. */ interface IEditContext { - public boolean onExistNote(Point p); + public boolean onExistNote(Point p, boolean autoSelect); public boolean isEditLengthPosition(Point point); public EditMode changeState(EditMode nextMode); public void newMMLNoteAndSelected(Point p); diff --git a/src/fourthline/mabiicco/ui/editor/MMLEditor.java b/src/fourthline/mabiicco/ui/editor/MMLEditor.java index 7c4dceab..d5e34078 100644 --- a/src/fourthline/mabiicco/ui/editor/MMLEditor.java +++ b/src/fourthline/mabiicco/ui/editor/MMLEditor.java @@ -321,7 +321,7 @@ public void applyAreaSelect() { * @return ノート上の場合はtrue. */ @Override - public boolean onExistNote(Point point) { + public boolean onExistNote(Point point, boolean autoSelect) { int note = pianoRollView.convertY2Note( point.y ); int tickOffset = (int)pianoRollView.convertXtoTick( point.x ); MMLNoteEvent noteEvent = editEventList.searchOnTickOffset(tickOffset); @@ -329,6 +329,11 @@ public boolean onExistNote(Point point) { if ( (noteEvent != null) && (note == noteEvent.getNote()) ) { return true; } + + if (autoSelect) { + return mmlManager.selectTrackOnExistNote(note, tickOffset); + } + return false; }