| 1 |
/********************************************************************** |
| 2 |
|
| 3 |
Audacity: A Digital Audio Editor |
| 4 |
|
| 5 |
WaveChannelVZoomHandle.h |
| 6 |
|
| 7 |
Paul Licameli split from TrackPanel.cpp |
| 8 |
|
| 9 |
**********************************************************************/ |
| 10 |
|
| 11 |
#ifndef __AUDACITY_WAVE_TRACK_VZOOM_HANDLE__ |
| 12 |
#define __AUDACITY_WAVE_TRACK_VZOOM_HANDLE__ |
| 13 |
|
| 14 |
class wxMouseState; |
| 15 |
class PopupMenuTable; |
| 16 |
class WaveChannel; |
| 17 |
class WaveTrack; |
| 18 |
#include "WaveChannelViewConstants.h" |
| 19 |
#include "../../../../UIHandle.h" |
| 20 |
#include "Prefs.h" |
| 21 |
|
| 22 |
namespace WaveChannelVZoomHandle |
| 23 |
{ |
| 24 |
// See RefreshCode.h for bit flags: |
| 25 |
using Result = unsigned; |
| 26 |
|
| 27 |
AUDACITY_DLL_API |
| 28 |
HitTestPreview HitPreview(const bool bVZoom); |
| 29 |
|
| 30 |
AUDACITY_DLL_API |
| 31 |
bool IsDragZooming(int zoomStart, int zoomEnd, bool hasDragZoom); |
| 32 |
|
| 33 |
using DoZoomFunction = void (*)(AudacityProject *pProject, |
| 34 |
WaveChannel &wc, |
| 35 |
WaveChannelViewConstants::ZoomActions ZoomKind, |
| 36 |
const wxRect &rect, int zoomStart, int zoomEnd, |
| 37 |
bool fixedMousePoint); |
| 38 |
|
| 39 |
AUDACITY_DLL_API |
| 40 |
Result DoDrag( |
| 41 |
const TrackPanelMouseEvent &event, AudacityProject *pProject, |
| 42 |
int zoomStart, int &zoomEnd, bool hasDragZoom ); |
| 43 |
|
| 44 |
AUDACITY_DLL_API |
| 45 |
Result DoRelease( |
| 46 |
const TrackPanelMouseEvent &event, AudacityProject *pProject, |
| 47 |
wxWindow *pParent, WaveChannel &wc, const wxRect &mRect, |
| 48 |
DoZoomFunction doZoom, PopupMenuTable &table, |
| 49 |
int zoomStart, int zoomEnd ); |
| 50 |
|
| 51 |
AUDACITY_DLL_API |
| 52 |
void DoDraw( |
| 53 |
TrackPanelDrawingContext &context, |
| 54 |
const wxRect &rect, unsigned iPass, int zoomStart, int zoomEnd, bool hasDragZoom ); |
| 55 |
|
| 56 |
AUDACITY_DLL_API |
| 57 |
wxRect DoDrawingArea( |
| 58 |
const wxRect &rect, const wxRect &panelRect, unsigned iPass ); |
| 59 |
}; |
| 60 |
|
| 61 |
#include "../../../../widgets/PopupMenuTable.h" // to inherit |
| 62 |
|
| 63 |
class AUDACITY_DLL_API WaveChannelVRulerMenuTable |
| 64 |
: public PopupMenuTable |
| 65 |
, private PrefsListener |
| 66 |
{ |
| 67 |
public: |
| 68 |
struct InitMenuData |
| 69 |
{ |
| 70 |
public: |
| 71 |
AudacityProject &project; |
| 72 |
WaveChannel &wc; |
| 73 |
wxRect rect; |
| 74 |
unsigned result; |
| 75 |
int yy; |
| 76 |
WaveChannelVZoomHandle::DoZoomFunction doZoom; |
| 77 |
}; |
| 78 |
|
| 79 |
protected: |
| 80 |
WaveChannelVRulerMenuTable( const Identifier &id ) |
| 81 |
: PopupMenuTable{ id } |
| 82 |
{} |
| 83 |
|
| 84 |
void InitUserData(void *pUserData) override; |
| 85 |
|
| 86 |
protected: |
| 87 |
InitMenuData *mpData {}; |
| 88 |
|
| 89 |
void OnZoom(WaveChannelViewConstants::ZoomActions iZoomCode); |
| 90 |
void OnZoomFitVertical(wxCommandEvent&) |
| 91 |
{ OnZoom(WaveChannelViewConstants::kZoom1to1); } |
| 92 |
void OnZoomReset(wxCommandEvent&) |
| 93 |
{ OnZoom(WaveChannelViewConstants::kZoomReset); } |
| 94 |
void OnZoomHalfWave(wxCommandEvent&) |
| 95 |
{ OnZoom(WaveChannelViewConstants::kZoomHalfWave); } |
| 96 |
void OnZoomInVertical(wxCommandEvent&) |
| 97 |
{ OnZoom(WaveChannelViewConstants::kZoomIn); } |
| 98 |
void OnZoomOutVertical(wxCommandEvent&) |
| 99 |
{ OnZoom(WaveChannelViewConstants::kZoomOut); } |
| 100 |
|
| 101 |
void UpdatePrefs() override; |
| 102 |
}; |
| 103 |
|
| 104 |
enum { |
| 105 |
OnZoomFitVerticalID = 20000, |
| 106 |
OnZoomResetID, |
| 107 |
OnZoomHalfWaveID, |
| 108 |
OnZoomInVerticalID, |
| 109 |
OnZoomOutVerticalID, |
| 110 |
|
| 111 |
// Reserve an ample block of ids for waveform scale types |
| 112 |
OnFirstWaveformScaleID, |
| 113 |
OnLastWaveformScaleID = OnFirstWaveformScaleID + 9, |
| 114 |
|
| 115 |
// Reserve an ample block of ids for spectrum scale types |
| 116 |
OnFirstSpectrumScaleID, |
| 117 |
OnLastSpectrumScaleID = OnFirstSpectrumScaleID + 19, |
| 118 |
}; |
| 119 |
|
| 120 |
#endif |