mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 16:40:07 +02:00
Static TrackInfo slider accessors, const Track* arguments
This commit is contained in:
parent
1d1dded9ba
commit
b15bf441ec
@ -3657,7 +3657,7 @@ void AudacityProject::OnTrackPan()
|
||||
}
|
||||
const auto wt = static_cast<WaveTrack*>(track);
|
||||
|
||||
LWSlider *slider = mTrackPanel->GetTrackInfo()->PanSlider(wt);
|
||||
LWSlider *slider = mTrackPanel->PanSlider(wt);
|
||||
if (slider->ShowDialog()) {
|
||||
SetTrackPan(wt, slider);
|
||||
}
|
||||
@ -3671,7 +3671,7 @@ void AudacityProject::OnTrackPanLeft()
|
||||
}
|
||||
const auto wt = static_cast<WaveTrack*>(track);
|
||||
|
||||
LWSlider *slider = mTrackPanel->GetTrackInfo()->PanSlider(wt);
|
||||
LWSlider *slider = mTrackPanel->PanSlider(wt);
|
||||
slider->Decrease(1);
|
||||
SetTrackPan(wt, slider);
|
||||
}
|
||||
@ -3684,7 +3684,7 @@ void AudacityProject::OnTrackPanRight()
|
||||
}
|
||||
const auto wt = static_cast<WaveTrack*>(track);
|
||||
|
||||
LWSlider *slider = mTrackPanel->GetTrackInfo()->PanSlider(wt);
|
||||
LWSlider *slider = mTrackPanel->PanSlider(wt);
|
||||
slider->Increase(1);
|
||||
SetTrackPan(wt, slider);
|
||||
}
|
||||
@ -3698,7 +3698,7 @@ void AudacityProject::OnTrackGain()
|
||||
}
|
||||
const auto wt = static_cast<WaveTrack*>(track);
|
||||
|
||||
LWSlider *slider = mTrackPanel->GetTrackInfo()->GainSlider(wt);
|
||||
LWSlider *slider = mTrackPanel->GainSlider(wt);
|
||||
if (slider->ShowDialog()) {
|
||||
SetTrackGain(wt, slider);
|
||||
}
|
||||
@ -3712,7 +3712,7 @@ void AudacityProject::OnTrackGainInc()
|
||||
}
|
||||
const auto wt = static_cast<WaveTrack*>(track);
|
||||
|
||||
LWSlider *slider = mTrackPanel->GetTrackInfo()->GainSlider(wt);
|
||||
LWSlider *slider = mTrackPanel->GainSlider(wt);
|
||||
slider->Increase(1);
|
||||
SetTrackGain(wt, slider);
|
||||
}
|
||||
@ -3725,7 +3725,7 @@ void AudacityProject::OnTrackGainDec()
|
||||
}
|
||||
const auto wt = static_cast<WaveTrack*>(track);
|
||||
|
||||
LWSlider *slider = mTrackPanel->GetTrackInfo()->GainSlider(wt);
|
||||
LWSlider *slider = mTrackPanel->GainSlider(wt);
|
||||
slider->Decrease(1);
|
||||
SetTrackGain(wt, slider);
|
||||
}
|
||||
|
@ -570,6 +570,32 @@ TrackPanel::~TrackPanel()
|
||||
DeleteMenus();
|
||||
}
|
||||
|
||||
LWSlider *TrackPanel::GainSlider( const WaveTrack *wt )
|
||||
{
|
||||
auto rect = FindTrackRect( wt, true );
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetGainRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::GainSlider(sliderRect, wt, false, this);
|
||||
}
|
||||
|
||||
LWSlider *TrackPanel::PanSlider( const WaveTrack *wt )
|
||||
{
|
||||
auto rect = FindTrackRect( wt, true );
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetPanRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::PanSlider(sliderRect, wt, false, this);
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider *TrackPanel::VelocitySlider( const NoteTrack *nt )
|
||||
{
|
||||
auto rect = FindTrackRect( nt, true );
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetVelocityRect( rect.GetTopLeft(), sliderRect );
|
||||
return TrackInfo::VelocitySlider(sliderRect, nt, false, this);
|
||||
}
|
||||
#endif
|
||||
|
||||
SelectionState &TrackPanel::GetSelectionState()
|
||||
{
|
||||
return GetProject()->GetSelectionState();
|
||||
@ -4865,10 +4891,17 @@ void TrackPanel::HandleSliders(wxMouseEvent &event, bool pan)
|
||||
// is displayed, but it doesn't hurt to do this for all plats.
|
||||
WaveTrack *capturedTrack = (WaveTrack *) mCapturedTrack;
|
||||
|
||||
if (pan)
|
||||
slider = mTrackInfo.PanSlider(capturedTrack, true);
|
||||
else
|
||||
slider = mTrackInfo.GainSlider(capturedTrack, true);
|
||||
auto rect = FindTrackRect( capturedTrack, true );
|
||||
if (pan) {
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetPanRect(rect.GetTopLeft(), sliderRect);
|
||||
slider = mTrackInfo.PanSlider(sliderRect, capturedTrack, true, this);
|
||||
}
|
||||
else {
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetGainRect(rect.GetTopLeft(), sliderRect);
|
||||
slider = mTrackInfo.GainSlider(sliderRect, capturedTrack, true, this);
|
||||
}
|
||||
|
||||
slider->OnMouseEvent(event);
|
||||
|
||||
@ -4923,7 +4956,10 @@ void TrackPanel::HandleVelocitySlider(wxMouseEvent &event)
|
||||
wxASSERT(mCapturedTrack->GetKind() == Track::Note);
|
||||
NoteTrack *capturedTrack = static_cast<NoteTrack *>(mCapturedTrack);
|
||||
|
||||
LWSlider *slider = mTrackInfo.VelocitySlider(capturedTrack, true);
|
||||
auto rect = FindTrackRect( capturedTrack, true );
|
||||
wxRect sliderRect;
|
||||
TrackInfo::GetVelocityRect(rect.GetTopLeft(), sliderRect);
|
||||
auto slider = mTrackInfo.VelocitySlider(sliderRect, capturedTrack, true, this);
|
||||
|
||||
slider->OnMouseEvent(event);
|
||||
|
||||
@ -8715,7 +8751,7 @@ TrackPanel::FoundCell TrackPanel::FindCell(int mouseX, int mouseY)
|
||||
|
||||
/// This finds the rectangle of a given track, either the
|
||||
/// of the label 'adornment' or the track itself
|
||||
wxRect TrackPanel::FindTrackRect(Track * target, bool label)
|
||||
wxRect TrackPanel::FindTrackRect( const Track * target, bool label )
|
||||
{
|
||||
if (!target) {
|
||||
return { 0, 0, 0, 0 };
|
||||
@ -8813,11 +8849,6 @@ TrackInfo::TrackInfo(TrackPanel * pParentIn)
|
||||
{
|
||||
pParent = pParentIn;
|
||||
|
||||
mGain = NULL;
|
||||
mGainCaptured=NULL;
|
||||
mPan = NULL;
|
||||
mPanCaptured=NULL;
|
||||
|
||||
ReCreateSliders();
|
||||
|
||||
UpdatePrefs();
|
||||
@ -8834,48 +8865,48 @@ void TrackInfo::ReCreateSliders(){
|
||||
|
||||
float defPos = 1.0;
|
||||
/* i18n-hint: Title of the Gain slider, used to adjust the volume */
|
||||
mGain = std::make_unique<LWSlider>(pParent, _("Gain"),
|
||||
gGain = std::make_unique<LWSlider>(pParent, _("Gain"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
DB_SLIDER);
|
||||
mGain->SetDefaultValue(defPos);
|
||||
gGain->SetDefaultValue(defPos);
|
||||
|
||||
mGainCaptured = std::make_unique<LWSlider>(pParent, _("Gain"),
|
||||
gGainCaptured = std::make_unique<LWSlider>(pParent, _("Gain"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
DB_SLIDER);
|
||||
mGainCaptured->SetDefaultValue(defPos);
|
||||
gGainCaptured->SetDefaultValue(defPos);
|
||||
|
||||
GetPanRect(point, sliderRect);
|
||||
|
||||
defPos = 0.0;
|
||||
/* i18n-hint: Title of the Pan slider, used to move the sound left or right */
|
||||
mPan = std::make_unique<LWSlider>(pParent, _("Pan"),
|
||||
gPan = std::make_unique<LWSlider>(pParent, _("Pan"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
PAN_SLIDER);
|
||||
mPan->SetDefaultValue(defPos);
|
||||
gPan->SetDefaultValue(defPos);
|
||||
|
||||
mPanCaptured = std::make_unique<LWSlider>(pParent, _("Pan"),
|
||||
gPanCaptured = std::make_unique<LWSlider>(pParent, _("Pan"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
PAN_SLIDER);
|
||||
mPanCaptured->SetDefaultValue(defPos);
|
||||
gPanCaptured->SetDefaultValue(defPos);
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
GetVelocityRect(point, sliderRect);
|
||||
|
||||
/* i18n-hint: Title of the Velocity slider, used to adjust the volume of note tracks */
|
||||
mVelocity = std::make_unique<LWSlider>(pParent, _("Velocity"),
|
||||
gVelocity = std::make_unique<LWSlider>(pParent, _("Velocity"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
VEL_SLIDER);
|
||||
mVelocity->SetDefaultValue(0.0);
|
||||
mVelocityCaptured = std::make_unique<LWSlider>(pParent, _("Velocity"),
|
||||
gVelocity->SetDefaultValue(0.0);
|
||||
gVelocityCaptured = std::make_unique<LWSlider>(pParent, _("Velocity"),
|
||||
wxPoint(sliderRect.x, sliderRect.y),
|
||||
wxSize(sliderRect.width, sliderRect.height),
|
||||
VEL_SLIDER);
|
||||
mVelocityCaptured->SetDefaultValue(0.0);
|
||||
gVelocityCaptured->SetDefaultValue(0.0);
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -9275,11 +9306,11 @@ void TrackInfo::DrawSliders(wxDC *dc, WaveTrack *t, wxRect rect, bool captured)
|
||||
|
||||
GetGainRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( !TrackInfo::HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
|
||||
GainSlider(t, captured)->OnPaint(*dc);
|
||||
GainSlider(sliderRect, t, captured, pParent)->OnPaint(*dc);
|
||||
|
||||
GetPanRect(rect.GetTopLeft(), sliderRect);
|
||||
if ( !TrackInfo::HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
|
||||
PanSlider(t, captured)->OnPaint(*dc);
|
||||
PanSlider(sliderRect, t, captured, pParent)->OnPaint(*dc);
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
@ -9289,7 +9320,7 @@ void TrackInfo::DrawVelocitySlider(wxDC *dc, NoteTrack *t, wxRect rect, bool cap
|
||||
|
||||
GetVelocityRect( rect.GetTopLeft(), sliderRect );
|
||||
if ( !TrackInfo::HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) ) {
|
||||
VelocitySlider(t, captured)->OnPaint(*dc);
|
||||
VelocitySlider(sliderRect, t, captured, pParent)->OnPaint(*dc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -9315,59 +9346,64 @@ unsigned TrackInfo::DefaultWaveTrackHeight()
|
||||
return (unsigned) std::max( needed, (int) Track::DefaultHeight );
|
||||
}
|
||||
|
||||
LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const
|
||||
{
|
||||
wxPoint topLeft{
|
||||
kLeftMargin, t->GetY() - pParent->GetViewInfo()->vpos + kTopMargin };
|
||||
wxRect sliderRect;
|
||||
GetGainRect(topLeft, sliderRect);
|
||||
std::unique_ptr<LWSlider>
|
||||
TrackInfo::gGainCaptured
|
||||
, TrackInfo::gPanCaptured
|
||||
, TrackInfo::gGain
|
||||
, TrackInfo::gPan
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
, TrackInfo::gVelocityCaptured
|
||||
, TrackInfo::gVelocity
|
||||
#endif
|
||||
;
|
||||
|
||||
LWSlider * TrackInfo::GainSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float gain = t->GetGain();
|
||||
|
||||
mGain->Move(pos);
|
||||
mGain->Set(gain);
|
||||
mGainCaptured->Move(pos);
|
||||
mGainCaptured->Set(gain);
|
||||
gGain->Move(pos);
|
||||
gGain->Set(gain);
|
||||
gGainCaptured->Move(pos);
|
||||
gGainCaptured->Set(gain);
|
||||
|
||||
return (captured ? mGainCaptured : mGain).get();
|
||||
auto slider = (captured ? gGainCaptured : gGain).get();
|
||||
slider->SetParent( pParent ? pParent : ::GetActiveProject() );
|
||||
return slider;
|
||||
}
|
||||
|
||||
LWSlider * TrackInfo::PanSlider(WaveTrack *t, bool captured) const
|
||||
LWSlider * TrackInfo::PanSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
wxPoint topLeft{
|
||||
kLeftMargin, t->GetY() - pParent->GetViewInfo()->vpos + kTopMargin };
|
||||
wxRect sliderRect;
|
||||
GetPanRect(topLeft, sliderRect);
|
||||
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float pan = t->GetPan();
|
||||
|
||||
mPan->Move(pos);
|
||||
mPan->Set(pan);
|
||||
mPanCaptured->Move(pos);
|
||||
mPanCaptured->Set(pan);
|
||||
gPan->Move(pos);
|
||||
gPan->Set(pan);
|
||||
gPanCaptured->Move(pos);
|
||||
gPanCaptured->Set(pan);
|
||||
|
||||
return (captured ? mPanCaptured : mPan).get();
|
||||
auto slider = (captured ? gPanCaptured : gPan).get();
|
||||
slider->SetParent( pParent ? pParent : ::GetActiveProject() );
|
||||
return slider;
|
||||
}
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider * TrackInfo::VelocitySlider(NoteTrack *t, bool captured) const
|
||||
LWSlider * TrackInfo::VelocitySlider
|
||||
(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
|
||||
{
|
||||
wxPoint topLeft{
|
||||
kLeftMargin, t->GetY() - pParent->GetViewInfo()->vpos + kTopMargin };
|
||||
wxRect sliderRect;
|
||||
GetVelocityRect(topLeft, sliderRect);
|
||||
|
||||
wxPoint pos = sliderRect.GetPosition();
|
||||
float velocity = t->GetVelocity();
|
||||
|
||||
mVelocity->Move(pos);
|
||||
mVelocity->Set(velocity);
|
||||
mVelocityCaptured->Move(pos);
|
||||
mVelocityCaptured->Set(velocity);
|
||||
gVelocity->Move(pos);
|
||||
gVelocity->Set(velocity);
|
||||
gVelocityCaptured->Move(pos);
|
||||
gVelocityCaptured->Set(velocity);
|
||||
|
||||
return (captured ? mVelocityCaptured : mVelocity).get();
|
||||
auto slider = (captured ? gVelocityCaptured : gVelocity).get();
|
||||
slider->SetParent( pParent ? pParent : ::GetActiveProject() );
|
||||
return slider;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -124,11 +124,17 @@ public:
|
||||
static unsigned DefaultNoteTrackHeight();
|
||||
static unsigned DefaultWaveTrackHeight();
|
||||
|
||||
LWSlider * GainSlider(WaveTrack *t, bool captured = false) const;
|
||||
LWSlider * PanSlider(WaveTrack *t, bool captured = false) const;
|
||||
static LWSlider * GainSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
static LWSlider * PanSlider
|
||||
(const wxRect &sliderRect, const WaveTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider * VelocitySlider(NoteTrack *t, bool captured = false) const;
|
||||
static LWSlider * VelocitySlider
|
||||
(const wxRect &sliderRect, const NoteTrack *t, bool captured,
|
||||
wxWindow *pParent);
|
||||
#endif
|
||||
|
||||
private:
|
||||
@ -136,10 +142,10 @@ private:
|
||||
|
||||
TrackPanel * pParent;
|
||||
static wxFont gFont;
|
||||
std::unique_ptr<LWSlider>
|
||||
mGainCaptured, mPanCaptured, mGain, mPan;
|
||||
static std::unique_ptr<LWSlider>
|
||||
gGainCaptured, gPanCaptured, gGain, gPan;
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
std::unique_ptr<LWSlider> mVelocityCaptured, mVelocity;
|
||||
static std::unique_ptr<LWSlider> gVelocityCaptured, gVelocity;
|
||||
#endif
|
||||
|
||||
friend class TrackPanel;
|
||||
@ -538,7 +544,7 @@ protected:
|
||||
// If label, rectangle includes track control panel only.
|
||||
// If !label, rectangle includes all of that, and the vertical ruler, and
|
||||
// the proper track area.
|
||||
virtual wxRect FindTrackRect(Track * target, bool label);
|
||||
virtual wxRect FindTrackRect( const Track * target, bool label );
|
||||
|
||||
virtual int GetVRulerWidth() const;
|
||||
virtual int GetVRulerOffset() const { return mTrackInfo.GetTrackInfoWidth(); }
|
||||
@ -593,9 +599,17 @@ protected:
|
||||
virtual wxString TrackSubText(WaveTrack *t);
|
||||
|
||||
TrackInfo mTrackInfo;
|
||||
public:
|
||||
TrackInfo *GetTrackInfo() { return &mTrackInfo; }
|
||||
const TrackInfo *GetTrackInfo() const { return &mTrackInfo; }
|
||||
|
||||
public:
|
||||
|
||||
LWSlider *GainSlider( const WaveTrack *wt );
|
||||
LWSlider *PanSlider( const WaveTrack *wt );
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
LWSlider *VelocitySlider( const NoteTrack *nt );
|
||||
#endif
|
||||
|
||||
TrackInfo *GetTrackInfo() { return &mTrackInfo; }
|
||||
const TrackInfo *GetTrackInfo() const { return &mTrackInfo; }
|
||||
|
||||
protected:
|
||||
TrackPanelListener *mListener;
|
||||
|
@ -156,6 +156,8 @@ class LWSlider
|
||||
|
||||
static void DeleteSharedTipPanel();
|
||||
|
||||
void SetParent(wxWindow *parent) { mParent = parent; }
|
||||
|
||||
private:
|
||||
|
||||
wxString GetTip(float value) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user