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 return std::dynamic_pointer_cast<const Channel>(
mpTrack.lock());
40#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
78 evt, pProject, pParent, pTrack.get(),
mRect,
92 const wxRect &rect,
unsigned iPass )
102 const wxRect &rect,
const wxRect &panelRect,
unsigned iPass )
114 const wxRect &rect,
int zoomStart,
int zoomEnd,
115 bool fixedMousePoint)
118 static const float ZOOMLIMIT = 0.001f;
120 int height = rect.height;
124 if (zoomEnd < zoomStart)
127 float min, max, minBand = 0;
128 const double rate = pTrack->
GetRate();
129 const float halfrate = rate / 2;
130 float maxFreq = 8000.0;
143 cache.GetDisplayBounds(
min, max);
145 const bool linear = waveSettings.isLinear();
147 top = (
LINEAR_TO_DB(2.0) + waveSettings.dBRange) / waveSettings.dBRange;
148 half = (
LINEAR_TO_DB(0.5) + waveSettings.dBRange) / waveSettings.dBRange;
159 wxFAIL_MSG(
"Zooming Case not implemented by Audacity");
193 const float tmin =
min, tmax = max;
194 const float p1 = (zoomStart - ypos) / (
float)height;
195 const float p2 = (zoomEnd - ypos) / (
float)height;
196 max = (tmax * (1.0 - p1) + tmin * p1);
197 min = (tmax * (1.0 - p2) + tmin * p2);
200 if (max -
min < ZOOMLIMIT) {
201 float c = (
min + max) / 2;
202 min = c - ZOOMLIMIT / 2.0;
203 max = c + ZOOMLIMIT / 2.0;
210 const float oldRange = max -
min;
211 const float l = std::max(ZOOMLIMIT, 0.5f * oldRange);
212 const float ratio = l / (max -
min);
214 const float p1 = (zoomStart - ypos) / (
float)height;
215 float c = (max * (1.0 - p1) +
min * p1);
217 min = c - ratio * (1.0f - p1) * oldRange,
218 max = c + ratio * p1 * oldRange;
227 if (min <= -1.0 && max >= 1.0) {
233 float minRange = (
min < -1) ? -top : -1.0;
234 float maxRange = (max > 1) ? top : 1.0;
236 const float p1 = (zoomStart - ypos) / (
float)height;
237 if (fixedMousePoint) {
238 const float oldRange = max -
min;
239 const float c = (max * (1.0 - p1) +
min * p1);
241 std::max(minRange, c - 2 * (1.0f - p1) * oldRange));
242 max = std::max(minRange + ZOOMLIMIT,
243 std::min(maxRange, c + 2 * p1 * oldRange));
246 const float c = p1 *
min + (1 - p1) * max;
247 const float l = (max -
min);
249 std::max(minRange, c - l));
250 max = std::max(minRange + ZOOMLIMIT,
261 zoomEnd = zoomStart = 0;
283 for (
int ii = 0, nn =
names.size(); ii < nn; ++ii) {
294 menu.Check(
id,
true);
304 MakeLabel(
XXO(
"Zoom Reset"),
bVZoom,
XXO(
"Shift-Right-Click") ),
310 #ifdef EXPERIMENTAL_HALF_WAVE
317 MakeLabel(
XXO(
"Zoom In"),
bVZoom,
XXO(
"Left-Click/Left-Drag") ),
320 MakeLabel(
XXO(
"Zoom Out"),
bVZoom,
XXO(
"Shift-Left-Click") ),
@ Internal
Indicates internal failure from Audacity.
XXO("&Cut/Copy/Paste Toolbar")
audacity::BasicSettings * gPrefs
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)
A Track that contains audio waveform data.
double GetRate() const override
Namespace containing an enum 'what to do on a refresh?'.
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 Result DoDrag(const TrackPanelMouseEvent &event, AudacityProject *pProject, int zoomStart, int &zoomEnd)
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 wxRect DoDrawingArea(const wxRect &rect, const wxRect &panelRect, unsigned iPass)
AUDACITY_DLL_API bool IsDragZooming(int zoomStart, int zoomEnd)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
AuthorizationHandler handler