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