1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-17 09:07:41 +02:00

Bug1426: Better selection for key-modified clicks in TCP, Mixer board

This commit is contained in:
Paul Licameli 2016-06-26 12:03:45 -04:00
parent ee7b3b2b89
commit 4823244050
4 changed files with 45 additions and 77 deletions

View File

@ -699,65 +699,21 @@ wxColour MixerTrackCluster::GetTrackColor()
// event handlers
void MixerTrackCluster::HandleSelect(const bool bShiftDown)
void MixerTrackCluster::HandleSelect(bool bShiftDown, bool bControlDown)
{
if (bShiftDown)
{
// ShiftDown => Just toggle selection on this track.
#ifdef EXPERIMENTAL_MIDI_OUT
bool bSelect = !mTrack->GetSelected();
mTrack->SetSelected(bSelect);
Track *pTrack = mTrack;
#else
bool bSelect = !mLeftTrack->GetSelected();
mLeftTrack->SetSelected(bSelect);
Track *pTrack = mLeftTrack;
#endif
if (mRightTrack)
mRightTrack->SetSelected(bSelect);
// Refresh only this MixerTrackCluster and WaveTrack in TrackPanel.
this->Refresh(true);
#ifdef EXPERIMENTAL_MIDI_OUT
mProject->RefreshTPTrack(mTrack);
#else
mProject->RefreshTPTrack(mLeftTrack);
#endif
}
else
{
// exclusive select
mProject->SelectNone();
#ifdef EXPERIMENTAL_MIDI_OUT
mTrack->SetSelected(true);
#else
mLeftTrack->SetSelected(true);
#endif
if (mRightTrack)
mRightTrack->SetSelected(true);
if (mProject->GetSel0() >= mProject->GetSel1())
{
// No range previously selected, so use the range of this track.
#ifdef EXPERIMENTAL_MIDI_OUT
mProject->mViewInfo.selectedRegion.setTimes(
mTrack->GetOffset(), mTrack->GetEndTime());
#else
mProject->mViewInfo.selectedRegion.setTimes(
mLeftTrack->GetOffset(), mLeftTrack->GetEndTime());
#endif
}
// Exclusive select, so refresh all MixerTrackClusters.
// This could just be a call to wxWindow::Refresh, but this is
// more efficient and when ProjectLogo is shown as background,
// it's necessary to prevent blinking.
mMixerBoard->RefreshTrackClusters(false);
}
mProject->GetTrackPanel()->HandleListSelection(pTrack, bShiftDown, bControlDown);
}
void MixerTrackCluster::OnMouseEvent(wxMouseEvent& event)
{
if (event.ButtonUp())
this->HandleSelect(event.ShiftDown());
this->HandleSelect(event.ShiftDown(), event.ControlDown());
else
event.Skip();
}
@ -791,8 +747,8 @@ void MixerTrackCluster::OnPaint(wxPaintEvent & WXUNUSED(event))
void MixerTrackCluster::OnButton_MusicalInstrument(wxCommandEvent& WXUNUSED(event))
{
bool bShiftDown = ::wxGetMouseState().ShiftDown();
this->HandleSelect(bShiftDown);
const auto &state = ::wxGetMouseState();
this->HandleSelect(state.ShiftDown(), state.ControlDown());
}
void MixerTrackCluster::OnSlider_Gain(wxCommandEvent& WXUNUSED(event))

View File

@ -100,7 +100,7 @@ private:
wxColour GetTrackColor();
// event handlers
void HandleSelect(const bool bShiftDown);
void HandleSelect(bool bShiftDown, bool bControlDown);
void OnKeyEvent(wxKeyEvent& event);
void OnMouseEvent(wxMouseEvent& event);

View File

@ -1879,12 +1879,11 @@ void TrackPanel::SelectRangeOfTracks(Track *sTrack, Track *eTrack)
// Swap the track pointers if needed
if (eTrack->GetIndex() < sTrack->GetIndex())
std::swap(sTrack, eTrack);
Track *t = eTrack;
TrackListIterator iter(mTracks);
sTrack = iter.StartWith(sTrack);
do {
SelectTrack(sTrack, true);
SelectTrack(sTrack, true, false);
if (sTrack == eTrack) {
break;
}
@ -4937,27 +4936,27 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event)
{
wxRect midiRect;
#ifdef EXPERIMENTAL_MIDI_OUT
// this is an awful hack: make a NEW rectangle at an offset because
// MuteSoloFunc thinks buttons are located below some text, e.g.
// "Mono, 44100Hz 32-bit float", but this is not true for a Note track
wxRect muteSoloRect(rect);
muteSoloRect.y -= 34; // subtract the height of wave track text
if (MuteSoloFunc(t, muteSoloRect, event.m_x, event.m_y, false) ||
MuteSoloFunc(t, muteSoloRect, event.m_x, event.m_y, true))
return;
// this is an awful hack: make a NEW rectangle at an offset because
// MuteSoloFunc thinks buttons are located below some text, e.g.
// "Mono, 44100Hz 32-bit float", but this is not true for a Note track
wxRect muteSoloRect(rect);
muteSoloRect.y -= 34; // subtract the height of wave track text
if (MuteSoloFunc(t, muteSoloRect, event.m_x, event.m_y, false) ||
MuteSoloFunc(t, muteSoloRect, event.m_x, event.m_y, true))
return;
// this is a similar hack: GainFunc expects a Wave track slider, so it's
// looking in the wrong place. We pass it a bogus rectangle created when
// the slider was placed to "fake" GainFunc into finding the slider in
// its actual location.
if (GainFunc(t, ((NoteTrack *) t)->GetGainPlacementRect(),
event, event.m_x, event.m_y))
return;
// this is a similar hack: GainFunc expects a Wave track slider, so it's
// looking in the wrong place. We pass it a bogus rectangle created when
// the slider was placed to "fake" GainFunc into finding the slider in
// its actual location.
if (GainFunc(t, ((NoteTrack *) t)->GetGainPlacementRect(),
event, event.m_x, event.m_y))
return;
#endif
mTrackInfo.GetTrackControlsRect(rect, midiRect);
if (midiRect.Contains(event.m_x, event.m_y) &&
((NoteTrack *) t)->LabelClick(midiRect, event.m_x, event.m_y,
event.Button(wxMOUSE_BTN_RIGHT))) {
((NoteTrack *)t)->LabelClick(midiRect, event.m_x, event.m_y,
event.Button(wxMOUSE_BTN_RIGHT))) {
Refresh(false);
return;
}
@ -4977,20 +4976,31 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event)
// can drag the track up or down to swap it with others
if (!unsafe) {
mRearrangeCount = 0;
SetCapturedTrack( t, IsRearranging );
SetCapturedTrack(t, IsRearranging);
TrackPanel::CalculateRearrangingThresholds(event);
}
HandleListSelection(t, event.ShiftDown(), event.ControlDown());
if (!unsafe)
MakeParentModifyState(true);
}
void TrackPanel::HandleListSelection(Track *t, bool shift, bool ctrl)
{
// AS: If the shift button is being held down, invert
// the selection on this track.
if (event.ShiftDown()) {
if (ctrl) {
SelectTrack(t, !t->GetSelected());
Refresh(false);
return;
}
SelectNone();
SelectTrack(t, true);
if (shift && mLastPickedTrack)
SelectRangeOfTracks(t, mLastPickedTrack);
else
SelectTrack(t, true);
SetFocusedTrack(t);
SelectTrackLength(t);
@ -4998,9 +5008,6 @@ void TrackPanel::HandleLabelClick(wxMouseEvent & event)
MixerBoard* pMixerBoard = this->GetMixerBoard();
if (pMixerBoard)
pMixerBoard->RefreshTrackClusters();
if (!unsafe)
MakeParentModifyState(true);
}
/// The user is dragging one of the tracks: change the track order

View File

@ -398,6 +398,11 @@ protected:
virtual void HandleResize(wxMouseEvent & event);
virtual void HandleLabelClick(wxMouseEvent & event);
public:
virtual void HandleListSelection(Track *t, bool shift, bool ctrl);
protected:
virtual void HandleRearrange(wxMouseEvent & event);
virtual void CalculateRearrangingThresholds(wxMouseEvent & event);
virtual void HandleClosing(wxMouseEvent & event);