mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-08 16:11:14 +02:00
Highlighting of envelopes
This commit is contained in:
parent
b5696ca9db
commit
7fb107e143
@ -27,6 +27,7 @@ a draggable point type.
|
|||||||
*//*******************************************************************/
|
*//*******************************************************************/
|
||||||
|
|
||||||
#include "Envelope.h"
|
#include "Envelope.h"
|
||||||
|
#include "Experimental.h"
|
||||||
#include "ViewInfo.h"
|
#include "ViewInfo.h"
|
||||||
|
|
||||||
#include <math.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 "TrackPanelDrawingContext.h"
|
||||||
|
#include "tracks/ui/EnvelopeHandle.h"
|
||||||
|
|
||||||
/// TODO: This should probably move to track artist.
|
/// TODO: This should probably move to track artist.
|
||||||
void Envelope::DrawPoints
|
void Envelope::DrawPoints
|
||||||
@ -320,7 +322,13 @@ void Envelope::DrawPoints
|
|||||||
float zoomMin, float zoomMax, bool mirrored) const
|
float zoomMin, float zoomMax, bool mirrored) const
|
||||||
{
|
{
|
||||||
auto &dc = context.dc;
|
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);
|
dc.SetBrush(*wxWHITE_BRUSH);
|
||||||
|
|
||||||
for (int i = 0; i < (int)mEnv.size(); i++) {
|
for (int i = 0; i < (int)mEnv.size(); i++) {
|
||||||
@ -329,7 +337,7 @@ void Envelope::DrawPoints
|
|||||||
if (position >= 0 && position < r.width) {
|
if (position >= 0 && position < r.width) {
|
||||||
// Change colour if this is the draggable point...
|
// Change colour if this is the draggable point...
|
||||||
if (i == mDragPoint) {
|
if (i == mDragPoint) {
|
||||||
dc.SetPen(AColor::envelopePen);
|
dc.SetPen( pen );
|
||||||
dc.SetBrush(AColor::envelopeBrush);
|
dc.SetBrush(AColor::envelopeBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +379,7 @@ void Envelope::DrawPoints
|
|||||||
|
|
||||||
// Change colour back again if was the draggable point.
|
// Change colour back again if was the draggable point.
|
||||||
if (i == mDragPoint) {
|
if (i == mDragPoint) {
|
||||||
dc.SetPen(AColor::envelopePen);
|
dc.SetPen( pen );
|
||||||
dc.SetBrush(*wxWHITE_BRUSH);
|
dc.SetBrush(*wxWHITE_BRUSH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "Audacity.h"
|
#include "Audacity.h"
|
||||||
#include "TimeTrack.h"
|
#include "TimeTrack.h"
|
||||||
|
#include "Experimental.h"
|
||||||
|
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
@ -258,11 +259,17 @@ void TimeTrack::WriteXML(XMLWriter &xmlFile) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "TrackPanelDrawingContext.h"
|
#include "TrackPanelDrawingContext.h"
|
||||||
|
#include "tracks/ui/EnvelopeHandle.h"
|
||||||
|
|
||||||
void TimeTrack::Draw
|
void TimeTrack::Draw
|
||||||
(TrackPanelDrawingContext &context, const wxRect & r, const ZoomInfo &zoomInfo) const
|
(TrackPanelDrawingContext &context, const wxRect & r, const ZoomInfo &zoomInfo) const
|
||||||
{
|
{
|
||||||
auto &dc = context.dc;
|
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 min = zoomInfo.PositionToTime(0);
|
||||||
double max = zoomInfo.PositionToTime(r.width);
|
double max = zoomInfo.PositionToTime(r.width);
|
||||||
@ -294,7 +301,8 @@ void TimeTrack::Draw
|
|||||||
GetEnvelope()->GetValues
|
GetEnvelope()->GetValues
|
||||||
( 0, 0, envValues.get(), mid.width, 0, zoomInfo );
|
( 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));
|
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++)
|
for (int x = 0; x < mid.width; x++)
|
||||||
|
@ -1040,7 +1040,8 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, int leftOffset, const wxRect
|
|||||||
bool dB, float dBRange,
|
bool dB, float dBRange,
|
||||||
double t0, double t1,
|
double t0, double t1,
|
||||||
const ZoomInfo &zoomInfo,
|
const ZoomInfo &zoomInfo,
|
||||||
bool drawEnvelope, bool bIsSyncLockSelected)
|
bool drawEnvelope, bool bIsSyncLockSelected,
|
||||||
|
bool highlightEnvelope)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Visually (one vertical slice of the waveform background, on its side;
|
// 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);
|
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;
|
lmaxtop = maxtop;
|
||||||
lmintop = mintop;
|
lmintop = mintop;
|
||||||
lmaxbot = maxbot;
|
lmaxbot = maxbot;
|
||||||
@ -1133,6 +1139,10 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, int leftOffset, const wxRect
|
|||||||
else {
|
else {
|
||||||
dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
|
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 sync-lock selected, draw in linked graphics.
|
||||||
if (bIsSyncLockSelected && t0 < t1) {
|
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[],
|
void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &rect, const double env[],
|
||||||
float zoomMin, float zoomMax,
|
float zoomMin, float zoomMax,
|
||||||
bool dB, float dBRange)
|
bool dB, float dBRange, bool highlight)
|
||||||
{
|
{
|
||||||
int h = rect.height;
|
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) {
|
for (int x0 = 0; x0 < rect.width; ++x0) {
|
||||||
int cenvTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
|
int cenvTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
|
||||||
@ -1743,6 +1754,7 @@ void FindWavePortions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "tracks/ui/EnvelopeHandle.h"
|
||||||
void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
|
void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
|
||||||
const WaveTrack *track,
|
const WaveTrack *track,
|
||||||
const WaveClip *clip,
|
const WaveClip *clip,
|
||||||
@ -1759,6 +1771,12 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
|
|||||||
Profiler profiler;
|
Profiler profiler;
|
||||||
#endif
|
#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 ClipParameters params(false, track, clip, rect, selectedRegion, zoomInfo);
|
||||||
const wxRect &hiddenMid = params.hiddenMid;
|
const wxRect &hiddenMid = params.hiddenMid;
|
||||||
// The "hiddenMid" rect contains the part of the display actually
|
// The "hiddenMid" rect contains the part of the display actually
|
||||||
@ -1819,7 +1837,7 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
|
|||||||
track->ZeroLevelYCoordinate(mid),
|
track->ZeroLevelYCoordinate(mid),
|
||||||
dB, dBRange,
|
dB, dBRange,
|
||||||
t0, t1, zoomInfo, drawEnvelope,
|
t0, t1, zoomInfo, drawEnvelope,
|
||||||
!track->GetSelected());
|
!track->GetSelected(), highlightEnvelope);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveDisplay display(hiddenMid.width);
|
WaveDisplay display(hiddenMid.width);
|
||||||
@ -1960,7 +1978,7 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (drawEnvelope) {
|
if (drawEnvelope) {
|
||||||
DrawEnvelope(dc, mid, env, zoomMin, zoomMax, dB, dBRange);
|
DrawEnvelope(dc, mid, env, zoomMin, zoomMax, dB, dBRange, highlightEnvelope);
|
||||||
clip->GetEnvelope()->DrawPoints
|
clip->GetEnvelope()->DrawPoints
|
||||||
(context, rect, zoomInfo, dB, dBRange, zoomMin, zoomMax, true);
|
(context, rect, zoomInfo, dB, dBRange, zoomMin, zoomMax, true);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,8 @@ class AUDACITY_DLL_API TrackArtist {
|
|||||||
int zeroLevelYCoordinate,
|
int zeroLevelYCoordinate,
|
||||||
bool dB, float dBRange,
|
bool dB, float dBRange,
|
||||||
double t0, double t1, const ZoomInfo &zoomInfo,
|
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[],
|
void DrawMinMaxRMS(wxDC &dc, const wxRect & rect, const double env[],
|
||||||
float zoomMin, float zoomMax,
|
float zoomMin, float zoomMax,
|
||||||
bool dB, float dBRange,
|
bool dB, float dBRange,
|
||||||
@ -175,7 +176,7 @@ class AUDACITY_DLL_API TrackArtist {
|
|||||||
|
|
||||||
void DrawEnvelope(wxDC & dc, const wxRect & rect, const double env[],
|
void DrawEnvelope(wxDC & dc, const wxRect & rect, const double env[],
|
||||||
float zoomMin, float zoomMax,
|
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);
|
void DrawEnvLine(wxDC & dc, const wxRect & rect, int x0, int y0, int cy, bool top);
|
||||||
|
|
||||||
// Preference values
|
// Preference values
|
||||||
|
@ -10,6 +10,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
|
|
||||||
#include "../../Audacity.h"
|
#include "../../Audacity.h"
|
||||||
#include "EnvelopeHandle.h"
|
#include "EnvelopeHandle.h"
|
||||||
|
#include "../../Experimental.h"
|
||||||
|
|
||||||
#include "../../MemoryX.h"
|
#include "../../MemoryX.h"
|
||||||
|
|
||||||
@ -28,12 +29,17 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
|
|
||||||
EnvelopeHandle::EnvelopeHandle( Envelope *pEnvelope )
|
EnvelopeHandle::EnvelopeHandle( Envelope *pEnvelope )
|
||||||
: mEnvelope{ pEnvelope }
|
: mEnvelope{ pEnvelope }
|
||||||
{}
|
{
|
||||||
|
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
|
||||||
|
mChangeHighlight = RefreshCode::RefreshCell;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
EnvelopeHandle::~EnvelopeHandle()
|
EnvelopeHandle::~EnvelopeHandle()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
HitTestPreview EnvelopeHandle::HitPreview(const AudacityProject *pProject, bool unsafe)
|
HitTestPreview EnvelopeHandle::HitPreview
|
||||||
|
(const AudacityProject *pProject, bool unsafe)
|
||||||
{
|
{
|
||||||
static auto disabledCursor =
|
static auto disabledCursor =
|
||||||
::MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16);
|
::MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16);
|
||||||
|
@ -28,7 +28,8 @@ class EnvelopeHandle final : public UIHandle
|
|||||||
{
|
{
|
||||||
EnvelopeHandle(const EnvelopeHandle&) = delete;
|
EnvelopeHandle(const EnvelopeHandle&) = delete;
|
||||||
EnvelopeHandle &operator=(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
|
static UIHandlePtr HitEnvelope
|
||||||
(std::weak_ptr<EnvelopeHandle> &holder,
|
(std::weak_ptr<EnvelopeHandle> &holder,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user