From ed4057ae1b1e35156f849424b8c0c7f7fecdf9f3 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 22 Jun 2017 15:17:39 -0400 Subject: [PATCH] Highlighting of cutlines and clip boundaries --- src/TrackArtist.cpp | 20 ++++++++++++++----- src/WaveTrackLocation.h | 15 ++++++++++++++ .../wavetrack/ui/CutlineHandle.cpp | 7 ++++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index 9a482f2a1..c6d124f9a 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -1490,6 +1490,7 @@ void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &rect, int x0, int y0, int } #include "tracks/ui/TimeShiftHandle.h" +#include "tracks/playabletrack/wavetrack/ui/CutlineHandle.h" void TrackArtist::DrawWaveform(TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect & rect, @@ -1523,27 +1524,36 @@ void TrackArtist::DrawWaveform(TrackPanelDrawingContext &context, // Update cache for locations, e.g. cutlines and merge points track->UpdateLocationsCache(); +#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING + auto target2 = dynamic_cast(context.target.get()); +#endif for (const auto loc : track->GetCachedLocations()) { + bool highlight = false; +#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING + highlight = + target2 && target2->GetTrack().get() == track && + target2->GetLocation() == loc; +#endif const int xx = zoomInfo.TimeToPosition(loc.pos); if (xx >= 0 && xx < rect.width) { // delta is used to adjust the top and bottom edge of a split line. int delta =0; - dc.SetPen(*wxGREY_PEN); + dc.SetPen( highlight ? AColor::uglyPen : *wxGREY_PEN ); AColor::Line(dc, (int) (rect.x + xx - 1), rect.y, (int) (rect.x + xx - 1), rect.y + rect.height); if (loc.typ == WaveTrackLocation::locationCutLine) { - dc.SetPen(*wxRED_PEN); + dc.SetPen( highlight ? AColor::uglyPen : *wxRED_PEN ); } else { delta = rect.height/3; #ifdef EXPERIMENTAL_DA // JKC Black does not show up enough. - dc.SetPen(*wxWHITE_PEN); + dc.SetPen(highlight ? AColor::uglyPen : *wxWHITE_PEN); #else - dc.SetPen(*wxBLACK_PEN); + dc.SetPen(highlight ? AColor::uglyPen : *wxBLACK_PEN); #endif } AColor::Line(dc, (int) (rect.x + xx), rect.y+delta, (int) (rect.x + xx), rect.y - delta + rect.height); - dc.SetPen(*wxGREY_PEN); + dc.SetPen( highlight ? AColor::uglyPen : *wxGREY_PEN ); AColor::Line(dc, (int) (rect.x + xx + 1), rect.y+delta, (int) (rect.x + xx + 1), rect.y - delta + rect.height); } } diff --git a/src/WaveTrackLocation.h b/src/WaveTrackLocation.h index 6b56926bf..8662ac31b 100644 --- a/src/WaveTrackLocation.h +++ b/src/WaveTrackLocation.h @@ -36,4 +36,19 @@ struct WaveTrackLocation { int clipidx2; // second clip (right one) }; +inline +bool operator == (const WaveTrackLocation &a, const WaveTrackLocation &b) +{ + return a.pos == b.pos && + a.typ == b.typ && + a.clipidx1 == b.clipidx1 && + a.clipidx2 == b.clipidx2; +} + +inline +bool operator != (const WaveTrackLocation &a, const WaveTrackLocation &b) +{ + return !( a == b ); +} + #endif diff --git a/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp b/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp index 15ba6277d..67beb53e4 100644 --- a/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/CutlineHandle.cpp @@ -10,6 +10,7 @@ Paul Licameli split from TrackPanel.cpp #include "../../../../Audacity.h" #include "CutlineHandle.h" +#include "../../../../Experimental.h" #include "../../../../MemoryX.h" @@ -26,7 +27,11 @@ CutlineHandle::CutlineHandle ( const std::shared_ptr &pTrack, WaveTrackLocation location ) : mpTrack{ pTrack } , mLocation{ location } -{} +{ +#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING + mChangeHighlight = RefreshCode::RefreshCell; +#endif +} HitTestPreview CutlineHandle::HitPreview(bool cutline, bool unsafe) {