Audacity 3.2.0
Functions | Variables
anonymous_namespace{NoteTrackControls.cpp} Namespace Reference

Functions

void GetMidiControlsHorizontalBounds (const wxRect &rect, wxRect &dest)
 
void SliderDrawFunction (LWSlider *(*Selector)(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *), wxDC *dc, const wxRect &rect, const Track *pTrack, wxWindow *pParent, bool captured, bool highlight)
 
void VelocitySliderDrawFunction (TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
 
static void DrawLabelControls (const NoteTrack *pTrack, wxDC &dc, const wxRect &rect, int highlightedChannel)
 
void MidiControlsDrawFunction (TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
 

Variables

std::unique_ptr< LWSlidergVelocityCaptured
 
std::unique_ptr< LWSlidergVelocity
 

Function Documentation

◆ DrawLabelControls()

static void anonymous_namespace{NoteTrackControls.cpp}::DrawLabelControls ( const NoteTrack pTrack,
wxDC &  dc,
const wxRect &  rect,
int  highlightedChannel 
)
static

Definition at line 198 of file NoteTrackControls.cpp.

200{
201 dc.SetTextForeground(theTheme.Colour(clrLabelTrackText));
202 wxASSERT_MSG(rect.width % 4 == 0, "Midi channel control rect width must be divisible by 4");
203 wxASSERT_MSG(rect.height % 4 == 0, "Midi channel control rect height must be divisible by 4");
204
205 auto cellWidth = rect.width / 4;
206 auto cellHeight = rect.height / 4;
207
208 wxRect box;
209 for (int row = 0; row < 4; row++) {
210 for (int col = 0; col < 4; col++) {
211 // chanName is the "external" channel number (1-16)
212 // used by AColor and button labels
213 int chanName = row * 4 + col + 1;
214
215 box.x = rect.x + col * cellWidth;
216 box.y = rect.y + row * cellHeight;
217 box.width = cellWidth;
218 box.height = cellHeight;
219
220 bool visible = pTrack ? pTrack->IsVisibleChan(chanName - 1) : true;
221 if (visible) {
222 // highlightedChannel counts 0 based
223 if ( chanName == highlightedChannel + 1 )
224 AColor::LightMIDIChannel(&dc, chanName);
225 else
226 AColor::MIDIChannel(&dc, chanName);
227 dc.DrawRectangle(box);
228// two choices: channel is enabled (to see and play) when button is in
229// "up" position (original Audacity style) or in "down" position
230//
231#define CHANNEL_ON_IS_DOWN 1
232#if CHANNEL_ON_IS_DOWN
233 AColor::DarkMIDIChannel(&dc, chanName);
234#else
235 AColor::LightMIDIChannel(&dc, chanName);
236#endif
237 AColor::Line(dc, box.x, box.y, box.x + box.width - 1, box.y);
238 AColor::Line(dc, box.x, box.y, box.x, box.y + box.height - 1);
239
240#if CHANNEL_ON_IS_DOWN
241 AColor::LightMIDIChannel(&dc, chanName);
242#else
243 AColor::DarkMIDIChannel(&dc, chanName);
244#endif
245 AColor::Line(dc,
246 box.x + box.width - 1, box.y,
247 box.x + box.width - 1, box.y + box.height - 1);
248 AColor::Line(dc,
249 box.x, box.y + box.height - 1,
250 box.x + box.width - 1, box.y + box.height - 1);
251 } else {
252 if ( chanName == highlightedChannel + 1 )
253 AColor::LightMIDIChannel(&dc, chanName);
254 else
255 AColor::MIDIChannel(&dc, 0);
256 dc.DrawRectangle(box);
257#if CHANNEL_ON_IS_DOWN
259#else
261#endif
262 AColor::Line(dc, box.x, box.y, box.x + box.width - 1, box.y);
263 AColor::Line(dc, box.x, box.y, box.x, box.y + box.height - 1);
264
265#if CHANNEL_ON_IS_DOWN
267#else
269#endif
270 AColor::Line(dc,
271 box.x + box.width - 1, box.y,
272 box.x + box.width - 1, box.y + box.height - 1);
273 AColor::Line(dc,
274 box.x, box.y + box.height - 1,
275 box.x + box.width - 1, box.y + box.height - 1);
276
277 }
278
279 wxString text;
280 wxCoord w;
281 wxCoord h;
282
283 text.Printf(wxT("%d"), chanName);
284 dc.GetTextExtent(text, &w, &h);
285
286 dc.DrawText(text, box.x + (box.width - w) / 2, box.y + (box.height - h) / 2);
287 }
288 }
289 dc.SetTextForeground(theTheme.Colour(clrTrackPanelText));
290 AColor::MIDIChannel(&dc, 0); // always return with gray color selected
291}
wxT("CloseDown"))
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:185
static void LightMIDIChannel(wxDC *dc, int channel)
Definition: AColor.cpp:662
static void MIDIChannel(wxDC *dc, int channel)
Definition: AColor.cpp:646
static void DarkMIDIChannel(wxDC *dc, int channel)
Definition: AColor.cpp:680
bool IsVisibleChan(int c) const
Definition: NoteTrack.h:155
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), AColor::DarkMIDIChannel(), NoteTrack::IsVisibleChan(), AColor::LightMIDIChannel(), AColor::Line(), AColor::MIDIChannel(), theTheme, and wxT().

Referenced by MidiControlsDrawFunction().

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

◆ GetMidiControlsHorizontalBounds()

void anonymous_namespace{NoteTrackControls.cpp}::GetMidiControlsHorizontalBounds ( const wxRect &  rect,
wxRect &  dest 
)

Definition at line 157 of file NoteTrackControls.cpp.

158{
159 dest.x = rect.x + 1; // To center slightly
160 // PRL: TODO: kMidiCellWidth is defined in terms of the other constant
161 // kTrackInfoWidth but I am trying to avoid use of that constant.
162 // Can cell width be computed from dest.width instead?
163 dest.width = kMidiCellWidth * 4;
164}
@ kMidiCellWidth

References kMidiCellWidth.

Referenced by NoteTrackControls::GetMidiControlsRect(), and MidiControlsDrawFunction().

Here is the caller graph for this function:

◆ MidiControlsDrawFunction()

void anonymous_namespace{NoteTrackControls.cpp}::MidiControlsDrawFunction ( TrackPanelDrawingContext context,
const wxRect &  rect,
const Track pTrack 
)

Definition at line 293 of file NoteTrackControls.cpp.

296{
297 auto target = dynamic_cast<NoteTrackButtonHandle*>( context.target.get() );
298 bool hit = target && target->GetTrack().get() == pTrack;
299 auto channel = hit ? target->GetChannel() : -1;
300 auto &dc = context.dc;
301 wxRect midiRect = rect;
302 GetMidiControlsHorizontalBounds(rect, midiRect);
304 ( static_cast<const NoteTrack *>(pTrack), dc, midiRect, channel );
305}
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
Definition: Channel.h:320
std::shared_ptr< NoteTrack > GetTrack() const
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
static void DrawLabelControls(const NoteTrack *pTrack, wxDC &dc, const wxRect &rect, int highlightedChannel)
void GetMidiControlsHorizontalBounds(const wxRect &rect, wxRect &dest)

References TrackPanelDrawingContext::dc, DrawLabelControls(), ChannelGroup::GetChannel(), GetMidiControlsHorizontalBounds(), NoteTrackButtonHandle::GetTrack(), and TrackPanelDrawingContext::target.

Referenced by NoteTrackTCPLines::NoteTrackTCPLines().

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

◆ SliderDrawFunction()

void anonymous_namespace{NoteTrackControls.cpp}::SliderDrawFunction ( LWSlider *(*)(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *)  Selector,
wxDC *  dc,
const wxRect &  rect,
const Track pTrack,
wxWindow *  pParent,
bool  captured,
bool  highlight 
)

Definition at line 166 of file NoteTrackControls.cpp.

172{
173 wxRect sliderRect = rect;
174 CommonTrackInfo::GetSliderHorizontalBounds( rect.GetTopLeft(), sliderRect );
175 auto nt = static_cast<const NoteTrack*>( pTrack );
176 Selector( sliderRect, nt, captured, pParent )->OnPaint(*dc, highlight);
177}
void OnPaint(wxDC &dc, bool highlighted)
Definition: ASlider.cpp:717
AUDACITY_DLL_API void GetSliderHorizontalBounds(const wxPoint &topleft, wxRect &dest)

References CommonTrackInfo::GetSliderHorizontalBounds().

Referenced by VelocitySliderDrawFunction().

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

◆ VelocitySliderDrawFunction()

void anonymous_namespace{NoteTrackControls.cpp}::VelocitySliderDrawFunction ( TrackPanelDrawingContext context,
const wxRect &  rect,
const Track pTrack 
)

Definition at line 179 of file NoteTrackControls.cpp.

182{
183 auto dc = &context.dc;
184 auto target = dynamic_cast<VelocitySliderHandle*>( context.target.get() );
185 bool hit = target && target->GetTrack().get() == pTrack;
186 bool captured = hit && target->IsDragging();
187
188 const auto artist = TrackArtist::Get( context );
189 auto pParent = FindProjectFrame( artist->parent->GetProject() );
190
192 &NoteTrackControls::VelocitySlider, dc, rect, pTrack,
193 pParent, captured, hit);
194}
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
static LWSlider * VelocitySlider(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
std::shared_ptr< Track > GetTrack() const
Definition: SliderHandle.h:36
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
void SliderDrawFunction(LWSlider *(*Selector)(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *), wxDC *dc, const wxRect &rect, const Track *pTrack, wxWindow *pParent, bool captured, bool highlight)

References TrackPanelDrawingContext::dc, FindProjectFrame(), TrackArtist::Get(), SliderHandle::GetTrack(), SliderDrawFunction(), TrackPanelDrawingContext::target, and NoteTrackControls::VelocitySlider().

Referenced by NoteTrackTCPLines::NoteTrackTCPLines().

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

Variable Documentation

◆ gVelocity

std::unique_ptr<LWSlider> anonymous_namespace{NoteTrackControls.cpp}::gVelocity

◆ gVelocityCaptured

std::unique_ptr<LWSlider> anonymous_namespace{NoteTrackControls.cpp}::gVelocityCaptured