diff --git a/src/AllThemeResources.h b/src/AllThemeResources.h index e69426e88..ee45bf373 100644 --- a/src/AllThemeResources.h +++ b/src/AllThemeResources.h @@ -371,3 +371,7 @@ from there. Audacity will look for a file called "Pause.png". DEFINE_COLOUR( clrSpectro4Sel, wxColour( 191, 0, 0), wxT("Spectro4Sel") ); DEFINE_COLOUR( clrSpectro5Sel, wxColour( 191, 191, 191), wxT("Spectro5Sel") ); + DEFINE_COLOUR( clrClipAffordanceOutlinePen, wxColour( 0, 0, 0), wxT("ClipAffordanceOutlinePen") ); + DEFINE_COLOUR( clrClipAffordanceInactiveBrush, wxColour( 202, 202, 202), wxT("ClipAffordanceUnselectedBrush") ); + DEFINE_COLOUR( clrClipAffordanceActiveBrush, wxColour( 219, 219, 219), wxT("ClipAffordanceSelectedBrush") ); + DEFINE_COLOUR( clrClipAffordanceStroke, wxColour( 255, 255, 255), wxT("ClipAffordanceStroke") ); diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index d17cab4f2..27a2f1af9 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -56,6 +56,9 @@ audio tracks. #include +//Thickness of the clip frame outline, shown when clip is dragged +static constexpr int ClipSelectionStrokeSize{ 1 };//px + TrackArtist::TrackArtist( TrackPanel *parent_ ) : parent( parent_ ) { @@ -260,6 +263,60 @@ void TrackArtist::UpdatePrefs() SetColours(0); } +void TrackArt::DrawClipAffordance(wxDC& dc, const wxRect& rect, bool highlight, bool selected) +{ + if (selected) + { + wxRect strokeRect{ + rect.x - ClipSelectionStrokeSize, + rect.y, + rect.width + ClipSelectionStrokeSize * 2, + rect.height + ClipFrameRadius }; + dc.SetBrush(*wxTRANSPARENT_BRUSH); + AColor::UseThemeColour(&dc, clrClipAffordanceStroke, clrClipAffordanceStroke); + dc.DrawRoundedRectangle(strokeRect, ClipFrameRadius); + } + AColor::UseThemeColour(&dc, highlight ? clrClipAffordanceActiveBrush : clrClipAffordanceInactiveBrush, clrClipAffordanceOutlinePen); + dc.DrawRoundedRectangle(wxRect(rect.x, rect.y + ClipSelectionStrokeSize, rect.width, rect.height + ClipFrameRadius), ClipFrameRadius); +} + +void TrackArt::DrawClipEdges(wxDC& dc, const wxRect& clipRect, bool selected) +{ + dc.SetBrush(*wxTRANSPARENT_BRUSH); + { + AColor::UseThemeColour(&dc, -1, clrClipAffordanceOutlinePen); + AColor::Line(dc, + clipRect.GetLeft(), clipRect.GetTop(), + clipRect.GetLeft(), clipRect.GetBottom()); + AColor::Line(dc, + clipRect.GetRight(), clipRect.GetTop(), + clipRect.GetRight(), clipRect.GetBottom()); + } + if(selected) + { + if constexpr (ClipSelectionStrokeSize == 1) + { + AColor::UseThemeColour(&dc, -1, clrClipAffordanceStroke); + AColor::Line(dc, + clipRect.GetLeft() - ClipSelectionStrokeSize, clipRect.GetTop(), + clipRect.GetLeft() - ClipSelectionStrokeSize, clipRect.GetBottom()); + AColor::Line(dc, + clipRect.GetRight() + ClipSelectionStrokeSize, clipRect.GetTop(), + clipRect.GetRight() + ClipSelectionStrokeSize, clipRect.GetBottom()); + } + else if constexpr (ClipSelectionStrokeSize > 1) + { + AColor::UseThemeColour(&dc, clrClipAffordanceStroke, clrClipAffordanceStroke); + dc.DrawRectangle(wxRect( + clipRect.GetLeft() - ClipSelectionStrokeSize, clipRect.GetTop(), + ClipSelectionStrokeSize, clipRect.GetHeight())); + dc.DrawRectangle(wxRect( + clipRect.GetRight() + 1, clipRect.GetTop(), + ClipSelectionStrokeSize, clipRect.GetHeight())); + } + } +} + // Draws the sync-lock bitmap, tiled; always draws stationary relative to the DC // // AWD: now that the tiles don't link together, we're drawing a tilted grid, at diff --git a/src/TrackArtist.h b/src/TrackArtist.h index 331b4a6c5..a238e17a9 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -38,6 +38,14 @@ class ZoomInfo; namespace TrackArt { + static constexpr int ClipFrameRadius{ 6 }; + + AUDACITY_DLL_API + void DrawClipAffordance(wxDC& dc, const wxRect& affordanceRect, bool highlight = false, bool selected = false); + + AUDACITY_DLL_API + void DrawClipEdges(wxDC& dc, const wxRect& clipRect, bool selected = false); + // Helper: draws the "sync-locked" watermark tiled to a rectangle AUDACITY_DLL_API void DrawSyncLockTiles( diff --git a/src/ViewInfo.h b/src/ViewInfo.h index d51ffb9ef..2c628be61 100644 --- a/src/ViewInfo.h +++ b/src/ViewInfo.h @@ -101,6 +101,7 @@ private: // See big pictorial comment in TrackPanel.cpp for explanation of these numbers enum : int { // constants related to y coordinates in the track panel + kAffordancesAreaHeight = 20, kTopInset = 4, kTopMargin = kTopInset + kBorderThickness, kBottomMargin = kShadowThickness + kBorderThickness,