ToolManager.cpp does not depend on Meter

This commit is contained in:
Paul Licameli 2019-06-15 09:03:30 -04:00
parent b84f5b66f0
commit 0b897c81b0
5 changed files with 20 additions and 20 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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<bool, Resetter>;
public:
static TempAllowFocus TemporarilyAllowFocus();
private:
//
// Event handlers

View File

@ -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 };
}

View File

@ -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<bool, Resetter>;
public:
static TempAllowFocus TemporarilyAllowFocus();
};
#endif