smoosic 1.0.42 → 1.0.43

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.
@@ -274,11 +274,23 @@ export class SuiRenderState implements SuiRendererBase {
274
274
  this.handlingRedraw = false;
275
275
  }
276
276
  }
277
+ delay2 = async () => {
278
+ return new Promise<void>((resolve) => {
279
+ setTimeout(() => {
280
+ resolve();
281
+ }, this.demonPollTime);
282
+ });
283
+ }
284
+ async pollRedrawTask() {
285
+ while (true) {
286
+ await this.handleRedrawTimer();
287
+ await this.delay2();
288
+ }
289
+ }
277
290
  pollRedraw() {
278
291
  setTimeout(async () => {
279
- await this.handleRedrawTimer();
280
- this.pollRedraw();
281
- }, this.demonPollTime);
292
+ this.pollRedrawTask();
293
+ }, 1);
282
294
  }
283
295
 
284
296
  startDemon() {
@@ -1230,7 +1230,7 @@ export class SmoScore {
1230
1230
  newMeasure.transposeIndex = 0;
1231
1231
  // Consider key change if the proto measure is non-concert pitch
1232
1232
  newMeasure.keySignature =
1233
- SmoMusic.vexKeySigWithOffset(newMeasure.keySignature,
1233
+ SmoMusic.vexKeySigWithOffset(measure.keySignature,
1234
1234
  newMeasure.transposeIndex - measure.transposeIndex);
1235
1235
  newMeasure.voices = [{ notes: SmoMeasure.getDefaultNotes(newMeasure) }];
1236
1236
  measure.modifiers.forEach((modifier) => {
@@ -1242,6 +1242,14 @@ export class SmoScore {
1242
1242
  parameters.measures = measures;
1243
1243
  const staff = new SmoSystemStaff(parameters);
1244
1244
  this.staves.push(staff);
1245
+ let newPos = parameters.staffId;
1246
+ let curPos = this.staves.length - 1;
1247
+ while (curPos > newPos) {
1248
+ const lastStaff = this.staves[curPos];
1249
+ this.staves[curPos] = this.staves[curPos - 1];
1250
+ this.staves[curPos - 1] = lastStaff;
1251
+ curPos -= 1;
1252
+ }
1245
1253
  this.activeStaff = this.staves.length - 1;
1246
1254
  this.numberStaves();
1247
1255
  return staff;
@@ -9,8 +9,10 @@ import { computed, ref, Ref, reactive, watch } from 'vue';
9
9
  interface Props {
10
10
  domId: string,
11
11
  label: string,
12
+ staffLength: number,
12
13
  getInstrument: () => SmoInstrument,
13
14
  addStaveCb: () => Promise<void>,
15
+ setStaffId: (staffId: number) => void,
14
16
  commitCb: () => Promise<void>,
15
17
  cancelCb: () => Promise<void>
16
18
  };
@@ -18,6 +20,9 @@ const props = defineProps<Props>();
18
20
 
19
21
  const { domId, getInstrument } = { ...props };
20
22
 
23
+ const updateInsertLocation = async (loc: number) => {
24
+ props.setStaffId(loc);
25
+ }
21
26
  const instrumentChoices: SelectOption[] = [{
22
27
  value: 'piano',
23
28
  label: 'Grand Piano'
@@ -128,6 +133,7 @@ const updateClefCb = async (value: string) => {
128
133
  const getId = (str: string) => {
129
134
  return `${domId}-${str}`;
130
135
  }
136
+
131
137
  </script>
132
138
  <template>
133
139
  <dialogContainer :domId="domId" :label="label" :commitCb="props.commitCb" :cancelCb="props.cancelCb">
@@ -159,6 +165,13 @@ const getId = (str: string) => {
159
165
  <label class="form-check-label" :for="getId('font-weight')">Use Percussion Symbols</label>
160
166
  </div>
161
167
  </div>
168
+ <div class="row mb-2 ms-2 align-items-center">
169
+ <div class="col col-8 ps-0">
170
+ <numberInputApp :domId="getId('staffId')" :initialValue="props.staffLength - 1" :precision="0"
171
+ :maxValue="props.staffLength" :minValue="1"
172
+ :changeCb="updateInsertLocation"></numberInputApp>
173
+ </div>
174
+ </div>
162
175
  <div class="row mb-2">
163
176
  <div class="col col-8 ps-0">
164
177
  <numberInputApp :domId="getId('stafflines')" :initialValue="instrument.lines" :precision="0"
@@ -60,17 +60,24 @@ export const SuiCreatePartVue = (parameters: SuiDialogParams) => {
60
60
  const selection = parameters.view.tracker.selections[0];
61
61
  const instrument = new SmoInstrument(parameters.view.score.getStaffInstrument(selection.selector));
62
62
  let addStave = false;
63
+ const staffLocation = ref(parameters.view.storeScore.staves.length - 1);
63
64
  const addStaveCb = () => {
64
65
  addStave = !addStave;
65
66
  }
67
+ const setStaffId = (staffId: number) => {
68
+ if (staffId < parameters.view.storeScore.staves.length && staffId >= 0) {
69
+ staffLocation.value = staffId;
70
+ }
71
+ }
66
72
  const commitCb = async () => {
67
73
  const staffParams: SmoSystemStaffParams = SmoSystemStaff.defaults;
68
74
  staffParams.staffId = parameters.view.storeScore.staves.length;
69
75
  staffParams.measureInstrumentMap[0] = instrument;
76
+ staffParams.staffId = staffLocation.value;
70
77
  await parameters.view.addStaff(staffParams);
71
78
  if (addStave) {
72
79
  const staffParams2: SmoSystemStaffParams = SmoSystemStaff.defaults;
73
- staffParams2.staffId = parameters.view.storeScore.staves.length;
80
+ staffParams2.staffId = staffParams.staffId + 1;
74
81
  const instParams: SmoInstrumentParams = SmoInstrument.defaults;
75
82
  instParams.instrument = instrument.instrument;
76
83
  instParams.clef = instrument.clef === 'treble' ? 'bass' : 'treble';
@@ -79,7 +86,7 @@ export const SuiCreatePartVue = (parameters: SuiDialogParams) => {
79
86
  await parameters.view.addStaff(staffParams2);
80
87
  const partInfo = parameters.view.score.staves[staffParams.staffId].partInfo;
81
88
  partInfo.stavesAfter = 1;
82
- }
89
+ }
83
90
  }
84
91
  const cancelCb = async () => {
85
92
  }
@@ -88,8 +95,10 @@ export const SuiCreatePartVue = (parameters: SuiDialogParams) => {
88
95
  const appParams = {
89
96
  domId: replaceVueRoot(modalContainerId),
90
97
  label: 'Instrument Properties',
98
+ staffLength: parameters.view.storeScore.staves.length,
91
99
  getInstrument,
92
- addStaveCb
100
+ addStaveCb,
101
+ setStaffId
93
102
  }
94
103
  const rootId = replaceVueRoot(modalContainerId);
95
104
  InstallDialog({