360{
361 auto &dc = context.
dc;
363 const auto &selectedRegion = *artist->pSelectedRegion;
364 const auto &zoomInfo = *artist->pZoomInfo;
365
367 double sel0 = selectedRegion.t0();
368 double sel1 = selectedRegion.t1();
369
371 const double h1 =
X_TO_TIME(rect.x + rect.width);
372
373 Alg_seq_ptr seq = &track.
GetSeq();
374
376 sel0 = sel1 = 0.0;
377
379
380
381
382 int numPitches = (rect.height) / data.GetPitchHeight(1);
383 if (numPitches < 0) numPitches = 0;
384
385
386
387
388
389
390
391 wxPen blackStripePen;
393 wxBrush blackStripeBrush;
395 wxPen barLinePen;
397
398 const auto &blankBrush = artist->blankBrush;
399 const auto &blankPen = artist->blankPen;
401 blackStripeBrush, blackStripePen, barLinePen);
402
403 dc.SetClippingRegion(rect);
404
405
406
407
408 wxRect selBG;
409 selBG.y = rect.y;
410 selBG.height = rect.height;
413
414 wxPen selectedWhiteKeyPen;
415 selectedWhiteKeyPen.SetColour(165, 165, 190);
416 dc.SetPen(selectedWhiteKeyPen);
417
418 wxBrush selectedWhiteKeyBrush;
420
421 wxPen selectedBlackKeyPen;
423 wxBrush selectedBlackKeyBrush;
425 wxPen selectedBarLinePen;
427
429 selectedWhiteKeyBrush, selectedWhiteKeyPen,
430 selectedBlackKeyBrush, selectedBlackKeyPen,
431 selectedBarLinePen);
434 int marg = data.GetNoteMargin();
435
436
437
438 Alg_attribute line = symbol_table.insert_string("line");
439 Alg_attribute
rectangle = symbol_table.insert_string(
"rectangle");
440 Alg_attribute
triangle = symbol_table.insert_string(
"triangle");
441 Alg_attribute polygon = symbol_table.insert_string("polygon");
442 Alg_attribute oval = symbol_table.insert_string("oval");
443 Alg_attribute text = symbol_table.insert_string("text");
444 Alg_attribute texts = symbol_table.insert_string("texts");
445 Alg_attribute x1r = symbol_table.insert_string("x1r");
446 Alg_attribute x2r = symbol_table.insert_string("x2r");
447 Alg_attribute y1r = symbol_table.insert_string("y1r");
448 Alg_attribute y2r = symbol_table.insert_string("y2r");
449 Alg_attribute linecolori = symbol_table.insert_string("linecolori");
450 Alg_attribute fillcolori = symbol_table.insert_string("fillcolori");
451 Alg_attribute linethicki = symbol_table.insert_string("linethicki");
452 Alg_attribute filll = symbol_table.insert_string("filll");
453 Alg_attribute fonta = symbol_table.insert_string("fonta");
454 Alg_attribute roman = symbol_table.insert_string("roman");
455 Alg_attribute swiss = symbol_table.insert_string("swiss");
456 Alg_attribute modern = symbol_table.insert_string("modern");
457 Alg_attribute weighta = symbol_table.insert_string("weighta");
458 Alg_attribute bold = symbol_table.insert_string("bold");
459 Alg_attribute sizei = symbol_table.insert_string("sizei");
460 Alg_attribute justifys = symbol_table.insert_string("justifys");
461
462
463 seq->convert_to_seconds();
464
465 Alg_iterator iterator(seq, false);
466 iterator.begin();
467
468 Alg_event_ptr evt;
469 while (0 != (evt = iterator.next())) {
470 if (evt->get_type() == 'n') {
471 Alg_note_ptr note = (Alg_note_ptr) evt;
472
475 double x1 = xx + note->dur;
476 if (xx < h1 && x1 > h) {
477 const char *shape = NULL;
478 if (note->loud > 0.0 || 0 == (shape =
IsShape(note))) {
479 wxRect nr;
480 nr.y = data.PitchToY(note->pitch);
481 nr.height = data.GetPitchHeight(1);
482
485
486 if (nr.x + nr.width >= rect.x && nr.x < rect.x + rect.width) {
487 if (nr.x < rect.x) {
488 nr.width -= (rect.x - nr.x);
489 nr.x = rect.x;
490 }
491 if (nr.x + nr.width > rect.x + rect.width)
492 nr.width = rect.x + rect.width - nr.x;
493
494 if (nr.y + nr.height < rect.y + marg + 3) {
495
496 nr.y = rect.y;
497 nr.height = marg;
498 dc.SetBrush(*wxBLACK_BRUSH);
499 dc.SetPen(*wxBLACK_PEN);
500 dc.DrawRectangle(nr);
501 } else if (nr.y >= rect.y + rect.height - marg - 1) {
502
503 nr.y = rect.y + rect.height - marg;
504 nr.height = marg;
505 dc.SetBrush(*wxBLACK_BRUSH);
506 dc.SetPen(*wxBLACK_PEN);
507 dc.DrawRectangle(nr);
508 } else {
509 if (nr.y + nr.height > rect.y + rect.height - marg)
510 nr.height = rect.y + rect.height - nr.y;
511 if (nr.y < rect.y + marg) {
512 int offset = rect.y + marg - nr.y;
513 nr.height -= offset;
514 nr.y += offset;
515 }
516
517 if (muted)
519 else
521 dc.DrawRectangle(nr);
522 if (data.GetPitchHeight(1) > 2) {
528 nr.x+nr.width-1, nr.y+nr.height-1);
530 nr.x+nr.width-1, nr.y+nr.height-1);
531 }
532
533 }
534 }
535 } else if (shape) {
536
537
538
539
540 int yy = data.PitchToY(note->pitch);
543 long fillcolor = -1;
544 long fillflag = 0;
545
546
548 if (shape != text) {
549 if (linecolor != -1)
550 dc.SetPen(wxPen(wxColour(
RED(linecolor),
553 linethick, wxPENSTYLE_SOLID));
554 }
555 if (shape != line) {
558
559 if (fillcolor != -1)
560 dc.SetBrush(wxBrush(wxColour(
RED(fillcolor),
563 wxBRUSHSTYLE_SOLID));
564 if (!fillflag) dc.SetBrush(*wxTRANSPARENT_BRUSH);
565 }
567 if (shape == line) {
568
569
570 if (xx < h) {
571 yy = (int)((yy + (y1 - yy) * (h - xx) / (x1 - xx)) + 0.5);
572 xx = h;
573 }
574 if (x1 > h1) {
575 y1 = (int)((yy + (y1 - yy) * (h1 - xx) / (x1 - xx)) + 0.5);
576 x1 = h1;
577 }
580 if (xx < h) {
581 xx =
X_TO_TIME(rect.x - (linethick + 10));
582 }
583 if (x1 > h1) {
584 xx =
X_TO_TIME(rect.x + rect.width + linethick + 10);
585 }
588 wxPoint points[3];
591 points[0].y = yy;
594 points[1].y = y1;
598 dc.DrawPolygon(3, points);
599 } else if (shape == polygon) {
600 wxPoint points[20];
603 points[0].y = yy;
606 points[1].y = y1;
610 int n = 3;
611 while (n < 20) {
613 sprintf(
name,
"x%dr", n);
614 Alg_attribute attr = symbol_table.insert_string(
name);
616 if (xn == -1000000.0) break;
619 sprintf(
name,
"y%dr", n - 1);
620 attr = symbol_table.insert_string(
name);
622 if (yn == -1000000.0) break;
623 points[n].y = data.PitchToY(yn);
624 n++;
625 }
626 dc.DrawPolygon(n, points);
627 } else if (shape == oval) {
632 dc.DrawEllipse(ix, yy, ix1, y1 - yy + 1);
633 } else if (shape == text) {
634 if (linecolor != -1)
635 dc.SetTextForeground(wxColour(
RED(linecolor),
638
639 else dc.SetTextForeground(dc.GetBrush().GetColour());
640
641
642
643
644
645
647
648
653 wxFont wxfont;
654 wxfont.SetFamily(font == roman ? wxFONTFAMILY_ROMAN :
655 (font == swiss ? wxFONTFAMILY_SWISS :
656 (font == modern ? wxFONTFAMILY_MODERN : wxFONTFAMILY_DEFAULT)));
657 wxfont.SetStyle(wxFONTSTYLE_NORMAL);
658 wxfont.SetWeight(weight == bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL);
659 wxfont.SetPointSize(
size);
660 dc.SetFont(wxfont);
661
662
664 wxCoord textWidth, textHeight;
665 dc.GetTextExtent(wxString::FromUTF8(s), &textWidth, &textHeight);
666 long hoffset = 0;
667 long voffset = -textHeight;
668
669 if (strlen(justify) != 2) justify = "ld";
670
671 if (justify[0] == 'c') hoffset = -(textWidth/2);
672 else if (justify[0] == 'r') hoffset = -textWidth;
673
674 if (justify[1] == 't') voffset = 0;
675 else if (justify[1] == 'c') voffset = -(textHeight/2);
676 else if (justify[1] == 'b') voffset = -textHeight;
677 if (fillflag) {
678
679
680
681 dc.SetPen(wxPen(wxColour(
RED(fillcolor),
684 1, wxPENSTYLE_SOLID));
685 dc.DrawRectangle(
TIME_TO_X(xx) + hoffset, yy + voffset,
686 textWidth, textHeight);
687 }
689 }
690 }
691 }
692 }
693 }
694 }
695 iterator.end();
696
697 dc.SetPen(*wxBLACK_PEN);
698 AColor::Line(dc, rect.x, rect.y + marg, rect.x + rect.width, rect.y + marg);
699 AColor::Line(dc, rect.x, rect.y + rect.height - marg - 1,
700 rect.x + rect.width, rect.y + rect.height - marg - 1);
701
704 }
705
706
707 {
710
712 }
713
714 dc.DestroyClippingRegion();
716}
#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)
bool GetSelected() const
Selectedness is always the same for all channels of a group.
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)