MixerBoard listens for events for track sliders, mute, solo, name

This commit is contained in:
Paul Licameli 2018-02-11 17:17:31 -05:00
parent 5ab2faceea
commit ccc2bbe3ef
7 changed files with 33 additions and 208 deletions

View File

@ -212,7 +212,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
.Style( DB_SLIDER )
.Orientation( wxVERTICAL ));
mSlider_Gain->SetName(_("Gain"));
this->UpdateGain();
#ifdef EXPERIMENTAL_MIDI_OUT
mSlider_Velocity =
safenew MixerTrackSlider(
@ -224,7 +224,6 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
.Style( VEL_SLIDER )
.Orientation( wxVERTICAL ));
mSlider_Velocity->SetName(_("Velocity"));
this->UpdateVelocity();
#endif
// other controls and meter at right
@ -260,8 +259,6 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
ASlider::Options{}.Style( PAN_SLIDER ));
mSlider_Pan->SetName(_("Pan"));
this->UpdatePan();
// mute/solo buttons stacked below Pan slider
ctrlPos.y += PAN_HEIGHT + kDoubleInset;
ctrlSize.Set(mMixerBoard->mMuteSoloWidth, MUTE_SOLO_HEIGHT);
@ -278,7 +275,6 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
*(mMixerBoard->mImageMuteUp), *(mMixerBoard->mImageMuteOver),
*(mMixerBoard->mImageMuteDown), *(mMixerBoard->mImageMuteDown),
*(mMixerBoard->mImageMuteDisabled));
this->UpdateMute();
ctrlPos.y += MUTE_SOLO_HEIGHT;
mToggleButton_Solo =
@ -289,7 +285,6 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
*(mMixerBoard->mImageSoloDisabled),
true); // toggle button
mToggleButton_Solo->SetName(_("Solo"));
this->UpdateSolo();
bool bSoloNone = mProject->IsSoloNone();
mToggleButton_Solo->Show(!bSoloNone);
@ -322,11 +317,12 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
mMeter->SetToolTip(_("Signal Level Meter"));
#endif // wxUSE_TOOLTIPS
UpdateForStateChange();
#ifdef __WXMAC__
wxSizeEvent event(GetSize(), GetId());
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
UpdateGain();
#endif
}
@ -450,77 +446,51 @@ void MixerTrackCluster::ResetMeter(const bool bResetClipping)
}
// These are used by TrackPanel for synchronizing control states, etc.
// Update the controls that can be affected by state change.
// Update appearance to match the state of the track
void MixerTrackCluster::UpdateForStateChange()
{
this->UpdateName();
this->UpdatePan();
this->UpdateGain();
}
void MixerTrackCluster::UpdateName()
{
const wxString newName = mTrack->GetName();
SetName(newName);
mStaticText_TrackName->SetLabel(newName);
mStaticText_TrackName->SetName(newName);
#if wxUSE_TOOLTIPS
mStaticText_TrackName->SetToolTip(newName);
#endif
mBitmapButton_MusicalInstrument->SetBitmapLabel(
*(mMixerBoard->GetMusicalInstrumentBitmap(mTrack.get())));
Refresh();
}
if (newName != GetName()) {
SetName(newName);
mStaticText_TrackName->SetLabel(newName);
mStaticText_TrackName->SetName(newName);
#if wxUSE_TOOLTIPS
mStaticText_TrackName->SetToolTip(newName);
#endif
mBitmapButton_MusicalInstrument->SetBitmapLabel(
*(mMixerBoard->GetMusicalInstrumentBitmap(mTrack.get())));
}
void MixerTrackCluster::UpdateMute()
{
mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
if (mTrack->GetMute())
mToggleButton_Mute->PushDown();
else
mToggleButton_Mute->PopUp();
}
void MixerTrackCluster::UpdateSolo()
{
bool bIsSolo = mTrack->GetSolo();
if (bIsSolo)
mToggleButton_Solo->PushDown();
else
mToggleButton_Solo->PopUp();
mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
}
void MixerTrackCluster::UpdatePan()
{
if (!GetWave()) {
if (!GetWave())
mSlider_Pan->Hide();
return;
}
mSlider_Pan->Set(GetWave()->GetPan());
}
else
mSlider_Pan->Set(GetWave()->GetPan());
void MixerTrackCluster::UpdateGain()
{
if (!GetWave()) {
if (!GetWave())
mSlider_Gain->Hide();
return;
}
mSlider_Gain->Set(GetWave()->GetGain());
}
else
mSlider_Gain->Set(GetWave()->GetGain());
#ifdef EXPERIMENTAL_MIDI_OUT
void MixerTrackCluster::UpdateVelocity()
{
if (!GetNote()) {
if (!GetNote())
mSlider_Velocity->Hide();
return;
}
mSlider_Velocity->Set(GetNote()->GetVelocity());
}
else
mSlider_Velocity->Set(GetNote()->GetVelocity());
#endif
}
void MixerTrackCluster::UpdateMeter(const double t0, const double t1)
{
@ -704,6 +674,8 @@ void MixerTrackCluster::OnMouseEvent(wxMouseEvent& event)
void MixerTrackCluster::OnPaint(wxPaintEvent & WXUNUSED(event))
{
UpdateForStateChange();
auto selected = mTrack->GetSelected();
wxColour col = theTheme.Colour(selected ? clrTrackInfoSelected : clrTrackInfo) ;
@ -773,8 +745,6 @@ void MixerTrackCluster::OnButton_Mute(wxCommandEvent& WXUNUSED(event))
// Update the TrackPanel correspondingly.
if (mProject->IsSoloSimple())
{
// Have to refresh all tracks.
mMixerBoard->UpdateSolo();
mProject->RedrawProject();
}
else
@ -789,12 +759,6 @@ void MixerTrackCluster::OnButton_Solo(wxCommandEvent& WXUNUSED(event))
mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
// Update the TrackPanel correspondingly.
if (mProject->IsSoloSimple())
{
// Have to refresh all tracks.
mMixerBoard->UpdateMute();
mMixerBoard->UpdateSolo();
}
// Bug 509: Must repaint all, as many tracks can change with one Solo change.
mProject->RedrawProject();
}
@ -957,6 +921,10 @@ MixerBoard::MixerBoard(AudacityProject* pProject,
mProject->GetTracks()->Bind(EVT_TRACKLIST_DELETION,
&MixerBoard::OnTrackSetChanged,
this);
mProject->GetTracks()->Bind(EVT_TRACKLIST_TRACK_DATA_CHANGE,
&MixerBoard::OnTrackChanged,
this);
}
@ -1157,80 +1125,6 @@ void MixerBoard::ResetMeters(const bool bResetClipping)
mMixerTrackClusters[i]->ResetMeter(bResetClipping);
}
void MixerBoard::UpdateName(const PlayableTrack* pTrack)
{
MixerTrackCluster* pMixerTrackCluster;
this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
if (pMixerTrackCluster)
pMixerTrackCluster->UpdateName();
}
void MixerBoard::UpdateMute(const PlayableTrack* pTrack /*= NULL*/) // NULL means update for all tracks.
{
if (pTrack == NULL)
{
for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
mMixerTrackClusters[i]->UpdateMute();
}
else
{
MixerTrackCluster* pMixerTrackCluster;
FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
if (pMixerTrackCluster)
pMixerTrackCluster->UpdateMute();
}
}
void MixerBoard::UpdateSolo(const PlayableTrack* pTrack /*= NULL*/) // NULL means update for all tracks.
{
if (pTrack == NULL)
{
for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
mMixerTrackClusters[i]->UpdateSolo();
}
else
{
MixerTrackCluster* pMixerTrackCluster;
FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
if (pMixerTrackCluster)
pMixerTrackCluster->UpdateSolo();
}
}
void MixerBoard::UpdatePan(const PlayableTrack* pTrack)
{
if (pTrack == NULL)
{
for (unsigned int i = 0; i < mMixerTrackClusters.size(); i++)
mMixerTrackClusters[i]->UpdatePan();
}
else
{
MixerTrackCluster* pMixerTrackCluster;
FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
if (pMixerTrackCluster)
pMixerTrackCluster->UpdatePan();
}
}
void MixerBoard::UpdateGain(const PlayableTrack* pTrack)
{
MixerTrackCluster* pMixerTrackCluster;
FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
if (pMixerTrackCluster)
pMixerTrackCluster->UpdateGain();
}
#ifdef EXPERIMENTAL_MIDI_OUT
void MixerBoard::UpdateVelocity(const PlayableTrack* pTrack)
{
MixerTrackCluster* pMixerTrackCluster;
FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
if (pMixerTrackCluster)
pMixerTrackCluster->UpdateVelocity();
}
#endif
void MixerBoard::UpdateMeters(const double t1, const bool bLoopedPlay)
{
if (!this->IsShown() || (t1 == BAD_STREAM_TIME))

View File

@ -98,16 +98,7 @@ public:
void ResetMeter(const bool bResetClipping);
// These are used by TrackPanel for synchronizing control states.
void UpdateForStateChange(); // Update the controls that can be affected by state change.
void UpdateName();
void UpdateMute();
void UpdateSolo();
void UpdatePan();
void UpdateGain();
#ifdef EXPERIMENTAL_MIDI_OUT
void UpdateVelocity();
#endif
void UpdateForStateChange();
void UpdateMeter(const double t0, const double t1);
private:
@ -225,15 +216,6 @@ public:
void ResetMeters(const bool bResetClipping);
void UpdateName(const PlayableTrack* pTrack);
void UpdateMute(const PlayableTrack* pTrack = NULL); // NULL means update for all tracks.
void UpdateSolo(const PlayableTrack* pTrack = NULL); // NULL means update for all tracks.
void UpdatePan(const PlayableTrack* pTrack = NULL); // NULL means update for all tracks.
void UpdateGain(const PlayableTrack* pTrack);
#ifdef EXPERIMENTAL_MIDI_OUT
void UpdateVelocity(const PlayableTrack* pTrack);
#endif
void UpdateMeters(const double t1, const bool bLoopedPlay);
void UpdateWidth();
@ -254,7 +236,6 @@ private:
void OnTrackSetChanged(wxEvent &event);
void OnTrackChanged(TrackListEvent &event);
public:
// mute & solo button images: Create once and store on MixerBoard for use in all MixerTrackClusters.
std::unique_ptr<wxImage> mImageMuteUp, mImageMuteOver, mImageMuteDown,

View File

@ -5524,14 +5524,6 @@ void AudacityProject::DoTrackMute(Track *t, bool exclusive)
{
HandleTrackMute(t, exclusive);
// Update mixer board, too.
MixerBoard* pMixerBoard = this->GetMixerBoard();
if (pMixerBoard)
{
pMixerBoard->UpdateMute(); // Update for all tracks.
pMixerBoard->UpdateSolo(); // Update for all tracks.
}
mTrackPanel->UpdateAccessibility();
mTrackPanel->Refresh(false);
}
@ -5540,14 +5532,6 @@ void AudacityProject::DoTrackSolo(Track *t, bool exclusive)
{
HandleTrackSolo(t, exclusive);
// Update mixer board, too.
MixerBoard* pMixerBoard = this->GetMixerBoard();
if (pMixerBoard)
{
pMixerBoard->UpdateMute(); // Update for all tracks.
pMixerBoard->UpdateSolo(); // Update for all tracks.
}
mTrackPanel->UpdateAccessibility();
mTrackPanel->Refresh(false);
}

View File

@ -3,7 +3,7 @@
#include "../LabelTrack.h"
#include "../Menus.h"
#include "../Mix.h"
#include "../MixerBoard.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../ShuttleGui.h"
@ -13,6 +13,7 @@
#include "../WaveTrack.h"
#include "../commands/CommandContext.h"
#include "../commands/CommandManager.h"
#include "../widgets/ASlider.h"
#include <wx/combobox.h>
@ -103,7 +104,6 @@ void DoMixAndRender
void DoPanTracks(AudacityProject &project, float PanValue)
{
auto tracks = project.GetTracks();
auto mixerBoard = project.GetMixerBoard();
// count selected wave tracks
const auto range = tracks->Any< WaveTrack >();
@ -115,8 +115,6 @@ void DoPanTracks(AudacityProject &project, float PanValue)
left->SetPan( PanValue );
project.RedrawProject();
if (mixerBoard)
mixerBoard->UpdatePan();
auto flags = UndoPush::AUTOSAVE;
/*i18n-hint: One or more audio tracks have been panned*/
@ -832,7 +830,6 @@ void OnMuteAllTracks(const CommandContext &context)
auto tracks = project.GetTracks();
auto soloSimple = project.IsSoloSimple();
auto soloNone = project.IsSoloNone();
auto mixerBoard = project.GetMixerBoard();
for (auto pt : tracks->Any<PlayableTrack>())
{
@ -843,11 +840,6 @@ void OnMuteAllTracks(const CommandContext &context)
project.ModifyState(true);
project.RedrawProject();
if (mixerBoard) {
mixerBoard->UpdateMute();
if (soloSimple || soloNone)
mixerBoard->UpdateSolo();
}
}
void OnUnmuteAllTracks(const CommandContext &context)
@ -856,7 +848,6 @@ void OnUnmuteAllTracks(const CommandContext &context)
auto tracks = project.GetTracks();
auto soloSimple = project.IsSoloSimple();
auto soloNone = project.IsSoloNone();
auto mixerBoard = project.GetMixerBoard();
for (auto pt : tracks->Any<PlayableTrack>())
{
@ -867,11 +858,6 @@ void OnUnmuteAllTracks(const CommandContext &context)
project.ModifyState(true);
project.RedrawProject();
if (mixerBoard) {
mixerBoard->UpdateMute();
if (soloSimple || soloNone)
mixerBoard->UpdateSolo();
}
}
void OnPanLeft(const CommandContext &context)

View File

@ -14,7 +14,6 @@
#ifdef EXPERIMENTAL_MIDI_OUT
#include "../../../../HitTestResult.h"
#include "../../../../MixerBoard.h"
#include "../../../../Project.h"
#include "../../../../RefreshCode.h"
#include "../../../../TrackPanel.h" // for TrackInfo
@ -51,10 +50,6 @@ UIHandle::Result VelocitySliderHandle::SetValue
if (pTrack) {
pTrack->SetVelocity(newValue);
MixerBoard *const pMixerBoard = pProject->GetMixerBoard();
if (pMixerBoard)
pMixerBoard->UpdateVelocity(pTrack.get());
}
return RefreshCode::RefreshCell;

View File

@ -12,7 +12,6 @@ Paul Licameli split from TrackPanel.cpp
#include "WaveTrackSliderHandles.h"
#include "../../../../HitTestResult.h"
#include "../../../../MixerBoard.h"
#include "../../../../Project.h"
#include "../../../../RefreshCode.h"
#include "../../../../TrackPanel.h"
@ -50,10 +49,6 @@ UIHandle::Result GainSliderHandle::SetValue
for (auto channel :
TrackList::Channels(pTrack.get()))
channel->SetGain(newValue);
MixerBoard *const pMixerBoard = pProject->GetMixerBoard();
if (pMixerBoard)
pMixerBoard->UpdateGain(pTrack.get());
}
return RefreshCode::RefreshNone;
@ -131,10 +126,6 @@ UIHandle::Result PanSliderHandle::SetValue(AudacityProject *pProject, float newV
for (auto channel :
TrackList::Channels(pTrack.get()))
channel->SetPan(newValue);
MixerBoard *const pMixerBoard = pProject->GetMixerBoard();
if (pMixerBoard)
pMixerBoard->UpdatePan(pTrack.get());
}
return result;

View File

@ -15,7 +15,6 @@ Paul Licameli split from TrackPanel.cpp
#include "../../HitTestResult.h"
#include "../../RefreshCode.h"
#include "../../Menus.h"
#include "../../MixerBoard.h"
#include "../../Project.h"
#include "../../TrackPanel.h" // for TrackInfo
#include "../../TrackPanelMouseEvent.h"
@ -214,11 +213,6 @@ void TrackMenuTable::OnSetName(wxCommandEvent &)
for (auto channel : TrackList::Channels(pTrack))
channel->SetName(newName);
MixerBoard *const pMixerBoard = proj->GetMixerBoard();
auto pt = dynamic_cast<PlayableTrack*>(pTrack);
if (pt && pMixerBoard)
pMixerBoard->UpdateName(pt);
proj->PushState(wxString::Format(_("Renamed '%s' to '%s'"),
oldName,
newName),