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());
65 results.push_back(result);
139#include "../../../../widgets/ASlider.h"
140#include "../../../../TrackPanelDrawingContext.h"
160 dest.width = rect.width / 4 * 4;
165 (
const wxRect &sliderRect,
const NoteTrack *t,
bool captured, wxWindow*),
166 wxDC *dc,
const wxRect &rect,
const Track *pTrack,
168 bool captured,
bool highlight )
170 wxRect sliderRect = rect;
172 auto nt =
static_cast<const NoteTrack*
>( pTrack );
173 Selector( sliderRect, nt, captured, pParent )->OnPaint(*dc, highlight);
178 const wxRect &rect,
const Track *pTrack )
180 auto dc = &context.
dc;
182 bool hit = target && target->
GetTrack().get() == pTrack;
183 bool captured = hit && target->IsDragging();
190 pParent, captured, hit);
196(
const NoteTrack *pTrack, wxDC & dc,
const wxRect &rect,
int highlightedChannel )
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");
202 auto cellWidth = rect.width / 4;
203 auto cellHeight = rect.height / 4;
206 for (
int row = 0; row < 4; row++) {
207 for (
int col = 0; col < 4; col++) {
210 int chanName = row * 4 + col + 1;
212 box.x = rect.x + col * cellWidth;
213 box.y = rect.y + row * cellHeight;
214 box.width = cellWidth;
215 box.height = cellHeight;
217 bool visible = pTrack ? pTrack->
IsVisibleChan(chanName - 1) :
true;
220 if ( chanName == highlightedChannel + 1 )
224 dc.DrawRectangle(box);
228#define CHANNEL_ON_IS_DOWN 1
229#if CHANNEL_ON_IS_DOWN
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);
237#if CHANNEL_ON_IS_DOWN
243 box.x + box.width - 1, box.y,
244 box.x + box.width - 1, box.y + box.height - 1);
246 box.x, box.y + box.height - 1,
247 box.x + box.width - 1, box.y + box.height - 1);
249 if ( chanName == highlightedChannel + 1 )
253 dc.DrawRectangle(box);
254#if CHANNEL_ON_IS_DOWN
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);
262#if CHANNEL_ON_IS_DOWN
268 box.x + box.width - 1, box.y,
269 box.x + box.width - 1, box.y + box.height - 1);
271 box.x, box.y + box.height - 1,
272 box.x + box.width - 1, box.y + box.height - 1);
280 text.Printf(
wxT(
"%d"), chanName);
281 dc.GetTextExtent(text, &w, &h);
283 dc.DrawText(text, box.x + (box.width - w) / 2, box.y + (box.height - h) / 2);
292 const wxRect &rect,
const Track *pTrack )
295 bool hit = target && target->
GetTrack().get() == pTrack;
296 auto channel = hit ? target->
GetChannel() : -1;
297 auto &dc = context.
dc;
298 wxRect midiRect = rect;
301 (
static_cast<const NoteTrack *
>(pTrack), dc, midiRect, channel );
322 dest.y = rect.y + results.first;
323 dest.height = results.second;
332 dest.y = rect.y + results.first;
333 dest.height = results.second;
348 std::unique_ptr<LWSlider>
356(
const wxRect &sliderRect,
const NoteTrack *t,
bool captured, wxWindow *pParent)
358 static std::once_flag
flag;
362 wxPoint pos = sliderRect.GetPosition();
371 slider->SetParent( pParent );
383 gVelocity = std::make_unique<LWSlider>(
nullptr,
XO(
"Velocity"),
384 wxPoint(sliderRect.x, sliderRect.y),
385 wxSize(sliderRect.width, sliderRect.height),
389 wxPoint(sliderRect.x, sliderRect.y),
390 wxSize(sliderRect.width, sliderRect.height),
398 return std::make_shared<NoteTrackControls>( track.SharedPointer() );
402#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 LWSlider * VelocitySlider(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
static void GetVelocityRect(const wxRect &rect, wxRect &dest)
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
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
float GetVelocity() 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.
static const TCPLines & StaticNoteTCPLines()
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
std::shared_ptr< Track > GetTrack() const
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Abstract base class for an object holding data associated with points on a time axis.
static UIHandlePtr HitTest(std::weak_ptr< VelocitySliderHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
AUDACITY_DLL_API void GetSliderHorizontalBounds(const wxRect &rect, wxRect &dest)
static constexpr auto Margin
AUDACITY_DLL_API unsigned DefaultTrackHeight(const TCPLines &topLines)
AUDACITY_DLL_API std::pair< int, int > CalcItemY(const TCPLines &lines, unsigned iItem)
void VelocitySliderDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
std::unique_ptr< LWSlider > gVelocityCaptured
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)
std::unique_ptr< LWSlider > gVelocity
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)
const char * end(const char *str) noexcept
For defining overrides of the method.
std::optional< PreferredSystemAppearance > appearance