1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-05 06:59:07 +02:00

Draw a (slightly lighter) selection outside of clips in audio tracks.

This commit is contained in:
BusinessmanProgrammerSteve 2010-09-13 07:41:17 +00:00
parent c0b5fb01da
commit 50d2a5b665
3 changed files with 84 additions and 10 deletions

View File

@ -333,4 +333,6 @@ from there. Audacity will look for a file called "Pause.png".
DEFINE_COLOUR( clrSyncLockSel, wxColour(192, 192, 192), wxT("SyncLockSel")); DEFINE_COLOUR( clrSyncLockSel, wxColour(192, 192, 192), wxT("SyncLockSel"));
DEFINE_COLOUR( clrTrackInfoSyncLockSel, wxColour( 64, 64, 64), wxT("TrackInfoSyncLockSel")); DEFINE_COLOUR( clrTrackInfoSyncLockSel, wxColour( 64, 64, 64), wxT("TrackInfoSyncLockSel"));
DEFINE_COLOUR( clrSelTranslucent, wxColour(104, 104, 148, 127), wxT("SelTranslucent")); DEFINE_COLOUR( clrSelTranslucent, wxColour(104, 104, 148, 127), wxT("SelTranslucent"));
// This is for waveform drawing, selected outside of clips
DEFINE_COLOUR( clrBlankSelected, wxColour(170, 170, 192), wxT("BlankSelected"));

View File

@ -113,6 +113,7 @@ void TrackArtist::SetColours()
theTheme.SetBrushColour( sampleBrush, clrSample); theTheme.SetBrushColour( sampleBrush, clrSample);
theTheme.SetBrushColour( selsampleBrush, clrSelSample); theTheme.SetBrushColour( selsampleBrush, clrSelSample);
theTheme.SetBrushColour( dragsampleBrush, clrDragSample); theTheme.SetBrushColour( dragsampleBrush, clrDragSample);
theTheme.SetBrushColour( blankSelectedBrush, clrBlankSelected);
theTheme.SetPenColour( blankPen, clrBlank); theTheme.SetPenColour( blankPen, clrBlank);
theTheme.SetPenColour( unselectedPen, clrUnselected); theTheme.SetPenColour( unselectedPen, clrUnselected);
@ -120,13 +121,14 @@ void TrackArtist::SetColours()
theTheme.SetPenColour( samplePen, clrSample); theTheme.SetPenColour( samplePen, clrSample);
theTheme.SetPenColour( selsamplePen, clrSelSample); theTheme.SetPenColour( selsamplePen, clrSelSample);
theTheme.SetPenColour( muteSamplePen, clrMuteSample); theTheme.SetPenColour( muteSamplePen, clrMuteSample);
theTheme.SetPenColour( odProgressDonePen, clrProgressDone); theTheme.SetPenColour( odProgressDonePen, clrProgressDone);
theTheme.SetPenColour( odProgressNotYetPen, clrProgressNotYet); theTheme.SetPenColour( odProgressNotYetPen, clrProgressNotYet);
theTheme.SetPenColour( rmsPen, clrRms); theTheme.SetPenColour( rmsPen, clrRms);
theTheme.SetPenColour( muteRmsPen, clrMuteRms); theTheme.SetPenColour( muteRmsPen, clrMuteRms);
theTheme.SetPenColour( shadowPen, clrShadow); theTheme.SetPenColour( shadowPen, clrShadow);
theTheme.SetPenColour( clippedPen, clrClipped); theTheme.SetPenColour( clippedPen, clrClipped);
theTheme.SetPenColour( muteClippedPen, clrMuteClipped); theTheme.SetPenColour( muteClippedPen, clrMuteClipped);
theTheme.SetPenColour( blankSelectedPen,clrBlankSelected);
} }
void TrackArtist::SetInset(int left, int top, int right, int bottom) void TrackArtist::SetInset(int left, int top, int right, int bottom)
@ -1086,10 +1088,8 @@ void TrackArtist::DrawWaveform(WaveTrack *track,
bool dB, bool dB,
bool muted) bool muted)
{ {
// MM: Draw background. We should optimize that a bit more. DrawBackgroundWithSelection(&dc, r, track, blankSelectedBrush, blankBrush,
dc.SetPen(*wxTRANSPARENT_PEN); viewInfo->sel0, viewInfo->sel1, viewInfo->h, viewInfo->zoom);
dc.SetBrush(blankBrush);
dc.DrawRectangle(r);
for (WaveClipList::compatibility_iterator it = track->GetClipIterator(); it; it = it->GetNext()) for (WaveClipList::compatibility_iterator it = track->GetClipIterator(); it; it = it->GetNext())
DrawClipWaveform(track, it->GetData(), dc, r, viewInfo, DrawClipWaveform(track, it->GetData(), dc, r, viewInfo,
@ -1424,10 +1424,8 @@ void TrackArtist::DrawSpectrum(WaveTrack *track,
bool autocorrelation, bool autocorrelation,
bool logF) bool logF)
{ {
// MM: Draw background. We should optimize that a bit more. DrawBackgroundWithSelection(&dc, r, track, blankSelectedBrush, blankBrush,
dc.SetPen(*wxTRANSPARENT_PEN); viewInfo->sel0, viewInfo->sel1, viewInfo->h, viewInfo->zoom);
dc.SetBrush(blankBrush);
dc.DrawRectangle(r);
if(!viewInfo->bUpdateTrackIndicator && viewInfo->bIsPlaying) { if(!viewInfo->bUpdateTrackIndicator && viewInfo->bIsPlaying) {
// BG: Draw (undecorated) waveform instead of spectrum // BG: Draw (undecorated) waveform instead of spectrum
@ -2678,3 +2676,70 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect r)
} }
} }
void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &r,
Track *track, wxBrush &selBrush, wxBrush &unselBrush,
double sel0, double sel1, double h, double pps)
{
//MM: Draw background. We should optimize that a bit more.
//AWD: "+ 1.5" and "+ 2.5" throughout match code in
//AdornedRulerPanel::DoDrawSelection() and make selection line up with ruler.
//I don't know if/why this is correct.
dc->SetPen(*wxTRANSPARENT_PEN);
if (track->GetSelected() || track->IsSyncLockSelected())
{
// Rectangles before, within, after the selction
wxRect before = r;
wxRect within = r;
wxRect after = r;
before.width = int ((sel0 - h) * pps + 2.5);
if (before.GetRight() > r.GetRight()) {
before.width = r.width;
}
if (before.width > 0) {
dc->SetBrush(unselBrush);
dc->DrawRectangle(before);
within.x = before.GetRight();
}
within.width = r.x + int ((sel1 - h) * pps + 2.5) - within.x;
if (within.GetRight() > r.GetRight()) {
within.width = r.GetRight() - within.x;
}
if (within.width > 0) {
if (track->GetSelected()) {
dc->SetBrush(selBrush);
dc->DrawRectangle(within);
}
else {
// Per condition above, track must be sync-lock selected
dc->SetBrush(unselBrush);
dc->DrawRectangle(within);
DrawSyncLockTiles(dc, within);
}
after.x = within.GetRight();
}
else {
// `within` not drawn; start where it would have gone
after.x = within.x;
}
after.width = r.GetRight() - after.x;
if (after.width > 0) {
dc->SetBrush(unselBrush);
dc->DrawRectangle(after);
}
}
else
{
// Track not selected; just draw background
dc->SetBrush(unselBrush);
dc->DrawRectangle(r);
}
}

View File

@ -94,6 +94,11 @@ class AUDACITY_DLL_API TrackArtist {
// Helper: draws the "sync-locked" watermark tiled to a rectangle // Helper: draws the "sync-locked" watermark tiled to a rectangle
static void DrawSyncLockTiles(wxDC *dc, wxRect r); static void DrawSyncLockTiles(wxDC *dc, wxRect r);
// Helper: draws background with selection rect
static void DrawBackgroundWithSelection(wxDC *dc, const wxRect &r,
Track *track, wxBrush &selBrush, wxBrush &unselBrush,
double sel0, double sel1, double h, double pps);
private: private:
// //
@ -194,6 +199,7 @@ class AUDACITY_DLL_API TrackArtist {
wxBrush selsampleBrush; wxBrush selsampleBrush;
wxBrush dragsampleBrush;// for samples which are draggable. wxBrush dragsampleBrush;// for samples which are draggable.
wxBrush muteSampleBrush; wxBrush muteSampleBrush;
wxBrush blankSelectedBrush;
wxPen blankPen; wxPen blankPen;
wxPen unselectedPen; wxPen unselectedPen;
wxPen selectedPen; wxPen selectedPen;
@ -207,6 +213,7 @@ class AUDACITY_DLL_API TrackArtist {
wxPen shadowPen; wxPen shadowPen;
wxPen clippedPen; wxPen clippedPen;
wxPen muteClippedPen; wxPen muteClippedPen;
wxPen blankSelectedPen;
Ruler *vruler; Ruler *vruler;