16#include "../../../../HitTestResult.h"
20#include "../../../../RefreshCode.h"
21#include "../../../../TrackPanelMouseEvent.h"
23#include "../../../../prefs/WaveformSettings.h"
26 const std::shared_ptr<WaveTrack> &pTrack,
const wxRect &rect,
int y)
27 : mpTrack{ pTrack } , mZoomStart(y), mZoomEnd(y), mRect(rect)
35#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
73 evt, pProject, pParent, pTrack.get(),
mRect,
87 const wxRect &rect,
unsigned iPass )
97 const wxRect &rect,
const wxRect &panelRect,
unsigned iPass )
109 const wxRect &rect,
int zoomStart,
int zoomEnd,
110 bool fixedMousePoint)
113 static const float ZOOMLIMIT = 0.001f;
115 int height = rect.height;
119 if (zoomEnd < zoomStart)
122 float min, max, minBand = 0;
123 const double rate = pTrack->
GetRate();
124 const float halfrate = rate / 2;
125 float maxFreq = 8000.0;
138 cache.GetDisplayBounds(
min, max);
140 const bool linear = waveSettings.isLinear();
142 top = (
LINEAR_TO_DB(2.0) + waveSettings.dBRange) / waveSettings.dBRange;
143 half = (
LINEAR_TO_DB(0.5) + waveSettings.dBRange) / waveSettings.dBRange;
154 wxFAIL_MSG(
"Zooming Case not implemented by Audacity");
188 const float tmin =
min, tmax = max;
189 const float p1 = (zoomStart - ypos) / (
float)height;
190 const float p2 = (zoomEnd - ypos) / (
float)height;
191 max = (tmax * (1.0 - p1) + tmin * p1);
192 min = (tmax * (1.0 - p2) + tmin * p2);
195 if (max -
min < ZOOMLIMIT) {
196 float c = (
min + max) / 2;
197 min = c - ZOOMLIMIT / 2.0;
198 max = c + ZOOMLIMIT / 2.0;
205 const float oldRange = max -
min;
206 const float l = std::max(ZOOMLIMIT, 0.5f * oldRange);
207 const float ratio = l / (max -
min);
209 const float p1 = (zoomStart - ypos) / (
float)height;
210 float c = (max * (1.0 - p1) +
min * p1);
212 min = c - ratio * (1.0f - p1) * oldRange,
213 max = c + ratio * p1 * oldRange;
222 if (min <= -1.0 && max >= 1.0) {
228 float minRange = (
min < -1) ? -top : -1.0;
229 float maxRange = (max > 1) ? top : 1.0;
231 const float p1 = (zoomStart - ypos) / (
float)height;
232 if (fixedMousePoint) {
233 const float oldRange = max -
min;
234 const float c = (max * (1.0 - p1) +
min * p1);
236 std::max(minRange, c - 2 * (1.0f - p1) * oldRange));
237 max = std::max(minRange + ZOOMLIMIT,
238 std::min(maxRange, c + 2 * p1 * oldRange));
241 const float c = p1 *
min + (1 - p1) * max;
242 const float l = (max -
min);
244 std::max(minRange, c - l));
245 max = std::max(minRange + ZOOMLIMIT,
257 zoomEnd = zoomStart = 0;
279 for (
int ii = 0, nn =
names.size(); ii < nn; ++ii) {
290 menu.Check(
id,
true);
300 MakeLabel(
XXO(
"Zoom Reset"),
bVZoom,
XXO(
"Shift-Right-Click") ),
306 #ifdef EXPERIMENTAL_HALF_WAVE
313 MakeLabel(
XXO(
"Zoom In"),
bVZoom,
XXO(
"Left-Click/Left-Drag") ),
316 MakeLabel(
XXO(
"Zoom Out"),
bVZoom,
XXO(
"Shift-Left-Click") ),
@ Internal
Indicates internal failure from Audacity.
XXO("&Cut/Copy/Paste Toolbar")
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
static TrackList & Get(AudacityProject &project)
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
A Track that contains audio waveform data.
double GetRate() const override
Namespace containing an enum 'what to do on a refresh?'.
AUDACITY_DLL_API HitTestPreview HitPreview(const wxMouseState &state)
AUDACITY_DLL_API void DoDraw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass, int zoomStart, int zoomEnd)
AUDACITY_DLL_API Result DoRelease(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent, WaveTrack *pTrack, const wxRect &mRect, DoZoomFunction doZoom, PopupMenuTable &table, int zoomStart, int zoomEnd)
AUDACITY_DLL_API wxRect DoDrawingArea(const wxRect &rect, const wxRect &panelRect, unsigned iPass)
AUDACITY_DLL_API bool IsDragZooming(int zoomStart, int zoomEnd)
AUDACITY_DLL_API Result DoDrag(const TrackPanelMouseEvent &event, AudacityProject *pProject, int zoomStart, int &zoomEnd)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
AuthorizationHandler handler