1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 00:59:43 +02:00
This commit is contained in:
Leland Lucius 2015-09-08 11:24:59 -05:00
parent a7a1e11668
commit 2d88ad63e0
4 changed files with 79 additions and 45 deletions

View File

@ -5300,9 +5300,9 @@ void TrackPanel::HandleSliders(wxMouseEvent &event, bool pan)
WaveTrack *capturedTrack = (WaveTrack *) mCapturedTrack;
if (pan)
slider = mTrackInfo.PanSlider(capturedTrack);
slider = mTrackInfo.PanSlider(capturedTrack, true);
else
slider = mTrackInfo.GainSlider(capturedTrack);
slider = mTrackInfo.GainSlider(capturedTrack, true);
slider->OnMouseEvent(event);
@ -7718,7 +7718,7 @@ void TrackPanel::DrawOutside(Track * t, wxDC * dc, const wxRect & rec,
mTrackInfo.DrawMuteSolo(dc, rect, t, (captured && mMouseCapture == IsMuting), false, HasSoloButton());
mTrackInfo.DrawMuteSolo(dc, rect, t, (captured && mMouseCapture == IsSoloing), true, HasSoloButton());
mTrackInfo.DrawSliders(dc, (WaveTrack *)t, rect);
mTrackInfo.DrawSliders(dc, (WaveTrack *)t, rect, captured);
if (!t->GetMinimized()) {
int offset = 8;
@ -9648,6 +9648,11 @@ TrackInfo::TrackInfo(TrackPanel * pParentIn)
wxSize(sliderRect.width, sliderRect.height),
DB_SLIDER);
mGain->SetDefaultValue(1.0);
mGainCaptured = new LWSlider(pParent, _("Gain"),
wxPoint(sliderRect.x, sliderRect.y),
wxSize(sliderRect.width, sliderRect.height),
DB_SLIDER);
mGainCaptured->SetDefaultValue(1.0);
GetPanRect(rect, sliderRect);
@ -9657,6 +9662,11 @@ TrackInfo::TrackInfo(TrackPanel * pParentIn)
wxSize(sliderRect.width, sliderRect.height),
PAN_SLIDER);
mPan->SetDefaultValue(0.0);
mPanCaptured = new LWSlider(pParent, _("Pan"),
wxPoint(sliderRect.x, sliderRect.y),
wxSize(sliderRect.width, sliderRect.height),
PAN_SLIDER);
mPanCaptured->SetDefaultValue(0.0);
int fontSize = 10;
mFont.Create(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
@ -9677,7 +9687,9 @@ TrackInfo::TrackInfo(TrackPanel * pParentIn)
TrackInfo::~TrackInfo()
{
delete mGainCaptured;
delete mGain;
delete mPanCaptured;
delete mPan;
}
@ -10000,43 +10012,53 @@ void TrackInfo::DrawVelocitySlider(wxDC *dc, NoteTrack *t, wxRect rect) const
}
#endif
void TrackInfo::DrawSliders(wxDC *dc, WaveTrack *t, wxRect rect) const
void TrackInfo::DrawSliders(wxDC *dc, WaveTrack *t, wxRect rect, bool captured) const
{
wxRect sliderRect;
GetGainRect(rect, sliderRect);
if (sliderRect.y + sliderRect.height < rect.y + rect.height - 19) {
GainSlider(t)->OnPaint(*dc);
GainSlider(t, captured)->OnPaint(*dc);
}
GetPanRect(rect, sliderRect);
if (sliderRect.y + sliderRect.height < rect.y + rect.height - 19) {
PanSlider(t)->OnPaint(*dc);
PanSlider(t, captured)->OnPaint(*dc);
}
}
LWSlider * TrackInfo::GainSlider(WaveTrack *t) const
LWSlider * TrackInfo::GainSlider(WaveTrack *t, bool captured) const
{
wxRect rect(kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset, 1, t->GetHeight());
wxRect sliderRect;
GetGainRect(rect, sliderRect);
mGain->Move(wxPoint(sliderRect.x, sliderRect.y));
mGain->Set(t->GetGain());
wxPoint pos = sliderRect.GetPosition();
float gain = t->GetGain();
return mGain;
mGain->Move(pos);
mGain->Set(gain);
mGainCaptured->Move(pos);
mGainCaptured->Set(gain);
return captured ? mGainCaptured : mGain;
}
LWSlider * TrackInfo::PanSlider(WaveTrack *t) const
LWSlider * TrackInfo::PanSlider(WaveTrack *t, bool captured) const
{
wxRect rect(kLeftInset, t->GetY() - pParent->GetViewInfo()->vpos + kTopInset, 1, t->GetHeight());
wxRect sliderRect;
GetPanRect(rect, sliderRect);
mPan->Move(wxPoint(sliderRect.x, sliderRect.y));
mPan->Set(t->GetPan());
wxPoint pos = sliderRect.GetPosition();
float pan = t->GetPan();
return mPan;
mPan->Move(pos);
mPan->Set(pan);
mPanCaptured->Move(pos);
mPanCaptured->Set(pan);
return captured ? mPanCaptured : mPan;
}
static TrackPanel * TrackPanelFactory(wxWindow * parent,

View File

@ -90,7 +90,7 @@ private:
#ifdef EXPERIMENTAL_MIDI_OUT
void DrawVelocitySlider(wxDC * dc, NoteTrack *t, wxRect rect) const ;
#endif
void DrawSliders(wxDC * dc, WaveTrack *t, wxRect rect) const;
void DrawSliders(wxDC * dc, WaveTrack *t, wxRect rect, bool captured) const;
// Draw the minimize button *and* the sync-lock track icon, if necessary.
void DrawMinimize(wxDC * dc, const wxRect & rect, Track * t, bool down) const;
@ -105,12 +105,14 @@ private:
void GetSyncLockIconRect(const wxRect & rect, wxRect &dest) const;
public:
LWSlider * GainSlider(WaveTrack *t) const;
LWSlider * PanSlider(WaveTrack *t) const;
LWSlider * GainSlider(WaveTrack *t, bool captured = false) const;
LWSlider * PanSlider(WaveTrack *t, bool captured = false) const;
private:
TrackPanel * pParent;
wxFont mFont;
LWSlider *mGainCaptured;
LWSlider *mPanCaptured;
LWSlider *mGain;
LWSlider *mPan;

View File

@ -493,8 +493,6 @@ void LWSlider::Init(wxWindow * parent,
mStyle = style;
mOrientation = orientation;
mIsDragging = false;
mWidth = size.x;
mHeight = size.y;
mParent = parent;
mHW = heavyweight;
mPopup = popup;
@ -513,6 +511,8 @@ void LWSlider::Init(wxWindow * parent,
mScrollPage = 5.0f;
mTipPanel = NULL;
AdjustSize(size);
mpRuler = NULL; // Do this and Move() before Draw().
Move(pos);
}
@ -577,6 +577,39 @@ void LWSlider::Move(const wxPoint &newpos)
mTop = newpos.y;
}
void LWSlider::AdjustSize(const wxSize & sz)
{
mWidth = sz.GetWidth();
mHeight = sz.GetHeight();
mThumbWidth = 14;
mThumbHeight = 14;
if (mOrientation == wxHORIZONTAL)
{
mCenterY = mHeight - 9;
}
else
{
mCenterX = mWidth - 9;
}
if (mOrientation == wxHORIZONTAL)
{
mLeftX = mThumbWidth/2;
mRightX = mWidth - mThumbWidth/2 - 1;
mWidthX = mRightX - mLeftX;
}
else
{
mTopY = mThumbWidth/2;
mBottomY = mHeight - mThumbWidth/2 - 1;
mHeightY = mBottomY - mTopY;
}
Refresh();
}
void LWSlider::OnPaint(wxDC &dc)
{
if (!mBitmap || !mThumbBitmap)
@ -617,8 +650,7 @@ void LWSlider::OnPaint(wxDC &dc)
void LWSlider::OnSize( wxSizeEvent & event )
{
mWidth = event.GetSize().GetX();
mHeight = event.GetSize().GetY();
AdjustSize(event.GetSize());
Refresh();
}
@ -644,8 +676,6 @@ void LWSlider::Draw(wxDC & paintDC)
wxMemoryDC dc;
// Create the bitmap
mThumbWidth = 14;
mThumbHeight = 14;
mThumbBitmap = new wxBitmap();
mThumbBitmap->Create(mThumbWidth, mThumbHeight, paintDC);
dc.SelectObject(*mThumbBitmap);
@ -711,28 +741,6 @@ void LWSlider::Draw(wxDC & paintDC)
// Now the background bitmap
//
if (mOrientation == wxHORIZONTAL)
{
mCenterY = mHeight - 9;
}
else
{
mCenterX = mWidth - 9;
}
if (mOrientation == wxHORIZONTAL)
{
mLeftX = mThumbWidth/2;
mRightX = mWidth - mThumbWidth/2 - 1;
mWidthX = mRightX - mLeftX;
}
else
{
mTopY = mThumbWidth/2;
mBottomY = mHeight - mThumbWidth/2 - 1;
mHeightY = mBottomY - mTopY;
}
mBitmap = new wxBitmap();
mBitmap->Create(mWidth, mHeight, paintDC);
dc.SelectObject(*mBitmap);

View File

@ -142,6 +142,8 @@ class LWSlider
void Move(const wxPoint &newpos);
void AdjustSize(const wxSize & sz);
void OnPaint(wxDC &dc);
void OnSize(wxSizeEvent & event);
void OnMouseEvent(wxMouseEvent & event);