1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-02 08:59:28 +02:00
audacity/src/tracks/ui/EnvelopeHandle.h
Paul Licameli f64bc5a829 Pass non-const AudacityProject to HitTest::Preview...
... because that will be needed for elimination of some GetActiveProject()
calls.  Because some overrides need to find the focused track, but that may
mutate the project by setting the focused track when it wasn't yet defined.
2020-01-04 09:40:33 -05:00

94 lines
2.5 KiB
C++

/**********************************************************************
Audacity: A Digital Audio Editor
EnvelopeHandle.h
Paul Licameli split from TrackPanel.cpp
**********************************************************************/
#ifndef __AUDACITY_ENVELOPE_HANDLE__
#define __AUDACITY_ENVELOPE_HANDLE__
#include "../../UIHandle.h"
#include <vector>
class wxMouseEvent;
class wxMouseState;
class Envelope;
class EnvelopeEditor;
class ViewInfo;
class TimeTrack;
class WaveTrack;
class EnvelopeHandle final : public UIHandle
{
EnvelopeHandle(const EnvelopeHandle&) = delete;
EnvelopeHandle &operator=(const EnvelopeHandle&) = delete;
static UIHandlePtr HitEnvelope
(std::weak_ptr<EnvelopeHandle> &holder,
const wxMouseState &state, const wxRect &rect,
const AudacityProject *pProject,
Envelope *envelope, float zoomMin, float zoomMax,
bool dB, float dBRange, bool timeTrack);
public:
explicit EnvelopeHandle( Envelope *pEnvelope );
virtual ~EnvelopeHandle();
static UIHandlePtr HitAnywhere
(std::weak_ptr<EnvelopeHandle> &holder, Envelope *envelope,
bool timeTrack);
static UIHandlePtr TimeTrackHitTest
(std::weak_ptr<EnvelopeHandle> &holder,
const wxMouseState &state, const wxRect &rect,
const AudacityProject *pProject, const std::shared_ptr<TimeTrack> &tt);
static UIHandlePtr WaveTrackHitTest
(std::weak_ptr<EnvelopeHandle> &holder,
const wxMouseState &state, const wxRect &rect,
const AudacityProject *pProject, const std::shared_ptr<WaveTrack> &wt);
Envelope *GetEnvelope() const { return mEnvelope; }
void Enter(bool forward, AudacityProject *) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
Result Drag
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
HitTestPreview Preview
(const TrackPanelMouseState &state, AudacityProject *pProject)
override;
Result Release
(const TrackPanelMouseEvent &event, AudacityProject *pProject,
wxWindow *pParent) override;
Result Cancel(AudacityProject *pProject) override;
bool StopsOnKeystroke() override { return true; }
private:
bool ForwardEventToEnvelopes
(const wxMouseEvent &event, const ViewInfo &viewInfo);
wxRect mRect{};
bool mLog{};
float mLower{}, mUpper{};
double mdBRange{};
Envelope *mEnvelope{};
std::vector< std::unique_ptr<EnvelopeEditor> > mEnvelopeEditors;
bool mTimeTrack{};
};
#endif