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 195 of file NoteTrackControls.cpp.

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

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 290 of file NoteTrackControls.cpp.

293{
294 auto target = dynamic_cast<NoteTrackButtonHandle*>( context.target.get() );
295 bool hit = target && target->GetTrack().get() == pTrack;
296 auto channel = hit ? target->GetChannel() : -1;
297 auto &dc = context.dc;
298 wxRect midiRect = rect;
299 GetMidiControlsHorizontalBounds(rect, midiRect);
301 ( static_cast<const NoteTrack *>(pTrack), dc, midiRect, channel );
302}
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
Definition: Channel.h:323
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 163 of file NoteTrackControls.cpp.

169{
170 wxRect sliderRect = rect;
172 auto nt = static_cast<const NoteTrack*>( pTrack );
173 Selector( sliderRect, nt, captured, pParent )->OnPaint(*dc, highlight);
174}
void OnPaint(wxDC &dc, bool highlighted)
Definition: ASlider.cpp:723
AUDACITY_DLL_API void GetSliderHorizontalBounds(const wxRect &rect, 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 176 of file NoteTrackControls.cpp.

179{
180 auto dc = &context.dc;
181 auto target = dynamic_cast<VelocitySliderHandle*>( context.target.get() );
182 bool hit = target && target->GetTrack().get() == pTrack;
183 bool captured = hit && target->IsDragging();
184
185 const auto artist = TrackArtist::Get( context );
186 auto pParent = FindProjectFrame( artist->parent->GetProject() );
187
189 &NoteTrackControls::VelocitySlider, dc, rect, pTrack,
190 pParent, captured, hit);
191}
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:81
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