Audacity 3.2.0
WaveformAppearance.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/**********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 @file WaveformApperance.h
7
8 Paul Licameli
9
10 **********************************************************************/
11#ifndef __AUDACITY_WAVEFORM_APPEARANCE__
12#define __AUDACITY_WAVEFORM_APPEARANCE__
13
14#include "WaveClip.h"
15#include "WaveTrack.h"
16
19{
20public:
21 static WaveformAppearance &Get(WaveTrack &track);
22 static const WaveformAppearance &Get(const WaveTrack &track);
23
24 static WaveformAppearance &Get(WaveChannel &channel);
25 static const WaveformAppearance &Get(const WaveChannel &channel);
26
27 explicit WaveformAppearance(WaveTrack &track);
29
30 void CopyTo(Track &track) const override;
31 void Reparent(const std::shared_ptr<Track> &parent) override;
32 void WriteXMLAttributes(XMLWriter &writer) const override;
34 const std::string_view& attr, const XMLAttributeValueView& valueView)
35 override;
36
37 int GetColorIndex() const { return mColorIndex; }
38 void SetColorIndex(int colorIndex);
39
40private:
41 void Subscribe(const std::shared_ptr<WaveTrack> &pTrack);
42
43 std::weak_ptr<WaveTrack> mwTrack;
45 int mColorIndex{ 0 };
46};
47
49{
50 explicit WaveColorAttachment();
51 ~WaveColorAttachment() override;
52
53 std::unique_ptr<WaveClipListener> Clone() const override;
54
55 static WaveColorAttachment &Get(WaveClip &clip);
56 static const WaveColorAttachment &Get(const WaveClip &clip);
58 static const WaveColorAttachment &Get(const WaveChannelInterval &clip);
59
60 void MarkChanged() noexcept override; // NOFAIL-GUARANTEE
61 void Invalidate() override; // NOFAIL-GUARANTEE
62
63 // Write color
64 void WriteXMLAttributes(XMLWriter &writer) const override;
65
66 // Read color
67 bool HandleXMLAttribute(const std::string_view &attr,
68 const XMLAttributeValueView &valueView) override;
69
70 int GetColorIndex() const { return mColorIndex; }
71 void SetColorIndex(int colorIndex) { mColorIndex = colorIndex; }
72
73private:
75};
76
77#endif
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:238
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
Persistent appearance settings that apply to all channels of a track.
bool HandleXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView) override
Deserialize an attribute, returning true if recognized.
void WriteXMLAttributes(XMLWriter &writer) const override
Serialize persistent attributes.
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.
static WaveformAppearance & Get(WaveTrack &track)
std::weak_ptr< WaveTrack > mwTrack
Observer::Subscription mSubscription
~WaveformAppearance() override
void Subscribe(const std::shared_ptr< WaveTrack > &pTrack)
WaveformAppearance(WaveTrack &track)
void CopyTo(Track &track) const override
Copy state, for undo/redo purposes.
void SetColorIndex(int colorIndex)
A view into an attribute value. The class does not take the ownership of the data.
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:25
void MarkChanged() noexcept override
void WriteXMLAttributes(XMLWriter &writer) const override
static WaveColorAttachment & Get(WaveClip &clip)
std::unique_ptr< WaveClipListener > Clone() const override
void SetColorIndex(int colorIndex)
void Invalidate() override
bool HandleXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView) override