|
@@ -1,6 +1,6 @@
|
|
|
import { IZoomView } from "../Common/Interfaces/IZoomView";
|
|
|
import { MusicSheetDrawer, GraphicalMusicSheet, BoundingBox, DrawingParameters,
|
|
|
- MusicSystem, GraphicalVoiceEntry } from "../MusicalScore/Graphical";
|
|
|
+ MusicSystem, EngravingRules} from "../MusicalScore/Graphical";
|
|
|
import { ScreenViewingRegion } from "./ScreenViewingRegion";
|
|
|
import { PointF2D, Fraction, SizeF2D } from "../Common/DataObjects";
|
|
|
import { AbstractZoomView } from "./AbstractZoomView";
|
|
@@ -8,6 +8,7 @@ import { InteractionType } from "../Common/Enums/InteractionType";
|
|
|
import { AbstractDisplayInteractionManager } from "./AbstractDisplayInteractionManager";
|
|
|
import { IUserDisplayInteractionListener } from "../Common/Interfaces/IUserDisplayInteractionListener";
|
|
|
import { PlaybackManager } from "../Playback";
|
|
|
+import { VoiceEntryInteractionListener } from "./VoiceEntryInteractionListener";
|
|
|
|
|
|
export class SheetRenderingManager extends AbstractZoomView implements IZoomView {
|
|
|
protected musicSheetDrawer: MusicSheetDrawer;
|
|
@@ -23,13 +24,20 @@ export class SheetRenderingManager extends AbstractZoomView implements IZoomView
|
|
|
protected internalPreviewImageScale: number = 3.0;
|
|
|
protected listeners: IUserDisplayInteractionListener[] = [];
|
|
|
public PlaybackManager: PlaybackManager;
|
|
|
+ private rules: EngravingRules;
|
|
|
|
|
|
- constructor(displayInteractionManager: AbstractDisplayInteractionManager, playbackManager?: PlaybackManager) {
|
|
|
+ constructor(displayInteractionManager: AbstractDisplayInteractionManager, rules: EngravingRules) {
|
|
|
super(displayInteractionManager);
|
|
|
+ this.rules = rules;
|
|
|
this.addZoomView(this);
|
|
|
this.lockRanges = true;
|
|
|
this.TopBarHeightInPixel = 70;
|
|
|
this.BottomBarHeightInPixel = 0;
|
|
|
+
|
|
|
+ if (this.rules.UseDefaultVoiceInteractionListener) { // default: true
|
|
|
+ // OSMD default listener (play voice entry, set playback position at voice entry). Can be removed.
|
|
|
+ this.listeners.push(new VoiceEntryInteractionListener(this));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public addListener(listener: IUserDisplayInteractionListener): void {
|
|
@@ -50,34 +58,22 @@ export class SheetRenderingManager extends AbstractZoomView implements IZoomView
|
|
|
if (!this.SingleTouchDisabled) {
|
|
|
const relPos: PointF2D = new PointF2D(relPosX, relPosY);
|
|
|
this.handleUserDisplayInteraction(relPos, PosInUnits, InteractionType.SingleTouch);
|
|
|
- for (const listener of this.listeners) {
|
|
|
- listener.userDisplayInteraction(relPos, PosInUnits, InteractionType.SingleTouch);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
protected unitPosDoubleTouched(PosInUnits: PointF2D, relPosX: number, relPosY: number): void {
|
|
|
if (!this.DoubleTouchDisabled) {
|
|
|
const relPos: PointF2D = new PointF2D(relPosX, relPosY);
|
|
|
this.handleUserDisplayInteraction(relPos, PosInUnits, InteractionType.DoubleTouch);
|
|
|
- for (const listener of this.listeners) {
|
|
|
- listener.userDisplayInteraction(relPos, PosInUnits, InteractionType.DoubleTouch);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
protected unitPosTouchDown(PosInUnits: PointF2D, relPosX: number, relPosY: number): void {
|
|
|
const relPos: PointF2D = new PointF2D(relPosX, relPosY);
|
|
|
this.handleUserDisplayInteraction(relPos, PosInUnits, InteractionType.TouchDown);
|
|
|
- for (const listener of this.listeners) {
|
|
|
- listener.userDisplayInteraction(new PointF2D(relPosX, relPosY), PosInUnits, InteractionType.TouchDown);
|
|
|
- }
|
|
|
this.yOffsetMouseDown = PosInUnits.y;
|
|
|
}
|
|
|
protected unitPosTouchUp(PosInUnits: PointF2D, relPosX: number, relPosY: number): void {
|
|
|
const relPos: PointF2D = new PointF2D(relPosX, relPosY);
|
|
|
this.handleUserDisplayInteraction(relPos, PosInUnits, InteractionType.TouchUp);
|
|
|
- for (const listener of this.listeners) {
|
|
|
- listener.userDisplayInteraction(new PointF2D(relPosX, relPosY), PosInUnits, InteractionType.TouchUp);
|
|
|
- }
|
|
|
if (this.displayInteractionManager.WasZoomGestureActive === false) {
|
|
|
this.unlockFromCursorIfNecessary(PosInUnits);
|
|
|
}
|
|
@@ -86,9 +82,6 @@ export class SheetRenderingManager extends AbstractZoomView implements IZoomView
|
|
|
protected unitPosMove(PosInUnits: PointF2D, relPosX: number, relPosY: number): void {
|
|
|
const relPos: PointF2D = new PointF2D(relPosX, relPosY);
|
|
|
this.handleUserDisplayInteraction(relPos, PosInUnits, InteractionType.Move);
|
|
|
- for (const listener of this.listeners) {
|
|
|
- listener.userDisplayInteraction(new PointF2D(relPosX, relPosY), PosInUnits, InteractionType.Move);
|
|
|
- }
|
|
|
this.unlockFromCursorIfNecessary(PosInUnits);
|
|
|
}
|
|
|
|
|
@@ -240,31 +233,14 @@ export class SheetRenderingManager extends AbstractZoomView implements IZoomView
|
|
|
switch (type) {
|
|
|
case InteractionType.TouchDown:
|
|
|
case InteractionType.SingleTouch:
|
|
|
- case InteractionType.DoubleTouch: {
|
|
|
- const clickVe: GraphicalVoiceEntry = this.graphicalMusicSheet.GetNearestVoiceEntry(positionOnMusicSheet);
|
|
|
- // set cursor and/or start/end marker position
|
|
|
-
|
|
|
- if (clickVe) {
|
|
|
- if (clickVe.parentStaffEntry.parentVerticalContainer !== undefined) {
|
|
|
- const clickedTimeStamp: Fraction = clickVe.parentStaffEntry.parentVerticalContainer.AbsoluteTimestamp;
|
|
|
- this.setStartPosition(clickedTimeStamp);
|
|
|
- // playback clicked note
|
|
|
- if (clickVe.notes[0]?.sourceNote.Pitch !== undefined) {
|
|
|
- this.PlaybackManager?.playVoiceEntry(clickVe.parentVoiceEntry);
|
|
|
- }
|
|
|
- }
|
|
|
+ case InteractionType.DoubleTouch:
|
|
|
+ case InteractionType.TouchUp:
|
|
|
+ case InteractionType.TouchDown:
|
|
|
+ case InteractionType.Move:
|
|
|
+ for (const listener of this.listeners) {
|
|
|
+ listener.userDisplayInteraction(relativePositionOnDisplay, positionOnMusicSheet, type);
|
|
|
}
|
|
|
break;
|
|
|
- }
|
|
|
- case InteractionType.TouchUp: {
|
|
|
- break;
|
|
|
- }
|
|
|
- case InteractionType.TouchDown: {
|
|
|
- break;
|
|
|
- }
|
|
|
- case InteractionType.Move: {
|
|
|
- break;
|
|
|
- }
|
|
|
default:
|
|
|
throw new Error("type");
|
|
|
}
|
|
@@ -279,4 +255,7 @@ export class SheetRenderingManager extends AbstractZoomView implements IZoomView
|
|
|
this.PlaybackManager?.reset();
|
|
|
}
|
|
|
|
|
|
+ public get GraphicalMusicSheet(): GraphicalMusicSheet {
|
|
|
+ return this.graphicalMusicSheet;
|
|
|
+ }
|
|
|
}
|