Audacity  3.0.3
TrackArtist.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  TrackArtist.h
6 
7  Dominic Mazzoni
8 
9  This singleton class handles the actual rendering of WaveTracks
10  (both waveforms and spectra), NoteTracks, and LabelTracks.
11 
12  It's actually a little harder than it looks, because for
13  waveforms at least it needs to cache the samples that are
14  currently on-screen.
15 
16 **********************************************************************/
17 
18 #ifndef __AUDACITY_TRACKARTIST__
19 #define __AUDACITY_TRACKARTIST__
20 
21 
22 
23 
24 #include <wx/brush.h> // member variable
25 #include <wx/pen.h> // member variables
26 
27 #include "Prefs.h"
28 
29 class wxRect;
30 
31 class TrackList;
32 class TrackPanel;
33 class SelectedRegion;
34 class Track;
35 class TrackPanel;
37 class ZoomInfo;
38 
39 namespace TrackArt {
40 
41  static constexpr int ClipFrameRadius{ 6 };
42 
43  AUDACITY_DLL_API
44  void DrawClipAffordance(wxDC& dc, const wxRect& affordanceRect, const wxString& title, bool highlight = false, bool selected = false);
45 
46  AUDACITY_DLL_API
47  wxRect GetAffordanceTitleRect(const wxRect& affordanceRect);
48 
49  AUDACITY_DLL_API
50  void DrawClipEdges(wxDC& dc, const wxRect& clipRect, bool selected = false);
51 
52  // Helper: draws the "sync-locked" watermark tiled to a rectangle
53  AUDACITY_DLL_API
54  void DrawSyncLockTiles(
55  TrackPanelDrawingContext &context, const wxRect &rect );
56 
57  // Helper: draws background with selection rect
58  AUDACITY_DLL_API
60  const wxRect &rect, const Track *track,
61  const wxBrush &selBrush, const wxBrush &unselBrush,
62  bool useSelection = true);
63 
64  AUDACITY_DLL_API
66  const wxRect& rect, const Track* track);
67 
68  AUDACITY_DLL_API
70  const wxRect & rect );
71 
72  AUDACITY_DLL_API
73  wxString TruncateText(wxDC& dc, const wxString& text, const int maxWidth);
74 }
75 
76 class AUDACITY_DLL_API TrackArtist final : private PrefsListener {
77 
78 public:
79 
80  enum : unsigned {
89 
90  NPasses
91  };
92 
93  TrackArtist( TrackPanel *parent_ );
94  ~TrackArtist();
96 
97  void SetBackgroundBrushes(wxBrush unselectedBrushIn, wxBrush selectedBrushIn,
98  wxPen unselectedPenIn, wxPen selectedPenIn) {
99  this->unselectedBrush = unselectedBrushIn;
100  this->selectedBrush = selectedBrushIn;
101  this->unselectedPen = unselectedPenIn;
102  this->selectedPen = selectedPenIn;
103  }
104 
105  void SetColours(int iColorIndex);
106 
107  void UpdatePrefs() override;
108  void UpdateSelectedPrefs( int id ) override;
109 
111 
112  // Preference values
113  float mdBrange; // "/GUI/EnvdBRange"
114  bool mShowClipping; // "/GUI/ShowClipping"
116  bool mbShowTrackNameInTrack; // "/GUI/ShowTrackNameInWaveform"
117 
118  wxBrush blankBrush;
120  wxBrush selectedBrush;
121  wxBrush sampleBrush;
122  wxBrush selsampleBrush;
123  wxBrush dragsampleBrush;// for samples which are draggable.
126  wxPen blankPen;
128  wxPen selectedPen;
129  wxPen samplePen;
130  wxPen rmsPen;
131  wxPen muteRmsPen;
136  wxPen shadowPen;
137  wxPen clippedPen;
140 
141 #ifdef EXPERIMENTAL_FFT_Y_GRID
142  bool fftYGridOld;
143 #endif //EXPERIMENTAL_FFT_Y_GRID
144 
145 #ifdef EXPERIMENTAL_FIND_NOTES
146  bool fftFindNotesOld;
147  int findNotesMinAOld;
148  int findNotesNOld;
149  bool findNotesQuantizeOld;
150 #endif
151 
152  const SelectedRegion *pSelectedRegion{};
153  ZoomInfo *pZoomInfo{};
154 
155  bool drawEnvelope{ false };
156  bool bigPoints{ false };
157  bool drawSliders{ false };
158  bool onBrushTool{ false };
159  bool hasSolo{ false };
160 };
161 
162 extern AUDACITY_DLL_API int GetWaveYPos(float value, float min, float max,
163  int height, bool dB, bool outer, float dBr,
164  bool clip);
165 extern float FromDB(float value, double dBRange);
166 extern AUDACITY_DLL_API float ValueOfPixel(int yy, int height, bool offset,
167  bool dB, double dBRange, float zoomMin, float zoomMax);
168 
169 #endif // define __AUDACITY_TRACKARTIST__
TrackArtist::clippedPen
wxPen clippedPen
Definition: TrackArtist.h:137
outer
static const wxPoint2DDouble outer[]
Definition: ASlider.cpp:395
TrackArtist::mdBrange
float mdBrange
Definition: TrackArtist.h:113
TrackArtist::muteClippedPen
wxPen muteClippedPen
Definition: TrackArtist.h:138
TrackArt::ClipFrameRadius
static constexpr int ClipFrameRadius
Definition: TrackArtist.h:41
TrackArtist::odProgressNotYetPen
wxPen odProgressNotYetPen
Definition: TrackArtist.h:134
ZoomInfo
Definition: ZoomInfo.h:47
TrackArtist::PassBorders
@ PassBorders
Definition: TrackArtist.h:83
TrackPanelDrawingContext
Definition: TrackPanelDrawingContext.h:22
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1280
TrackArtist::PassSnapping
@ PassSnapping
Definition: TrackArtist.h:88
GetWaveYPos
AUDACITY_DLL_API int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
Definition: TrackArtist.cpp:136
TrackArtist::selectedPen
wxPen selectedPen
Definition: TrackArtist.h:128
ValueOfPixel
AUDACITY_DLL_API float ValueOfPixel(int yy, int height, bool offset, bool dB, double dBRange, float zoomMin, float zoomMax)
Definition: TrackArtist.cpp:192
TrackArtist
This class handles the actual rendering of WaveTracks (both waveforms and spectra),...
Definition: TrackArtist.h:76
TrackPanel
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:67
TrackArtist::rmsPen
wxPen rmsPen
Definition: TrackArtist.h:130
TrackArtist::muteRmsPen
wxPen muteRmsPen
Definition: TrackArtist.h:131
TrackArt::GetAffordanceTitleRect
AUDACITY_DLL_API wxRect GetAffordanceTitleRect(const wxRect &affordanceRect)
Definition: TrackArtist.cpp:332
PrefsListener
A listener notified of changes in preferences.
Definition: Prefs.h:389
TrackArt::DrawSyncLockTiles
AUDACITY_DLL_API void DrawSyncLockTiles(TrackPanelDrawingContext &context, const wxRect &rect)
Definition: TrackArtist.cpp:392
PrefsListener::UpdateSelectedPrefs
virtual void UpdateSelectedPrefs(int id)
Definition: Prefs.cpp:127
FromDB
float FromDB(float value, double dBRange)
Definition: TrackArtist.cpp:183
TrackArtist::unselectedBrush
wxBrush unselectedBrush
Definition: TrackArtist.h:119
TrackArt::DrawClipAffordance
AUDACITY_DLL_API void DrawClipAffordance(wxDC &dc, const wxRect &affordanceRect, const wxString &title, bool highlight=false, bool selected=false)
Definition: TrackArtist.cpp:302
TrackArtist::mShowClipping
bool mShowClipping
Definition: TrackArtist.h:114
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
TrackArt::DrawNegativeOffsetTrackArrows
AUDACITY_DLL_API void DrawNegativeOffsetTrackArrows(TrackPanelDrawingContext &context, const wxRect &rect)
Definition: TrackArtist.cpp:213
TrackArtist::dragsampleBrush
wxBrush dragsampleBrush
Definition: TrackArtist.h:123
TrackArtist::blankSelectedBrush
wxBrush blankSelectedBrush
Definition: TrackArtist.h:125
TrackArtist::shadowPen
wxPen shadowPen
Definition: TrackArtist.h:136
TrackArtist::sampleBrush
wxBrush sampleBrush
Definition: TrackArtist.h:121
TrackArtist::PassControls
@ PassControls
Definition: TrackArtist.h:84
TrackArt
Definition: TrackArtist.h:39
TrackArtist::blankBrush
wxBrush blankBrush
Definition: TrackArtist.h:118
TrackArtist::selsampleBrush
wxBrush selsampleBrush
Definition: TrackArtist.h:122
TrackArtist::muteSampleBrush
wxBrush muteSampleBrush
Definition: TrackArtist.h:124
TrackArt::DrawCursor
AUDACITY_DLL_API void DrawCursor(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track)
Definition: TrackArtist.cpp:581
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
TrackArt::TruncateText
AUDACITY_DLL_API wxString TruncateText(wxDC &dc, const wxString &text, const int maxWidth)
Definition: TrackArtist.cpp:243
TrackArtist::blankSelectedPen
wxPen blankSelectedPen
Definition: TrackArtist.h:139
TrackArtist::mbShowTrackNameInTrack
bool mbShowTrackNameInTrack
Definition: TrackArtist.h:116
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
TrackArt::DrawBackgroundWithSelection
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArtist.cpp:502
TrackArtist::parent
TrackPanel * parent
Definition: TrackArtist.h:110
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
TrackArtist::mSampleDisplay
int mSampleDisplay
Definition: TrackArtist.h:115
TrackArt::DrawClipEdges
AUDACITY_DLL_API void DrawClipEdges(wxDC &dc, const wxRect &clipRect, bool selected=false)
Definition: TrackArtist.cpp:342
TrackArtist::SetBackgroundBrushes
void SetBackgroundBrushes(wxBrush unselectedBrushIn, wxBrush selectedBrushIn, wxPen unselectedPenIn, wxPen selectedPenIn)
Definition: TrackArtist.h:97
TrackArtist::PassZooming
@ PassZooming
Definition: TrackArtist.h:85
PrefsListener::UpdatePrefs
virtual void UpdatePrefs()=0
TrackArtist::selectedBrush
wxBrush selectedBrush
Definition: TrackArtist.h:120
TrackArtist::PassTracks
@ PassTracks
Definition: TrackArtist.h:81
TrackArtist::blankPen
wxPen blankPen
Definition: TrackArtist.h:126
TrackArtist::muteSamplePen
wxPen muteSamplePen
Definition: TrackArtist.h:133
Prefs.h
TrackArtist::selsamplePen
wxPen selsamplePen
Definition: TrackArtist.h:132
TrackArtist::samplePen
wxPen samplePen
Definition: TrackArtist.h:129
TrackArtist::PassMargins
@ PassMargins
Definition: TrackArtist.h:82
TrackArtist::PassBackground
@ PassBackground
Definition: TrackArtist.h:86
TrackArtist::unselectedPen
wxPen unselectedPen
Definition: TrackArtist.h:127
TrackArtist::PassFocus
@ PassFocus
Definition: TrackArtist.h:87
TrackArtist::odProgressDonePen
wxPen odProgressDonePen
Definition: TrackArtist.h:135
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:35