1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 16:19:43 +02:00

Split "Do" functions out of the "Set" functions for some Track settings

This commit is contained in:
Paul Licameli 2018-01-11 20:57:37 -05:00
parent 92ba1f10e1
commit 8b60e7f02d
6 changed files with 60 additions and 14 deletions

View File

@ -210,11 +210,11 @@ double NoteTrack::GetEndTime() const
return GetStartTime() + GetSeq().get_real_dur();
}
void NoteTrack::SetHeight(int h)
void NoteTrack::DoSetHeight(int h)
{
auto oldHeight = GetHeight();
auto oldMargin = GetNoteMargin(oldHeight);
Track::SetHeight(h);
PlayableTrack::DoSetHeight(h);
auto margin = GetNoteMargin(h);
Zoom(
wxRect{ 0, 0, 1, h }, // only height matters

View File

@ -84,7 +84,7 @@ class AUDACITY_DLL_API NoteTrack final
double GetStartTime() const override;
double GetEndTime() const override;
void SetHeight(int h) override;
void DoSetHeight(int h) override;
Alg_seq &GetSeq() const;

View File

@ -153,6 +153,11 @@ int Track::GetY() const
}
void Track::SetY(int y)
{
DoSetY(y);
}
void Track::DoSetY(int y)
{
mY = y;
}
@ -168,14 +173,21 @@ int Track::GetHeight() const
void Track::SetHeight(int h)
{
mHeight = h;
auto pList = mList.lock();
DoSetHeight(h);
if (pList) {
pList->RecalcPositions(mNode);
pList->ResizingEvent(mNode);
}
}
void Track::DoSetHeight(int h)
{
mHeight = h;
}
bool Track::GetMinimized() const
{
return mMinimized;
@ -184,23 +196,37 @@ bool Track::GetMinimized() const
void Track::SetMinimized(bool isMinimized)
{
auto pList = mList.lock();
mMinimized = isMinimized;
DoSetMinimized(isMinimized);
if (pList) {
pList->RecalcPositions(mNode);
pList->ResizingEvent(mNode);
}
}
void Track::DoSetMinimized(bool isMinimized)
{
mMinimized = isMinimized;
}
void Track::SetLinked(bool l)
{
auto pList = mList.lock();
mLinked = l;
DoSetLinked(l);
if (pList) {
pList->RecalcPositions(mNode);
pList->ResizingEvent(mNode);
}
}
void Track::DoSetLinked(bool l)
{
mLinked = l;
}
Track *Track::GetLink() const
{
auto pList = mList.lock();
@ -787,7 +813,7 @@ void TrackList::RecalcPositions(TrackNodePointer node)
for (auto n = TrackListIterator{ this, node }; n != theEnd; ++n) {
t = *n;
t->SetIndex(i++);
t->SetY(y);
t->DoSetY(y);
y += t->GetHeight();
}
}

View File

@ -151,12 +151,28 @@ class AUDACITY_DLL_API Track /* not final */
int GetIndex() const;
void SetIndex(int index);
int GetY() const;
private:
// Always maintain a strictly contiguous layout of tracks.
// So client code is not permitted to modify this attribute directly.
void SetY(int y);
// No need yet to make this virtual
void DoSetY(int y);
public:
int GetHeight() const;
virtual void SetHeight(int h);
void SetHeight(int h);
protected:
virtual void DoSetHeight(int h);
public:
bool GetMinimized() const;
virtual void SetMinimized(bool isMinimized);
void SetMinimized(bool isMinimized);
protected:
virtual void DoSetMinimized(bool isMinimized);
public:
Track *GetLink() const;
private:
@ -215,10 +231,14 @@ class AUDACITY_DLL_API Track /* not final */
void SetDefaultName( const wxString &n ) { mDefaultName = n; }
bool GetSelected() const { return mSelected; }
bool GetLinked () const { return mLinked; }
virtual void SetSelected(bool s);
bool GetLinked () const { return mLinked; }
void SetLinked (bool l);
private:
// No need yet to make this virtual
void DoSetLinked(bool l);
public:
virtual int GetChannel() const { return mChannel;};
virtual double GetOffset() const = 0;

View File

@ -452,7 +452,7 @@ float WaveTrack::GetChannelGain(int channel) const
return right*mGain;
}
void WaveTrack::SetMinimized(bool isMinimized){
void WaveTrack::DoSetMinimized(bool isMinimized){
#ifdef EXPERIMENTAL_HALF_WAVE
// Show half wave on collapse, full on restore.
@ -465,7 +465,7 @@ void WaveTrack::SetMinimized(bool isMinimized){
pWtvc->DoZoomPreset( isMinimized ? 1:0);
#endif
Track::SetMinimized( isMinimized );
PlayableTrack::DoSetMinimized( isMinimized );
}
void WaveTrack::SetWaveColorIndex(int colorIndex)

View File

@ -132,7 +132,7 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
// Takes gain and pan into account
float GetChannelGain(int channel) const;
void SetMinimized(bool isMinimized) override;
void DoSetMinimized(bool isMinimized) override;
int GetWaveColorIndex() const { return mWaveColorIndex; };
void SetWaveColorIndex(int colorIndex);