1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 00:30:07 +02:00

Remove some uses of Track::GetHeight()...

Pass top-left point, not a rectangle, to places that did not use width or
height.
This commit is contained in:
Paul Licameli 2017-06-04 08:29:32 -04:00
parent 5395f253bf
commit afd3b0ba19
2 changed files with 31 additions and 28 deletions

View File

@ -5383,7 +5383,7 @@ bool TrackPanel::GainFunc(Track * t, wxRect rect, wxMouseEvent &event,
int x, int y) int x, int y)
{ {
wxRect sliderRect; wxRect sliderRect;
mTrackInfo.GetGainRect(rect, sliderRect); mTrackInfo.GetGainRect(rect.GetTopLeft(), sliderRect);
if (!sliderRect.Contains(x, y)) if (!sliderRect.Contains(x, y))
return false; return false;
@ -5398,7 +5398,7 @@ bool TrackPanel::PanFunc(Track * t, wxRect rect, wxMouseEvent &event,
int x, int y) int x, int y)
{ {
wxRect sliderRect; wxRect sliderRect;
mTrackInfo.GetPanRect(rect, sliderRect); mTrackInfo.GetPanRect(rect.GetTopLeft(), sliderRect);
if (!sliderRect.Contains(x, y)) if (!sliderRect.Contains(x, y))
return false; return false;
@ -5414,7 +5414,7 @@ bool TrackPanel::VelocityFunc(Track * t, wxRect rect, wxMouseEvent &event,
int x, int y) int x, int y)
{ {
wxRect sliderRect; wxRect sliderRect;
mTrackInfo.GetVelocityRect(rect, sliderRect); mTrackInfo.GetVelocityRect(rect.GetTopLeft(), sliderRect);
if (!sliderRect.Contains(x, y)) if (!sliderRect.Contains(x, y))
return false; return false;
@ -9137,9 +9137,9 @@ TrackInfo::~TrackInfo()
} }
void TrackInfo::ReCreateSliders(){ void TrackInfo::ReCreateSliders(){
wxRect rect(0, 0, 1000, 1000); wxPoint point{ 0, 0 };
wxRect sliderRect; wxRect sliderRect;
GetGainRect(rect, sliderRect); GetGainRect(point, sliderRect);
float defPos = 1.0; float defPos = 1.0;
/* i18n-hint: Title of the Gain slider, used to adjust the volume */ /* i18n-hint: Title of the Gain slider, used to adjust the volume */
@ -9155,7 +9155,7 @@ void TrackInfo::ReCreateSliders(){
DB_SLIDER); DB_SLIDER);
mGainCaptured->SetDefaultValue(defPos); mGainCaptured->SetDefaultValue(defPos);
GetPanRect(rect, sliderRect); GetPanRect(point, sliderRect);
defPos = 0.0; defPos = 0.0;
/* i18n-hint: Title of the Pan slider, used to move the sound left or right */ /* i18n-hint: Title of the Pan slider, used to move the sound left or right */
@ -9172,7 +9172,7 @@ void TrackInfo::ReCreateSliders(){
mPanCaptured->SetDefaultValue(defPos); mPanCaptured->SetDefaultValue(defPos);
#ifdef EXPERIMENTAL_MIDI_OUT #ifdef EXPERIMENTAL_MIDI_OUT
GetVelocityRect(rect, sliderRect); GetVelocityRect(point, sliderRect);
/* i18n-hint: Title of the Velocity slider, used to adjust the volume of note tracks */ /* i18n-hint: Title of the Velocity slider, used to adjust the volume of note tracks */
mVelocity = std::make_unique<LWSlider>(pParent, _("Velocity"), mVelocity = std::make_unique<LWSlider>(pParent, _("Velocity"),
@ -9296,25 +9296,25 @@ void TrackInfo::GetMuteSoloRect(const wxRect & rect, wxRect & dest, bool solo, b
} }
void TrackInfo::GetGainRect(const wxRect & rect, wxRect & dest) const void TrackInfo::GetGainRect(const wxPoint &topleft, wxRect & dest) const
{ {
dest.x = rect.x + 7; dest.x = topleft.x + 7;
dest.y = rect.y + CalcItemY( kItemGain ); dest.y = topleft.y + CalcItemY( kItemGain );
dest.width = 84; dest.width = 84;
dest.height = 25; dest.height = 25;
} }
void TrackInfo::GetPanRect(const wxRect & rect, wxRect & dest) const void TrackInfo::GetPanRect(const wxPoint &topleft, wxRect & dest) const
{ {
GetGainRect( rect, dest ); GetGainRect( topleft, dest );
dest.y = rect.y + CalcItemY( kItemPan ); dest.y = topleft.y + CalcItemY( kItemPan );
} }
#ifdef EXPERIMENTAL_MIDI_OUT #ifdef EXPERIMENTAL_MIDI_OUT
void TrackInfo::GetVelocityRect(const wxRect & rect, wxRect & dest) const void TrackInfo::GetVelocityRect(const wxPoint &topleft, wxRect & dest) const
{ {
dest.x = rect.x + 7; dest.x = topleft.x + 7;
dest.y = rect.y + 100; dest.y = topleft.y + 100;
dest.width = 84; dest.width = 84;
dest.height = 25; dest.height = 25;
} }
@ -9592,12 +9592,12 @@ void TrackInfo::DrawSliders(wxDC *dc, WaveTrack *t, wxRect rect, bool captured)
// Larger slidermargin means it disappears sooner on collapsing track. // Larger slidermargin means it disappears sooner on collapsing track.
const int sliderMargin = 14; const int sliderMargin = 14;
GetGainRect(rect, sliderRect); GetGainRect(rect.GetTopLeft(), sliderRect);
if (sliderRect.y + sliderRect.height < rect.y + rect.height - sliderMargin) { if (sliderRect.y + sliderRect.height < rect.y + rect.height - sliderMargin) {
GainSlider(t, captured)->OnPaint(*dc); GainSlider(t, captured)->OnPaint(*dc);
} }
GetPanRect(rect, sliderRect); GetPanRect(rect.GetTopLeft(), sliderRect);
if (sliderRect.y + sliderRect.height < rect.y + rect.height - sliderMargin) { if (sliderRect.y + sliderRect.height < rect.y + rect.height - sliderMargin) {
PanSlider(t, captured)->OnPaint(*dc); PanSlider(t, captured)->OnPaint(*dc);
} }
@ -9608,7 +9608,7 @@ void TrackInfo::DrawVelocitySlider(wxDC *dc, NoteTrack *t, wxRect rect, bool cap
{ {
wxRect sliderRect; wxRect sliderRect;
GetVelocityRect(rect, sliderRect); GetVelocityRect(rect.GetTopLeft(), sliderRect);
if (sliderRect.y + sliderRect.height < rect.y + rect.height - 19) { if (sliderRect.y + sliderRect.height < rect.y + rect.height - 19) {
VelocitySlider(t, captured)->OnPaint(*dc); VelocitySlider(t, captured)->OnPaint(*dc);
} }
@ -9618,9 +9618,10 @@ void TrackInfo::DrawVelocitySlider(wxDC *dc, NoteTrack *t, wxRect rect, bool cap
LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const
{ {
// PRL: Add the inset, but why not also the border? // PRL: Add the inset, but why not also the border?
wxRect rect(kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset, 1, t->GetHeight()); wxPoint topLeft{
kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset };
wxRect sliderRect; wxRect sliderRect;
GetGainRect(rect, sliderRect); GetGainRect(topLeft, sliderRect);
wxPoint pos = sliderRect.GetPosition(); wxPoint pos = sliderRect.GetPosition();
float gain = t->GetGain(); float gain = t->GetGain();
@ -9636,9 +9637,10 @@ LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const
LWSlider * TrackInfo::PanSlider(WaveTrack *t, bool captured) const LWSlider * TrackInfo::PanSlider(WaveTrack *t, bool captured) const
{ {
// PRL: Add the inset, but why not also the border? // PRL: Add the inset, but why not also the border?
wxRect rect(kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset, 1, t->GetHeight()); wxPoint topLeft{
kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset };
wxRect sliderRect; wxRect sliderRect;
GetPanRect(rect, sliderRect); GetPanRect(topLeft, sliderRect);
wxPoint pos = sliderRect.GetPosition(); wxPoint pos = sliderRect.GetPosition();
float pan = t->GetPan(); float pan = t->GetPan();
@ -9655,9 +9657,10 @@ LWSlider * TrackInfo::PanSlider(WaveTrack *t, bool captured) const
LWSlider * TrackInfo::VelocitySlider(NoteTrack *t, bool captured) const LWSlider * TrackInfo::VelocitySlider(NoteTrack *t, bool captured) const
{ {
// PRL: Add the inset, but why not also the border? // PRL: Add the inset, but why not also the border?
wxRect rect(kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset, 1, t->GetHeight()); wxPoint topLeft{
kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset };
wxRect sliderRect; wxRect sliderRect;
GetVelocityRect(rect, sliderRect); GetVelocityRect(topLeft, sliderRect);
wxPoint pos = sliderRect.GetPosition(); wxPoint pos = sliderRect.GetPosition();
float velocity = t->GetVelocity(); float velocity = t->GetVelocity();

View File

@ -118,10 +118,10 @@ private:
void GetTitleBarRect(const wxRect & rect, wxRect &dest) const; void GetTitleBarRect(const wxRect & rect, wxRect &dest) const;
void GetMuteSoloRect(const wxRect & rect, wxRect &dest, bool solo, bool bHasSoloButton, void GetMuteSoloRect(const wxRect & rect, wxRect &dest, bool solo, bool bHasSoloButton,
const Track *pTrack) const; const Track *pTrack) const;
void GetGainRect(const wxRect & rect, wxRect &dest) const; void GetGainRect(const wxPoint & topLeft, wxRect &dest) const;
void GetPanRect(const wxRect & rect, wxRect &dest) const; void GetPanRect(const wxPoint & topLeft, wxRect &dest) const;
#ifdef EXPERIMENTAL_MIDI_OUT #ifdef EXPERIMENTAL_MIDI_OUT
void GetVelocityRect(const wxRect & rect, wxRect &dest) const; void GetVelocityRect(const wxPoint & topLeft, wxRect &dest) const;
#endif #endif
void GetMinimizeRect(const wxRect & rect, wxRect &dest) const; void GetMinimizeRect(const wxRect & rect, wxRect &dest) const;
void GetSyncLockIconRect(const wxRect & rect, wxRect &dest) const; void GetSyncLockIconRect(const wxRect & rect, wxRect &dest) const;