Audacity 3.2.0
Functions
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)
 
static void DrawLabelControls (const NoteTrack *pTrack, wxDC &dc, const wxRect &rect, int highlightedChannel)
 
void MidiControlsDrawFunction (TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
 

Function Documentation

◆ DrawLabelControls()

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

Definition at line 202 of file NoteTrackControls.cpp.

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

160{
161 dest.x = rect.x + 1; // To center slightly
162 // PRL: TODO: kMidiCellWidth is defined in terms of the other constant
163 // kTrackInfoWidth but I am trying to avoid use of that constant.
164 // Can cell width be computed from dest.width instead?
165 dest.width = kMidiCellWidth * 4;
166}
@ 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 297 of file NoteTrackControls.cpp.

300{
301 auto target = dynamic_cast<NoteTrackButtonHandle*>( context.target.get() );
302 bool hit = target && target->GetTrack().get() == pTrack;
303 auto channel = hit ? target->GetChannel() : -1;
304 auto &dc = context.dc;
305 wxRect midiRect = rect;
306 GetMidiControlsHorizontalBounds(rect, midiRect);
308 ( static_cast<const NoteTrack *>(pTrack), dc, midiRect, channel );
309}
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
Definition: Channel.h:344
std::shared_ptr< NoteTrack > GetTrack() const
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:86
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 168 of file NoteTrackControls.cpp.

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

References CommonTrackInfo::GetSliderHorizontalBounds().

Here is the call graph for this function: