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

Highlighting of envelopes

This commit is contained in:
Paul Licameli 2017-06-21 23:05:27 -04:00
parent b5696ca9db
commit 7fb107e143
6 changed files with 56 additions and 14 deletions

View File

@ -27,6 +27,7 @@ a draggable point type.
*//*******************************************************************/
#include "Envelope.h"
#include "Experimental.h"
#include "ViewInfo.h"
#include <math.h>
@ -312,6 +313,7 @@ static void DrawPoint(wxDC & dc, const wxRect & r, int x, int y, bool top)
}
#include "TrackPanelDrawingContext.h"
#include "tracks/ui/EnvelopeHandle.h"
/// TODO: This should probably move to track artist.
void Envelope::DrawPoints
@ -320,7 +322,13 @@ void Envelope::DrawPoints
float zoomMin, float zoomMax, bool mirrored) const
{
auto &dc = context.dc;
dc.SetPen(AColor::envelopePen);
bool highlight = false;
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
highlight = target && target->GetEnvelope() == this;
#endif
wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
dc.SetPen( pen );
dc.SetBrush(*wxWHITE_BRUSH);
for (int i = 0; i < (int)mEnv.size(); i++) {
@ -329,7 +337,7 @@ void Envelope::DrawPoints
if (position >= 0 && position < r.width) {
// Change colour if this is the draggable point...
if (i == mDragPoint) {
dc.SetPen(AColor::envelopePen);
dc.SetPen( pen );
dc.SetBrush(AColor::envelopeBrush);
}
@ -371,7 +379,7 @@ void Envelope::DrawPoints
// Change colour back again if was the draggable point.
if (i == mDragPoint) {
dc.SetPen(AColor::envelopePen);
dc.SetPen( pen );
dc.SetBrush(*wxWHITE_BRUSH);
}
}

View File

@ -15,6 +15,7 @@
#include "Audacity.h"
#include "TimeTrack.h"
#include "Experimental.h"
#include <cfloat>
#include <wx/intl.h>
@ -258,11 +259,17 @@ void TimeTrack::WriteXML(XMLWriter &xmlFile) const
}
#include "TrackPanelDrawingContext.h"
#include "tracks/ui/EnvelopeHandle.h"
void TimeTrack::Draw
(TrackPanelDrawingContext &context, const wxRect & r, const ZoomInfo &zoomInfo) const
{
auto &dc = context.dc;
bool highlight = false;
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
highlight = target && target->GetEnvelope() == this->GetEnvelope();
#endif
double min = zoomInfo.PositionToTime(0);
double max = zoomInfo.PositionToTime(r.width);
@ -294,7 +301,8 @@ void TimeTrack::Draw
GetEnvelope()->GetValues
( 0, 0, envValues.get(), mid.width, 0, zoomInfo );
dc.SetPen(AColor::envelopePen);
wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
dc.SetPen( pen );
double logLower = log(std::max(1.0e-7, mRangeLower)), logUpper = log(std::max(1.0e-7, mRangeUpper));
for (int x = 0; x < mid.width; x++)

View File

@ -1040,7 +1040,8 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, int leftOffset, const wxRect
bool dB, float dBRange,
double t0, double t1,
const ZoomInfo &zoomInfo,
bool drawEnvelope, bool bIsSyncLockSelected)
bool drawEnvelope, bool bIsSyncLockSelected,
bool highlightEnvelope)
{
// Visually (one vertical slice of the waveform background, on its side;
@ -1115,6 +1116,11 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, int leftOffset, const wxRect
dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
}
if (highlightEnvelope && lmaxbot < lmintop - 1) {
dc.SetBrush( AColor::uglyBrush );
dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
}
lmaxtop = maxtop;
lmintop = mintop;
lmaxbot = maxbot;
@ -1133,6 +1139,10 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, int leftOffset, const wxRect
else {
dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
}
if (highlightEnvelope && lmaxbot < lmintop - 1) {
dc.SetBrush( AColor::uglyBrush );
dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
}
// If sync-lock selected, draw in linked graphics.
if (bIsSyncLockSelected && t0 < t1) {
@ -1417,11 +1427,12 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &rect, const double env[],
float zoomMin, float zoomMax,
bool dB, float dBRange)
bool dB, float dBRange, bool highlight)
{
int h = rect.height;
dc.SetPen(AColor::envelopePen);
auto &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
dc.SetPen( pen );
for (int x0 = 0; x0 < rect.width; ++x0) {
int cenvTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
@ -1743,6 +1754,7 @@ void FindWavePortions
}
}
#include "tracks/ui/EnvelopeHandle.h"
void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
const WaveTrack *track,
const WaveClip *clip,
@ -1759,6 +1771,12 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
Profiler profiler;
#endif
bool highlightEnvelope = false;
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
highlightEnvelope = target && target->GetEnvelope() == clip->GetEnvelope();
#endif
const ClipParameters params(false, track, clip, rect, selectedRegion, zoomInfo);
const wxRect &hiddenMid = params.hiddenMid;
// The "hiddenMid" rect contains the part of the display actually
@ -1819,7 +1837,7 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
track->ZeroLevelYCoordinate(mid),
dB, dBRange,
t0, t1, zoomInfo, drawEnvelope,
!track->GetSelected());
!track->GetSelected(), highlightEnvelope);
}
WaveDisplay display(hiddenMid.width);
@ -1960,7 +1978,7 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
}
if (drawEnvelope) {
DrawEnvelope(dc, mid, env, zoomMin, zoomMax, dB, dBRange);
DrawEnvelope(dc, mid, env, zoomMin, zoomMax, dB, dBRange, highlightEnvelope);
clip->GetEnvelope()->DrawPoints
(context, rect, zoomInfo, dB, dBRange, zoomMin, zoomMax, true);
}

View File

@ -154,7 +154,8 @@ class AUDACITY_DLL_API TrackArtist {
int zeroLevelYCoordinate,
bool dB, float dBRange,
double t0, double t1, const ZoomInfo &zoomInfo,
bool drawEnvelope, bool bIsSyncLockSelected);
bool drawEnvelope, bool bIsSyncLockSelected,
bool highlightEnvelope);
void DrawMinMaxRMS(wxDC &dc, const wxRect & rect, const double env[],
float zoomMin, float zoomMax,
bool dB, float dBRange,
@ -175,7 +176,7 @@ class AUDACITY_DLL_API TrackArtist {
void DrawEnvelope(wxDC & dc, const wxRect & rect, const double env[],
float zoomMin, float zoomMax,
bool dB, float dBRange);
bool dB, float dBRange, bool highlight);
void DrawEnvLine(wxDC & dc, const wxRect & rect, int x0, int y0, int cy, bool top);
// Preference values

View File

@ -10,6 +10,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../Audacity.h"
#include "EnvelopeHandle.h"
#include "../../Experimental.h"
#include "../../MemoryX.h"
@ -28,12 +29,17 @@ Paul Licameli split from TrackPanel.cpp
EnvelopeHandle::EnvelopeHandle( Envelope *pEnvelope )
: mEnvelope{ pEnvelope }
{}
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;
#endif
}
EnvelopeHandle::~EnvelopeHandle()
{}
HitTestPreview EnvelopeHandle::HitPreview(const AudacityProject *pProject, bool unsafe)
HitTestPreview EnvelopeHandle::HitPreview
(const AudacityProject *pProject, bool unsafe)
{
static auto disabledCursor =
::MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16);

View File

@ -28,7 +28,8 @@ class EnvelopeHandle final : public UIHandle
{
EnvelopeHandle(const EnvelopeHandle&) = delete;
EnvelopeHandle &operator=(const EnvelopeHandle&) = delete;
static HitTestPreview HitPreview(const AudacityProject *pProject, bool unsafe);
static HitTestPreview HitPreview
(const AudacityProject *pProject, bool unsafe);
static UIHandlePtr HitEnvelope
(std::weak_ptr<EnvelopeHandle> &holder,