From 1c6513e0a45b6929bab27a5fa04b1b32e50c0292 Mon Sep 17 00:00:00 2001 From: Vitaly Sverchinsky Date: Thu, 15 Jul 2021 14:15:31 +0300 Subject: [PATCH] Few new track art routines --- src/AllThemeResources.h | 4 +++ src/TrackArtist.cpp | 57 +++++++++++++++++++++++++++++++++++++++++ src/TrackArtist.h | 8 ++++++ src/ViewInfo.h | 1 + 4 files changed, 70 insertions(+) diff --git a/src/AllThemeResources.h b/src/AllThemeResources.h index e62b72dec..28d7abb16 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 14f7699b0..3248c3140 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 99790c7a0..df1c59918 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 10f2a2d46..62264246e 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,