Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
ZoomInfo Class Reference

#include <ZoomInfo.h>

Inheritance diagram for ZoomInfo:
[legend]

Classes

struct  Interval
 

Public Types

enum  FisheyeState { HIDDEN , PINNED , NUM_STATES }
 
using int64 = std::int64_t
 
typedef std::vector< IntervalIntervals
 

Public Member Functions

 ZoomInfo (double start, double pixelsPerSecond)
 
 ~ZoomInfo ()
 
 ZoomInfo (const ZoomInfo &) PROHIBITED
 
ZoomInfooperator= (const ZoomInfo &) PROHIBITED
 
double PositionToTime (int64 position, int64 origin=0, bool ignoreFisheye=false) const
 
int64 TimeToPosition (double time, int64 origin=0, bool ignoreFisheye=false) const
 STM: Converts a project time to screen x position. More...
 
double TimeRangeToPixelWidth (double timeRange) const
 
double OffsetTimeByPixels (double time, int64 offset, bool ignoreFisheye=false) const
 
int GetWidth () const
 
void SetWidth (int width)
 
int GetVRulerWidth () const
 
void SetVRulerWidth (int width)
 
int GetVRulerOffset () const
 
int GetLeftOffset () const
 
int GetTracksUsableWidth () const
 
double GetScreenEndTime () const
 
bool ZoomInAvailable () const
 
bool ZoomOutAvailable () const
 
void SetZoom (double pixelsPerSecond)
 
double GetZoom () const
 
void ZoomBy (double multiplier)
 
void FindIntervals (double rate, Intervals &results, int64 width, int64 origin=0) const
 
FisheyeState GetFisheyeState () const
 
bool InFisheye (int64, int64=0) const
 
int64 GetFisheyeLeftBoundary (int64=0) const
 
int64 GetFisheyeRightBoundary (int64=0) const
 

Static Public Member Functions

static double GetDefaultZoom ()
 
static double GetMaxZoom ()
 
static double GetMinZoom ()
 

Public Attributes

int vpos
 
double h
 
int mWidth { 0 }
 
int mVRulerWidth { 36 }
 

Protected Attributes

double zoom
 

Detailed Description

Definition at line 36 of file ZoomInfo.h.

Member Typedef Documentation

◆ int64

using ZoomInfo::int64 = std::int64_t

Definition at line 41 of file ZoomInfo.h.

◆ Intervals

typedef std::vector<Interval> ZoomInfo::Intervals

Definition at line 136 of file ZoomInfo.h.

Member Enumeration Documentation

◆ FisheyeState

Enumerator
HIDDEN 
PINNED 
NUM_STATES 

Definition at line 148 of file ZoomInfo.h.

148 {
149 HIDDEN,
150 PINNED,
151
153 };
@ PINNED
Definition: ZoomInfo.h:150
@ HIDDEN
Definition: ZoomInfo.h:149
@ NUM_STATES
Definition: ZoomInfo.h:152

Constructor & Destructor Documentation

◆ ZoomInfo() [1/2]

ZoomInfo::ZoomInfo ( double  start,
double  pixelsPerSecond 
)

Definition at line 21 of file ZoomInfo.cpp.

22 : vpos(0)
23 , h(start)
24 , zoom(pixelsPerSecond)
25{
26}
double zoom
Definition: ZoomInfo.h:55
double h
Definition: ZoomInfo.h:52
int vpos
Definition: ZoomInfo.h:50

◆ ~ZoomInfo()

ZoomInfo::~ZoomInfo ( )

Definition at line 28 of file ZoomInfo.cpp.

29{
30}

◆ ZoomInfo() [2/2]

ZoomInfo::ZoomInfo ( const ZoomInfo )

Member Function Documentation

◆ FindIntervals()

void ZoomInfo::FindIntervals ( double  rate,
Intervals results,
int64  width,
int64  origin = 0 
) const

Definition at line 103 of file ZoomInfo.cpp.

105{
106 results.clear();
107 results.reserve(2);
108
109 const int64 rightmost(origin + (0.5 + width));
110 assert(origin <= rightmost);
111 {
112 results.push_back(Interval(origin, zoom, false));
113 }
114
115 if (origin < rightmost)
116 results.push_back(Interval(rightmost, 0, false));
117 assert(!results.empty() && results[0].position == origin);
118}
std::int64_t int64
Definition: ZoomInfo.h:41

References zoom.

Referenced by anonymous_namespace{WaveformView.cpp}::FindWavePortions(), and anonymous_namespace{SampleHandle.cpp}::SampleResolutionTest().

Here is the caller graph for this function:

◆ GetDefaultZoom()

static double ZoomInfo::GetDefaultZoom ( )
inlinestatic

Definition at line 113 of file ZoomInfo.h.

114 { return 44100.0 / 512.0; }

Referenced by anonymous_namespace{ViewMenus.cpp}::GetZoomOfPreset(), ViewActions::Handler::OnZoomNormal(), ZoomHandle::Release(), and TrackPanel::UpdateViewIfNoTracks().

Here is the caller graph for this function:

◆ GetFisheyeLeftBoundary()

int64 ZoomInfo::GetFisheyeLeftBoundary ( int64  = 0) const
inline

Definition at line 164 of file ZoomInfo.h.

165 {return 0;} // stub

◆ GetFisheyeRightBoundary()

int64 ZoomInfo::GetFisheyeRightBoundary ( int64  = 0) const
inline

Definition at line 167 of file ZoomInfo.h.

168 {return 0;} // stub

◆ GetFisheyeState()

FisheyeState ZoomInfo::GetFisheyeState ( ) const
inline

Definition at line 154 of file ZoomInfo.h.

155 { return HIDDEN; } // stub

◆ GetLeftOffset()

int ZoomInfo::GetLeftOffset ( ) const
inline

Definition at line 93 of file ZoomInfo.h.

94 { return GetVRulerOffset() + GetVRulerWidth() + 1; }
int GetVRulerOffset() const
Definition: ZoomInfo.h:90
int GetVRulerWidth() const
Definition: ZoomInfo.h:88

Referenced by LabelTrackView::DialogForLabelName(), TrackPanel::GetMostRecentXPos(), and TrackPanel::UpdateVRulerSize().

Here is the caller graph for this function:

◆ GetMaxZoom()

double ZoomInfo::GetMaxZoom ( )
static

Definition at line 77 of file ZoomInfo.cpp.

77{ return gMaxZoom;};
static const double gMaxZoom
Definition: ZoomInfo.cpp:17

References anonymous_namespace{ZoomInfo.cpp}::gMaxZoom.

Referenced by anonymous_namespace{ViewMenus.cpp}::GetZoomOfPreset().

Here is the caller graph for this function:

◆ GetMinZoom()

double ZoomInfo::GetMinZoom ( )
static

Definition at line 78 of file ZoomInfo.cpp.

78{ return gMinZoom;};
static const double gMinZoom
Definition: ZoomInfo.cpp:18

References anonymous_namespace{ZoomInfo.cpp}::gMinZoom.

◆ GetScreenEndTime()

double ZoomInfo::GetScreenEndTime ( ) const
inline

Definition at line 104 of file ZoomInfo.h.

105 {
106 auto width = GetTracksUsableWidth();
107 return PositionToTime(width, 0, true);
108 }
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:35
int GetTracksUsableWidth() const
Definition: ZoomInfo.h:96

Referenced by TrackPanel::HandlePageDownKey(), and TrackPanel::HandlePageUpKey().

Here is the caller graph for this function:

◆ GetTracksUsableWidth()

int ZoomInfo::GetTracksUsableWidth ( ) const
inline

Definition at line 96 of file ZoomInfo.h.

97 {
98 return
99 std::max( 0, GetWidth() - ( GetLeftOffset() + kRightMargin ) );
100 }
@ kRightMargin
Definition: ZoomInfo.h:28
int GetWidth() const
Definition: ZoomInfo.h:85
int GetLeftOffset() const
Definition: ZoomInfo.h:93

References kRightMargin.

◆ GetVRulerOffset()

int ZoomInfo::GetVRulerOffset ( ) const
inline

Definition at line 90 of file ZoomInfo.h.

90{ return kTrackInfoWidth + kLeftMargin; }
@ kTrackInfoWidth
Definition: ZoomInfo.h:30
@ kLeftMargin
Definition: ZoomInfo.h:27

References kLeftMargin, and kTrackInfoWidth.

Referenced by TrackPanel::UpdateTrackVRuler().

Here is the caller graph for this function:

◆ GetVRulerWidth()

int ZoomInfo::GetVRulerWidth ( ) const
inline

Definition at line 88 of file ZoomInfo.h.

88{ return mVRulerWidth; }
int mVRulerWidth
Definition: ZoomInfo.h:171

Referenced by TrackPanel::UpdateTrackVRuler(), and TrackPanel::UpdateVRulerSize().

Here is the caller graph for this function:

◆ GetWidth()

int ZoomInfo::GetWidth ( ) const
inline

Definition at line 85 of file ZoomInfo.h.

85{ return mWidth; }
int mWidth
Definition: ZoomInfo.h:170

◆ GetZoom()

double ZoomInfo::GetZoom ( ) const

Definition at line 76 of file ZoomInfo.cpp.

76{ return zoom;};

References zoom.

◆ InFisheye()

bool ZoomInfo::InFisheye ( int64  ,
int64  = 0 
) const
inline

Definition at line 159 of file ZoomInfo.h.

160 {return false;} // stub

◆ OffsetTimeByPixels()

double ZoomInfo::OffsetTimeByPixels ( double  time,
int64  offset,
bool  ignoreFisheye = false 
) const
inline

Definition at line 80 of file ZoomInfo.h.

81 {
82 return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye);
83 }
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:45

◆ operator=()

ZoomInfo & ZoomInfo::operator= ( const ZoomInfo )

◆ PositionToTime()

double ZoomInfo::PositionToTime ( int64  position,
int64  origin = 0,
bool  ignoreFisheye = false 
) const

◆ SetVRulerWidth()

void ZoomInfo::SetVRulerWidth ( int  width)
inline

Definition at line 89 of file ZoomInfo.h.

89{ mVRulerWidth = width; }

Referenced by TrackPanel::UpdateVRulerSize().

Here is the caller graph for this function:

◆ SetWidth()

void ZoomInfo::SetWidth ( int  width)
inline

Definition at line 86 of file ZoomInfo.h.

86{ mWidth = width; }

Referenced by TrackPanel::OnSize().

Here is the caller graph for this function:

◆ SetZoom()

void ZoomInfo::SetZoom ( double  pixelsPerSecond)

Definition at line 80 of file ZoomInfo.cpp.

81{
82 zoom = std::max(gMinZoom, std::min(gMaxZoom, pixelsPerSecond));
83// DA: Avoids stuck in snap-to
84#ifdef EXPERIMENTAL_DA
85 // Disable snapping if user zooms in a long way.
86 // Helps stop users be trapped in snap-to.
87 // The level chosen is in sample viewing range with samples
88 // still quite close together.
89 if( zoom > (gMaxZoom * 0.06 ))
90 {
92 if( project )
93 project->OnSnapToOff();
94 }
95#endif
96}
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
int min(int a, int b)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90

References GetActiveProject(), anonymous_namespace{ZoomInfo.cpp}::gMaxZoom, anonymous_namespace{ZoomInfo.cpp}::gMinZoom, min(), and zoom.

Referenced by TrackPanel::UpdateViewIfNoTracks(), and ZoomBy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TimeRangeToPixelWidth()

double ZoomInfo::TimeRangeToPixelWidth ( double  timeRange) const

Definition at line 61 of file ZoomInfo.cpp.

62{
63 return timeRange * zoom;
64}

References zoom.

◆ TimeToPosition()

auto ZoomInfo::TimeToPosition ( double  time,
int64  origin = 0,
bool  ignoreFisheye = false 
) const

STM: Converts a project time to screen x position.

Definition at line 45 of file ZoomInfo.cpp.

49{
50 double t = 0.5 + zoom * (projectTime - h) + origin ;
51 if( t < INT64_MIN )
52 return INT64_MIN;
53 if( t > INT64_MAX )
54 return INT64_MAX;
55 t = floor( t );
56 return t;
57}

Referenced by anonymous_namespace{TimeShiftHandle.cpp}::AdjustToSnap(), anonymous_namespace{SelectHandle.cpp}::ChooseTimeBoundary(), ClipParameters::ClipParameters(), LabelTrackView::ComputeLayout(), LabelTrackView::DialogForLabelName(), ClipParameters::GetClipRect(), LabelGlyphHandle::HandleGlyphClick(), EnvelopeEditor::HandleMouseButtonDown(), anonymous_namespace{CutlineHandle.cpp}::IsOverCutline(), SnapManager::PixelDiff(), anonymous_namespace{SampleHandle.cpp}::SampleResolutionTest(), SnapManager::Snap(), AdornedRulerPanel::Time2Pos(), and LinearUpdater::Update().

Here is the caller graph for this function:

◆ ZoomBy()

void ZoomInfo::ZoomBy ( double  multiplier)

Definition at line 98 of file ZoomInfo.cpp.

99{
100 SetZoom(zoom * multiplier);
101}
void SetZoom(double pixelsPerSecond)
Definition: ZoomInfo.cpp:80

References SetZoom(), and zoom.

Here is the call graph for this function:

◆ ZoomInAvailable()

bool ZoomInfo::ZoomInAvailable ( ) const

Definition at line 66 of file ZoomInfo.cpp.

67{
68 return zoom < gMaxZoom;
69}

References anonymous_namespace{ZoomInfo.cpp}::gMaxZoom, and zoom.

Referenced by ZoomInAvailableFlag().

Here is the caller graph for this function:

◆ ZoomOutAvailable()

bool ZoomInfo::ZoomOutAvailable ( ) const

Definition at line 71 of file ZoomInfo.cpp.

72{
73 return zoom > gMinZoom;
74}

References anonymous_namespace{ZoomInfo.cpp}::gMinZoom, and zoom.

Referenced by ZoomOutAvailableFlag().

Here is the caller graph for this function:

Member Data Documentation

◆ h

double ZoomInfo::h

◆ mVRulerWidth

int ZoomInfo::mVRulerWidth { 36 }

Definition at line 171 of file ZoomInfo.h.

◆ mWidth

int ZoomInfo::mWidth { 0 }

Definition at line 170 of file ZoomInfo.h.

◆ vpos

int ZoomInfo::vpos

◆ zoom

double ZoomInfo::zoom
protected

The documentation for this class was generated from the following files: