mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 23:30:07 +02:00
Stubs needed to eliminate remaining direct uses of ViewInfo::zoom ...
... and anticipate a problems fisheye will introduce with time ruler display and horizontal scrolling past zero. Will be used in waveform and spectrogram drawing, and in hit-test for sample editing. Those things will no longer make the assumption of uniform zoom level across the width of the screen, though that does remain true without the rest of the fisheye project.
This commit is contained in:
parent
c5754ee751
commit
a4482aa3af
@ -37,7 +37,8 @@ ZoomInfo::~ZoomInfo()
|
|||||||
/// the track as an additional parameter.
|
/// the track as an additional parameter.
|
||||||
double ZoomInfo::PositionToTime(wxInt64 position,
|
double ZoomInfo::PositionToTime(wxInt64 position,
|
||||||
wxInt64 origin
|
wxInt64 origin
|
||||||
) const
|
, bool // ignoreFisheye
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
return h + (position - origin) / zoom;
|
return h + (position - origin) / zoom;
|
||||||
}
|
}
|
||||||
@ -46,7 +47,8 @@ double ZoomInfo::PositionToTime(wxInt64 position,
|
|||||||
/// STM: Converts a project time to screen x position.
|
/// STM: Converts a project time to screen x position.
|
||||||
wxInt64 ZoomInfo::TimeToPosition(double projectTime,
|
wxInt64 ZoomInfo::TimeToPosition(double projectTime,
|
||||||
wxInt64 origin
|
wxInt64 origin
|
||||||
) const
|
, bool // ignoreFisheye
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
return floor(0.5 +
|
return floor(0.5 +
|
||||||
zoom * (projectTime - h) + origin
|
zoom * (projectTime - h) + origin
|
||||||
@ -73,6 +75,23 @@ void ZoomInfo::ZoomBy(double multiplier)
|
|||||||
SetZoom(zoom * multiplier);
|
SetZoom(zoom * multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoomInfo::FindIntervals
|
||||||
|
(double /*rate*/, Intervals &results, wxInt64 origin) const
|
||||||
|
{
|
||||||
|
results.clear();
|
||||||
|
results.reserve(2);
|
||||||
|
|
||||||
|
const wxInt64 rightmost(origin + (0.5 + screen * zoom));
|
||||||
|
wxASSERT(origin <= rightmost);
|
||||||
|
{
|
||||||
|
results.push_back(Interval(origin, zoom, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (origin < rightmost)
|
||||||
|
results.push_back(Interval(rightmost, 0, false));
|
||||||
|
wxASSERT(!results.empty() && results[0].position == origin);
|
||||||
|
}
|
||||||
|
|
||||||
ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
|
ViewInfo::ViewInfo(double start, double screenDuration, double pixelsPerSecond)
|
||||||
: ZoomInfo(start, screenDuration, pixelsPerSecond)
|
: ZoomInfo(start, screenDuration, pixelsPerSecond)
|
||||||
, selectedRegion()
|
, selectedRegion()
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef __AUDACITY_VIEWINFO__
|
#ifndef __AUDACITY_VIEWINFO__
|
||||||
#define __AUDACITY_VIEWINFO__
|
#define __AUDACITY_VIEWINFO__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include "SelectedRegion.h"
|
#include "SelectedRegion.h"
|
||||||
|
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ public:
|
|||||||
// origin specifies the pixel corresponding to time h
|
// origin specifies the pixel corresponding to time h
|
||||||
double PositionToTime(wxInt64 position,
|
double PositionToTime(wxInt64 position,
|
||||||
wxInt64 origin = 0
|
wxInt64 origin = 0
|
||||||
|
, bool ignoreFisheye = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// do NOT use this once to convert a duration to a pixel width!
|
// do NOT use this once to convert a duration to a pixel width!
|
||||||
@ -49,6 +51,7 @@ public:
|
|||||||
// origin specifies the pixel corresponding to time h
|
// origin specifies the pixel corresponding to time h
|
||||||
wxInt64 TimeToPosition(double time,
|
wxInt64 TimeToPosition(double time,
|
||||||
wxInt64 origin = 0
|
wxInt64 origin = 0
|
||||||
|
, bool ignoreFisheye = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
double OffsetTimeByPixels(double time, wxInt64 offset) const
|
double OffsetTimeByPixels(double time, wxInt64 offset) const
|
||||||
@ -78,6 +81,46 @@ public:
|
|||||||
// Limits zoom to certain bounds
|
// Limits zoom to certain bounds
|
||||||
// multipliers above 1.0 zoom in, below out
|
// multipliers above 1.0 zoom in, below out
|
||||||
void ZoomBy(double multiplier);
|
void ZoomBy(double multiplier);
|
||||||
|
|
||||||
|
struct Interval {
|
||||||
|
const wxInt64 position; const double averageZoom; const bool inFisheye;
|
||||||
|
Interval(wxInt64 p, double z, bool i)
|
||||||
|
: position(p), averageZoom(z), inFisheye(i) {}
|
||||||
|
};
|
||||||
|
typedef std::vector<Interval> Intervals;
|
||||||
|
|
||||||
|
// Find an increasing sequence of pixel positions. Each is the start
|
||||||
|
// of an interval, or is the end position.
|
||||||
|
// Each of the disjoint intervals should be drawn
|
||||||
|
// separately.
|
||||||
|
// It is guaranteed that there is at least one entry and the position of the
|
||||||
|
// first entry equals origin.
|
||||||
|
// @param origin specifies the pixel position corresponding to time ViewInfo::h.
|
||||||
|
void FindIntervals
|
||||||
|
(double rate, Intervals &results, wxInt64 origin = 0) const;
|
||||||
|
|
||||||
|
enum FisheyeState {
|
||||||
|
HIDDEN,
|
||||||
|
PINNED,
|
||||||
|
|
||||||
|
NUM_STATES,
|
||||||
|
};
|
||||||
|
FisheyeState GetFisheyeState() const
|
||||||
|
{ return HIDDEN; } // stub
|
||||||
|
|
||||||
|
// Return true if the mouse position is anywhere in the fisheye
|
||||||
|
// origin specifies the pixel corresponding to time h
|
||||||
|
bool InFisheye(wxInt64 position, wxInt64 origin = 0) const
|
||||||
|
{origin; return false;} // stub
|
||||||
|
|
||||||
|
// These accessors ignore the fisheye hiding state.
|
||||||
|
// Inclusive:
|
||||||
|
wxInt64 GetFisheyeLeftBoundary(wxInt64 origin = 0) const
|
||||||
|
{origin; return 0;} // stub
|
||||||
|
// Exclusive:
|
||||||
|
wxInt64 GetFisheyeRightBoundary(wxInt64 origin = 0) const
|
||||||
|
{origin; return 0;} // stub
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class AUDACITY_DLL_API ViewInfo
|
class AUDACITY_DLL_API ViewInfo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user