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,46 +1,46 @@
1
- // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
- // Copyright (c) Aaron David Newman 2026.
3
- import { SuiDialogParams, InstallDialog } from './dialog';
4
- import { SmoSelector } from '../../smo/xform/selections';
5
- import lyricComp from '../components/dialogs/lyric.vue';
6
- import { replaceVueRoot, modalContainerId } from '../common';
7
-
8
- /**
9
- * Vue-based replacement for SuiLyricDialog (src/ui/dialogs/lyric.ts),
10
- * following the SuiTextBlockDialogVue creation-function pattern.
11
- * SuiLyricDialog and its call sites are unchanged; nothing wires callers
12
- * over to this function yet (see specs/010-vue-lyric-dialog).
13
- */
14
- export const SuiLyricDialogVue = (parameters: SuiDialogParams) => {
15
- const rootId = replaceVueRoot(modalContainerId);
16
- const view = parameters.view;
17
- const tracker = view.tracker;
18
- const initialSelector: SmoSelector = JSON.parse(JSON.stringify(tracker.selections[0].selector));
19
-
20
- // Lyric text, deletions, verse/Y/font changes are all committed to the
21
- // score incrementally as the user types/navigates/deletes/adjusts
22
- // (see specs/010-vue-lyric-dialog/research.md §3-4, §8) -- unlike
23
- // SuiTextBlockDialogVue, there is no working copy to commit or revert
24
- // at dialog-close time, matching SuiLyricDialog wiring both its OK and
25
- // Cancel buttons to the same no-groupUndo _complete(). lyric.vue's own
26
- // handleCommit/handleCancel do the one remaining thing (commit whatever
27
- // note is currently being edited) before calling these.
28
- const commitCb = async () => {};
29
- const cancelCb = async () => {};
30
-
31
- const appParams = {
32
- domId: rootId,
33
- label: 'Lyric Editor',
34
- view,
35
- initialSelector
36
- };
37
-
38
- InstallDialog({
39
- root: rootId,
40
- app: lyricComp,
41
- appParams,
42
- dialogParams: parameters,
43
- commitCb,
44
- cancelCb
45
- });
46
- };
1
+ // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
+ // Copyright (c) Aaron David Newman 2026.
3
+ import { SuiDialogParams, InstallDialog } from './dialog';
4
+ import { SmoSelector } from '../../smo/xform/selections';
5
+ import lyricComp from '../components/dialogs/lyric.vue';
6
+ import { replaceVueRoot, modalContainerId } from '../common';
7
+
8
+ /**
9
+ * Vue-based replacement for SuiLyricDialog (src/ui/dialogs/lyric.ts),
10
+ * following the SuiTextBlockDialogVue creation-function pattern.
11
+ * SuiLyricDialog and its call sites are unchanged; nothing wires callers
12
+ * over to this function yet (see specs/010-vue-lyric-dialog).
13
+ */
14
+ export const SuiLyricDialogVue = (parameters: SuiDialogParams) => {
15
+ const rootId = replaceVueRoot(modalContainerId);
16
+ const view = parameters.view;
17
+ const tracker = view.tracker;
18
+ const initialSelector: SmoSelector = JSON.parse(JSON.stringify(tracker.selections[0].selector));
19
+
20
+ // Lyric text, deletions, verse/Y/font changes are all committed to the
21
+ // score incrementally as the user types/navigates/deletes/adjusts
22
+ // (see specs/010-vue-lyric-dialog/research.md §3-4, §8) -- unlike
23
+ // SuiTextBlockDialogVue, there is no working copy to commit or revert
24
+ // at dialog-close time, matching SuiLyricDialog wiring both its OK and
25
+ // Cancel buttons to the same no-groupUndo _complete(). lyric.vue's own
26
+ // handleCommit/handleCancel do the one remaining thing (commit whatever
27
+ // note is currently being edited) before calling these.
28
+ const commitCb = async () => {};
29
+ const cancelCb = async () => {};
30
+
31
+ const appParams = {
32
+ domId: rootId,
33
+ label: 'Lyric Editor',
34
+ view,
35
+ initialSelector
36
+ };
37
+
38
+ InstallDialog({
39
+ root: rootId,
40
+ app: lyricComp,
41
+ appParams,
42
+ dialogParams: parameters,
43
+ commitCb,
44
+ cancelCb
45
+ });
46
+ };
@@ -1,78 +1,78 @@
1
- // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
- // Copyright (c) Aaron David Newman 2021.
3
- import { SmoMeasureFormat } from '../../smo/data/measureModifiers';
4
- import { SuiDialogParams, InstallDialog } from './dialog';
5
- import { replaceVueRoot, modalContainerId } from '../common';
6
- import measureFormatApp from '../../ui/components/dialogs/measureFormat.vue';
7
-
8
- declare var $: any;
9
-
10
- export const SuiMeasureFormatDialogVue = async (parameters: SuiDialogParams) => {
11
- const selection = parameters.view.tracker.selections[0];
12
- const measure = selection.measure;
13
- let measureCount = 0;
14
- if (parameters.view.score.isPartExposed()) {
15
- const partInfo = parameters.view.score.staves[0].partInfo;
16
- measureCount = partInfo.layoutManager.globalLayout.maxMeasureSystem;
17
- } else {
18
- measureCount = parameters.view.score.layoutManager?.globalLayout.maxMeasureSystem || 0;
19
- }
20
- const isPart = parameters.view.score.isPartExposed();
21
- const measureFormat = new SmoMeasureFormat(measure.format);
22
- let changed = false;
23
- const backup = new SmoMeasureFormat(measureFormat);
24
-
25
- // Default the measure index to the first selected measure
26
- let displayMeasure = measure.measureNumber.displayMeasure;
27
- const initialDisplayMeasure = measure.measureNumber.displayMeasure;
28
- const measureNumberCb = async (newIndex: number) => {
29
- // Renumber measures to reflect new index
30
- if (newIndex !== measure.measureNumber.displayMeasure) {
31
- changed = true;
32
- displayMeasure = newIndex;
33
- }
34
- await parameters.view.renumberMeasures(measure.measureNumber.measureIndex, newIndex);
35
- }
36
- const updateMeasureFormatCb = async (mf: SmoMeasureFormat) => {
37
- changed = true;
38
- const newValue = new SmoMeasureFormat(mf);
39
- // The default index value is 0, so restore to default if unchanged
40
- if (mf.measureIndex === measure.measureNumber.displayMeasure) {
41
- newValue.measureIndex = 0;
42
- }
43
- await parameters.view.setMeasureFormat(newValue);
44
- }
45
- const commitCb = async() => {
46
- if (changed) {
47
- parameters.view.resetPartView();
48
- await parameters.view.refreshViewport();
49
- }
50
- }
51
- const cancelCb = async() => {
52
- if (changed) {
53
- await parameters.view.setMeasureFormat(backup);
54
- }
55
- }
56
- const rootId = replaceVueRoot(modalContainerId);
57
- const appParams = {
58
- domId: rootId,
59
- measureFormat,
60
- isPart,
61
- initialDisplayMeasure,
62
- measureNumberCb,
63
- commitCb,
64
- cancelCb,
65
- label: 'Measure Formatting',
66
- measureCount,
67
- updateMeasureFormatCb
68
- }
69
- InstallDialog({
70
- app: measureFormatApp,
71
- appParams,
72
- root: rootId,
73
- dialogParams: parameters,
74
- commitCb,
75
- cancelCb
76
- });
77
-
78
- }
1
+ // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
+ // Copyright (c) Aaron David Newman 2021.
3
+ import { SmoMeasureFormat } from '../../smo/data/measureModifiers';
4
+ import { SuiDialogParams, InstallDialog } from './dialog';
5
+ import { replaceVueRoot, modalContainerId } from '../common';
6
+ import measureFormatApp from '../../ui/components/dialogs/measureFormat.vue';
7
+
8
+ declare var $: any;
9
+
10
+ export const SuiMeasureFormatDialogVue = async (parameters: SuiDialogParams) => {
11
+ const selection = parameters.view.tracker.selections[0];
12
+ const measure = selection.measure;
13
+ let measureCount = 0;
14
+ if (parameters.view.score.isPartExposed()) {
15
+ const partInfo = parameters.view.score.staves[0].partInfo;
16
+ measureCount = partInfo.layoutManager.globalLayout.maxMeasureSystem;
17
+ } else {
18
+ measureCount = parameters.view.score.layoutManager?.globalLayout.maxMeasureSystem || 0;
19
+ }
20
+ const isPart = parameters.view.score.isPartExposed();
21
+ const measureFormat = new SmoMeasureFormat(measure.format);
22
+ let changed = false;
23
+ const backup = new SmoMeasureFormat(measureFormat);
24
+
25
+ // Default the measure index to the first selected measure
26
+ let displayMeasure = measure.measureNumber.displayMeasure;
27
+ const initialDisplayMeasure = measure.measureNumber.displayMeasure;
28
+ const measureNumberCb = async (newIndex: number) => {
29
+ // Renumber measures to reflect new index
30
+ if (newIndex !== measure.measureNumber.displayMeasure) {
31
+ changed = true;
32
+ displayMeasure = newIndex;
33
+ }
34
+ await parameters.view.renumberMeasures(measure.measureNumber.measureIndex, newIndex);
35
+ }
36
+ const updateMeasureFormatCb = async (mf: SmoMeasureFormat) => {
37
+ changed = true;
38
+ const newValue = new SmoMeasureFormat(mf);
39
+ // The default index value is 0, so restore to default if unchanged
40
+ if (mf.measureIndex === measure.measureNumber.displayMeasure) {
41
+ newValue.measureIndex = 0;
42
+ }
43
+ await parameters.view.setMeasureFormat(newValue);
44
+ }
45
+ const commitCb = async() => {
46
+ if (changed) {
47
+ parameters.view.resetPartView();
48
+ await parameters.view.refreshViewport();
49
+ }
50
+ }
51
+ const cancelCb = async() => {
52
+ if (changed) {
53
+ await parameters.view.setMeasureFormat(backup);
54
+ }
55
+ }
56
+ const rootId = replaceVueRoot(modalContainerId);
57
+ const appParams = {
58
+ domId: rootId,
59
+ measureFormat,
60
+ isPart,
61
+ initialDisplayMeasure,
62
+ measureNumberCb,
63
+ commitCb,
64
+ cancelCb,
65
+ label: 'Measure Formatting',
66
+ measureCount,
67
+ updateMeasureFormatCb
68
+ }
69
+ InstallDialog({
70
+ app: measureFormatApp,
71
+ appParams,
72
+ root: rootId,
73
+ dialogParams: parameters,
74
+ commitCb,
75
+ cancelCb
76
+ });
77
+
78
+ }
@@ -1,148 +1,148 @@
1
- // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
- // Copyright (c) Aaron David Newman 2021.
3
- import { SuiScoreViewOperations } from '../../render/sui/scoreViewOperations';
4
- import { DialogDefinition, SuiDialogParams, InstallDialog } from './dialog';
5
- import { SuiComponentAdapter, SuiDialogAdapterBase } from './adapter';
6
- import { getButtonsFcn, SuiButtonArrayComponent, SuiButtonArrayParameters } from './components/buttonArray';
7
- import { SuiDialogNotifier, SuiBaseComponentParams } from './components/baseComponent';
8
- import { SmoMicrotone } from '../../smo/data/noteModifiers';
9
- import { replaceVueRoot, modalContainerId } from '../common';
10
- import { DialogButtonDefinition, DialogButtonState } from '../buttons/button';
11
- import { reactive } from 'vue';
12
- import { SmoScore } from '../../smo/data/score';
13
- import { SmoSelection } from '../../smo/xform/selections';
14
- import microtoneApp from '../components/dialogs/microtones.vue';
15
-
16
- export const SuiMicrotoneDialogVue = (parameters: SuiDialogParams) => {
17
- const rootId = replaceVueRoot(modalContainerId);
18
- const setForAll: Record<string, number> = {};
19
- let notesCount = 0;
20
- parameters.view.tracker.selections.forEach((sel) => {
21
- const microtones = sel.note!.getMicrotones();
22
- notesCount += 1;
23
- microtones.forEach((microtone) => {
24
- if (!setForAll[microtone.tone]) {
25
- setForAll[microtone.tone] = 0;
26
- }
27
- setForAll[microtone.tone] = setForAll[microtone.tone] + 1;
28
- });
29
- });
30
- const keys = Object.keys(setForAll);
31
- const transitionButtonState = (button: DialogButtonDefinition) => {
32
- if (button.state === 'selected') {
33
- button.state = 'unselected';
34
- } else {
35
- button.state = 'selected';
36
- }
37
- }
38
- const microtoneCb = async (button: DialogButtonDefinition) => {
39
- transitionButtonState(button);
40
- const code = button.id;
41
- await parameters.view.modifyCurrentSelections('microtone', (score: SmoScore, selections: SmoSelection[]) => {
42
- for (let i = 0; i < selections.length; ++i) {
43
- const sel = selections[i];
44
- const note = sel.note!;
45
- note.removeMicrotone();
46
- if (button.state === 'selected') {
47
- const defs = SmoMicrotone.defaults;
48
- defs.tone = code;
49
- note.addMicrotone(new SmoMicrotone(defs));
50
- }
51
- }
52
- });
53
- }
54
- const accidentals: DialogButtonDefinition[] = reactive([{
55
- classes: '',
56
- icon: 'icon-bravura icon-accidentalThreeQuarterTonesFlatZimmermann',
57
- id: 'flat75sz',
58
- hotkey: '',
59
- label: '3/4 Flat',
60
- callback: microtoneCb,
61
- state: 'unselected',
62
- group: 'accidentals'
63
- }, {
64
- classes: '',
65
- icon: 'icon-bravura icon-accidentalQuarterToneFlatStein',
66
- id: 'flat25sz',
67
- hotkey: '',
68
- label: '1/4 Flat',
69
- callback: microtoneCb,
70
- state: 'unselected',
71
- group: 'accidentals'
72
- }, {
73
- classes: '',
74
- icon: 'icon-bravura icon-accidentalBakiyeFlat',
75
- id: 'flat25ar',
76
- hotkey: '',
77
- label: '1/4 flat (Armenian)',
78
- callback: microtoneCb,
79
- state: 'unselected',
80
- group: 'accidentals'
81
- }, {
82
- classes: '',
83
- icon: 'icon-bravura icon-accidentalThreeQuarterTonesSharpStein',
84
- id: 'sharp75',
85
- hotkey: '',
86
- label: '3/4 Sharp',
87
- callback: microtoneCb,
88
- state: 'unselected',
89
- group: 'Glyphs'
90
- }, {
91
- classes: '',
92
- icon: 'icon-bravura icon-accidentalQuarterToneSharpStein',
93
- id: 'sharp25',
94
- hotkey: '',
95
- label: '1/4 Sharp',
96
- callback: microtoneCb,
97
- state: 'unselected',
98
- group: 'accidentals'
99
- }, {
100
- classes: '',
101
- icon: 'icon-bravura icon-accidentalSori',
102
- id: 'sori',
103
- hotkey: '',
104
- label: 'Bow Down',
105
- callback: microtoneCb,
106
- state: 'unselected',
107
- group: 'accidentals'
108
- }, {
109
- classes: '',
110
- icon: 'icon-bravura icon-accidentalKoron',
111
- id: 'koron',
112
- hotkey: '',
113
- label: 'Koron',
114
- callback: microtoneCb,
115
- state: 'unselected',
116
- group: 'accidentals'
117
- }
118
- ]);
119
-
120
- keys.forEach((key) => {
121
- if (setForAll[key] === notesCount) {
122
- let btnId = accidentals.find((btn) => btn.id === key);
123
- if (btnId) {
124
- btnId.state = 'selected';
125
- }
126
- } else {
127
- let btnId = accidentals.find((btn) => btn.id === key);
128
- if (btnId) {
129
- btnId.state = 'partiallySelected';
130
- }
131
- }
132
- });
133
-
134
- // Undo on cancel for any changes made
135
- parameters.view.groupUndo(true);
136
- const commitCb = async () => {
137
- }
138
- const cancelCb = async () => {
139
- await parameters.view.undo();
140
- }
141
- const appParams = {
142
- domId: rootId,
143
- microtoneCb,
144
- accidentals
145
- };
146
-
147
- InstallDialog({ root: rootId, app: microtoneApp, appParams, dialogParams: parameters, commitCb, cancelCb });
1
+ // [Smoosic](https://github.com/AaronDavidNewman/Smoosic)
2
+ // Copyright (c) Aaron David Newman 2021.
3
+ import { SuiScoreViewOperations } from '../../render/sui/scoreViewOperations';
4
+ import { DialogDefinition, SuiDialogParams, InstallDialog } from './dialog';
5
+ import { SuiComponentAdapter, SuiDialogAdapterBase } from './adapter';
6
+ import { getButtonsFcn, SuiButtonArrayComponent, SuiButtonArrayParameters } from './components/buttonArray';
7
+ import { SuiDialogNotifier, SuiBaseComponentParams } from './components/baseComponent';
8
+ import { SmoMicrotone } from '../../smo/data/noteModifiers';
9
+ import { replaceVueRoot, modalContainerId } from '../common';
10
+ import { DialogButtonDefinition, DialogButtonState } from '../buttons/button';
11
+ import { reactive } from 'vue';
12
+ import { SmoScore } from '../../smo/data/score';
13
+ import { SmoSelection } from '../../smo/xform/selections';
14
+ import microtoneApp from '../components/dialogs/microtones.vue';
15
+
16
+ export const SuiMicrotoneDialogVue = (parameters: SuiDialogParams) => {
17
+ const rootId = replaceVueRoot(modalContainerId);
18
+ const setForAll: Record<string, number> = {};
19
+ let notesCount = 0;
20
+ parameters.view.tracker.selections.forEach((sel) => {
21
+ const microtones = sel.note!.getMicrotones();
22
+ notesCount += 1;
23
+ microtones.forEach((microtone) => {
24
+ if (!setForAll[microtone.tone]) {
25
+ setForAll[microtone.tone] = 0;
26
+ }
27
+ setForAll[microtone.tone] = setForAll[microtone.tone] + 1;
28
+ });
29
+ });
30
+ const keys = Object.keys(setForAll);
31
+ const transitionButtonState = (button: DialogButtonDefinition) => {
32
+ if (button.state === 'selected') {
33
+ button.state = 'unselected';
34
+ } else {
35
+ button.state = 'selected';
36
+ }
37
+ }
38
+ const microtoneCb = async (button: DialogButtonDefinition) => {
39
+ transitionButtonState(button);
40
+ const code = button.id;
41
+ await parameters.view.modifyCurrentSelections('microtone', (score: SmoScore, selections: SmoSelection[]) => {
42
+ for (let i = 0; i < selections.length; ++i) {
43
+ const sel = selections[i];
44
+ const note = sel.note!;
45
+ note.removeMicrotone();
46
+ if (button.state === 'selected') {
47
+ const defs = SmoMicrotone.defaults;
48
+ defs.tone = code;
49
+ note.addMicrotone(new SmoMicrotone(defs));
50
+ }
51
+ }
52
+ });
53
+ }
54
+ const accidentals: DialogButtonDefinition[] = reactive([{
55
+ classes: '',
56
+ icon: 'icon-bravura icon-accidentalThreeQuarterTonesFlatZimmermann',
57
+ id: 'flat75sz',
58
+ hotkey: '',
59
+ label: '3/4 Flat',
60
+ callback: microtoneCb,
61
+ state: 'unselected',
62
+ group: 'accidentals'
63
+ }, {
64
+ classes: '',
65
+ icon: 'icon-bravura icon-accidentalQuarterToneFlatStein',
66
+ id: 'flat25sz',
67
+ hotkey: '',
68
+ label: '1/4 Flat',
69
+ callback: microtoneCb,
70
+ state: 'unselected',
71
+ group: 'accidentals'
72
+ }, {
73
+ classes: '',
74
+ icon: 'icon-bravura icon-accidentalBakiyeFlat',
75
+ id: 'flat25ar',
76
+ hotkey: '',
77
+ label: '1/4 flat (Armenian)',
78
+ callback: microtoneCb,
79
+ state: 'unselected',
80
+ group: 'accidentals'
81
+ }, {
82
+ classes: '',
83
+ icon: 'icon-bravura icon-accidentalThreeQuarterTonesSharpStein',
84
+ id: 'sharp75',
85
+ hotkey: '',
86
+ label: '3/4 Sharp',
87
+ callback: microtoneCb,
88
+ state: 'unselected',
89
+ group: 'Glyphs'
90
+ }, {
91
+ classes: '',
92
+ icon: 'icon-bravura icon-accidentalQuarterToneSharpStein',
93
+ id: 'sharp25',
94
+ hotkey: '',
95
+ label: '1/4 Sharp',
96
+ callback: microtoneCb,
97
+ state: 'unselected',
98
+ group: 'accidentals'
99
+ }, {
100
+ classes: '',
101
+ icon: 'icon-bravura icon-accidentalSori',
102
+ id: 'sori',
103
+ hotkey: '',
104
+ label: 'Bow Down',
105
+ callback: microtoneCb,
106
+ state: 'unselected',
107
+ group: 'accidentals'
108
+ }, {
109
+ classes: '',
110
+ icon: 'icon-bravura icon-accidentalKoron',
111
+ id: 'koron',
112
+ hotkey: '',
113
+ label: 'Koron',
114
+ callback: microtoneCb,
115
+ state: 'unselected',
116
+ group: 'accidentals'
117
+ }
118
+ ]);
119
+
120
+ keys.forEach((key) => {
121
+ if (setForAll[key] === notesCount) {
122
+ let btnId = accidentals.find((btn) => btn.id === key);
123
+ if (btnId) {
124
+ btnId.state = 'selected';
125
+ }
126
+ } else {
127
+ let btnId = accidentals.find((btn) => btn.id === key);
128
+ if (btnId) {
129
+ btnId.state = 'partiallySelected';
130
+ }
131
+ }
132
+ });
133
+
134
+ // Undo on cancel for any changes made
135
+ parameters.view.groupUndo(true);
136
+ const commitCb = async () => {
137
+ }
138
+ const cancelCb = async () => {
139
+ await parameters.view.undo();
140
+ }
141
+ const appParams = {
142
+ domId: rootId,
143
+ microtoneCb,
144
+ accidentals
145
+ };
146
+
147
+ InstallDialog({ root: rootId, app: microtoneApp, appParams, dialogParams: parameters, commitCb, cancelCb });
148
148
  }