mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Highlight MIDI channel buttons
This commit is contained in:
parent
25641ae568
commit
44d6d5f427
@ -251,7 +251,7 @@ void NoteTrack::WarpAndTransposeNotes(double t0, double t1,
|
|||||||
// Draws the midi channel toggle buttons within the given rect.
|
// Draws the midi channel toggle buttons within the given rect.
|
||||||
// The rect should be evenly divisible by 4 on both axis.
|
// The rect should be evenly divisible by 4 on both axis.
|
||||||
void NoteTrack::DrawLabelControls
|
void NoteTrack::DrawLabelControls
|
||||||
( const NoteTrack *pTrack, wxDC & dc, const wxRect &rect )
|
( const NoteTrack *pTrack, wxDC & dc, const wxRect &rect, int highlightedChannel )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(rect.width % 4 == 0, "Midi channel control rect width must be divisible by 4");
|
wxASSERT_MSG(rect.width % 4 == 0, "Midi channel control rect width must be divisible by 4");
|
||||||
wxASSERT_MSG(rect.height % 4 == 0, "Midi channel control rect height must be divisible by 4");
|
wxASSERT_MSG(rect.height % 4 == 0, "Midi channel control rect height must be divisible by 4");
|
||||||
@ -273,7 +273,11 @@ void NoteTrack::DrawLabelControls
|
|||||||
|
|
||||||
bool visible = pTrack ? pTrack->IsVisibleChan(chanName - 1) : true;
|
bool visible = pTrack ? pTrack->IsVisibleChan(chanName - 1) : true;
|
||||||
if (visible) {
|
if (visible) {
|
||||||
AColor::MIDIChannel(&dc, chanName);
|
// highlightedChannel counts 0 based
|
||||||
|
if ( chanName == highlightedChannel + 1 )
|
||||||
|
AColor::LightMIDIChannel(&dc, chanName);
|
||||||
|
else
|
||||||
|
AColor::MIDIChannel(&dc, chanName);
|
||||||
dc.DrawRectangle(box);
|
dc.DrawRectangle(box);
|
||||||
// two choices: channel is enabled (to see and play) when button is in
|
// two choices: channel is enabled (to see and play) when button is in
|
||||||
// "up" position (original Audacity style) or in "down" position
|
// "up" position (original Audacity style) or in "down" position
|
||||||
@ -299,7 +303,10 @@ void NoteTrack::DrawLabelControls
|
|||||||
box.x, box.y + box.height - 1,
|
box.x, box.y + box.height - 1,
|
||||||
box.x + box.width - 1, box.y + box.height - 1);
|
box.x + box.width - 1, box.y + box.height - 1);
|
||||||
} else {
|
} else {
|
||||||
AColor::MIDIChannel(&dc, 0);
|
if ( chanName == highlightedChannel + 1 )
|
||||||
|
AColor::LightMIDIChannel(&dc, chanName);
|
||||||
|
else
|
||||||
|
AColor::MIDIChannel(&dc, 0);
|
||||||
dc.DrawRectangle(box);
|
dc.DrawRectangle(box);
|
||||||
#if CHANNEL_ON_IS_DOWN
|
#if CHANNEL_ON_IS_DOWN
|
||||||
AColor::LightMIDIChannel(&dc, 0);
|
AColor::LightMIDIChannel(&dc, 0);
|
||||||
|
@ -90,7 +90,8 @@ class AUDACITY_DLL_API NoteTrack final
|
|||||||
const TimeWarper &warper, double semitones);
|
const TimeWarper &warper, double semitones);
|
||||||
|
|
||||||
static void DrawLabelControls
|
static void DrawLabelControls
|
||||||
( const NoteTrack *pTrack, wxDC & dc, const wxRect &rect );
|
( const NoteTrack *pTrack, wxDC & dc, const wxRect &rect,
|
||||||
|
int highlightedChannel = -1 );
|
||||||
int FindChannel(const wxRect &rect, int mx, int my);
|
int FindChannel(const wxRect &rect, int mx, int my);
|
||||||
bool LabelClick(const wxRect &rect, int x, int y, bool right);
|
bool LabelClick(const wxRect &rect, int x, int y, bool right);
|
||||||
|
|
||||||
|
@ -2056,16 +2056,19 @@ void TrackInfo::MinimizeSyncLockDrawFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "tracks/playabletrack/notetrack/ui/NoteTrackButtonHandle.h"
|
||||||
void TrackInfo::MidiControlsDrawFunction
|
void TrackInfo::MidiControlsDrawFunction
|
||||||
( TrackPanelDrawingContext &context,
|
( TrackPanelDrawingContext &context,
|
||||||
const wxRect &rect, const Track *pTrack )
|
const wxRect &rect, const Track *pTrack )
|
||||||
{
|
{
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
|
auto target = dynamic_cast<NoteTrackButtonHandle*>( context.target.get() );
|
||||||
|
auto channel = target ? target->GetChannel() : -1;
|
||||||
auto &dc = context.dc;
|
auto &dc = context.dc;
|
||||||
wxRect midiRect = rect;
|
wxRect midiRect = rect;
|
||||||
GetMidiControlsHorizontalBounds(rect, midiRect);
|
GetMidiControlsHorizontalBounds(rect, midiRect);
|
||||||
NoteTrack::DrawLabelControls
|
NoteTrack::DrawLabelControls
|
||||||
( static_cast<const NoteTrack *>(pTrack), dc, midiRect );
|
( static_cast<const NoteTrack *>(pTrack), dc, midiRect, channel );
|
||||||
#endif // EXPERIMENTAL_MIDI_OUT
|
#endif // EXPERIMENTAL_MIDI_OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,12 +24,23 @@ NoteTrackButtonHandle::NoteTrackButtonHandle
|
|||||||
: mpTrack{ pTrack }
|
: mpTrack{ pTrack }
|
||||||
, mChannel{ channel }
|
, mChannel{ channel }
|
||||||
, mRect{ rect }
|
, mRect{ rect }
|
||||||
{}
|
{
|
||||||
|
mChangeHighlight = RefreshCode::RefreshCell;
|
||||||
|
}
|
||||||
|
|
||||||
NoteTrackButtonHandle::~NoteTrackButtonHandle()
|
NoteTrackButtonHandle::~NoteTrackButtonHandle()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UIHandle::Result NoteTrackButtonHandle::NeedChangeHighlight
|
||||||
|
(const NoteTrackButtonHandle &oldState, const NoteTrackButtonHandle &newState)
|
||||||
|
{
|
||||||
|
if (oldState.GetChannel() != newState.GetChannel())
|
||||||
|
// Repaint whenever the highlighted button is different
|
||||||
|
return RefreshCode::RefreshCell;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
UIHandlePtr NoteTrackButtonHandle::HitTest
|
UIHandlePtr NoteTrackButtonHandle::HitTest
|
||||||
(std::weak_ptr<NoteTrackButtonHandle> &holder,
|
(std::weak_ptr<NoteTrackButtonHandle> &holder,
|
||||||
const wxMouseState &state, const wxRect &rect,
|
const wxMouseState &state, const wxRect &rect,
|
||||||
|
@ -42,6 +42,10 @@ public:
|
|||||||
|
|
||||||
int GetChannel() const { return mChannel; }
|
int GetChannel() const { return mChannel; }
|
||||||
|
|
||||||
|
static UIHandle::Result NeedChangeHighlight
|
||||||
|
(const NoteTrackButtonHandle &oldState,
|
||||||
|
const NoteTrackButtonHandle &newState);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Result Click
|
Result Click
|
||||||
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
|
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user