MCPcopy Create free account
hub / github.com/audacity/audacity / DrawBackgroundWithSelection

Method DrawBackgroundWithSelection

src/TrackArt.cpp:648–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

646}
647
648void TrackArt::DrawBackgroundWithSelection(
649 TrackPanelDrawingContext &context, const wxRect &rect,
650 const Channel &channel, const wxBrush &selBrush, const wxBrush &unselBrush,
651 bool useSelection, bool useBeatsAlternateColor)
652{
653 const auto dc = &context.dc;
654 const auto artist = TrackArtist::Get( context );
655 const auto &selectedRegion = *artist->pSelectedRegion;
656 const auto& zoomInfo = *artist->pZoomInfo;
657
658
659 //MM: Draw background. We should optimize that a bit more.
660 const double sel0 = useSelection ? selectedRegion.t0() : 0.0;
661 const double sel1 = useSelection ? selectedRegion.t1() : 0.0;
662
663 auto pTrack = dynamic_cast<const Track*>(&channel.GetChannelGroup());
664 if (!pTrack)
665 return;
666 auto &track = *pTrack;
667 BeatsGridlinePainter gridlinePainter(zoomInfo, GetProject(track));
668
669 dc->SetPen(*wxTRANSPARENT_PEN);
670
671 const auto& beatStrongBrush = artist->beatStrongBrush[useBeatsAlternateColor];
672 const auto& beatStrongSelBrush = artist->beatStrongSelBrush[useBeatsAlternateColor];
673 const auto& beatWeakBrush = artist->beatWeakBrush[useBeatsAlternateColor];
674 const auto& beatWeakSelBrush = artist->beatWeakSelBrush[useBeatsAlternateColor];
675 const auto& beatSepearatorPen = artist->beatSepearatorPen[useBeatsAlternateColor];
676 const auto& barSepearatorPen = artist->barSepearatorPen[useBeatsAlternateColor];
677
678 auto drawBgRect = [dc, &gridlinePainter, &rect](
679 const wxBrush& regularBrush,
680 const wxBrush& beatStrongBrush,
681 const wxBrush& beatWeakBrush, const wxRect& subRect)
682 {
683 if (!gridlinePainter.enabled)
684 {
685 // Track not selected; just draw background
686 dc->SetBrush(regularBrush);
687 dc->DrawRectangle(subRect);
688 }
689 else
690 {
691 gridlinePainter.DrawBackground(
692 *dc, subRect, rect, beatStrongBrush, beatWeakBrush);
693 }
694 };
695
696 if (SyncLock::IsSelectedOrSyncLockSelected(track)) {
697 // Rectangles before, within, after the selection
698 wxRect before = rect;
699 wxRect within = rect;
700 wxRect after = rect;
701
702 before.width = (int)(zoomInfo.TimeToPosition(sel0) );
703 if (before.GetRight() > rect.GetRight()) {
704 before.width = rect.width;
705 }

Callers

nothing calls this directly

Calls 7

GetFunction · 0.85
TimeToPositionMethod · 0.80
GetRightMethod · 0.80
DrawSeparatorsMethod · 0.80
GetChannelGroupMethod · 0.45
DrawBackgroundMethod · 0.45
GetSelectedMethod · 0.45

Tested by

no test coverage detected