smoosic 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/smoosic.js +167 -74
- package/package.json +82 -77
- package/release/smoosic.js +171 -78
- package/release/styles/menus.css +26 -0
- package/specs/022-text-reposition-on-resize/spec.md +1 -0
- package/specs/027-fix-bottom-modifier-lookup/checklists/requirements.md +38 -0
- package/specs/027-fix-bottom-modifier-lookup/contracts/division-lookup-contract.md +51 -0
- package/specs/027-fix-bottom-modifier-lookup/data-model.md +43 -0
- package/specs/027-fix-bottom-modifier-lookup/plan.md +77 -0
- package/specs/027-fix-bottom-modifier-lookup/quickstart.md +36 -0
- package/specs/027-fix-bottom-modifier-lookup/research.md +58 -0
- package/specs/027-fix-bottom-modifier-lookup/spec.md +105 -0
- package/specs/027-fix-bottom-modifier-lookup/tasks.md +167 -0
- package/specs/028-unsaved-changes-indicator/checklists/requirements.md +39 -0
- package/specs/028-unsaved-changes-indicator/contracts/score-change-contract.md +44 -0
- package/specs/028-unsaved-changes-indicator/data-model.md +64 -0
- package/specs/028-unsaved-changes-indicator/plan.md +96 -0
- package/specs/028-unsaved-changes-indicator/quickstart.md +54 -0
- package/specs/028-unsaved-changes-indicator/research.md +68 -0
- package/specs/028-unsaved-changes-indicator/spec.md +135 -0
- package/specs/028-unsaved-changes-indicator/tasks.md +173 -0
- package/specs/029-remove-promise-helpers/checklists/requirements.md +39 -0
- package/specs/029-remove-promise-helpers/contracts/public-api-contract.md +32 -0
- package/specs/029-remove-promise-helpers/data-model.md +45 -0
- package/specs/029-remove-promise-helpers/plan.md +86 -0
- package/specs/029-remove-promise-helpers/quickstart.md +53 -0
- package/specs/029-remove-promise-helpers/research.md +71 -0
- package/specs/029-remove-promise-helpers/spec.md +107 -0
- package/specs/029-remove-promise-helpers/tasks.md +164 -0
- package/specs/030-copy-paste-voices/checklists/requirements.md +39 -0
- package/specs/030-copy-paste-voices/contracts/voice-copy-paste-contract.md +47 -0
- package/specs/030-copy-paste-voices/data-model.md +63 -0
- package/specs/030-copy-paste-voices/plan.md +80 -0
- package/specs/030-copy-paste-voices/quickstart.md +50 -0
- package/specs/030-copy-paste-voices/research.md +80 -0
- package/specs/030-copy-paste-voices/spec.md +124 -0
- package/specs/030-copy-paste-voices/tasks.md +183 -0
- package/specs/031-select-voice/checklists/requirements.md +39 -0
- package/specs/031-select-voice/contracts/select-voice-contract.md +43 -0
- package/specs/031-select-voice/data-model.md +47 -0
- package/specs/031-select-voice/plan.md +79 -0
- package/specs/031-select-voice/quickstart.md +43 -0
- package/specs/031-select-voice/research.md +55 -0
- package/specs/031-select-voice/spec.md +113 -0
- package/specs/031-select-voice/tasks.md +171 -0
- package/src/application/application.ts +464 -459
- package/src/common/promiseHelpers.ts +2 -2
- package/src/render/audio/samples.ts +117 -118
- package/src/render/sui/pageDivisions.ts +58 -0
- package/src/render/sui/renderState.ts +469 -464
- package/src/render/sui/scoreChangeState.ts +62 -0
- package/src/render/sui/scoreView.ts +30 -0
- package/src/render/sui/scoreViewOperations.ts +2555 -2380
- package/src/render/sui/svgPageMap.ts +16 -17
- package/src/render/sui/textEdit.ts +310 -311
- package/src/render/sui/tracker.ts +40 -0
- package/src/render/vex/vxNote.ts +3 -1
- package/src/smo/xform/copypaste.ts +304 -4
- package/src/smo/xform/selections.ts +68 -0
- package/src/smo/xform/undo.ts +9 -0
- package/src/styles/menus.css +26 -0
- package/src/ui/buttons/ribbon.ts +3 -1
- package/src/ui/components/buttons/sidebar.vue +15 -6
- package/src/ui/components/dialogs/library.vue +3 -1
- package/src/ui/components/dialogs/unsavedChanges.vue +44 -0
- package/src/ui/dialogs/adapter.ts +181 -183
- package/src/ui/dialogs/addMeasure.ts +97 -97
- package/src/ui/dialogs/annotationVue.ts +56 -56
- package/src/ui/dialogs/audioSettings.ts +121 -123
- package/src/ui/dialogs/chordChangeVue.ts +46 -46
- package/src/ui/dialogs/clefChange.ts +53 -53
- package/src/ui/dialogs/customTuplets.ts +95 -96
- package/src/ui/dialogs/customTupletsVue.ts +47 -47
- package/src/ui/dialogs/dialog.ts +627 -620
- package/src/ui/dialogs/durations.ts +34 -34
- package/src/ui/dialogs/dynamics.ts +140 -142
- package/src/ui/dialogs/factory.ts +198 -198
- package/src/ui/dialogs/fileDialogs.ts +245 -179
- package/src/ui/dialogs/fonts.ts +93 -93
- package/src/ui/dialogs/globalLayout.ts +40 -40
- package/src/ui/dialogs/gracenote.ts +31 -31
- package/src/ui/dialogs/hairpin.ts +108 -110
- package/src/ui/dialogs/hairpinVue.ts +51 -51
- package/src/ui/dialogs/instrument.ts +111 -111
- package/src/ui/dialogs/keySignature.ts +175 -176
- package/src/ui/dialogs/keySignatureVue.ts +47 -47
- package/src/ui/dialogs/library.ts +207 -207
- package/src/ui/dialogs/libraryVue.ts +62 -48
- package/src/ui/dialogs/lyricVue.ts +46 -46
- package/src/ui/dialogs/measureFormat.ts +78 -78
- package/src/ui/dialogs/microtones.ts +147 -147
- package/src/ui/dialogs/noteHead.ts +319 -319
- package/src/ui/dialogs/pageLayout.ts +61 -61
- package/src/ui/dialogs/partInfo.ts +60 -60
- package/src/ui/dialogs/pedalMarking.ts +117 -117
- package/src/ui/dialogs/pedalMarkingVue.ts +73 -73
- package/src/ui/dialogs/pitch.ts +352 -352
- package/src/ui/dialogs/preferences.ts +40 -40
- package/src/ui/dialogs/rehearsalMark.ts +64 -64
- package/src/ui/dialogs/rehearsalMarkVue.ts +57 -57
- package/src/ui/dialogs/scoreId.ts +35 -36
- package/src/ui/dialogs/scoreView.ts +42 -42
- package/src/ui/dialogs/slur.ts +308 -310
- package/src/ui/dialogs/slurVue.ts +91 -91
- package/src/ui/dialogs/staffGroup.ts +112 -112
- package/src/ui/dialogs/tabNote.ts +84 -84
- package/src/ui/dialogs/tabStave.ts +182 -182
- package/src/ui/dialogs/tempo.ts +261 -263
- package/src/ui/dialogs/tempoVue.ts +73 -73
- package/src/ui/dialogs/textBlockVue.ts +127 -127
- package/src/ui/dialogs/textBracket.ts +114 -116
- package/src/ui/dialogs/textBracketVue.ts +56 -56
- package/src/ui/dialogs/tie.ts +140 -142
- package/src/ui/dialogs/timeSignature.ts +65 -66
- package/src/ui/dialogs/transposeScore.ts +39 -39
- package/src/ui/dialogs/unsavedChanges.ts +43 -0
- package/src/ui/dialogs/volta.ts +120 -122
- package/src/ui/dialogs/voltaVue.ts +51 -51
- package/src/ui/fileio/library.ts +110 -111
- package/src/ui/menus/edit.ts +100 -1
- package/src/ui/menus/file.ts +19 -3
- package/tests/pageDivisions.ts +156 -0
- package/tests/promiseHelpersUsage.ts +142 -0
- package/tests/scoreChangeState.ts +102 -0
- package/tests/selectVoice.ts +189 -0
- package/tests/voiceCopyPaste.ts +417 -0
|
@@ -1,184 +1,182 @@
|
|
|
1
|
-
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
-
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
-
/**
|
|
4
|
-
* Support for converting Smo object model to MIDI
|
|
5
|
-
* @module /ui/dialog/adapter
|
|
6
|
-
*/
|
|
7
|
-
import { SuiScoreViewOperations } from '../../render/sui/scoreViewOperations';
|
|
8
|
-
import { SuiTracker } from '../../render/sui/tracker';
|
|
9
|
-
import { CompleteNotifier } from '../common';
|
|
10
|
-
import { BrowserEventSource } from '../eventSource';
|
|
11
|
-
import { UndoBuffer } from '../../smo/xform/undo';
|
|
12
|
-
import { DialogDefinition, SuiDialogBase } from './dialog';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* An adapter
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @method
|
|
43
|
-
* @method
|
|
44
|
-
* @
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
view: SuiScoreViewOperations
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
abstract
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
69
|
-
* @param
|
|
70
|
-
* @param
|
|
71
|
-
*
|
|
72
|
-
* @
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
this.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
});
|
|
183
|
-
}
|
|
1
|
+
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
+
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
+
/**
|
|
4
|
+
* Support for converting Smo object model to MIDI
|
|
5
|
+
* @module /ui/dialog/adapter
|
|
6
|
+
*/
|
|
7
|
+
import { SuiScoreViewOperations } from '../../render/sui/scoreViewOperations';
|
|
8
|
+
import { SuiTracker } from '../../render/sui/tracker';
|
|
9
|
+
import { CompleteNotifier } from '../common';
|
|
10
|
+
import { BrowserEventSource } from '../eventSource';
|
|
11
|
+
import { UndoBuffer } from '../../smo/xform/undo';
|
|
12
|
+
import { DialogDefinition, SuiDialogBase } from './dialog';
|
|
13
|
+
declare var $: any;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Compute an initial dialog position near a score modifier, for Vue dialogs that want to
|
|
17
|
+
* open next to the thing they're editing instead of at the default fixed location.
|
|
18
|
+
* Mirrors the intent of the legacy `SuiDialogBase.positionFromModifier()`, adjusted for
|
|
19
|
+
* current scroll position; unlike the legacy version this does not clamp to the viewport
|
|
20
|
+
* edge or flip side when the dialog would be clipped, since that requires measuring the
|
|
21
|
+
* dialog element after it mounts.
|
|
22
|
+
* @category SuiDialog
|
|
23
|
+
*/
|
|
24
|
+
export const getModifierDialogPosition = (view: SuiScoreViewOperations, modifier: any): { top: number, left: number } | undefined => {
|
|
25
|
+
if (!modifier || !modifier.logicalBox) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const screenBox = view.renderer.pageMap.svgToClient(modifier.logicalBox);
|
|
29
|
+
const netScroll = view.tracker.scroller.netScroll;
|
|
30
|
+
return { top: screenBox.y - netScroll.y, left: screenBox.x - netScroll.x };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An adapter is the glue logic between UI components and the score view.
|
|
35
|
+
* An adapter consists mostly of accessors (get/set) for the component data. The
|
|
36
|
+
* components have their initial values set from the adapter get, and changes to components
|
|
37
|
+
* result in sets to the adapter. The adapter can then update the score.
|
|
38
|
+
* For dialogs that use this pattern,
|
|
39
|
+
* the dialog automatically creates the components and binds their values with the
|
|
40
|
+
* adapter.
|
|
41
|
+
* @method commit - called when OK button of dialog is clicked
|
|
42
|
+
* @method cancel - called when cancel button of dialog is clicked
|
|
43
|
+
* @method remove - optional. Called when 'remove' button is clicked, for artifacts like dynamics that can be removed.
|
|
44
|
+
* @category SuiDialog
|
|
45
|
+
*/
|
|
46
|
+
export abstract class SuiComponentAdapter {
|
|
47
|
+
view: SuiScoreViewOperations;
|
|
48
|
+
constructor(view: SuiScoreViewOperations) {
|
|
49
|
+
this.view = view;
|
|
50
|
+
}
|
|
51
|
+
abstract commit(): Promise<any>;
|
|
52
|
+
abstract cancel(): Promise<any>;
|
|
53
|
+
async remove(): Promise<any> {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A dialog that uses the adapter pattern takes the adapter as argument.
|
|
59
|
+
* Other than that it's the same as normal dialog parameters
|
|
60
|
+
* The adapter type is a generic, so that the specific dialog can reference the
|
|
61
|
+
* specific adapter class
|
|
62
|
+
* @param ctor constructor for reflection
|
|
63
|
+
* @param id ID for dom placement
|
|
64
|
+
* @param tracker
|
|
65
|
+
* @param completeNotifier UI component to notify when dialog is complete
|
|
66
|
+
* @param startProise UI component that notifies us when to display
|
|
67
|
+
* @param view
|
|
68
|
+
* @param eventSource where to register for KB and mouse events
|
|
69
|
+
* @param undoBuffer where to undo things we change
|
|
70
|
+
* @param adapter an adapter which has getters and setters for all of the dialog components. The adapter should
|
|
71
|
+
* read the values from the actual score, and update the score with the component values.
|
|
72
|
+
* @category SuiDialog
|
|
73
|
+
*/
|
|
74
|
+
export interface SuiDialogAdapterParams<T extends SuiComponentAdapter> {
|
|
75
|
+
ctor: string,
|
|
76
|
+
id: string,
|
|
77
|
+
tracker: SuiTracker,
|
|
78
|
+
completeNotifier: CompleteNotifier,
|
|
79
|
+
startPromise: Promise<void> | null
|
|
80
|
+
view: SuiScoreViewOperations,
|
|
81
|
+
eventSource: BrowserEventSource,
|
|
82
|
+
undoBuffer?: UndoBuffer,
|
|
83
|
+
// definition: DialogDefinition,
|
|
84
|
+
adapter: T
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* SuiDialogAdapterBase is the base class for dialogs that use the adapter pattern
|
|
89
|
+
* (almost all of them).
|
|
90
|
+
* @typeParam T a class that implements the Adapter interface and fulfills the
|
|
91
|
+
* adapter data contract, with getters and setters from the components
|
|
92
|
+
* @category SuiDialog
|
|
93
|
+
*/
|
|
94
|
+
export class SuiDialogAdapterBase<T extends SuiComponentAdapter> extends SuiDialogBase {
|
|
95
|
+
adapter: T;
|
|
96
|
+
constructor(def: DialogDefinition, params: SuiDialogAdapterParams<T>) {
|
|
97
|
+
super(def, params);
|
|
98
|
+
this.adapter = params.adapter;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Call the components bind() methods to activate them. Also, verify that each
|
|
102
|
+
* adapter meets the contract with the components
|
|
103
|
+
*/
|
|
104
|
+
bindComponents() {
|
|
105
|
+
this.components.forEach((component) => {
|
|
106
|
+
// do some runtime validation of the adapter
|
|
107
|
+
if (!component.noProperty) {
|
|
108
|
+
if (typeof((this.adapter as any)[component.smoName]) === 'undefined') {
|
|
109
|
+
throw ('Dialog ' + this.label + ' has component ' + component.smoName + ' but no setter in the adapter ');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
component.bind();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Called before dialog is displayed.
|
|
117
|
+
* components that interface (bind) with the adapter are called 'bound' components.
|
|
118
|
+
* On initialize, update the component with the score value, as told by the adapter.
|
|
119
|
+
*/
|
|
120
|
+
initialValue() {
|
|
121
|
+
this.components.forEach((comp) => {
|
|
122
|
+
(comp as any).setValue((this.adapter as any)[comp.smoName]);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* When a component changes, it notifies the parent dialog. Usually, we just
|
|
127
|
+
* proxy the call to the adapter. The specific dialog can override this method if
|
|
128
|
+
* something in the UI needs to change as a result of the component state (e.g.
|
|
129
|
+
* show or hide another component)
|
|
130
|
+
*/
|
|
131
|
+
async changed() {
|
|
132
|
+
this.components.forEach((comp) => {
|
|
133
|
+
if (comp.changeFlag) {
|
|
134
|
+
(this.adapter as any)[comp.smoName] = (comp as any).getValue();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
await this.view.updatePromise();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* If there is any 'saving' to be done when the dialog clicks OK,
|
|
141
|
+
* that is handled by the adapter. Else it can be a noop.
|
|
142
|
+
*/
|
|
143
|
+
async commit(): Promise<any> {
|
|
144
|
+
await this.adapter.commit();
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* If there is any undo or restore to be done when the dialog clicks OK,
|
|
148
|
+
* that is handled by the adapter. Else it can be a noop.
|
|
149
|
+
*/
|
|
150
|
+
async cancel(): Promise<any> {
|
|
151
|
+
await this.adapter.cancel();
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* For score artifacts that can be removed,
|
|
155
|
+
*/
|
|
156
|
+
async remove() {
|
|
157
|
+
await this.adapter.remove();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Binds the main dialog buttons. For OK/Cancel/remove, the logic calls the appropriate
|
|
161
|
+
* derived function, which calls the appropriate adapter method, then calls complete()
|
|
162
|
+
* to restore the event handling loop to the application
|
|
163
|
+
*/
|
|
164
|
+
bindElements() {
|
|
165
|
+
var dgDom = this.dgDom;
|
|
166
|
+
$(dgDom.element).find('.ok-button').off('click').on('click', () => {
|
|
167
|
+
this.view.groupUndo(false);
|
|
168
|
+
this.commit();
|
|
169
|
+
this.complete();
|
|
170
|
+
});
|
|
171
|
+
$(dgDom.element).find('.cancel-button').off('click').on('click', () => {
|
|
172
|
+
this.view.groupUndo(false);
|
|
173
|
+
this.cancel();
|
|
174
|
+
this.complete();
|
|
175
|
+
});
|
|
176
|
+
$(dgDom.element).find('.remove-button').off('click').on('click', () => {
|
|
177
|
+
this.view.groupUndo(false);
|
|
178
|
+
this.remove();
|
|
179
|
+
this.complete();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
184
182
|
}
|
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
-
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
-
import { SmoMeasure } from '../../smo/data/measure';
|
|
4
|
-
import { SmoSelection } from '../../smo/xform/selections';
|
|
5
|
-
import { SuiToggleComponent } from './components/toggle';
|
|
6
|
-
import { replaceVueRoot, modalContainerId } from '../common';
|
|
7
|
-
import addMeasuresApp from '../../ui/components/dialogs/addMeasures.vue';
|
|
8
|
-
import { SuiRockerComponent } from './components/rocker';
|
|
9
|
-
import { watch, ref, Ref } from 'vue';
|
|
10
|
-
import { DialogDefinition, SuiDialogBase, SuiDialogParams, InstallDialog } from './dialog';
|
|
11
|
-
|
|
12
|
-
declare var $: any;
|
|
13
|
-
export const SuiInsertMeasuresVue = async (parameters: SuiDialogParams) => {
|
|
14
|
-
const selection = parameters.view.tracker.selections[0];
|
|
15
|
-
const measure = selection.measure;
|
|
16
|
-
let numberMeasures = ref(1);
|
|
17
|
-
let append = ref(false);
|
|
18
|
-
const getNumberMeasures = (): Ref<number> => {
|
|
19
|
-
return numberMeasures;
|
|
20
|
-
}
|
|
21
|
-
const getAppend = (): Ref<boolean> => {
|
|
22
|
-
return append;
|
|
23
|
-
}
|
|
24
|
-
const commitCb = async () => {
|
|
25
|
-
await parameters.view.addMeasures(append.value, numberMeasures.value);
|
|
26
|
-
}
|
|
27
|
-
const cancelCb = async () => {
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const rootId = replaceVueRoot(modalContainerId);
|
|
31
|
-
const appParams = {
|
|
32
|
-
domId: rootId,
|
|
33
|
-
label: 'Insert Measures',
|
|
34
|
-
getNumberMeasures,
|
|
35
|
-
getAppend,
|
|
36
|
-
commitCb,
|
|
37
|
-
cancelCb
|
|
38
|
-
};
|
|
39
|
-
InstallDialog({
|
|
40
|
-
app: addMeasuresApp,
|
|
41
|
-
appParams,
|
|
42
|
-
root: rootId,
|
|
43
|
-
dialogParams: parameters,
|
|
44
|
-
commitCb,
|
|
45
|
-
cancelCb
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Insert some number of measures
|
|
50
|
-
* @category SuiDialog
|
|
51
|
-
*/
|
|
52
|
-
export class SuiInsertMeasures extends SuiDialogBase {
|
|
53
|
-
static dialogElements: DialogDefinition =
|
|
54
|
-
{
|
|
55
|
-
label: 'Insert Measures',
|
|
56
|
-
elements:
|
|
57
|
-
[{
|
|
58
|
-
smoName: 'measureCount',
|
|
59
|
-
defaultValue: 0,
|
|
60
|
-
control: 'SuiRockerComponent',
|
|
61
|
-
label: 'Measures to Insert'
|
|
62
|
-
}, {
|
|
63
|
-
smoName: 'append',
|
|
64
|
-
control: 'SuiToggleComponent',
|
|
65
|
-
label: 'Append to Selection'
|
|
66
|
-
}],
|
|
67
|
-
staticText: []
|
|
68
|
-
};
|
|
69
|
-
measure: SmoMeasure;
|
|
70
|
-
selection: SmoSelection;
|
|
71
|
-
constructor(parameters: SuiDialogParams) {
|
|
72
|
-
super(SuiInsertMeasures.dialogElements,
|
|
73
|
-
parameters);
|
|
74
|
-
this.selection = this.view.tracker.selections[0];
|
|
75
|
-
const selection = parameters.view.tracker.selections[0];
|
|
76
|
-
const measure = selection.measure;
|
|
77
|
-
this.measure = measure;
|
|
78
|
-
if (!this.startPromise) {
|
|
79
|
-
this.startPromise = new Promise((resolve) => {
|
|
80
|
-
resolve();
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
async commit() {
|
|
85
|
-
await this.view.addMeasures(this.appendCtrl.getValue(), this.measureCountCtrl.getValue());
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
get measureCountCtrl(): SuiRockerComponent {
|
|
89
|
-
return this.cmap.measureCountCtrl as SuiRockerComponent;
|
|
90
|
-
}
|
|
91
|
-
get appendCtrl(): SuiToggleComponent {
|
|
92
|
-
return this.cmap.appendCtrl as SuiToggleComponent;
|
|
93
|
-
}
|
|
94
|
-
populateInitial() {
|
|
95
|
-
this.measureCountCtrl.setValue(1);
|
|
96
|
-
}
|
|
97
|
-
// noop
|
|
1
|
+
// [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
|
|
2
|
+
// Copyright (c) Aaron David Newman 2021.
|
|
3
|
+
import { SmoMeasure } from '../../smo/data/measure';
|
|
4
|
+
import { SmoSelection } from '../../smo/xform/selections';
|
|
5
|
+
import { SuiToggleComponent } from './components/toggle';
|
|
6
|
+
import { replaceVueRoot, modalContainerId } from '../common';
|
|
7
|
+
import addMeasuresApp from '../../ui/components/dialogs/addMeasures.vue';
|
|
8
|
+
import { SuiRockerComponent } from './components/rocker';
|
|
9
|
+
import { watch, ref, Ref } from 'vue';
|
|
10
|
+
import { DialogDefinition, SuiDialogBase, SuiDialogParams, InstallDialog } from './dialog';
|
|
11
|
+
|
|
12
|
+
declare var $: any;
|
|
13
|
+
export const SuiInsertMeasuresVue = async (parameters: SuiDialogParams) => {
|
|
14
|
+
const selection = parameters.view.tracker.selections[0];
|
|
15
|
+
const measure = selection.measure;
|
|
16
|
+
let numberMeasures = ref(1);
|
|
17
|
+
let append = ref(false);
|
|
18
|
+
const getNumberMeasures = (): Ref<number> => {
|
|
19
|
+
return numberMeasures;
|
|
20
|
+
}
|
|
21
|
+
const getAppend = (): Ref<boolean> => {
|
|
22
|
+
return append;
|
|
23
|
+
}
|
|
24
|
+
const commitCb = async () => {
|
|
25
|
+
await parameters.view.addMeasures(append.value, numberMeasures.value);
|
|
26
|
+
}
|
|
27
|
+
const cancelCb = async () => {
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
const rootId = replaceVueRoot(modalContainerId);
|
|
31
|
+
const appParams = {
|
|
32
|
+
domId: rootId,
|
|
33
|
+
label: 'Insert Measures',
|
|
34
|
+
getNumberMeasures,
|
|
35
|
+
getAppend,
|
|
36
|
+
commitCb,
|
|
37
|
+
cancelCb
|
|
38
|
+
};
|
|
39
|
+
InstallDialog({
|
|
40
|
+
app: addMeasuresApp,
|
|
41
|
+
appParams,
|
|
42
|
+
root: rootId,
|
|
43
|
+
dialogParams: parameters,
|
|
44
|
+
commitCb,
|
|
45
|
+
cancelCb
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Insert some number of measures
|
|
50
|
+
* @category SuiDialog
|
|
51
|
+
*/
|
|
52
|
+
export class SuiInsertMeasures extends SuiDialogBase {
|
|
53
|
+
static dialogElements: DialogDefinition =
|
|
54
|
+
{
|
|
55
|
+
label: 'Insert Measures',
|
|
56
|
+
elements:
|
|
57
|
+
[{
|
|
58
|
+
smoName: 'measureCount',
|
|
59
|
+
defaultValue: 0,
|
|
60
|
+
control: 'SuiRockerComponent',
|
|
61
|
+
label: 'Measures to Insert'
|
|
62
|
+
}, {
|
|
63
|
+
smoName: 'append',
|
|
64
|
+
control: 'SuiToggleComponent',
|
|
65
|
+
label: 'Append to Selection'
|
|
66
|
+
}],
|
|
67
|
+
staticText: []
|
|
68
|
+
};
|
|
69
|
+
measure: SmoMeasure;
|
|
70
|
+
selection: SmoSelection;
|
|
71
|
+
constructor(parameters: SuiDialogParams) {
|
|
72
|
+
super(SuiInsertMeasures.dialogElements,
|
|
73
|
+
parameters);
|
|
74
|
+
this.selection = this.view.tracker.selections[0];
|
|
75
|
+
const selection = parameters.view.tracker.selections[0];
|
|
76
|
+
const measure = selection.measure;
|
|
77
|
+
this.measure = measure;
|
|
78
|
+
if (!this.startPromise) {
|
|
79
|
+
this.startPromise = new Promise((resolve) => {
|
|
80
|
+
resolve();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async commit() {
|
|
85
|
+
await this.view.addMeasures(this.appendCtrl.getValue(), this.measureCountCtrl.getValue());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get measureCountCtrl(): SuiRockerComponent {
|
|
89
|
+
return this.cmap.measureCountCtrl as SuiRockerComponent;
|
|
90
|
+
}
|
|
91
|
+
get appendCtrl(): SuiToggleComponent {
|
|
92
|
+
return this.cmap.appendCtrl as SuiToggleComponent;
|
|
93
|
+
}
|
|
94
|
+
populateInitial() {
|
|
95
|
+
this.measureCountCtrl.setValue(1);
|
|
96
|
+
}
|
|
97
|
+
// noop
|
|
98
98
|
}
|