mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 15:20:15 +02:00
Free TimeTrack, Mix, EnvelopeHandle from cycles...
... the first two, intermediate between the two large s.c.c.'s, the last at a high level. The size of the largest s.c.c. is now 35.
This commit is contained in:
commit
db140902ff
@ -272,6 +272,8 @@ src/WaveTrack.h
|
||||
src/WaveTrackLocation.h
|
||||
src/WrappedType.cpp
|
||||
src/WrappedType.h
|
||||
src/ZoomInfo.cpp
|
||||
src/ZoomInfo.h
|
||||
src/blockfile/LegacyAliasBlockFile.cpp
|
||||
src/blockfile/LegacyAliasBlockFile.h
|
||||
src/blockfile/LegacyBlockFile.cpp
|
||||
|
@ -1290,6 +1290,7 @@
|
||||
5EBD35861F78D37A0084D13F /* pt_PT.po in Sources */ = {isa = PBXBuildFile; fileRef = 5EBD35851F78D37A0084D13F /* pt_PT.po */; };
|
||||
5EC4257222B92383005E8AB5 /* CommonTrackControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EC4256E22B92383005E8AB5 /* CommonTrackControls.cpp */; };
|
||||
5EC4257322B92383005E8AB5 /* CommonTrackView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EC4257022B92383005E8AB5 /* CommonTrackView.cpp */; };
|
||||
5EC4257922BA7CF2005E8AB5 /* ZoomInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EC4257722BA7CF2005E8AB5 /* ZoomInfo.cpp */; };
|
||||
5EC7ED061E101C5C0052CAE2 /* NotYetAvailableException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EC7ED041E101C5C0052CAE2 /* NotYetAvailableException.cpp */; };
|
||||
5ECF728722871A4F007F2A35 /* ShuttleGetDefinition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ECF728522871A4F007F2A35 /* ShuttleGetDefinition.cpp */; };
|
||||
5ECF728A22887B3B007F2A35 /* MissingAliasFileDialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5ECF728822887B3B007F2A35 /* MissingAliasFileDialog.cpp */; };
|
||||
@ -3339,6 +3340,8 @@
|
||||
5EC4256F22B92383005E8AB5 /* CommonTrackControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTrackControls.h; sourceTree = "<group>"; };
|
||||
5EC4257022B92383005E8AB5 /* CommonTrackView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonTrackView.cpp; sourceTree = "<group>"; };
|
||||
5EC4257122B92383005E8AB5 /* CommonTrackView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonTrackView.h; sourceTree = "<group>"; };
|
||||
5EC4257722BA7CF2005E8AB5 /* ZoomInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ZoomInfo.cpp; sourceTree = "<group>"; };
|
||||
5EC4257822BA7CF2005E8AB5 /* ZoomInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZoomInfo.h; sourceTree = "<group>"; };
|
||||
5EC7ED041E101C5C0052CAE2 /* NotYetAvailableException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotYetAvailableException.cpp; sourceTree = "<group>"; };
|
||||
5EC7ED051E101C5C0052CAE2 /* NotYetAvailableException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotYetAvailableException.h; sourceTree = "<group>"; };
|
||||
5ECCE7651DE49834009900E9 /* AudacityException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudacityException.h; sourceTree = "<group>"; };
|
||||
@ -4455,6 +4458,7 @@
|
||||
1790B0F909883BFD008A330A /* WaveClip.cpp */,
|
||||
1790B0FB09883BFD008A330A /* WaveTrack.cpp */,
|
||||
28FC1AF90A47762C00A188AE /* WrappedType.cpp */,
|
||||
5EC4257722BA7CF2005E8AB5 /* ZoomInfo.cpp */,
|
||||
1790AFC809883BFD008A330A /* AboutDialog.h */,
|
||||
1790AFCA09883BFD008A330A /* AColor.h */,
|
||||
5E08C7382180D460004079AE /* AdornedRulerPanel.h */,
|
||||
@ -4594,6 +4598,7 @@
|
||||
2844163A1B82D6BC0000574D /* WaveTrackLocation.h */,
|
||||
28FC1AFA0A47762C00A188AE /* WrappedType.h */,
|
||||
5ED18DB71CC290AB00FAFE95 /* wxFileNameWrapper.h */,
|
||||
5EC4257822BA7CF2005E8AB5 /* ZoomInfo.h */,
|
||||
5EFEAD9F2273382D0077DFF6 /* AudacityApp.mm */,
|
||||
1790AFDC09883BFD008A330A /* blockfile */,
|
||||
174D9025098C78AF00D5909F /* commands */,
|
||||
@ -8399,6 +8404,7 @@
|
||||
1790B15F09883BFD008A330A /* ExportOGG.cpp in Sources */,
|
||||
1790B16009883BFD008A330A /* ExportPCM.cpp in Sources */,
|
||||
5E7396691DAFDB5600BA0A4D /* LabelDefaultClickHandle.cpp in Sources */,
|
||||
5EC4257922BA7CF2005E8AB5 /* ZoomInfo.cpp in Sources */,
|
||||
1790B16109883BFD008A330A /* FFT.cpp in Sources */,
|
||||
1790B16209883BFD008A330A /* FileFormats.cpp in Sources */,
|
||||
1790B16309883BFD008A330A /* FreqWindow.cpp in Sources */,
|
||||
|
@ -1455,3 +1455,46 @@ void Envelope::testMe()
|
||||
checkResult( 18, NextPointAfter( 0 ), 5 );
|
||||
checkResult( 19, NextPointAfter( 5 ), 10 );
|
||||
}
|
||||
|
||||
#include "ZoomInfo.h"
|
||||
void Envelope::GetValues
|
||||
( const Envelope &env,
|
||||
double alignedTime, double sampleDur,
|
||||
double *buffer, int bufferLen, int leftOffset,
|
||||
const ZoomInfo &zoomInfo )
|
||||
{
|
||||
// Getting many envelope values, corresponding to pixel columns, which may
|
||||
// not be uniformly spaced in time when there is a fisheye.
|
||||
|
||||
double prevDiscreteTime=0.0, prevSampleVal=0.0, nextSampleVal=0.0;
|
||||
for ( int xx = 0; xx < bufferLen; ++xx ) {
|
||||
auto time = zoomInfo.PositionToTime( xx, -leftOffset );
|
||||
if ( sampleDur <= 0 )
|
||||
// Sample interval not defined (as for time track)
|
||||
buffer[xx] = env.GetValue( time );
|
||||
else {
|
||||
// The level of zoom-in may resolve individual samples.
|
||||
// If so, then instead of evaluating the envelope directly,
|
||||
// we draw a piecewise curve with knees at each sample time.
|
||||
// This actually makes clearer what happens as you drag envelope
|
||||
// points and make discontinuities.
|
||||
auto leftDiscreteTime = alignedTime +
|
||||
sampleDur * floor( ( time - alignedTime ) / sampleDur );
|
||||
if ( xx == 0 || leftDiscreteTime != prevDiscreteTime ) {
|
||||
prevDiscreteTime = leftDiscreteTime;
|
||||
prevSampleVal =
|
||||
env.GetValue( prevDiscreteTime, sampleDur );
|
||||
nextSampleVal =
|
||||
env.GetValue( prevDiscreteTime + sampleDur, sampleDur );
|
||||
}
|
||||
auto ratio = ( time - leftDiscreteTime ) / sampleDur;
|
||||
if ( env.GetExponential() )
|
||||
buffer[ xx ] = exp(
|
||||
( 1.0 - ratio ) * log( prevSampleVal )
|
||||
+ ratio * log( nextSampleVal ) );
|
||||
else
|
||||
buffer[ xx ] =
|
||||
( 1.0 - ratio ) * prevSampleVal + ratio * nextSampleVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,15 @@ public:
|
||||
|
||||
virtual ~Envelope();
|
||||
|
||||
/** \brief Get many envelope points for pixel columns at once,
|
||||
* but don't assume uniform time per pixel.
|
||||
*/
|
||||
static void GetValues
|
||||
( const Envelope &env,
|
||||
double aligned_time, double sampleDur,
|
||||
double *buffer, int bufferLen, int leftOffset,
|
||||
const ZoomInfo &zoomInfo);
|
||||
|
||||
// Return true if violations of point ordering invariants were detected
|
||||
// and repaired
|
||||
bool ConsistencyCheck();
|
||||
|
@ -103,48 +103,6 @@ void EnvelopeEditor::DrawPoints
|
||||
}
|
||||
}
|
||||
|
||||
void EnvelopeEditor::GetValues
|
||||
( const Envelope &env,
|
||||
double alignedTime, double sampleDur,
|
||||
double *buffer, int bufferLen, int leftOffset,
|
||||
const ZoomInfo &zoomInfo )
|
||||
{
|
||||
// Getting many envelope values, corresponding to pixel columns, which may
|
||||
// not be uniformly spaced in time when there is a fisheye.
|
||||
|
||||
double prevDiscreteTime=0.0, prevSampleVal=0.0, nextSampleVal=0.0;
|
||||
for ( int xx = 0; xx < bufferLen; ++xx ) {
|
||||
auto time = zoomInfo.PositionToTime( xx, -leftOffset );
|
||||
if ( sampleDur <= 0 )
|
||||
// Sample interval not defined (as for time track)
|
||||
buffer[xx] = env.GetValue( time );
|
||||
else {
|
||||
// The level of zoom-in may resolve individual samples.
|
||||
// If so, then instead of evaluating the envelope directly,
|
||||
// we draw a piecewise curve with knees at each sample time.
|
||||
// This actually makes clearer what happens as you drag envelope
|
||||
// points and make discontinuities.
|
||||
auto leftDiscreteTime = alignedTime +
|
||||
sampleDur * floor( ( time - alignedTime ) / sampleDur );
|
||||
if ( xx == 0 || leftDiscreteTime != prevDiscreteTime ) {
|
||||
prevDiscreteTime = leftDiscreteTime;
|
||||
prevSampleVal =
|
||||
env.GetValue( prevDiscreteTime, sampleDur );
|
||||
nextSampleVal =
|
||||
env.GetValue( prevDiscreteTime + sampleDur, sampleDur );
|
||||
}
|
||||
auto ratio = ( time - leftDiscreteTime ) / sampleDur;
|
||||
if ( env.GetExponential() )
|
||||
buffer[ xx ] = exp(
|
||||
( 1.0 - ratio ) * log( prevSampleVal )
|
||||
+ ratio * log( nextSampleVal ) );
|
||||
else
|
||||
buffer[ xx ] =
|
||||
( 1.0 - ratio ) * prevSampleVal + ratio * nextSampleVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnvelopeEditor::EnvelopeEditor(Envelope &envelope, bool mirrored)
|
||||
: mEnvelope(envelope)
|
||||
, mMirrored(mirrored)
|
||||
|
@ -29,15 +29,6 @@ public:
|
||||
bool dB, double dBRange,
|
||||
float zoomMin, float zoomMax, bool mirrored);
|
||||
|
||||
/** \brief Get many envelope points for pixel columns at once,
|
||||
* but don't assume uniform time per pixel.
|
||||
*/
|
||||
static void GetValues
|
||||
( const Envelope &env,
|
||||
double aligned_time, double sampleDur,
|
||||
double *buffer, int bufferLen, int leftOffset,
|
||||
const ZoomInfo &zoomInfo);
|
||||
|
||||
EnvelopeEditor(Envelope &envelope, bool mirrored);
|
||||
~EnvelopeEditor();
|
||||
|
||||
|
@ -318,6 +318,8 @@ audacity_SOURCES = \
|
||||
WaveTrackLocation.h \
|
||||
WrappedType.cpp \
|
||||
WrappedType.h \
|
||||
ZoomInfo.cpp \
|
||||
ZoomInfo.h \
|
||||
wxFileNameWrapper.h \
|
||||
commands/AppCommandEvent.cpp \
|
||||
commands/AppCommandEvent.h \
|
||||
|
@ -350,8 +350,8 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \
|
||||
UndoManager.cpp UndoManager.h UserException.cpp \
|
||||
UserException.h ViewInfo.cpp ViewInfo.h VoiceKey.cpp \
|
||||
VoiceKey.h WaveClip.cpp WaveClip.h WaveTrack.cpp WaveTrack.h \
|
||||
WaveTrackLocation.h WrappedType.cpp WrappedType.h \
|
||||
wxFileNameWrapper.h commands/AppCommandEvent.cpp \
|
||||
WaveTrackLocation.h WrappedType.cpp WrappedType.h ZoomInfo.cpp \
|
||||
ZoomInfo.h wxFileNameWrapper.h commands/AppCommandEvent.cpp \
|
||||
commands/AppCommandEvent.h commands/AudacityCommand.cpp \
|
||||
commands/AudacityCommand.h commands/BatchEvalCommand.cpp \
|
||||
commands/BatchEvalCommand.h commands/Command.cpp \
|
||||
@ -708,6 +708,7 @@ am_audacity_OBJECTS = $(am__objects_1) audacity-AboutDialog.$(OBJEXT) \
|
||||
audacity-UserException.$(OBJEXT) audacity-ViewInfo.$(OBJEXT) \
|
||||
audacity-VoiceKey.$(OBJEXT) audacity-WaveClip.$(OBJEXT) \
|
||||
audacity-WaveTrack.$(OBJEXT) audacity-WrappedType.$(OBJEXT) \
|
||||
audacity-ZoomInfo.$(OBJEXT) \
|
||||
commands/audacity-AppCommandEvent.$(OBJEXT) \
|
||||
commands/audacity-AudacityCommand.$(OBJEXT) \
|
||||
commands/audacity-BatchEvalCommand.$(OBJEXT) \
|
||||
@ -1439,8 +1440,8 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \
|
||||
UndoManager.cpp UndoManager.h UserException.cpp \
|
||||
UserException.h ViewInfo.cpp ViewInfo.h VoiceKey.cpp \
|
||||
VoiceKey.h WaveClip.cpp WaveClip.h WaveTrack.cpp WaveTrack.h \
|
||||
WaveTrackLocation.h WrappedType.cpp WrappedType.h \
|
||||
wxFileNameWrapper.h commands/AppCommandEvent.cpp \
|
||||
WaveTrackLocation.h WrappedType.cpp WrappedType.h ZoomInfo.cpp \
|
||||
ZoomInfo.h wxFileNameWrapper.h commands/AppCommandEvent.cpp \
|
||||
commands/AppCommandEvent.h commands/AudacityCommand.cpp \
|
||||
commands/AudacityCommand.h commands/BatchEvalCommand.cpp \
|
||||
commands/BatchEvalCommand.h commands/Command.cpp \
|
||||
@ -2653,6 +2654,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-WaveClip.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-WaveTrack.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-WrappedType.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audacity-ZoomInfo.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaudacity_la-BlockFile.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaudacity_la-DirManager.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaudacity_la-Dither.Plo@am__quote@
|
||||
@ -4720,6 +4722,20 @@ audacity-WrappedType.obj: WrappedType.cpp
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-WrappedType.obj `if test -f 'WrappedType.cpp'; then $(CYGPATH_W) 'WrappedType.cpp'; else $(CYGPATH_W) '$(srcdir)/WrappedType.cpp'; fi`
|
||||
|
||||
audacity-ZoomInfo.o: ZoomInfo.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-ZoomInfo.o -MD -MP -MF $(DEPDIR)/audacity-ZoomInfo.Tpo -c -o audacity-ZoomInfo.o `test -f 'ZoomInfo.cpp' || echo '$(srcdir)/'`ZoomInfo.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-ZoomInfo.Tpo $(DEPDIR)/audacity-ZoomInfo.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ZoomInfo.cpp' object='audacity-ZoomInfo.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-ZoomInfo.o `test -f 'ZoomInfo.cpp' || echo '$(srcdir)/'`ZoomInfo.cpp
|
||||
|
||||
audacity-ZoomInfo.obj: ZoomInfo.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT audacity-ZoomInfo.obj -MD -MP -MF $(DEPDIR)/audacity-ZoomInfo.Tpo -c -o audacity-ZoomInfo.obj `if test -f 'ZoomInfo.cpp'; then $(CYGPATH_W) 'ZoomInfo.cpp'; else $(CYGPATH_W) '$(srcdir)/ZoomInfo.cpp'; fi`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/audacity-ZoomInfo.Tpo $(DEPDIR)/audacity-ZoomInfo.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ZoomInfo.cpp' object='audacity-ZoomInfo.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o audacity-ZoomInfo.obj `if test -f 'ZoomInfo.cpp'; then $(CYGPATH_W) 'ZoomInfo.cpp'; else $(CYGPATH_W) '$(srcdir)/ZoomInfo.cpp'; fi`
|
||||
|
||||
commands/audacity-AppCommandEvent.o: commands/AppCommandEvent.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT commands/audacity-AppCommandEvent.o -MD -MP -MF commands/$(DEPDIR)/audacity-AppCommandEvent.Tpo -c -o commands/audacity-AppCommandEvent.o `test -f 'commands/AppCommandEvent.cpp' || echo '$(srcdir)/'`commands/AppCommandEvent.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) commands/$(DEPDIR)/audacity-AppCommandEvent.Tpo commands/$(DEPDIR)/audacity-AppCommandEvent.Po
|
||||
|
@ -22,17 +22,13 @@
|
||||
#include <wx/wxcrtvararg.h>
|
||||
#include <wx/dc.h>
|
||||
#include <wx/intl.h>
|
||||
#include "AColor.h"
|
||||
#include "widgets/Ruler.h"
|
||||
#include "Envelope.h"
|
||||
#include "EnvelopeEditor.h"
|
||||
#include "Prefs.h"
|
||||
#include "Project.h"
|
||||
#include "ProjectSettings.h"
|
||||
#include "ProjectFileIORegistry.h"
|
||||
#include "TrackArtist.h"
|
||||
#include "ViewInfo.h"
|
||||
#include "AllThemeResources.h"
|
||||
|
||||
//TODO-MB: are these sensible values?
|
||||
#define TIMETRACK_MIN 0.01
|
||||
@ -272,70 +268,6 @@ void TimeTrack::WriteXML(XMLWriter &xmlFile) const
|
||||
xmlFile.EndTag(wxT("timetrack"));
|
||||
}
|
||||
|
||||
#include "TrackPanelDrawingContext.h"
|
||||
#include "tracks/ui/EnvelopeHandle.h"
|
||||
|
||||
void TimeTrack::Draw
|
||||
( TrackPanelDrawingContext &context, const wxRect & r ) const
|
||||
{
|
||||
auto &dc = context.dc;
|
||||
const auto artist = TrackArtist::Get( context );
|
||||
const auto &zoomInfo = *artist->pZoomInfo;
|
||||
|
||||
bool highlight = false;
|
||||
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
|
||||
auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
|
||||
highlight = target && target->GetEnvelope() == this->GetEnvelope();
|
||||
#endif
|
||||
|
||||
double min = zoomInfo.PositionToTime(0);
|
||||
double max = zoomInfo.PositionToTime(r.width);
|
||||
if (min > max)
|
||||
{
|
||||
wxASSERT(false);
|
||||
min = max;
|
||||
}
|
||||
|
||||
AColor::UseThemeColour( &dc, clrUnselected );
|
||||
dc.DrawRectangle(r);
|
||||
|
||||
//copy this rectangle away for future use.
|
||||
wxRect mid = r;
|
||||
|
||||
// Draw the Ruler
|
||||
mRuler->SetBounds(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
|
||||
mRuler->SetRange(min, max);
|
||||
mRuler->SetFlip(false); // If we don't do this, the Ruler doesn't redraw itself when the envelope is modified.
|
||||
// I have no idea why!
|
||||
//
|
||||
// LL: It's because the ruler only Invalidate()s when the NEW value is different
|
||||
// than the current value.
|
||||
mRuler->SetFlip( true );
|
||||
//mRuler->SetFlip(GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
|
||||
mRuler->SetTickColour( theTheme.Colour( clrTrackPanelText ));
|
||||
mRuler->Draw(dc, GetEnvelope());
|
||||
|
||||
Doubles envValues{ size_t(mid.width) };
|
||||
EnvelopeEditor::GetValues( *GetEnvelope(),
|
||||
0, 0, envValues.get(), mid.width, 0, zoomInfo );
|
||||
|
||||
wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
|
||||
dc.SetPen( pen );
|
||||
|
||||
double logLower = log(std::max(1.0e-7, GetRangeLower())),
|
||||
logUpper = log(std::max(1.0e-7, GetRangeUpper()));
|
||||
for (int x = 0; x < mid.width; x++)
|
||||
{
|
||||
double y;
|
||||
if(mDisplayLog)
|
||||
y = (double)mid.height * (logUpper - log(envValues[x])) / (logUpper - logLower);
|
||||
else
|
||||
y = (double)mid.height * (GetRangeUpper() - envValues[x]) / (GetRangeUpper() - GetRangeLower());
|
||||
int thisy = r.y + (int)y;
|
||||
AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
|
||||
}
|
||||
}
|
||||
|
||||
void TimeTrack::testMe()
|
||||
{
|
||||
GetEnvelope()->Flatten(0.0);
|
||||
|
@ -55,9 +55,6 @@ class TimeTrack final : public Track {
|
||||
double GetStartTime() const override { return 0.0; }
|
||||
double GetEndTime() const override { return 0.0; }
|
||||
|
||||
void Draw
|
||||
( TrackPanelDrawingContext &context, const wxRect & r ) const;
|
||||
|
||||
// XMLTagHandler callback methods for loading and saving
|
||||
|
||||
bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
|
||||
@ -91,6 +88,8 @@ class TimeTrack final : public Track {
|
||||
|
||||
void testMe();
|
||||
|
||||
Ruler &GetRuler() const { return *mRuler; } // hide this later
|
||||
|
||||
private:
|
||||
// Identifying the type of track
|
||||
TrackKind GetKind() const override { return TrackKind::Time; }
|
||||
|
@ -1816,7 +1816,7 @@ void TrackArt::DrawClipWaveform(TrackPanelDrawingContext &context,
|
||||
|
||||
std::vector<double> vEnv(mid.width);
|
||||
double *const env = &vEnv[0];
|
||||
EnvelopeEditor::GetValues( *clip->GetEnvelope(),
|
||||
Envelope::GetValues( *clip->GetEnvelope(),
|
||||
tOffset,
|
||||
|
||||
// PRL: change back to make envelope evaluate only at sample times
|
||||
@ -1956,7 +1956,7 @@ void TrackArt::DrawClipWaveform(TrackPanelDrawingContext &context,
|
||||
if (!showIndividualSamples) {
|
||||
std::vector<double> vEnv2(rectPortion.width);
|
||||
double *const env2 = &vEnv2[0];
|
||||
EnvelopeEditor::GetValues( *clip->GetEnvelope(),
|
||||
Envelope::GetValues( *clip->GetEnvelope(),
|
||||
tOffset,
|
||||
|
||||
// PRL: change back to make envelope evaluate only at sample times
|
||||
@ -3254,11 +3254,79 @@ void TrackArt::DrawNoteTrack(TrackPanelDrawingContext &context,
|
||||
#endif // USE_MIDI
|
||||
|
||||
|
||||
// Header needed only for experimental drawing below
|
||||
//#include "tracks/ui/EnvelopeHandle.h"
|
||||
namespace {
|
||||
void DrawHorzRulerAndCurve
|
||||
( TrackPanelDrawingContext &context, const wxRect & r,
|
||||
const TimeTrack &track, Ruler &ruler )
|
||||
{
|
||||
auto &dc = context.dc;
|
||||
const auto artist = TrackArtist::Get( context );
|
||||
const auto &zoomInfo = *artist->pZoomInfo;
|
||||
|
||||
bool highlight = false;
|
||||
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
|
||||
auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
|
||||
highlight = target && target->GetEnvelope() == this->GetEnvelope();
|
||||
#endif
|
||||
|
||||
double min = zoomInfo.PositionToTime(0);
|
||||
double max = zoomInfo.PositionToTime(r.width);
|
||||
if (min > max)
|
||||
{
|
||||
wxASSERT(false);
|
||||
min = max;
|
||||
}
|
||||
|
||||
AColor::UseThemeColour( &dc, clrUnselected );
|
||||
dc.DrawRectangle(r);
|
||||
|
||||
//copy this rectangle away for future use.
|
||||
wxRect mid = r;
|
||||
|
||||
// Draw the Ruler
|
||||
ruler.SetBounds(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
|
||||
ruler.SetRange(min, max);
|
||||
ruler.SetFlip(false); // If we don't do this, the Ruler doesn't redraw itself when the envelope is modified.
|
||||
// I have no idea why!
|
||||
//
|
||||
// LL: It's because the ruler only Invalidate()s when the NEW value is different
|
||||
// than the current value.
|
||||
ruler.SetFlip( true );
|
||||
// ruler.SetFlip(track.GetHeight() > 75 ? true : true); // MB: so why don't we just call Invalidate()? :)
|
||||
ruler.SetTickColour( theTheme.Colour( clrTrackPanelText ));
|
||||
ruler.Draw(dc, track.GetEnvelope());
|
||||
|
||||
Doubles envValues{ size_t(mid.width) };
|
||||
Envelope::GetValues( *track.GetEnvelope(),
|
||||
0, 0, envValues.get(), mid.width, 0, zoomInfo );
|
||||
|
||||
wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
|
||||
dc.SetPen( pen );
|
||||
|
||||
auto rangeLower = track.GetRangeLower(), rangeUpper = track.GetRangeUpper();
|
||||
double logLower = log(std::max(1.0e-7, rangeLower)),
|
||||
logUpper = log(std::max(1.0e-7, rangeUpper));
|
||||
|
||||
for (int x = 0; x < mid.width; x++)
|
||||
{
|
||||
double y;
|
||||
if ( track.GetDisplayLog() )
|
||||
y = (double)mid.height * (logUpper - log(envValues[x])) / (logUpper - logLower);
|
||||
else
|
||||
y = (double)mid.height * (rangeUpper - envValues[x]) / (rangeUpper - rangeLower);
|
||||
int thisy = r.y + (int)y;
|
||||
AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrackArt::DrawTimeTrack(TrackPanelDrawingContext &context,
|
||||
const TimeTrack *track,
|
||||
const wxRect & rect)
|
||||
{
|
||||
track->Draw( context, rect );
|
||||
DrawHorzRulerAndCurve( context, rect, *track, track->GetRuler() );
|
||||
wxRect envRect = rect;
|
||||
envRect.height -= 2;
|
||||
double lower = track->GetRangeLower(), upper = track->GetRangeUpper();
|
||||
|
121
src/ViewInfo.cpp
121
src/ViewInfo.cpp
@ -15,133 +15,12 @@ Paul Licameli
|
||||
#include <algorithm>
|
||||
|
||||
#include "AudioIOBase.h"
|
||||
#include "prefs/GUISettings.h"
|
||||
#include "Prefs.h"
|
||||
#include "Project.h"
|
||||
#include "xml/XMLWriter.h"
|
||||
#include "prefs/TracksBehaviorsPrefs.h"
|
||||
#include "xml/XMLWriter.h"
|
||||
|
||||
namespace {
|
||||
static const double gMaxZoom = 6000000;
|
||||
static const double gMinZoom = 0.001;
|
||||
}
|
||||
|
||||
ZoomInfo &ZoomInfo::Get( AudacityProject &project )
|
||||
{
|
||||
return ViewInfo::Get( project );
|
||||
}
|
||||
|
||||
const ZoomInfo &ZoomInfo::Get( const AudacityProject &project )
|
||||
{
|
||||
return Get( const_cast< AudacityProject & >( project ) );
|
||||
}
|
||||
|
||||
ZoomInfo::ZoomInfo(double start, double pixelsPerSecond)
|
||||
: vpos(0)
|
||||
, h(start)
|
||||
, zoom(pixelsPerSecond)
|
||||
{
|
||||
UpdatePrefs();
|
||||
}
|
||||
|
||||
ZoomInfo::~ZoomInfo()
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomInfo::UpdatePrefs()
|
||||
{
|
||||
dBr = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE);
|
||||
}
|
||||
|
||||
/// Converts a position (mouse X coordinate) to
|
||||
/// project time, in seconds. Needs the left edge of
|
||||
/// the track as an additional parameter.
|
||||
double ZoomInfo::PositionToTime(wxInt64 position,
|
||||
wxInt64 origin
|
||||
, bool // ignoreFisheye
|
||||
) const
|
||||
{
|
||||
return h + (position - origin) / zoom;
|
||||
}
|
||||
|
||||
|
||||
/// STM: Converts a project time to screen x position.
|
||||
wxInt64 ZoomInfo::TimeToPosition(double projectTime,
|
||||
wxInt64 origin
|
||||
, bool // ignoreFisheye
|
||||
) const
|
||||
{
|
||||
double t = 0.5 + zoom * (projectTime - h) + origin ;
|
||||
if( t < wxINT64_MIN )
|
||||
return wxINT64_MIN;
|
||||
if( t > wxINT64_MAX )
|
||||
return wxINT64_MAX;
|
||||
t = floor( t );
|
||||
return t;
|
||||
}
|
||||
|
||||
// This always ignores the fisheye. Use with caution!
|
||||
// You should prefer to call TimeToPosition twice, for endpoints, and take the difference!
|
||||
double ZoomInfo::TimeRangeToPixelWidth(double timeRange) const
|
||||
{
|
||||
return timeRange * zoom;
|
||||
}
|
||||
|
||||
bool ZoomInfo::ZoomInAvailable() const
|
||||
{
|
||||
return zoom < gMaxZoom;
|
||||
}
|
||||
|
||||
bool ZoomInfo::ZoomOutAvailable() const
|
||||
{
|
||||
return zoom > gMinZoom;
|
||||
}
|
||||
|
||||
double ZoomInfo::GetZoom( ) const { return zoom;};
|
||||
double ZoomInfo::GetMaxZoom( ) { return gMaxZoom;};
|
||||
double ZoomInfo::GetMinZoom( ) { return gMinZoom;};
|
||||
|
||||
void ZoomInfo::SetZoom(double pixelsPerSecond)
|
||||
{
|
||||
zoom = std::max(gMinZoom, std::min(gMaxZoom, pixelsPerSecond));
|
||||
// DA: Avoids stuck in snap-to
|
||||
#ifdef EXPERIMENTAL_DA
|
||||
// Disable snapping if user zooms in a long way.
|
||||
// Helps stop users be trapped in snap-to.
|
||||
// The level chosen is in sample viewing range with samples
|
||||
// still quite close together.
|
||||
if( zoom > (gMaxZoom * 0.06 ))
|
||||
{
|
||||
AudacityProject * project = GetActiveProject();
|
||||
if( project )
|
||||
project->OnSnapToOff();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ZoomInfo::ZoomBy(double multiplier)
|
||||
{
|
||||
SetZoom(zoom * multiplier);
|
||||
}
|
||||
|
||||
void ZoomInfo::FindIntervals
|
||||
(double /*rate*/, Intervals &results, wxInt64 width, wxInt64 origin) const
|
||||
{
|
||||
results.clear();
|
||||
results.reserve(2);
|
||||
|
||||
const wxInt64 rightmost(origin + (0.5 + width));
|
||||
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);
|
||||
}
|
||||
|
||||
static const AudacityProject::AttachedObjects::RegisteredFactory key{
|
||||
[]( AudacityProject &project ) {
|
||||
auto result =
|
||||
|
131
src/ViewInfo.h
131
src/ViewInfo.h
@ -14,20 +14,11 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <wx/event.h> // inherit wxEvtHandler
|
||||
#include "ClientData.h"
|
||||
#include "SelectedRegion.h"
|
||||
#include "MemoryX.h"
|
||||
#include "Prefs.h"
|
||||
#include "ZoomInfo.h" // to inherit
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CONST
|
||||
#else
|
||||
#define CONST const
|
||||
#endif
|
||||
|
||||
class AudacityProject;
|
||||
|
||||
// See big pictorial comment in TrackPanel.cpp for explanation of these numbers
|
||||
enum : int {
|
||||
kLeftInset = 4,
|
||||
@ -51,126 +42,6 @@ enum : int {
|
||||
kTrackInfoSliderExtra = 5,
|
||||
};
|
||||
|
||||
// The subset of ViewInfo information (other than selection)
|
||||
// that is sufficient for purposes of TrackArtist,
|
||||
// and for computing conversions between track times and pixel positions.
|
||||
class AUDACITY_DLL_API ZoomInfo /* not final */
|
||||
// Note that ViewInfo inherits from ZoomInfo but there are no virtual functions.
|
||||
// That's okay if we pass always by reference and never copy, suffering "slicing."
|
||||
: public ClientData::Base
|
||||
, protected PrefsListener
|
||||
{
|
||||
public:
|
||||
static ZoomInfo &Get( AudacityProject &project );
|
||||
static const ZoomInfo &Get( const AudacityProject &project );
|
||||
|
||||
ZoomInfo(double start, double pixelsPerSecond);
|
||||
~ZoomInfo();
|
||||
|
||||
// Be sure we don't slice
|
||||
ZoomInfo(const ZoomInfo&) PROHIBITED;
|
||||
ZoomInfo& operator= (const ZoomInfo&) PROHIBITED;
|
||||
|
||||
void UpdatePrefs() override;
|
||||
|
||||
int vpos; // vertical scroll pos
|
||||
|
||||
double h; // h pos in secs
|
||||
|
||||
protected:
|
||||
double zoom; // pixels per second
|
||||
|
||||
public:
|
||||
float dBr; // decibel scale range
|
||||
|
||||
// do NOT use this once to convert a pixel width to a duration!
|
||||
// Instead, call twice to convert start and end times,
|
||||
// and take the difference.
|
||||
// origin specifies the pixel corresponding to time h
|
||||
double PositionToTime(wxInt64 position,
|
||||
wxInt64 origin = 0
|
||||
, bool ignoreFisheye = false
|
||||
) const;
|
||||
|
||||
// do NOT use this once to convert a duration to a pixel width!
|
||||
// Instead, call twice to convert start and end positions,
|
||||
// and take the difference.
|
||||
// origin specifies the pixel corresponding to time h
|
||||
wxInt64 TimeToPosition(double time,
|
||||
wxInt64 origin = 0
|
||||
, bool ignoreFisheye = false
|
||||
) const;
|
||||
|
||||
// This always ignores the fisheye. Use with caution!
|
||||
// You should prefer to call TimeToPosition twice, for endpoints, and take the difference!
|
||||
double TimeRangeToPixelWidth(double timeRange) const;
|
||||
|
||||
double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye = false) const
|
||||
{
|
||||
return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye);
|
||||
}
|
||||
|
||||
bool ZoomInAvailable() const;
|
||||
bool ZoomOutAvailable() const;
|
||||
|
||||
static double GetDefaultZoom()
|
||||
{ return 44100.0 / 512.0; }
|
||||
|
||||
|
||||
// Limits zoom to certain bounds
|
||||
void SetZoom(double pixelsPerSecond);
|
||||
|
||||
// This function should not be used to convert positions to times and back
|
||||
// Use TimeToPosition and PositionToTime and OffsetTimeByPixels instead
|
||||
double GetZoom() const;
|
||||
|
||||
static double GetMaxZoom( );
|
||||
static double GetMinZoom( );
|
||||
|
||||
// Limits zoom to certain bounds
|
||||
// multipliers above 1.0 zoom in, below out
|
||||
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 width, 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 WXUNUSED(origin = 0)) const
|
||||
{return false;} // stub
|
||||
|
||||
// These accessors ignore the fisheye hiding state.
|
||||
// Inclusive:
|
||||
wxInt64 GetFisheyeLeftBoundary(wxInt64 WXUNUSED(origin = 0)) const
|
||||
{return 0;} // stub
|
||||
// Exclusive:
|
||||
wxInt64 GetFisheyeRightBoundary(wxInt64 WXUNUSED(origin = 0)) const
|
||||
{return 0;} // stub
|
||||
};
|
||||
|
||||
class PlayRegion
|
||||
{
|
||||
public:
|
||||
|
123
src/ZoomInfo.cpp
Normal file
123
src/ZoomInfo.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ZoomInfo.cpp
|
||||
|
||||
Paul Licameli split from ViewInfo.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "ZoomInfo.h"
|
||||
|
||||
#include "prefs/GUISettings.h"
|
||||
|
||||
namespace {
|
||||
static const double gMaxZoom = 6000000;
|
||||
static const double gMinZoom = 0.001;
|
||||
}
|
||||
|
||||
ZoomInfo::ZoomInfo(double start, double pixelsPerSecond)
|
||||
: vpos(0)
|
||||
, h(start)
|
||||
, zoom(pixelsPerSecond)
|
||||
{
|
||||
UpdatePrefs();
|
||||
}
|
||||
|
||||
ZoomInfo::~ZoomInfo()
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomInfo::UpdatePrefs()
|
||||
{
|
||||
dBr = gPrefs->Read(ENV_DB_KEY, ENV_DB_RANGE);
|
||||
}
|
||||
|
||||
/// Converts a position (mouse X coordinate) to
|
||||
/// project time, in seconds. Needs the left edge of
|
||||
/// the track as an additional parameter.
|
||||
double ZoomInfo::PositionToTime(wxInt64 position,
|
||||
wxInt64 origin
|
||||
, bool // ignoreFisheye
|
||||
) const
|
||||
{
|
||||
return h + (position - origin) / zoom;
|
||||
}
|
||||
|
||||
|
||||
/// STM: Converts a project time to screen x position.
|
||||
wxInt64 ZoomInfo::TimeToPosition(double projectTime,
|
||||
wxInt64 origin
|
||||
, bool // ignoreFisheye
|
||||
) const
|
||||
{
|
||||
double t = 0.5 + zoom * (projectTime - h) + origin ;
|
||||
if( t < wxINT64_MIN )
|
||||
return wxINT64_MIN;
|
||||
if( t > wxINT64_MAX )
|
||||
return wxINT64_MAX;
|
||||
t = floor( t );
|
||||
return t;
|
||||
}
|
||||
|
||||
// This always ignores the fisheye. Use with caution!
|
||||
// You should prefer to call TimeToPosition twice, for endpoints, and take the difference!
|
||||
double ZoomInfo::TimeRangeToPixelWidth(double timeRange) const
|
||||
{
|
||||
return timeRange * zoom;
|
||||
}
|
||||
|
||||
bool ZoomInfo::ZoomInAvailable() const
|
||||
{
|
||||
return zoom < gMaxZoom;
|
||||
}
|
||||
|
||||
bool ZoomInfo::ZoomOutAvailable() const
|
||||
{
|
||||
return zoom > gMinZoom;
|
||||
}
|
||||
|
||||
double ZoomInfo::GetZoom( ) const { return zoom;};
|
||||
double ZoomInfo::GetMaxZoom( ) { return gMaxZoom;};
|
||||
double ZoomInfo::GetMinZoom( ) { return gMinZoom;};
|
||||
|
||||
void ZoomInfo::SetZoom(double pixelsPerSecond)
|
||||
{
|
||||
zoom = std::max(gMinZoom, std::min(gMaxZoom, pixelsPerSecond));
|
||||
// DA: Avoids stuck in snap-to
|
||||
#ifdef EXPERIMENTAL_DA
|
||||
// Disable snapping if user zooms in a long way.
|
||||
// Helps stop users be trapped in snap-to.
|
||||
// The level chosen is in sample viewing range with samples
|
||||
// still quite close together.
|
||||
if( zoom > (gMaxZoom * 0.06 ))
|
||||
{
|
||||
AudacityProject * project = GetActiveProject();
|
||||
if( project )
|
||||
project->OnSnapToOff();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ZoomInfo::ZoomBy(double multiplier)
|
||||
{
|
||||
SetZoom(zoom * multiplier);
|
||||
}
|
||||
|
||||
void ZoomInfo::FindIntervals
|
||||
(double /*rate*/, Intervals &results, wxInt64 width, wxInt64 origin) const
|
||||
{
|
||||
results.clear();
|
||||
results.reserve(2);
|
||||
|
||||
const wxInt64 rightmost(origin + (0.5 + width));
|
||||
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);
|
||||
}
|
142
src/ZoomInfo.h
Normal file
142
src/ZoomInfo.h
Normal file
@ -0,0 +1,142 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ZoomInfo.h
|
||||
|
||||
Paul Licameli split from ViewInfo.h
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_ZOOM_INFO__
|
||||
#define __AUDACITY_ZOOM_INFO__
|
||||
|
||||
#include "ClientData.h" // to inherit
|
||||
#include "Prefs.h" // to inherit
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CONST
|
||||
#else
|
||||
#define CONST const
|
||||
#endif
|
||||
|
||||
class AudacityProject;
|
||||
|
||||
// The subset of ViewInfo information (other than selection)
|
||||
// that is sufficient for purposes of TrackArtist,
|
||||
// and for computing conversions between track times and pixel positions.
|
||||
class AUDACITY_DLL_API ZoomInfo /* not final */
|
||||
// Note that ViewInfo inherits from ZoomInfo but there are no virtual functions.
|
||||
// That's okay if we pass always by reference and never copy, suffering "slicing."
|
||||
: public ClientData::Base
|
||||
, protected PrefsListener
|
||||
{
|
||||
public:
|
||||
ZoomInfo(double start, double pixelsPerSecond);
|
||||
~ZoomInfo();
|
||||
|
||||
// Be sure we don't slice
|
||||
ZoomInfo(const ZoomInfo&) PROHIBITED;
|
||||
ZoomInfo& operator= (const ZoomInfo&) PROHIBITED;
|
||||
|
||||
void UpdatePrefs() override;
|
||||
|
||||
int vpos; // vertical scroll pos
|
||||
|
||||
double h; // h pos in secs
|
||||
|
||||
protected:
|
||||
double zoom; // pixels per second
|
||||
|
||||
public:
|
||||
float dBr; // decibel scale range
|
||||
|
||||
// do NOT use this once to convert a pixel width to a duration!
|
||||
// Instead, call twice to convert start and end times,
|
||||
// and take the difference.
|
||||
// origin specifies the pixel corresponding to time h
|
||||
double PositionToTime(wxInt64 position,
|
||||
wxInt64 origin = 0
|
||||
, bool ignoreFisheye = false
|
||||
) const;
|
||||
|
||||
// do NOT use this once to convert a duration to a pixel width!
|
||||
// Instead, call twice to convert start and end positions,
|
||||
// and take the difference.
|
||||
// origin specifies the pixel corresponding to time h
|
||||
wxInt64 TimeToPosition(double time,
|
||||
wxInt64 origin = 0
|
||||
, bool ignoreFisheye = false
|
||||
) const;
|
||||
|
||||
// This always ignores the fisheye. Use with caution!
|
||||
// You should prefer to call TimeToPosition twice, for endpoints, and take the difference!
|
||||
double TimeRangeToPixelWidth(double timeRange) const;
|
||||
|
||||
double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye = false) const
|
||||
{
|
||||
return PositionToTime(offset + TimeToPosition(time, ignoreFisheye), ignoreFisheye);
|
||||
}
|
||||
|
||||
bool ZoomInAvailable() const;
|
||||
bool ZoomOutAvailable() const;
|
||||
|
||||
static double GetDefaultZoom()
|
||||
{ return 44100.0 / 512.0; }
|
||||
|
||||
|
||||
// Limits zoom to certain bounds
|
||||
void SetZoom(double pixelsPerSecond);
|
||||
|
||||
// This function should not be used to convert positions to times and back
|
||||
// Use TimeToPosition and PositionToTime and OffsetTimeByPixels instead
|
||||
double GetZoom() const;
|
||||
|
||||
static double GetMaxZoom( );
|
||||
static double GetMinZoom( );
|
||||
|
||||
// Limits zoom to certain bounds
|
||||
// multipliers above 1.0 zoom in, below out
|
||||
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 width, 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 WXUNUSED(origin = 0)) const
|
||||
{return false;} // stub
|
||||
|
||||
// These accessors ignore the fisheye hiding state.
|
||||
// Inclusive:
|
||||
wxInt64 GetFisheyeLeftBoundary(wxInt64 WXUNUSED(origin = 0)) const
|
||||
{return 0;} // stub
|
||||
// Exclusive:
|
||||
wxInt64 GetFisheyeRightBoundary(wxInt64 WXUNUSED(origin = 0)) const
|
||||
{return 0;} // stub
|
||||
};
|
||||
|
||||
#endif
|
@ -61,7 +61,7 @@ std::pair<wxRect, bool> EditCursorOverlay::DoGetRectangle(wxSize size)
|
||||
}
|
||||
else {
|
||||
mCursorTime = selection.t0();
|
||||
mNewCursorX = ZoomInfo::Get( *mProject ).TimeToPosition(
|
||||
mNewCursorX = ViewInfo::Get( *mProject ).TimeToPosition(
|
||||
mCursorTime, TrackPanel::Get( *mProject ).GetLeftOffset());
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ void EditCursorOverlay::Draw(OverlayPanel &panel, wxDC &dc)
|
||||
if (mLastCursorX == -1)
|
||||
return;
|
||||
|
||||
const auto &viewInfo = ZoomInfo::Get( *mProject );
|
||||
const auto &viewInfo = ViewInfo::Get( *mProject );
|
||||
|
||||
auto &trackPanel = TrackPanel::Get( *mProject );
|
||||
const bool
|
||||
|
@ -321,6 +321,7 @@
|
||||
<ClCompile Include="..\..\..\src\VoiceKey.cpp" />
|
||||
<ClCompile Include="..\..\..\src\WaveClip.cpp" />
|
||||
<ClCompile Include="..\..\..\src\WaveTrack.cpp" />
|
||||
<ClCompile Include="..\..\..\src\ZoomInfo.cpp" />
|
||||
<ClCompile Include="..\..\..\src\widgets\BackedPanel.cpp" />
|
||||
<ClCompile Include="..\..\..\src\widgets\HelpSystem.cpp" />
|
||||
<ClCompile Include="..\..\..\src\widgets\NumericTextCtrl.cpp" />
|
||||
@ -714,6 +715,7 @@
|
||||
<ClInclude Include="..\..\..\src\WaveClip.h" />
|
||||
<ClInclude Include="..\..\..\src\WaveTrack.h" />
|
||||
<ClInclude Include="..\..\..\src\WrappedType.h" />
|
||||
<ClInclude Include="..\..\..\src\ZoomInfo.h" />
|
||||
<ClInclude Include="..\..\..\src\effects\Amplify.h" />
|
||||
<ClInclude Include="..\..\..\src\effects\AutoDuck.h" />
|
||||
<ClInclude Include="..\..\..\src\effects\BassTreble.h" />
|
||||
|
@ -383,6 +383,9 @@
|
||||
<ClCompile Include="..\..\..\src\WrappedType.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\ZoomInfo.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\effects\Amplify.cpp">
|
||||
<Filter>src\effects</Filter>
|
||||
</ClCompile>
|
||||
@ -1495,6 +1498,9 @@
|
||||
<ClInclude Include="..\..\..\src\WrappedType.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\ZoomInfo.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\effects\Amplify.h">
|
||||
<Filter>src\effects</Filter>
|
||||
</ClInclude>
|
||||
|
Loading…
x
Reference in New Issue
Block a user