Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
WaveformAppearance Class Reference

Persistent appearance settings that apply to all channels of a track. More...

#include <WaveformAppearance.h>

Inheritance diagram for WaveformAppearance:
[legend]
Collaboration diagram for WaveformAppearance:
[legend]

Public Member Functions

 WaveformAppearance (WaveTrack &track)
 
 ~WaveformAppearance () override
 
void CopyTo (Track &track) const override
 Copy state, for undo/redo purposes. More...
 
void Reparent (const std::shared_ptr< Track > &parent) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
void WriteXMLAttributes (XMLWriter &writer) const override
 Serialize persistent attributes. More...
 
bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView) override
 Deserialize an attribute, returning true if recognized. More...
 
int GetColorIndex () const
 
void SetColorIndex (int colorIndex)
 
- Public Member Functions inherited from TrackAttachment
virtual ~TrackAttachment ()
 
virtual void CopyTo (Track &track) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 Deserialize an attribute, returning true if recognized. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static WaveformAppearanceGet (WaveTrack &track)
 
static const WaveformAppearanceGet (const WaveTrack &track)
 
static WaveformAppearanceGet (WaveChannel &channel)
 
static const WaveformAppearanceGet (const WaveChannel &channel)
 

Private Member Functions

void Subscribe (const std::shared_ptr< WaveTrack > &pTrack)
 

Private Attributes

std::weak_ptr< WaveTrackmwTrack
 
Observer::Subscription mSubscription
 
int mColorIndex { 0 }
 

Detailed Description

Persistent appearance settings that apply to all channels of a track.

Definition at line 18 of file WaveformAppearance.h.

Constructor & Destructor Documentation

◆ WaveformAppearance()

WaveformAppearance::WaveformAppearance ( WaveTrack track)
explicit

Definition at line 45 of file WaveformAppearance.cpp.

46 : mwTrack{
47 std::static_pointer_cast<WaveTrack>(track.shared_from_this()) }
48{
49 Subscribe(mwTrack.lock());
50}
std::weak_ptr< WaveTrack > mwTrack
void Subscribe(const std::shared_ptr< WaveTrack > &pTrack)

References mwTrack, and Subscribe().

Here is the call graph for this function:

◆ ~WaveformAppearance()

WaveformAppearance::~WaveformAppearance ( )
overridedefault

Member Function Documentation

◆ CopyTo()

void WaveformAppearance::CopyTo ( Track track) const
overridevirtual

Copy state, for undo/redo purposes.

Reimplemented from TrackAttachment.

Definition at line 71 of file WaveformAppearance.cpp.

72{
73 if (const auto pTrack = dynamic_cast<WaveTrack *>(&track)) {
74 auto &other = Get(*pTrack);
75 other.mColorIndex = mColorIndex;
76 }
77}
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
static WaveformAppearance & Get(WaveTrack &track)

References Get(), and mColorIndex.

Here is the call graph for this function:

◆ Get() [1/4]

const WaveformAppearance & WaveformAppearance::Get ( const WaveChannel channel)
static

Definition at line 40 of file WaveformAppearance.cpp.

41{
42 return Get(const_cast<WaveChannel &>(channel));
43}

References Get().

Here is the call graph for this function:

◆ Get() [2/4]

const WaveformAppearance & WaveformAppearance::Get ( const WaveTrack track)
static

Definition at line 30 of file WaveformAppearance.cpp.

31{
32 return Get(const_cast<WaveTrack&>(track));
33}

References Get().

Here is the call graph for this function:

◆ Get() [3/4]

WaveformAppearance & WaveformAppearance::Get ( WaveChannel channel)
static

Definition at line 35 of file WaveformAppearance.cpp.

36{
37 return Get(channel.GetTrack());
38}
WaveTrack & GetTrack()
Definition: WaveTrack.h:841

References Get(), and WaveChannel::GetTrack().

Here is the call graph for this function:

◆ Get() [4/4]

WaveformAppearance & WaveformAppearance::Get ( WaveTrack track)
static

Definition at line 25 of file WaveformAppearance.cpp.

26{
27 return track.AttachedObjects::Get<WaveformAppearance>(keyWA);
28}
static const AttachedTrackObjects::RegisteredFactory keyWA
Persistent appearance settings that apply to all channels of a track.

References keyWA.

Referenced by SetTrackVisualsCommand::ApplyInner(), CopyTo(), Get(), and WaveColorMenuTable::OnWaveColorChange().

Here is the caller graph for this function:

◆ GetColorIndex()

int WaveformAppearance::GetColorIndex ( ) const
inline

Definition at line 37 of file WaveformAppearance.h.

37{ return mColorIndex; }

References mColorIndex.

◆ HandleXMLAttribute()

bool WaveformAppearance::HandleXMLAttribute ( const std::string_view &  attr,
const XMLAttributeValueView valueView 
)
overridevirtual

Deserialize an attribute, returning true if recognized.

default recognizes no attributes, and returns false

Reimplemented from TrackAttachment.

Definition at line 92 of file WaveformAppearance.cpp.

94{
95 long nValue;
96 if (attr == ColorIndex_attr && valueView.TryGet(nValue))
97 mColorIndex = nValue;
98 return false;
99}
static constexpr auto ColorIndex_attr
bool TryGet(bool &value) const noexcept
Try to get a boolean value from the view.

References ColorIndex_attr, mColorIndex, and XMLAttributeValueView::TryGet().

Here is the call graph for this function:

◆ Reparent()

void WaveformAppearance::Reparent ( const std::shared_ptr< Track > &  parent)
overridevirtual

Object may be shared among tracks but hold a special back-pointer to one of them; reassign it.

default does nothing

Reimplemented from TrackAttachment.

Definition at line 79 of file WaveformAppearance.cpp.

80{
81 mwTrack = std::dynamic_pointer_cast<WaveTrack>(parent);
82 Subscribe(mwTrack.lock());
83}

References mwTrack, and Subscribe().

Here is the call graph for this function:

◆ SetColorIndex()

void WaveformAppearance::SetColorIndex ( int  colorIndex)

Definition at line 101 of file WaveformAppearance.cpp.

102{
103 mColorIndex = colorIndex;
104 const auto pTrack = mwTrack.lock();
105 if (!pTrack)
106 return;
107 for (const auto &pInterval : pTrack->Intervals())
108 for (const auto &pChannel : pInterval->Channels())
109 WaveColorAttachment::Get(*pChannel)
110 .SetColorIndex(colorIndex);
111}
static WaveColorAttachment & Get(WaveClip &clip)
void SetColorIndex(int colorIndex)

References WaveColorAttachment::Get(), mColorIndex, mwTrack, and WaveColorAttachment::SetColorIndex().

Referenced by SetTrackVisualsCommand::ApplyInner(), and WaveColorMenuTable::OnWaveColorChange().

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

◆ Subscribe()

void WaveformAppearance::Subscribe ( const std::shared_ptr< WaveTrack > &  pTrack)
private

Definition at line 54 of file WaveformAppearance.cpp.

55{
56 if (pTrack)
58 pTrack->Subscribe([this](const WaveTrackMessage &message){
59 switch (message.type) {
60 case WaveTrackMessage::New:
61 case WaveTrackMessage::Deserialized:
62 WaveColorAttachment::Get(*message.pClip).SetColorIndex(mColorIndex);
63 default:
64 break;
65 }
66 });
67 else
69}
void Reset() noexcept
Breaks the connection (constant time)
Definition: Observer.cpp:101
Observer::Subscription mSubscription
enum WaveTrackMessage::Type type

References mSubscription, Observer::Subscription::Reset(), and WaveTrackMessage::type.

Referenced by Reparent(), and WaveformAppearance().

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

◆ WriteXMLAttributes()

void WaveformAppearance::WriteXMLAttributes ( XMLWriter ) const
overridevirtual

Serialize persistent attributes.

default does nothing

Reimplemented from TrackAttachment.

Definition at line 87 of file WaveformAppearance.cpp.

88{
89 writer.WriteAttr(ColorIndex_attr, mColorIndex);
90}

References ColorIndex_attr, mColorIndex, and XMLWriter::WriteAttr().

Here is the call graph for this function:

Member Data Documentation

◆ mColorIndex

int WaveformAppearance::mColorIndex { 0 }
private

◆ mSubscription

Observer::Subscription WaveformAppearance::mSubscription
private

Definition at line 44 of file WaveformAppearance.h.

Referenced by Subscribe().

◆ mwTrack

std::weak_ptr<WaveTrack> WaveformAppearance::mwTrack
private

Definition at line 43 of file WaveformAppearance.h.

Referenced by Reparent(), SetColorIndex(), and WaveformAppearance().


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