diff --git a/lib-src/FileDialog/win/FileDialogPrivate.cpp b/lib-src/FileDialog/win/FileDialogPrivate.cpp index 295dcb386..f26016fd3 100644 --- a/lib-src/FileDialog/win/FileDialogPrivate.cpp +++ b/lib-src/FileDialog/win/FileDialogPrivate.cpp @@ -1175,7 +1175,7 @@ void FileDialog::Disabler::Exit(wxDialog *dialog) if (mModalCount == 0) { ::EnableWindow(mHwnd, TRUE); - ::SetWindowPos(mHwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + ::SetWindowPos(mHwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } } } diff --git a/src/Project.cpp b/src/Project.cpp index f4b7f089b..e4177350c 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -555,21 +555,32 @@ void GetDefaultWindowRect(wxRect *defRect) { *defRect = wxGetClientDisplayRect(); - defRect->width = 940; - defRect->height = 674; + int width = 940; + int height = 674; //These conditional values assist in improving placement and size //of new windows on different platforms. #ifdef __WXGTK__ - defRect->height += 20; + height += 20; #endif #ifdef __WXMSW__ - defRect->height += 40; + height += 40; #endif + #ifdef __WXMAC__ - defRect->height += 55; + height += 55; #endif + + if (width < defRect->width) + { + defRect->width = width; + } + + if (height < defRect->height) + { + defRect->height = height; + } } bool IsWindowAccessible(wxRect *requestedRect) @@ -639,6 +650,20 @@ void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized) } #endif + // Make sure initial sizes fit within the display bounds + if (normalRect.GetRight() > defaultRect.GetRight()) { + normalRect.SetRight(defaultRect.GetRight()); + } + if (normalRect.GetBottom() > defaultRect.GetBottom()) { + normalRect.SetBottom(defaultRect.GetBottom()); + } + if (windowRect.GetRight() > defaultRect.GetRight()) { + windowRect.SetRight(defaultRect.GetRight()); + } + if (windowRect.GetBottom() > defaultRect.GetBottom()) { + windowRect.SetBottom(defaultRect.GetBottom()); + } + if (gAudacityProjects.IsEmpty()) { if (*pMaximized || *pIconized) { *nextRect = normalRect; diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index e07469ce0..55db864ad 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -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, diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 7244a4b55..55a35106f 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -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; diff --git a/src/toolbars/ToolBar.h b/src/toolbars/ToolBar.h index e88b6ace7..51df2f0c7 100644 --- a/src/toolbars/ToolBar.h +++ b/src/toolbars/ToolBar.h @@ -87,6 +87,8 @@ class ToolBar:public wxPanel ToolBar(int type, const wxString & label, const wxString & section, bool resizable = false); virtual ~ToolBar(); + virtual bool AcceptsFocus() const { return false; }; + virtual void Create(wxWindow *parent); virtual void EnableDisableButtons() = 0; virtual void ReCreateButtons(); diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h index d0146e25a..44e60acca 100644 --- a/src/toolbars/ToolDock.h +++ b/src/toolbars/ToolDock.h @@ -53,6 +53,8 @@ class ToolDock:public wxPanel ToolDock( ToolManager *manager, wxWindow *parent, int dockid ); ~ToolDock(); + virtual bool AcceptsFocus() const { return false; }; + void LayoutToolBars(); void Expose( int type, bool show ); int GetOrder( ToolBar *bar ); diff --git a/src/widgets/AButton.h b/src/widgets/AButton.h index d498edb6b..026f700c7 100644 --- a/src/widgets/AButton.h +++ b/src/widgets/AButton.h @@ -56,6 +56,9 @@ class AButton: public wxWindow { virtual ~ AButton(); + virtual bool AcceptsFocus() const { return false; }; + virtual bool AcceptsFocusFromKeyboard() const { return true; }; + // Associate a set of four images (button up, highlight, button down, // disabled) with one nondefault state of the button virtual void SetAlternateImages(unsigned idx, diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index 9fddf9d4e..53c775437 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -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); diff --git a/src/widgets/ASlider.h b/src/widgets/ASlider.h index 7544fd4c1..d56cb217c 100644 --- a/src/widgets/ASlider.h +++ b/src/widgets/ASlider.h @@ -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); diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index 1bfb1743b..1cff7090f 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -414,8 +414,11 @@ void Meter::OnErase(wxEraseEvent & WXUNUSED(event)) void Meter::OnPaint(wxPaintEvent & WXUNUSED(event)) { -// wxDC *paintDC = wxAutoBufferedPaintDCFactory(this); +#if defined(__WXMAC__) wxPaintDC *paintDC = new wxPaintDC(this); +#else + wxDC *paintDC = wxAutoBufferedPaintDCFactory(this); +#endif wxDC & destDC = *paintDC; if (mLayoutValid == false) diff --git a/src/widgets/Meter.h b/src/widgets/Meter.h index 55bfd7fa2..c5d3a442b 100644 --- a/src/widgets/Meter.h +++ b/src/widgets/Meter.h @@ -113,6 +113,9 @@ class Meter : public wxPanel ~Meter(); + virtual bool AcceptsFocus() const { return false; }; + virtual bool AcceptsFocusFromKeyboard() const { return true; }; + void UpdatePrefs(); void Clear(); diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index 54bc3a98d..a0bf1dbbc 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -282,6 +282,8 @@ public: ~AdornedRulerPanel(); + virtual bool AcceptsFocus() const { return false; }; + public: static int GetRulerHeight() { return 28; } void SetLeftOffset(int offset);