diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index 696c9d0cf..425b82be7 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -60,7 +60,7 @@ #include "../ProjectWindow.h" #include "../widgets/AButton.h" #include "../widgets/ASlider.h" -#include "../widgets/Meter.h" +#include "../widgets/MeterPanelBase.h" #include "../widgets/Grabber.h" //////////////////////////////////////////////////////////// @@ -1527,7 +1527,7 @@ bool ToolManager::RestoreFocus() if (mLastFocus) { auto temp1 = AButton::TemporarilyAllowFocus(); auto temp2 = ASlider::TemporarilyAllowFocus(); - auto temp3 = MeterPanel::TemporarilyAllowFocus(); + auto temp3 = MeterPanelBase::TemporarilyAllowFocus(); mLastFocus->SetFocus(); return true; } diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index 24b6f3336..3f452e596 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -268,7 +268,7 @@ enum { OnPreferencesID }; -BEGIN_EVENT_TABLE(MeterPanel, wxPanelWrapper) +BEGIN_EVENT_TABLE(MeterPanel, MeterPanelBase) EVT_TIMER(OnMeterUpdateID, MeterPanel::OnMeterUpdate) EVT_MOUSE_EVENTS(MeterPanel::OnMouse) EVT_CONTEXT_MENU(MeterPanel::OnContext) @@ -2123,13 +2123,6 @@ wxString MeterPanel::Key(const wxString & key) const return wxT("/Meter/Output/") + key; } -bool MeterPanel::s_AcceptsFocus{ false }; - -auto MeterPanel::TemporarilyAllowFocus() -> TempAllowFocus { - s_AcceptsFocus = true; - return TempAllowFocus{ &s_AcceptsFocus }; -} - // This compensates for a but in wxWidgets 3.0.2 for mac: // Couldn't set focus from keyboard when AcceptsFocus returns false; // this bypasses that limitation diff --git a/src/widgets/Meter.h b/src/widgets/Meter.h index e8dc551cd..c000ac8ce 100644 --- a/src/widgets/Meter.h +++ b/src/widgets/Meter.h @@ -117,9 +117,6 @@ class MeterPanel final : public MeterPanelBase, private PrefsListener Style style = HorizontalStereo, float fDecayRate = 60.0f); - bool AcceptsFocus() const override { return s_AcceptsFocus; } - bool AcceptsFocusFromKeyboard() const override { return true; } - void SetFocusFromKbd() override; void Clear() override; @@ -192,13 +189,6 @@ class MeterPanel final : public MeterPanelBase, private PrefsListener void UpdatePrefs() override; void UpdateSelectedPrefs( int ) override; - static bool s_AcceptsFocus; - struct Resetter { void operator () (bool *p) const { if(p) *p = false; } }; - using TempAllowFocus = std::unique_ptr; - - public: - static TempAllowFocus TemporarilyAllowFocus(); - private: // // Event handlers diff --git a/src/widgets/MeterPanelBase.cpp b/src/widgets/MeterPanelBase.cpp index 46eb81897..f85e13acf 100644 --- a/src/widgets/MeterPanelBase.cpp +++ b/src/widgets/MeterPanelBase.cpp @@ -13,3 +13,10 @@ Paul Licameli split from Meter.cpp MeterPanelBase::~MeterPanelBase() { } + +bool MeterPanelBase::s_AcceptsFocus{ false }; + +auto MeterPanelBase::TemporarilyAllowFocus() -> TempAllowFocus { + s_AcceptsFocus = true; + return TempAllowFocus{ &s_AcceptsFocus }; +} diff --git a/src/widgets/MeterPanelBase.h b/src/widgets/MeterPanelBase.h index c2b459f3e..5cdee6728 100644 --- a/src/widgets/MeterPanelBase.h +++ b/src/widgets/MeterPanelBase.h @@ -26,7 +26,17 @@ public: int numFrames, float *sampleData) = 0; virtual bool IsMeterDisabled() const = 0; virtual float GetMaxPeak() const = 0; + + bool AcceptsFocus() const override { return s_AcceptsFocus; } + bool AcceptsFocusFromKeyboard() const override { return true; } + private: + static bool s_AcceptsFocus; + struct Resetter { void operator () (bool *p) const { if(p) *p = false; } }; + using TempAllowFocus = std::unique_ptr; + +public: + static TempAllowFocus TemporarilyAllowFocus(); }; #endif