17#include "../../ui/PlayableTrackButtonHandles.h"
20#include "../../../../TrackArtist.h"
21#include "../../../../TrackPanel.h"
22#include "../../../ui/CommonTrackInfo.h"
23#include "../../../../TrackPanelMouseEvent.h"
25#include "../../../../widgets/PopupMenuTable.h"
27#include "../../../../ProjectWindows.h"
28#include "../../../../RefreshCode.h"
42 std::vector<UIHandlePtr> results;
43 const wxMouseState &state = st.
state;
44 const wxRect &rect = st.
rect;
45 if (state.ButtonIsDown(wxMOUSE_BTN_ANY)) {
46 auto track = std::static_pointer_cast<NoteTrack>(
FindTrack());
56#ifdef EXPERIMENTAL_MIDI_OUT
67 results.push_back(result);
141#include "../../../../widgets/ASlider.h"
142#include "../../../../TrackPanelDrawingContext.h"
170 (
const wxRect &sliderRect,
const NoteTrack *t,
bool captured, wxWindow*),
171 wxDC *dc,
const wxRect &rect,
const Track *pTrack,
173 bool captured,
bool highlight )
175 wxRect sliderRect = rect;
177 auto nt =
static_cast<const NoteTrack*
>( pTrack );
178 Selector( sliderRect, nt, captured, pParent )->OnPaint(*dc, highlight);
181#ifdef EXPERIMENTAL_MIDI_OUT
182void VelocitySliderDrawFunction
184 const wxRect &rect,
const Track *pTrack )
186 auto dc = &context.
dc;
187 auto target =
dynamic_cast<VelocitySliderHandle*
>( context.
target.get() );
188 bool hit = target && target->GetTrack().get() == pTrack;
189 bool captured = hit && target->IsDragging();
196 pParent, captured, hit);
203(
const NoteTrack *pTrack, wxDC & dc,
const wxRect &rect,
int highlightedChannel )
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");
209 auto cellWidth = rect.width / 4;
210 auto cellHeight = rect.height / 4;
213 for (
int row = 0; row < 4; row++) {
214 for (
int col = 0; col < 4; col++) {
217 int chanName = row * 4 + col + 1;
219 box.x = rect.x + col * cellWidth;
220 box.y = rect.y + row * cellHeight;
221 box.width = cellWidth;
222 box.height = cellHeight;
224 bool visible = pTrack ? pTrack->
IsVisibleChan(chanName - 1) :
true;
227 if ( chanName == highlightedChannel + 1 )
231 dc.DrawRectangle(box);
235#define CHANNEL_ON_IS_DOWN 1
236#if CHANNEL_ON_IS_DOWN
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);
244#if CHANNEL_ON_IS_DOWN
250 box.x + box.width - 1, box.y,
251 box.x + box.width - 1, box.y + box.height - 1);
253 box.x, box.y + box.height - 1,
254 box.x + box.width - 1, box.y + box.height - 1);
256 if ( chanName == highlightedChannel + 1 )
260 dc.DrawRectangle(box);
261#if CHANNEL_ON_IS_DOWN
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);
269#if CHANNEL_ON_IS_DOWN
275 box.x + box.width - 1, box.y,
276 box.x + box.width - 1, box.y + box.height - 1);
278 box.x, box.y + box.height - 1,
279 box.x + box.width - 1, box.y + box.height - 1);
287 text.Printf(
wxT(
"%d"), chanName);
288 dc.GetTextExtent(text, &w, &h);
290 dc.DrawText(text, box.x + (box.width - w) / 2, box.y + (box.height - h) / 2);
299 const wxRect &rect,
const Track *pTrack )
302 bool hit = target && target->
GetTrack().get() == pTrack;
303 auto channel = hit ? target->
GetChannel() : -1;
304 auto &dc = context.
dc;
305 wxRect midiRect = rect;
308 (
static_cast<const NoteTrack *
>(pTrack), dc, midiRect, channel );
315 NoteTrackControlsBase::StaticNoteTCPLines();
319#ifdef EXPERIMENTAL_MIDI_OUT
321 VelocitySliderDrawFunction },
330 dest.y = topleft.y + results.first;
331 dest.height = results.second;
339 dest.y = rect.y + results.first;
340 dest.height = results.second;
355#ifdef EXPERIMENTAL_MIDI_OUT
356 std::unique_ptr<LWSlider>
364#ifdef EXPERIMENTAL_MIDI_OUT
366(
const wxRect &sliderRect,
const NoteTrack *t,
bool captured, wxWindow *pParent)
368 static std::once_flag
flag;
372 wxPoint pos = sliderRect.GetPosition();
373 float velocity = t ? t->GetVelocity() : 0.0;
375 gVelocity->Move(pos);
376 gVelocity->Set(velocity);
377 gVelocityCaptured->Move(pos);
378 gVelocityCaptured->Set(velocity);
380 auto slider = (captured ? gVelocityCaptured : gVelocity).get();
381 slider->SetParent( pParent );
390#ifdef EXPERIMENTAL_MIDI_OUT
391 wxPoint point{ 0, 0 };
396 gVelocity = std::make_unique<LWSlider>(
nullptr,
XO(
"Velocity"),
397 wxPoint(sliderRect.x, sliderRect.y),
398 wxSize(sliderRect.width, sliderRect.height),
400 gVelocity->SetDefaultValue(0.0);
401 gVelocityCaptured = std::make_unique<LWSlider>(
nullptr,
XO(
"Velocity"),
402 wxPoint(sliderRect.x, sliderRect.y),
403 wxSize(sliderRect.width, sliderRect.height),
405 gVelocityCaptured->SetDefaultValue(0.0);
412 return std::make_shared<NoteTrackControls>( track.SharedPointer() );
416#include "../../../ui/ChannelView.h"
std::shared_ptr< UIHandle > UIHandlePtr
std::vector< TrackInfo::TCPLine > TCPLines
XXO("&Cut/Copy/Paste Toolbar")
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(DoGetNoteTrackControls)
NoteTrackTCPLines noteTrackTCPLines
TrackInfo::TCPLine TCPLine
AppendItem("Up", OnUpOctaveID, XXO("Up &Octave"), POPUP_MENU_FN(OnChangeOctave))
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
static void LightMIDIChannel(wxDC *dc, int channel)
static void MIDIChannel(wxDC *dc, int channel)
static void DarkMIDIChannel(wxDC *dc, int channel)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
virtual std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *) override=0
std::shared_ptr< Track > FindTrack()
Lightweight version of ASlider. In other words it does not have a window permanently associated with ...
static void ReCreateVelocitySlider(struct ThemeChangeMessage)
static void GetMidiControlsRect(const wxRect &rect, wxRect &dest)
std::weak_ptr< NoteTrackButtonHandle > mClickHandle
std::weak_ptr< SoloButtonHandle > mSoloHandle
std::weak_ptr< VelocitySliderHandle > mVelocityHandle
static unsigned DefaultNoteTrackHeight()
const TCPLines & GetTCPLines() const override
static void GetVelocityRect(const wxPoint &topleft, wxRect &dest)
static LWSlider * VelocitySlider(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
std::weak_ptr< MuteButtonHandle > mMuteHandle
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject) override
A Track that is used for Midi notes. (Somewhat old code).
bool IsVisibleChan(int c) const
static NoteTrackRange & Get(const NoteTrack &track)
Allow mutative access to attached data of a const track.
void ShiftNoteRange(int offset)
Shifts all notes vertically by the given pitch.
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Abstract base class for an object holding data associated with points on a time axis.
AUDACITY_DLL_API unsigned DefaultTrackHeight(const TCPLines &topLines)
AUDACITY_DLL_API void GetSliderHorizontalBounds(const wxPoint &topleft, wxRect &dest)
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
AUDACITY_DLL_API std::pair< int, int > CalcItemY(const TCPLines &lines, unsigned iItem)
static void DrawLabelControls(const NoteTrack *pTrack, wxDC &dc, const wxRect &rect, int highlightedChannel)
void MidiControlsDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
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)
For defining overrides of the method.
std::optional< PreferredSystemAppearance > appearance