Skip to content

Commit

Permalink
Alt+マウス移動でカーソル下のノートがあるパートに切り替えられるようにしました.
Browse files Browse the repository at this point in the history
  • Loading branch information
fourthline committed May 1, 2014
1 parent 61af763 commit 7e09c04
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
5 changes: 5 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<include name="**/*.fxml" />
</fileset>
</copy>
<copy todir="${dest}">
<fileset dir="${src}">
<include name="**/*.css" />
</fileset>
</copy>
</target>

<!-- properties task -->
Expand Down
1 change: 1 addition & 0 deletions src/fourthline/mabiicco/ui/IMMLManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
23 changes: 23 additions & 0 deletions src/fourthline/mabiicco/ui/MMLSeqView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/fourthline/mabiicco/ui/editor/EditMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/fourthline/mabiicco/ui/editor/IEditContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/fourthline/mabiicco/ui/editor/MMLEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,19 @@ 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);

if ( (noteEvent != null) && (note == noteEvent.getNote()) ) {
return true;
}

if (autoSelect) {
return mmlManager.selectTrackOnExistNote(note, tickOffset);
}

return false;
}

Expand Down

0 comments on commit 7e09c04

Please sign in to comment.