Browse Source

cmScoreMatchGraphic.c : Added optional second line of text to boxes.

master
Kevin Larke 8 years ago
parent
commit
1e821a6a6f
1 changed files with 35 additions and 20 deletions
  1. 35
    20
      app/cmScoreMatchGraphic.c

+ 35
- 20
app/cmScoreMatchGraphic.c View File

37
   unsigned             top;
37
   unsigned             top;
38
   unsigned             width;
38
   unsigned             width;
39
   unsigned             height;
39
   unsigned             height;
40
-  cmChar_t*            text;
40
+  cmChar_t*            text0;
41
+  cmChar_t*            text1;
41
   struct cmSmgBox_str* link;  
42
   struct cmSmgBox_str* link;  
42
 } cmSmgBox_t;
43
 } cmSmgBox_t;
43
 
44
 
90
   cmSmgLoc_t*  locV;
91
   cmSmgLoc_t*  locV;
91
   unsigned     locN;
92
   unsigned     locN;
92
   cmSmgLine_t* lines;
93
   cmSmgLine_t* lines;
94
+
95
+  unsigned     boxW;
96
+  unsigned     boxH;
93
 } cmSmg_t;
97
 } cmSmg_t;
94
 
98
 
95
 cmSmgH_t cmSmgNullHandle = cmSTATIC_NULL_HANDLE;
99
 cmSmgH_t cmSmgNullHandle = cmSTATIC_NULL_HANDLE;
124
     while(b0!=NULL)
128
     while(b0!=NULL)
125
     {
129
     {
126
       b1 = b0->link;
130
       b1 = b0->link;
127
-      cmMemFree(b0->text);
131
+      cmMemFree(b0->text0);
132
+      cmMemFree(b0->text1);
128
       cmMemFree(b0);
133
       cmMemFree(b0);
129
       b0 = b1;
134
       b0 = b1;
130
     }
135
     }
146
   return kOkSmgRC;
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
   assert( locIdx < p->locN );
156
   assert( locIdx < p->locN );
152
   
157
   
153
   cmSmgBox_t* b = cmMemAllocZ(cmSmgBox_t,1);
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
   if( p->locV[locIdx].bV == NULL )
164
   if( p->locV[locIdx].bV == NULL )
159
   {
165
   {
192
     cmScoreLoc_t* l = cmScoreLoc(scH,i);
198
     cmScoreLoc_t* l = cmScoreLoc(scH,i);
193
 
199
 
194
     // insert the location label box
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
     // for each event in location i
203
     // for each event in location i
198
     for(j=0; j<l->evtCnt; ++j)
204
     for(j=0; j<l->evtCnt; ++j)
219
             else
225
             else
220
               text = cmMemAllocStr( cmMidiToSciPitch( e->pitch, NULL, 0));
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
             k += 1;
230
             k += 1;
225
           }
231
           }
282
   if((rc = _cmSmgInitFromMidi(ctx,p,midiFn)) != kOkSmgRC )
288
   if((rc = _cmSmgInitFromMidi(ctx,p,midiFn)) != kOkSmgRC )
283
     goto errLabel;
289
     goto errLabel;
284
 
290
 
291
+  p->boxW = 30;
292
+  p->boxH = 50;
285
   hp->h = p;
293
   hp->h = p;
286
 
294
 
287
  errLabel:
295
  errLabel:
385
     cmChar_t* text  = cmMemAllocStr( cmMidiToSciPitch( p->mV[i].pitch, NULL, 0));
393
     cmChar_t* text  = cmMemAllocStr( cmMidiToSciPitch( p->mV[i].pitch, NULL, 0));
386
 
394
 
387
     // insert a box to represent this midi event
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
     prevLocIdx = locIdx;
398
     prevLocIdx = locIdx;
391
 
399
 
412
   unsigned i;
420
   unsigned i;
413
   unsigned bordX = 5;
421
   unsigned bordX = 5;
414
   unsigned bordY = 5;
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
   unsigned left  = bordX;
424
   unsigned left  = bordX;
419
   
425
   
420
   for(i=0; i<p->locN; ++i)
426
   for(i=0; i<p->locN; ++i)
431
       else
437
       else
432
       {
438
       {
433
         b->top = top;
439
         b->top = top;
434
-        top   += boxH + bordY;
440
+        top   += p->boxH + bordY;
435
       }
441
       }
436
       
442
       
437
       b->left   = left;
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
       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 )
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
         return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file rect output.");
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
         unsigned tx = b->left + b->width/2;
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
           return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file text output.");
545
           return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file text output.");
531
       }
546
       }
532
       
547
       

Loading…
Cancel
Save