1 /**********************************************************************
2 
3   Audacity: A Digital Audio Editor
4 
5   EnvelopeEditor.h
6 
7   Paul Licameli split this from Envelope.h
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_ENVELOPE_EDITOR__
12 #define __AUDACITY_ENVELOPE_EDITOR__
13 
14 class wxMouseEvent;
15 class wxRect;
16 class Envelope;
17 struct TrackPanelDrawingContext;
18 class ZoomInfo;
19 
20 // A class that holds state for the duration of dragging
21 // of an envelope point.
22 class AUDACITY_DLL_API EnvelopeEditor
23 {
24 public:
25    static void DrawPoints(
26       const Envelope &env,
27       TrackPanelDrawingContext &context,
28       const wxRect & r,
29       bool dB, double dBRange,
30       float zoomMin, float zoomMax, bool mirrored, int origin = 0);
31 
32    EnvelopeEditor(Envelope &envelope, bool mirrored);
33    ~EnvelopeEditor();
34 
35    // Event Handlers
36    // Each of these returns true if the envelope needs to be redrawn
37    bool MouseEvent(const wxMouseEvent & event, wxRect & r,
38       const ZoomInfo &zoomInfo, bool dB, double dBRange,
39       float zoomMin = -1.0, float zoomMax = 1.0);
40 
41 private:
42    bool HandleMouseButtonDown(const wxMouseEvent & event, wxRect & r,
43       const ZoomInfo &zoomInfo, bool dB, double dBRange,
44       float zoomMin = -1.0, float zoomMax = 1.0);
45    bool HandleDragging(const wxMouseEvent & event, wxRect & r,
46       const ZoomInfo &zoomInfo, bool dB, double dBRange,
47       float zoomMin = -1.0, float zoomMax = 1.0, float eMin = 0., float eMax = 2.);
48    bool HandleMouseButtonUp();
49 
50 private:
51    float ValueOfPixel(int y, int height, bool upper,
52       bool dB, double dBRange,
53       float zoomMin, float zoomMax);
54    void MoveDragPoint(const wxMouseEvent & event, wxRect & r,
55       const ZoomInfo &zoomInfo, bool dB, double dBRange,
56       float zoomMin, float zoomMax);
57 
58    Envelope &mEnvelope;
59    const bool mMirrored;
60 
61    /** \brief Number of pixels contour is from the true envelope. */
62    int mContourOffset;
63 
64    // double mInitialVal;
65 
66    // int mInitialY;
67    bool mUpper;
68    int mButton;
69    bool mDirty;
70 };
71 
72 
73 #endif
74