Highlighting of samples

This commit is contained in:
Paul Licameli 2017-06-22 09:34:57 -04:00
parent 2d65cdc46a
commit ecebf7656e
3 changed files with 25 additions and 7 deletions

View File

@ -1322,7 +1322,8 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
bool dB, float dBRange,
const WaveClip *clip,
const ZoomInfo &zoomInfo,
bool bigPoints, bool showPoints, bool muted)
bool bigPoints, bool showPoints, bool muted,
bool highlight)
{
const double toffset = clip->GetOffset();
double rate = clip->GetRate();
@ -1355,7 +1356,8 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
if (mShowClipping)
clipped.reinit( size_t(slen) );
dc.SetPen(muted ? muteSamplePen : samplePen);
auto &pen = highlight ? AColor::uglyPen : muted ? muteSamplePen : samplePen;
dc.SetPen( pen );
for (decltype(slen) s = 0; s < slen; s++) {
const double time = toffset + (s + s0).as_double() / rate;
@ -1386,7 +1388,10 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
pr.width = tickSize;
pr.height = tickSize;
//different colour when draggable.
dc.SetBrush( bigPoints ? dragsampleBrush : sampleBrush);
auto &brush = highlight
? AColor::uglyBrush
: bigPoints ? dragsampleBrush : sampleBrush;
dc.SetBrush( brush );
for (decltype(slen) s = 0; s < slen; s++) {
if (ypos[s] >= 0 && ypos[s] < rect.height) {
pr.x = rect.x + xpos[s] - tickSize/2;
@ -1764,6 +1769,7 @@ void FindWavePortions
}
}
#include "tracks/playabletrack/wavetrack/ui/SampleHandle.h"
#include "tracks/ui/EnvelopeHandle.h"
void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
const WaveTrack *track,
@ -1977,11 +1983,17 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
#endif
);
}
else
else {
bool highlight = false;
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
auto target = dynamic_cast<SampleHandle*>(context.target.get());
highlight = target && target->GetTrack().get() == track;
#endif
DrawIndividualSamples(dc, leftOffset, rect, zoomMin, zoomMax,
dB, dBRange,
clip, zoomInfo,
bigPoints, showPoints, muted);
bigPoints, showPoints, muted, highlight);
}
}
leftOffset += rect.width + skippedRight;

View File

@ -170,7 +170,8 @@ class AUDACITY_DLL_API TrackArtist {
bool dB, float dBRange,
const WaveClip *clip,
const ZoomInfo &zoomInfo,
bool bigPoints, bool showPoints, bool muted);
bool bigPoints, bool showPoints, bool muted,
bool highlight);
void DrawNegativeOffsetTrackArrows(wxDC & dc, const wxRect & rect);

View File

@ -10,6 +10,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../../../Audacity.h"
#include "SampleHandle.h"
#include "../../Experimental.h"
#include <algorithm>
#include "../../../../MemoryX.h"
@ -36,7 +37,11 @@ static const double SMOOTHING_PROPORTION_MIN = 0.0;
SampleHandle::SampleHandle( const std::shared_ptr<WaveTrack> &pTrack )
: mClickedTrack{ pTrack }
{}
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;
#endif
}
HitTestPreview SampleHandle::HitPreview
(const wxMouseState &state, const AudacityProject *pProject, bool unsafe)