367{
368 auto &dc = context.
dc;
370 const auto &selectedRegion = *artist->pSelectedRegion;
371 const auto &zoomInfo = *artist->pZoomInfo;
372
374 double sel0 = selectedRegion.t0();
375 double sel1 = selectedRegion.t1();
376
378 const double h1 =
X_TO_TIME(rect.x + rect.width);
379
380 Alg_seq_ptr seq = &track->
GetSeq();
381
383 sel0 = sel1 = 0.0;
384
386
387
388
389 int numPitches = (rect.height) / data.GetPitchHeight(1);
390 if (numPitches < 0) numPitches = 0;
391
392
393
394
395
396
397
398 wxPen blackStripePen;
400 wxBrush blackStripeBrush;
402 wxPen barLinePen;
404
405 const auto &blankBrush = artist->blankBrush;
406 const auto &blankPen = artist->blankPen;
408 blackStripeBrush, blackStripePen, barLinePen);
409
410 dc.SetClippingRegion(rect);
411
412
413
414
415 wxRect selBG;
416 selBG.y = rect.y;
417 selBG.height = rect.height;
420
421 wxPen selectedWhiteKeyPen;
422 selectedWhiteKeyPen.SetColour(165, 165, 190);
423 dc.SetPen(selectedWhiteKeyPen);
424
425 wxBrush selectedWhiteKeyBrush;
427
428 wxPen selectedBlackKeyPen;
430 wxBrush selectedBlackKeyBrush;
432 wxPen selectedBarLinePen;
434
436 selectedWhiteKeyBrush, selectedWhiteKeyPen,
437 selectedBlackKeyBrush, selectedBlackKeyPen,
438 selectedBarLinePen);
441 int marg = data.GetNoteMargin();
442
443
444
445 Alg_attribute line = symbol_table.insert_string("line");
446 Alg_attribute
rectangle = symbol_table.insert_string(
"rectangle");
447 Alg_attribute
triangle = symbol_table.insert_string(
"triangle");
448 Alg_attribute polygon = symbol_table.insert_string("polygon");
449 Alg_attribute oval = symbol_table.insert_string("oval");
450 Alg_attribute text = symbol_table.insert_string("text");
451 Alg_attribute texts = symbol_table.insert_string("texts");
452 Alg_attribute x1r = symbol_table.insert_string("x1r");
453 Alg_attribute x2r = symbol_table.insert_string("x2r");
454 Alg_attribute y1r = symbol_table.insert_string("y1r");
455 Alg_attribute y2r = symbol_table.insert_string("y2r");
456 Alg_attribute linecolori = symbol_table.insert_string("linecolori");
457 Alg_attribute fillcolori = symbol_table.insert_string("fillcolori");
458 Alg_attribute linethicki = symbol_table.insert_string("linethicki");
459 Alg_attribute filll = symbol_table.insert_string("filll");
460 Alg_attribute fonta = symbol_table.insert_string("fonta");
461 Alg_attribute roman = symbol_table.insert_string("roman");
462 Alg_attribute swiss = symbol_table.insert_string("swiss");
463 Alg_attribute modern = symbol_table.insert_string("modern");
464 Alg_attribute weighta = symbol_table.insert_string("weighta");
465 Alg_attribute bold = symbol_table.insert_string("bold");
466 Alg_attribute sizei = symbol_table.insert_string("sizei");
467 Alg_attribute justifys = symbol_table.insert_string("justifys");
468
469
470 seq->convert_to_seconds();
471
472 Alg_iterator iterator(seq, false);
473 iterator.begin();
474
475 Alg_event_ptr evt;
476 while (0 != (evt = iterator.next())) {
477 if (evt->get_type() == 'n') {
478 Alg_note_ptr note = (Alg_note_ptr) evt;
479
481 double xx = note->time + track->
GetOffset();
482 double x1 = xx + note->dur;
483 if (xx < h1 && x1 > h) {
484 const char *shape = NULL;
485 if (note->loud > 0.0 || 0 == (shape =
IsShape(note))) {
486 wxRect nr;
487 nr.y = data.PitchToY(note->pitch);
488 nr.height = data.GetPitchHeight(1);
489
492
493 if (nr.x + nr.width >= rect.x && nr.x < rect.x + rect.width) {
494 if (nr.x < rect.x) {
495 nr.width -= (rect.x - nr.x);
496 nr.x = rect.x;
497 }
498 if (nr.x + nr.width > rect.x + rect.width)
499 nr.width = rect.x + rect.width - nr.x;
500
501 if (nr.y + nr.height < rect.y + marg + 3) {
502
503 nr.y = rect.y;
504 nr.height = marg;
505 dc.SetBrush(*wxBLACK_BRUSH);
506 dc.SetPen(*wxBLACK_PEN);
507 dc.DrawRectangle(nr);
508 } else if (nr.y >= rect.y + rect.height - marg - 1) {
509
510 nr.y = rect.y + rect.height - marg;
511 nr.height = marg;
512 dc.SetBrush(*wxBLACK_BRUSH);
513 dc.SetPen(*wxBLACK_PEN);
514 dc.DrawRectangle(nr);
515 } else {
516 if (nr.y + nr.height > rect.y + rect.height - marg)
517 nr.height = rect.y + rect.height - nr.y;
518 if (nr.y < rect.y + marg) {
519 int offset = rect.y + marg - nr.y;
520 nr.height -= offset;
521 nr.y += offset;
522 }
523
524 if (muted)
526 else
528 dc.DrawRectangle(nr);
529 if (data.GetPitchHeight(1) > 2) {
535 nr.x+nr.width-1, nr.y+nr.height-1);
537 nr.x+nr.width-1, nr.y+nr.height-1);
538 }
539
540 }
541 }
542 } else if (shape) {
543
544
545
546
547 int yy = data.PitchToY(note->pitch);
550 long fillcolor = -1;
551 long fillflag = 0;
552
553
555 if (shape != text) {
556 if (linecolor != -1)
557 dc.SetPen(wxPen(wxColour(
RED(linecolor),
560 linethick, wxPENSTYLE_SOLID));
561 }
562 if (shape != line) {
565
566 if (fillcolor != -1)
567 dc.SetBrush(wxBrush(wxColour(
RED(fillcolor),
570 wxBRUSHSTYLE_SOLID));
571 if (!fillflag) dc.SetBrush(*wxTRANSPARENT_BRUSH);
572 }
574 if (shape == line) {
575
576
577 if (xx < h) {
578 yy = (int)((yy + (y1 - yy) * (h - xx) / (x1 - xx)) + 0.5);
579 xx = h;
580 }
581 if (x1 > h1) {
582 y1 = (int)((yy + (y1 - yy) * (h1 - xx) / (x1 - xx)) + 0.5);
583 x1 = h1;
584 }
587 if (xx < h) {
588 xx =
X_TO_TIME(rect.x - (linethick + 10));
589 }
590 if (x1 > h1) {
591 xx =
X_TO_TIME(rect.x + rect.width + linethick + 10);
592 }
595 wxPoint points[3];
598 points[0].y = yy;
601 points[1].y = y1;
605 dc.DrawPolygon(3, points);
606 } else if (shape == polygon) {
607 wxPoint points[20];
610 points[0].y = yy;
613 points[1].y = y1;
617 int n = 3;
618 while (n < 20) {
620 sprintf(
name,
"x%dr", n);
621 Alg_attribute attr = symbol_table.insert_string(
name);
623 if (xn == -1000000.0) break;
626 sprintf(
name,
"y%dr", n - 1);
627 attr = symbol_table.insert_string(
name);
629 if (yn == -1000000.0) break;
630 points[n].y = data.PitchToY(yn);
631 n++;
632 }
633 dc.DrawPolygon(n, points);
634 } else if (shape == oval) {
639 dc.DrawEllipse(ix, yy, ix1, y1 - yy + 1);
640 } else if (shape == text) {
641 if (linecolor != -1)
642 dc.SetTextForeground(wxColour(
RED(linecolor),
645
646 else dc.SetTextForeground(dc.GetBrush().GetColour());
647
648
649
650
651
652
654
655
660 wxFont wxfont;
661 wxfont.SetFamily(font == roman ? wxFONTFAMILY_ROMAN :
662 (font == swiss ? wxFONTFAMILY_SWISS :
663 (font == modern ? wxFONTFAMILY_MODERN : wxFONTFAMILY_DEFAULT)));
664 wxfont.SetStyle(wxFONTSTYLE_NORMAL);
665 wxfont.SetWeight(weight == bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL);
666 wxfont.SetPointSize(
size);
667 dc.SetFont(wxfont);
668
669
671 wxCoord textWidth, textHeight;
672 dc.GetTextExtent(wxString::FromUTF8(s), &textWidth, &textHeight);
673 long hoffset = 0;
674 long voffset = -textHeight;
675
676 if (strlen(justify) != 2) justify = "ld";
677
678 if (justify[0] == 'c') hoffset = -(textWidth/2);
679 else if (justify[0] == 'r') hoffset = -textWidth;
680
681 if (justify[1] == 't') voffset = 0;
682 else if (justify[1] == 'c') voffset = -(textHeight/2);
683 else if (justify[1] == 'b') voffset = -textHeight;
684 if (fillflag) {
685
686
687
688 dc.SetPen(wxPen(wxColour(
RED(fillcolor),
691 1, wxPENSTYLE_SOLID));
692 dc.DrawRectangle(
TIME_TO_X(xx) + hoffset, yy + voffset,
693 textWidth, textHeight);
694 }
696 }
697 }
698 }
699 }
700 }
701 }
702 iterator.end();
703
704 dc.SetPen(*wxBLACK_PEN);
705 AColor::Line(dc, rect.x, rect.y + marg, rect.x + rect.width, rect.y + marg);
706 AColor::Line(dc, rect.x, rect.y + rect.height - marg - 1,
707 rect.x + rect.width, rect.y + rect.height - marg - 1);
708
709 if (h == 0.0 && track->
GetOffset() < 0.0) {
711 }
712
713
714 {
717
719 }
720
721 dc.DestroyClippingRegion();
723}
const TranslatableString name
#define SonifyBeginNoteBackground()
#define SonifyEndNoteBackground()
#define SonifyBeginNoteForeground()
#define SonifyEndNoteForeground()
static void LightMIDIChannel(wxDC *dc, int channel)
static void MIDIChannel(wxDC *dc, int channel)
static void DarkMIDIChannel(wxDC *dc, int channel)
bool IsVisibleChan(int c) const
wxColour & Colour(int iIndex)
AUDACITY_DLL_API void DrawClipEdges(wxDC &dc, const wxRect &clipRect, bool selected=false)
AUDACITY_DLL_API void DrawNegativeOffsetTrackArrows(TrackPanelDrawingContext &context, const wxRect &rect)
bool LookupLogicalAttribute(Alg_note_ptr note, Alg_attribute attr, bool def)
const char * IsShape(Alg_note_ptr note)
const char * LookupStringAttribute(Alg_note_ptr note, Alg_attribute attr, const char *def)
const char * LookupAtomAttribute(Alg_note_ptr note, Alg_attribute attr, char *def)
double LookupRealAttribute(Alg_note_ptr note, Alg_attribute attr, double def)
void DrawNoteBackground(TrackPanelDrawingContext &context, const NoteTrack *track, const wxRect &rect, const wxRect &sel, const wxBrush &wb, const wxPen &wp, const wxBrush &bb, const wxPen &bp, const wxPen &mp)
long LookupIntAttribute(Alg_note_ptr note, Alg_attribute attr, long def)