mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-08 08:01:19 +02:00
Fixes disappearing focus as reported by David and cleans things up a bit.
This commit is contained in:
parent
1e0d040cfb
commit
31081470cf
@ -149,9 +149,6 @@ class EffectUIHostInterface
|
||||
{
|
||||
public:
|
||||
virtual ~EffectUIHostInterface() {};
|
||||
|
||||
// virtual wxScrolledWindow *GetScrollableClientArea();
|
||||
// virtual wxScrolledWindow *GetStaticClientArea();
|
||||
};
|
||||
|
||||
class EffectUIClientInterface
|
||||
|
@ -1905,6 +1905,52 @@ void EffectDialog::OnPreview(wxCommandEvent & WXUNUSED(event))
|
||||
return;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// EffectPanel
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EffectPanel : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
EffectPanel(wxWindow *parent)
|
||||
: wxScrolledWindow(parent,
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxVSCROLL | wxTAB_TRAVERSAL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~EffectPanel()
|
||||
{
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxWindow implementation
|
||||
// ============================================================================
|
||||
|
||||
virtual bool AcceptsFocus() const
|
||||
{
|
||||
// Only accept focus if we're not a GUI host.
|
||||
//
|
||||
// This assumes that any effect will have more than one control in its
|
||||
// interface unless it is a GUI interface. It's a fairly safe assumption.
|
||||
#if defined(__WXMAC__)
|
||||
return GetChildren().GetCount() > 2;
|
||||
#else
|
||||
return GetChildren().GetCount() > 1;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// EffectUIHost
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
enum
|
||||
{
|
||||
kSaveAsID = 30001,
|
||||
@ -1919,7 +1965,6 @@ enum
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(EffectUIHost, wxDialog)
|
||||
// EVT_WINDOW_DESTROY(EffectUIHost::OnDestroy)
|
||||
EVT_CLOSE(EffectUIHost::OnClose)
|
||||
EVT_BUTTON(wxID_OK, EffectUIHost::OnOk)
|
||||
EVT_BUTTON(wxID_CANCEL, EffectUIHost::OnCancel)
|
||||
@ -1958,15 +2003,15 @@ EffectUIHost::~EffectUIHost()
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// EffectUIHost implementation
|
||||
// ============================================================================
|
||||
|
||||
bool EffectUIHost::Initialize()
|
||||
{
|
||||
wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxScrolledWindow *w = new wxScrolledWindow(this,
|
||||
wxID_ANY,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
wxVSCROLL | wxTAB_TRAVERSAL);
|
||||
EffectPanel *w = new EffectPanel(this);
|
||||
|
||||
// Try to give the window a sensible default/minimum size
|
||||
w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2/3),
|
||||
@ -1989,6 +2034,12 @@ bool EffectUIHost::Initialize()
|
||||
Fit();
|
||||
Center();
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
(w->GetChildren().GetCount() > 2 ? w : FindWindowById(wxID_OK))->SetFocus();
|
||||
#else
|
||||
(w->GetChildren().GetCount() > 1 ? w : FindWindowById(wxID_OK))->SetFocus();
|
||||
#endif
|
||||
|
||||
LoadUserPresets();
|
||||
|
||||
mClient->LoadUserPreset(mHost->GetCurrentSettingsGroup());
|
||||
@ -1996,13 +2047,10 @@ bool EffectUIHost::Initialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void EffectUIHost::OnDestroy(wxWindowDestroyEvent & WXUNUSED(evt))
|
||||
{
|
||||
mClient->CloseUI();
|
||||
}
|
||||
|
||||
void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt))
|
||||
{
|
||||
Hide();
|
||||
|
||||
mClient->CloseUI();
|
||||
mClient = NULL;
|
||||
|
||||
@ -2037,6 +2085,8 @@ void EffectUIHost::OnOk(wxCommandEvent & WXUNUSED(evt))
|
||||
return;
|
||||
}
|
||||
|
||||
Hide();
|
||||
|
||||
Close();
|
||||
|
||||
return;
|
||||
@ -2050,6 +2100,8 @@ void EffectUIHost::OnCancel(wxCommandEvent & WXUNUSED(evt))
|
||||
return;
|
||||
}
|
||||
|
||||
Hide();
|
||||
|
||||
Close();
|
||||
|
||||
return;
|
||||
|
@ -485,7 +485,6 @@ public:
|
||||
bool Initialize();
|
||||
|
||||
private:
|
||||
void OnDestroy(wxWindowDestroyEvent & evt);
|
||||
void OnClose(wxCloseEvent & evt);
|
||||
void OnOk(wxCommandEvent & evt);
|
||||
void OnCancel(wxCommandEvent & evt);
|
||||
|
@ -819,11 +819,6 @@ void VSTEffectEventHelper::OnSlider(wxCommandEvent & evt)
|
||||
mEffect->OnSlider(evt);
|
||||
}
|
||||
|
||||
void VSTEffectEventHelper::ControlSetFocus(wxFocusEvent & evt)
|
||||
{
|
||||
mEffect->ControlSetFocus(evt);
|
||||
}
|
||||
|
||||
void VSTEffectEventHelper::OnSizeWindow(wxCommandEvent & evt)
|
||||
{
|
||||
mEffect->OnSizeWindow(evt);
|
||||
@ -2070,7 +2065,6 @@ bool VSTEffect::PopulateUI(wxWindow *parent)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// Determine if the VST editor is supposed to be used or not
|
||||
mHost->GetSharedConfig(wxT("Settings"),
|
||||
wxT("UseGUI"),
|
||||
@ -3114,6 +3108,7 @@ void VSTEffect::BuildFancy()
|
||||
|
||||
#elif defined(__WXMSW__)
|
||||
|
||||
// Use a panel to host the plugins GUI
|
||||
wxPanel *w = new wxPanel(mParent, wxID_ANY);
|
||||
mHwnd = w->GetHWND();
|
||||
callDispatcher(effEditOpen, 0, 0, mHwnd, 0.0);
|
||||
@ -3121,9 +3116,9 @@ void VSTEffect::BuildFancy()
|
||||
#else
|
||||
|
||||
// Use a panel to host the plugins GUI
|
||||
wxPanel *w = new wxPanel(mParent);
|
||||
wxPanel *w = new wxPanel(mParent, wxID_ANY);
|
||||
|
||||
// Make sure is has a window
|
||||
// Make sure the parent has a window
|
||||
if (!GTK_WIDGET(w->m_wxwindow)->window)
|
||||
{
|
||||
gtk_widget_realize(GTK_WIDGET(w->m_wxwindow));
|
||||
@ -3218,7 +3213,6 @@ void VSTEffect::BuildPlain()
|
||||
gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||
gridSizer->Add(1, 1, 0);
|
||||
gridSizer->Add(1, 1, 0);
|
||||
ConnectFocus(mDuration);
|
||||
}
|
||||
|
||||
// Find the longest parameter name.
|
||||
@ -3362,48 +3356,6 @@ void VSTEffect::OnSlider(wxCommandEvent & evt)
|
||||
RefreshParameters(i);
|
||||
}
|
||||
|
||||
void VSTEffect::ConnectFocus(wxControl *c)
|
||||
{
|
||||
c->GetEventHandler()->Connect(wxEVT_SET_FOCUS,
|
||||
wxFocusEventHandler(VSTEffectEventHelper::ControlSetFocus));
|
||||
}
|
||||
|
||||
void VSTEffect::DisconnectFocus(wxControl *c)
|
||||
{
|
||||
c->GetEventHandler()->Disconnect(wxEVT_SET_FOCUS,
|
||||
wxFocusEventHandler(VSTEffectEventHelper::ControlSetFocus));
|
||||
}
|
||||
|
||||
void VSTEffect::ControlSetFocus(wxFocusEvent & evt)
|
||||
{
|
||||
wxControl *c = (wxControl *) evt.GetEventObject();
|
||||
wxScrolledWindow *p = (wxScrolledWindow *) c->GetParent();
|
||||
wxRect r = c->GetRect();
|
||||
wxRect rv = p->GetRect();
|
||||
rv.y = 0;
|
||||
|
||||
evt.Skip();
|
||||
|
||||
int y;
|
||||
int yppu;
|
||||
p->GetScrollPixelsPerUnit(NULL, &yppu);
|
||||
|
||||
if (r.y >= rv.y && r.GetBottom() <= rv.GetBottom()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (r.y < rv.y) {
|
||||
p->CalcUnscrolledPosition(0, r.y, NULL, &r.y);
|
||||
y = r.y / yppu;
|
||||
}
|
||||
else {
|
||||
p->CalcUnscrolledPosition(0, r.y, NULL, &r.y);
|
||||
y = (r.GetBottom() - rv.GetBottom() + yppu) / yppu;
|
||||
}
|
||||
|
||||
p->Scroll(-1, y);
|
||||
};
|
||||
|
||||
bool VSTEffect::LoadFXB(const wxFileName & fn)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -178,10 +178,6 @@ private:
|
||||
|
||||
// UI
|
||||
void OnSlider(wxCommandEvent & evt);
|
||||
void ConnectFocus(wxControl *c);
|
||||
void DisconnectFocus(wxControl *c);
|
||||
void ControlSetFocus(wxFocusEvent & evt);
|
||||
|
||||
void OnSizeWindow(wxCommandEvent & evt);
|
||||
void OnUpdateDisplay(wxCommandEvent & evt);
|
||||
|
||||
|
@ -415,11 +415,6 @@ void LadspaEffectEventHelper::OnTextCtrl(wxCommandEvent & evt)
|
||||
mEffect->OnTextCtrl(evt);
|
||||
}
|
||||
|
||||
void LadspaEffectEventHelper::ControlSetFocus(wxFocusEvent & evt)
|
||||
{
|
||||
mEffect->ControlSetFocus(evt);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LadspaEffect
|
||||
@ -1054,7 +1049,6 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
||||
gridSizer->Add(1, 1, 0);
|
||||
gridSizer->Add(1, 1, 0);
|
||||
gridSizer->Add(1, 1, 0);
|
||||
ConnectFocus(mDuration);
|
||||
}
|
||||
|
||||
for (unsigned long p = 0; p < mData->PortCount; p++)
|
||||
@ -1078,7 +1072,6 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
||||
mToggles[p]->SetName(labelText);
|
||||
mToggles[p]->SetValue(mInputControls[p] > 0);
|
||||
gridSizer->Add(mToggles[p], 0, wxALL, 5);
|
||||
ConnectFocus(mToggles[p]);
|
||||
|
||||
gridSizer->Add(1, 1, 0);
|
||||
gridSizer->Add(1, 1, 0);
|
||||
@ -1118,7 +1111,6 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
||||
mFields[p] = new wxTextCtrl(mParent, ID_TEXTS + p);
|
||||
mFields[p]->SetName(labelText);
|
||||
gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||
ConnectFocus(mFields[p]);
|
||||
|
||||
wxString str;
|
||||
if (haslo)
|
||||
@ -1145,7 +1137,6 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
||||
wxSize(200, -1));
|
||||
mSliders[p]->SetName(labelText);
|
||||
gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
|
||||
ConnectFocus(mSliders[p]);
|
||||
|
||||
if (hashi)
|
||||
{
|
||||
@ -1240,7 +1231,6 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
||||
wxTE_READONLY);
|
||||
mFields[p]->SetName(labelText);
|
||||
gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||
ConnectFocus(mFields[p]);
|
||||
}
|
||||
|
||||
paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5);
|
||||
@ -1600,45 +1590,3 @@ void LadspaEffect::RefreshControls(bool outputOnly)
|
||||
mFields[p]->SetValue(fieldText);
|
||||
}
|
||||
}
|
||||
|
||||
void LadspaEffect::ConnectFocus(wxControl *c)
|
||||
{
|
||||
c->GetEventHandler()->Connect(wxEVT_SET_FOCUS,
|
||||
wxFocusEventHandler(LadspaEffectEventHelper::ControlSetFocus));
|
||||
}
|
||||
|
||||
void LadspaEffect::DisconnectFocus(wxControl *c)
|
||||
{
|
||||
c->GetEventHandler()->Disconnect(wxEVT_SET_FOCUS,
|
||||
wxFocusEventHandler(LadspaEffectEventHelper::ControlSetFocus));
|
||||
}
|
||||
|
||||
void LadspaEffect::ControlSetFocus(wxFocusEvent & evt)
|
||||
{
|
||||
wxControl *c = (wxControl *) evt.GetEventObject();
|
||||
wxScrolledWindow *p = (wxScrolledWindow *) c->GetParent();
|
||||
wxRect r = c->GetRect();
|
||||
wxRect rv = p->GetRect();
|
||||
rv.y = 0;
|
||||
|
||||
evt.Skip();
|
||||
|
||||
int y;
|
||||
int yppu;
|
||||
p->GetScrollPixelsPerUnit(NULL, &yppu);
|
||||
|
||||
if (r.y >= rv.y && r.GetBottom() <= rv.GetBottom()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (r.y < rv.y) {
|
||||
p->CalcUnscrolledPosition(0, r.y, NULL, &r.y);
|
||||
y = r.y / yppu;
|
||||
}
|
||||
else {
|
||||
p->CalcUnscrolledPosition(0, r.y, NULL, &r.y);
|
||||
y = (r.GetBottom() - rv.GetBottom() + yppu) / yppu;
|
||||
}
|
||||
|
||||
p->Scroll(-1, y);
|
||||
};
|
||||
|
@ -134,9 +134,6 @@ private:
|
||||
void OnSlider(wxCommandEvent & evt);
|
||||
void OnTextCtrl(wxCommandEvent & evt);
|
||||
void RefreshControls(bool outputOnly = false);
|
||||
void ConnectFocus(wxControl *c);
|
||||
void DisconnectFocus(wxControl *c);
|
||||
void ControlSetFocus(wxFocusEvent & evt);
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user