mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-09 14:16:28 +01:00
Time track editing requires click on the curve in multi tool...
... and it will also work so, later, in all tools besides Zoom.
This commit is contained in:
@@ -48,7 +48,7 @@ HitTestResult WaveTrack::HitTest
|
|||||||
if (event.event.CmdDown())
|
if (event.event.CmdDown())
|
||||||
result = TimeShiftHandle::HitAnywhere(pProject);
|
result = TimeShiftHandle::HitAnywhere(pProject);
|
||||||
else if (NULL !=
|
else if (NULL !=
|
||||||
(result = EnvelopeHandle::WaveTrackHitTest(event.event, event.rect, pProject, this))
|
(result = EnvelopeHandle::WaveTrackHitTest(event.event, event.rect, pProject, *this))
|
||||||
.preview.cursor)
|
.preview.cursor)
|
||||||
;
|
;
|
||||||
else if (NULL != (result =
|
else if (NULL != (result =
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "TimeTrackVRulerControls.h"
|
#include "TimeTrackVRulerControls.h"
|
||||||
|
|
||||||
#include "../../../HitTestResult.h"
|
#include "../../../HitTestResult.h"
|
||||||
|
#include "../../../TrackPanelMouseEvent.h"
|
||||||
#include "../../../Project.h"
|
#include "../../../Project.h"
|
||||||
#include "../../../toolbars/ToolsToolBar.h"
|
#include "../../../toolbars/ToolsToolBar.h"
|
||||||
|
|
||||||
@@ -26,12 +27,8 @@ HitTestResult TimeTrack::HitTest
|
|||||||
if (result.preview.cursor)
|
if (result.preview.cursor)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
const ToolsToolBar *const pTtb = pProject->GetToolsToolBar();
|
return EnvelopeHandle::TimeTrackHitTest
|
||||||
if (pTtb->IsDown(multiTool))
|
( event.event, event.rect, pProject, *this );
|
||||||
// No hit test --unconditional availability.
|
|
||||||
result = EnvelopeHandle::HitAnywhere(pProject);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<TrackControls> TimeTrack::GetControls()
|
std::shared_ptr<TrackControls> TimeTrack::GetControls()
|
||||||
|
|||||||
@@ -62,39 +62,76 @@ HitTestResult EnvelopeHandle::HitAnywhere(const AudacityProject *pProject)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void GetTimeTrackData
|
||||||
|
(const AudacityProject &project, const TimeTrack &tt,
|
||||||
|
double &dBRange, bool &dB, float &zoomMin, float &zoomMax)
|
||||||
|
{
|
||||||
|
const auto &viewInfo = project.GetViewInfo();
|
||||||
|
dBRange = viewInfo.dBr;
|
||||||
|
dB = tt.GetDisplayLog();
|
||||||
|
zoomMin = tt.GetRangeLower(), zoomMax = tt.GetRangeUpper();
|
||||||
|
if (dB) {
|
||||||
|
// MB: silly way to undo the work of GetWaveYPos while still getting a logarithmic scale
|
||||||
|
zoomMin = LINEAR_TO_DB(std::max(1.0e-7, double(dBRange))) / dBRange + 1.0;
|
||||||
|
zoomMax = LINEAR_TO_DB(std::max(1.0e-7, double(zoomMax))) / dBRange + 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HitTestResult EnvelopeHandle::TimeTrackHitTest
|
||||||
|
(const wxMouseEvent &event, const wxRect &rect,
|
||||||
|
const AudacityProject *pProject, TimeTrack &tt)
|
||||||
|
{
|
||||||
|
auto envelope = tt.GetEnvelope();
|
||||||
|
if (!envelope)
|
||||||
|
return {};
|
||||||
|
bool dB;
|
||||||
|
double dBRange;
|
||||||
|
float zoomMin, zoomMax;
|
||||||
|
GetTimeTrackData( *pProject, tt, dBRange, dB, zoomMin, zoomMax);
|
||||||
|
return EnvelopeHandle::HitEnvelope
|
||||||
|
(event, rect, pProject, envelope, zoomMin, zoomMax, dB, dBRange);
|
||||||
|
}
|
||||||
|
|
||||||
HitTestResult EnvelopeHandle::WaveTrackHitTest
|
HitTestResult EnvelopeHandle::WaveTrackHitTest
|
||||||
(const wxMouseEvent &event, const wxRect &rect,
|
(const wxMouseEvent &event, const wxRect &rect,
|
||||||
const AudacityProject *pProject, Cell *pCell)
|
const AudacityProject *pProject, WaveTrack &wt)
|
||||||
{
|
{
|
||||||
const ViewInfo &viewInfo = pProject->GetViewInfo();
|
|
||||||
Track *const pTrack = static_cast<Track*>(pCell);
|
|
||||||
|
|
||||||
/// method that tells us if the mouse event landed on an
|
/// method that tells us if the mouse event landed on an
|
||||||
/// envelope boundary.
|
/// envelope boundary.
|
||||||
if (pTrack->GetKind() != Track::Wave)
|
const Envelope *const envelope = wt.GetEnvelopeAtX(event.GetX());
|
||||||
return {};
|
|
||||||
|
|
||||||
WaveTrack *const wavetrack = static_cast<WaveTrack*>(pTrack);
|
|
||||||
Envelope *const envelope = wavetrack->GetEnvelopeAtX(event.GetX());
|
|
||||||
|
|
||||||
if (!envelope)
|
if (!envelope)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const int displayType = wavetrack->GetDisplay();
|
const int displayType = wt.GetDisplay();
|
||||||
// Not an envelope hit, unless we're using a type of wavetrack display
|
// Not an envelope hit, unless we're using a type of wavetrack display
|
||||||
// suitable for envelopes operations, ie one of the Wave displays.
|
// suitable for envelopes operations, ie one of the Wave displays.
|
||||||
if (displayType != WaveTrack::Waveform)
|
if (displayType != WaveTrack::Waveform)
|
||||||
return {}; // No envelope, not a hit, so return.
|
return {}; // No envelope, not a hit, so return.
|
||||||
|
|
||||||
// Get envelope point, range 0.0 to 1.0
|
// Get envelope point, range 0.0 to 1.0
|
||||||
const bool dB = !wavetrack->GetWaveformSettings().isLinear();
|
const bool dB = !wt.GetWaveformSettings().isLinear();
|
||||||
const double envValue =
|
|
||||||
envelope->GetValue(viewInfo.PositionToTime(event.m_x, rect.x));
|
|
||||||
|
|
||||||
float zoomMin, zoomMax;
|
float zoomMin, zoomMax;
|
||||||
wavetrack->GetDisplayBounds(&zoomMin, &zoomMax);
|
wt.GetDisplayBounds(&zoomMin, &zoomMax);
|
||||||
|
|
||||||
const float dBRange = wavetrack->GetWaveformSettings().dBRange;
|
const float dBRange = wt.GetWaveformSettings().dBRange;
|
||||||
|
|
||||||
|
return EnvelopeHandle::HitEnvelope
|
||||||
|
(event, rect, pProject, envelope, zoomMin, zoomMax, dB, dBRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
HitTestResult EnvelopeHandle::HitEnvelope
|
||||||
|
(const wxMouseEvent &event, const wxRect &rect, const AudacityProject *pProject,
|
||||||
|
const Envelope *envelope, float zoomMin, float zoomMax,
|
||||||
|
bool dB, float dBRange)
|
||||||
|
{
|
||||||
|
const ViewInfo &viewInfo = pProject->GetViewInfo();
|
||||||
|
|
||||||
|
const double envValue =
|
||||||
|
envelope->GetValue(viewInfo.PositionToTime(event.m_x, rect.x));
|
||||||
|
|
||||||
// Get y position of envelope point.
|
// Get y position of envelope point.
|
||||||
int yValue = GetWaveYPos(envValue,
|
int yValue = GetWaveYPos(envValue,
|
||||||
@@ -187,14 +224,7 @@ UIHandle::Result EnvelopeHandle::Click
|
|||||||
auto clickedEnvelope = tt->GetEnvelope();
|
auto clickedEnvelope = tt->GetEnvelope();
|
||||||
if (!clickedEnvelope)
|
if (!clickedEnvelope)
|
||||||
return Cancelled;
|
return Cancelled;
|
||||||
mLog = tt->GetDisplayLog();
|
GetTimeTrackData( *pProject, *tt, mdBRange, mLog, mLower, mUpper);
|
||||||
mLower = tt->GetRangeLower(), mUpper = tt->GetRangeUpper();
|
|
||||||
if (mLog) {
|
|
||||||
// MB: silly way to undo the work of GetWaveYPos while still getting a logarithmic scale
|
|
||||||
mdBRange = viewInfo.dBr;
|
|
||||||
mLower = LINEAR_TO_DB(std::max(1.0e-7, double(mLower))) / mdBRange + 1.0;
|
|
||||||
mUpper = LINEAR_TO_DB(std::max(1.0e-7, double(mUpper))) / mdBRange + 1.0;
|
|
||||||
}
|
|
||||||
mEnvelopeEditor =
|
mEnvelopeEditor =
|
||||||
std::make_unique< EnvelopeEditor >( *clickedEnvelope, false );
|
std::make_unique< EnvelopeEditor >( *clickedEnvelope, false );
|
||||||
mEnvelopeEditorRight.reset();
|
mEnvelopeEditorRight.reset();
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
class wxMouseEvent;
|
class wxMouseEvent;
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
|
||||||
|
class Envelope;
|
||||||
class EnvelopeEditor;
|
class EnvelopeEditor;
|
||||||
struct HitTestResult;
|
struct HitTestResult;
|
||||||
class ViewInfo;
|
class ViewInfo;
|
||||||
|
class TimeTrack;
|
||||||
class WaveTrack;
|
class WaveTrack;
|
||||||
|
|
||||||
class EnvelopeHandle final : public UIHandle
|
class EnvelopeHandle final : public UIHandle
|
||||||
@@ -30,11 +32,20 @@ class EnvelopeHandle final : public UIHandle
|
|||||||
static EnvelopeHandle& Instance();
|
static EnvelopeHandle& Instance();
|
||||||
static HitTestPreview HitPreview(const AudacityProject *pProject, bool unsafe);
|
static HitTestPreview HitPreview(const AudacityProject *pProject, bool unsafe);
|
||||||
|
|
||||||
|
static HitTestResult HitEnvelope
|
||||||
|
(const wxMouseEvent &event, const wxRect &rect,
|
||||||
|
const AudacityProject *pProject,
|
||||||
|
const Envelope *envelope, float zoomMin, float zoomMax,
|
||||||
|
bool dB, float dBRange);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static HitTestResult HitAnywhere(const AudacityProject *pProject);
|
static HitTestResult HitAnywhere(const AudacityProject *pProject);
|
||||||
|
static HitTestResult TimeTrackHitTest
|
||||||
|
(const wxMouseEvent &event, const wxRect &rect,
|
||||||
|
const AudacityProject *pProject, TimeTrack &tt);
|
||||||
static HitTestResult WaveTrackHitTest
|
static HitTestResult WaveTrackHitTest
|
||||||
(const wxMouseEvent &event, const wxRect &rect,
|
(const wxMouseEvent &event, const wxRect &rect,
|
||||||
const AudacityProject *pProject, Cell *pCell);
|
const AudacityProject *pProject, WaveTrack &wt);
|
||||||
|
|
||||||
virtual ~EnvelopeHandle();
|
virtual ~EnvelopeHandle();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user