|
@@ -37,7 +37,8 @@ typedef struct cmSmgBox_str
|
37
|
37
|
unsigned top;
|
38
|
38
|
unsigned width;
|
39
|
39
|
unsigned height;
|
40
|
|
- cmChar_t* text;
|
|
40
|
+ cmChar_t* text0;
|
|
41
|
+ cmChar_t* text1;
|
41
|
42
|
struct cmSmgBox_str* link;
|
42
|
43
|
} cmSmgBox_t;
|
43
|
44
|
|
|
@@ -90,6 +91,9 @@ typedef struct
|
90
|
91
|
cmSmgLoc_t* locV;
|
91
|
92
|
unsigned locN;
|
92
|
93
|
cmSmgLine_t* lines;
|
|
94
|
+
|
|
95
|
+ unsigned boxW;
|
|
96
|
+ unsigned boxH;
|
93
|
97
|
} cmSmg_t;
|
94
|
98
|
|
95
|
99
|
cmSmgH_t cmSmgNullHandle = cmSTATIC_NULL_HANDLE;
|
|
@@ -124,7 +128,8 @@ cmSmgRC_t _cmSmgFree( cmSmg_t* p )
|
124
|
128
|
while(b0!=NULL)
|
125
|
129
|
{
|
126
|
130
|
b1 = b0->link;
|
127
|
|
- cmMemFree(b0->text);
|
|
131
|
+ cmMemFree(b0->text0);
|
|
132
|
+ cmMemFree(b0->text1);
|
128
|
133
|
cmMemFree(b0);
|
129
|
134
|
b0 = b1;
|
130
|
135
|
}
|
|
@@ -146,14 +151,15 @@ cmSmgRC_t _cmSmgFree( cmSmg_t* p )
|
146
|
151
|
return kOkSmgRC;
|
147
|
152
|
}
|
148
|
153
|
|
149
|
|
-cmSmgBox_t* _cmSmgInsertBox( cmSmg_t* p, unsigned locIdx, unsigned flags, unsigned id, cmChar_t* text )
|
|
154
|
+cmSmgBox_t* _cmSmgInsertBox( cmSmg_t* p, unsigned locIdx, unsigned flags, unsigned id, cmChar_t* text0, cmChar_t* text1 )
|
150
|
155
|
{
|
151
|
156
|
assert( locIdx < p->locN );
|
152
|
157
|
|
153
|
158
|
cmSmgBox_t* b = cmMemAllocZ(cmSmgBox_t,1);
|
154
|
|
- b->flags = flags;
|
155
|
|
- b->id = id;
|
156
|
|
- b->text = text;
|
|
159
|
+ b->flags = flags;
|
|
160
|
+ b->id = id;
|
|
161
|
+ b->text0 = text0;
|
|
162
|
+ b->text1 = text1;
|
157
|
163
|
|
158
|
164
|
if( p->locV[locIdx].bV == NULL )
|
159
|
165
|
{
|
|
@@ -192,7 +198,7 @@ cmSmgRC_t _cmSmgInitFromScore( cmCtx_t* ctx, cmSmg_t* p, const cmChar_t* scoreFn
|
192
|
198
|
cmScoreLoc_t* l = cmScoreLoc(scH,i);
|
193
|
199
|
|
194
|
200
|
// insert the location label box
|
195
|
|
- _cmSmgInsertBox(p, i, kLocSmgFl, cmInvalidId, cmTsPrintfP(NULL,"%i",i) );
|
|
201
|
+ _cmSmgInsertBox(p, i, kLocSmgFl, cmInvalidId, cmTsPrintfP(NULL,"%i",i), NULL );
|
196
|
202
|
|
197
|
203
|
// for each event in location i
|
198
|
204
|
for(j=0; j<l->evtCnt; ++j)
|
|
@@ -219,7 +225,7 @@ cmSmgRC_t _cmSmgInitFromScore( cmCtx_t* ctx, cmSmg_t* p, const cmChar_t* scoreFn
|
219
|
225
|
else
|
220
|
226
|
text = cmMemAllocStr( cmMidiToSciPitch( e->pitch, NULL, 0));
|
221
|
227
|
|
222
|
|
- p->scV[k].box = _cmSmgInsertBox(p, i, flags, e->csvEventId, text );
|
|
228
|
+ p->scV[k].box = _cmSmgInsertBox(p, i, flags, e->csvEventId, text, NULL );
|
223
|
229
|
|
224
|
230
|
k += 1;
|
225
|
231
|
}
|
|
@@ -282,6 +288,8 @@ cmSmgRC_t cmScoreMatchGraphicAlloc( cmCtx_t* ctx, cmSmgH_t* hp, const cmChar_t*
|
282
|
288
|
if((rc = _cmSmgInitFromMidi(ctx,p,midiFn)) != kOkSmgRC )
|
283
|
289
|
goto errLabel;
|
284
|
290
|
|
|
291
|
+ p->boxW = 30;
|
|
292
|
+ p->boxH = 50;
|
285
|
293
|
hp->h = p;
|
286
|
294
|
|
287
|
295
|
errLabel:
|
|
@@ -385,7 +393,7 @@ void _cmSmgResolveMidi( cmSmg_t* p )
|
385
|
393
|
cmChar_t* text = cmMemAllocStr( cmMidiToSciPitch( p->mV[i].pitch, NULL, 0));
|
386
|
394
|
|
387
|
395
|
// insert a box to represent this midi event
|
388
|
|
- cmSmgBox_t* box = _cmSmgInsertBox( p, locIdx, flags, p->mV[i].uid, text );
|
|
396
|
+ cmSmgBox_t* box = _cmSmgInsertBox( p, locIdx, flags, p->mV[i].uid, text, cmTsPrintfP(NULL,"%i",p->mV[i].uid) );
|
389
|
397
|
|
390
|
398
|
prevLocIdx = locIdx;
|
391
|
399
|
|
|
@@ -412,9 +420,7 @@ void _cmSmgLayout( cmSmg_t* p )
|
412
|
420
|
unsigned i;
|
413
|
421
|
unsigned bordX = 5;
|
414
|
422
|
unsigned bordY = 5;
|
415
|
|
- unsigned boxH = 30;
|
416
|
|
- unsigned boxW = 30;
|
417
|
|
- unsigned top = boxH + 2*bordY;
|
|
423
|
+ unsigned top = p->boxH + 2*bordY;
|
418
|
424
|
unsigned left = bordX;
|
419
|
425
|
|
420
|
426
|
for(i=0; i<p->locN; ++i)
|
|
@@ -431,16 +437,16 @@ void _cmSmgLayout( cmSmg_t* p )
|
431
|
437
|
else
|
432
|
438
|
{
|
433
|
439
|
b->top = top;
|
434
|
|
- top += boxH + bordY;
|
|
440
|
+ top += p->boxH + bordY;
|
435
|
441
|
}
|
436
|
442
|
|
437
|
443
|
b->left = left;
|
438
|
|
- b->width = boxW;
|
439
|
|
- b->height = boxH;
|
|
444
|
+ b->width = p->boxW;
|
|
445
|
+ b->height = p->boxH;
|
440
|
446
|
}
|
441
|
447
|
|
442
|
|
- left += boxW + bordX;
|
443
|
|
- top = boxH + 2*bordY;
|
|
448
|
+ left += p->boxW + bordX;
|
|
449
|
+ top = p->boxH + 2*bordY;
|
444
|
450
|
}
|
445
|
451
|
}
|
446
|
452
|
|
|
@@ -521,12 +527,21 @@ cmSmgRC_t cmScoreMatchGraphicWrite( cmSmgH_t h, const cmChar_t* fn )
|
521
|
527
|
if( cmFilePrintf(fH,"<rect x=\"%i\" y=\"%i\" width=\"%i\" height=\"%i\" class=\"%s\"/>\n",b->left,b->top,b->width,b->height,classStr) != kOkFileRC )
|
522
|
528
|
return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file rect output.");
|
523
|
529
|
|
524
|
|
- if( b->text != NULL )
|
|
530
|
+ if( b->text0 != NULL )
|
|
531
|
+ {
|
|
532
|
+ unsigned tx = b->left + b->width/2;
|
|
533
|
+ unsigned ty = b->top + 20;
|
|
534
|
+
|
|
535
|
+ if( cmFilePrintf(fH,"<text x=\"%i\" y=\"%i\" text-anchor=\"middle\" class=\"stext\">%s</text>\n",tx,ty,b->text0) != kOkFileRC )
|
|
536
|
+ return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file text output.");
|
|
537
|
+ }
|
|
538
|
+
|
|
539
|
+ if( b->text1 != NULL )
|
525
|
540
|
{
|
526
|
541
|
unsigned tx = b->left + b->width/2;
|
527
|
|
- unsigned ty = b->top + 20; //g->height/2;
|
|
542
|
+ unsigned ty = b->top + 20 + 20;
|
528
|
543
|
|
529
|
|
- if( cmFilePrintf(fH,"<text x=\"%i\" y=\"%i\" text-anchor=\"middle\" class=\"stext\">%s</text>\n",tx,ty,b->text) != kOkFileRC )
|
|
544
|
+ if( cmFilePrintf(fH,"<text x=\"%i\" y=\"%i\" text-anchor=\"middle\" class=\"stext\">%s</text>\n",tx,ty,b->text1) != kOkFileRC )
|
530
|
545
|
return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file text output.");
|
531
|
546
|
}
|
532
|
547
|
|