Merge pull request #4589 from ligfx/cleaninputconfigdiag

InputConfigDiag: move function bodies out of header
This commit is contained in:
Mat M 2017-01-05 14:29:35 -05:00 committed by GitHub
commit 6fe621f203
2 changed files with 48 additions and 21 deletions

View File

@ -104,6 +104,11 @@ void InputConfigDialog::ConfigExtension(wxCommandEvent& event)
} }
} }
PadSetting::PadSetting(wxControl* const _control) : wxcontrol(_control)
{
wxcontrol->SetClientData(this);
}
PadSettingExtension::PadSettingExtension(wxWindow* const parent, PadSettingExtension::PadSettingExtension(wxWindow* const parent,
ControllerEmu::Extension* const ext) ControllerEmu::Extension* const ext)
: PadSetting(new wxChoice(parent, wxID_ANY)), extension(ext) : PadSetting(new wxChoice(parent, wxID_ANY)), extension(ext)
@ -210,6 +215,11 @@ ControlDialog::ControlDialog(InputConfigDialog* const parent, InputConfig& confi
SetFocus(); SetFocus();
} }
ExtensionButton::ExtensionButton(wxWindow* const parent, ControllerEmu::Extension* const ext)
: wxButton(parent, wxID_ANY, _("Configure"), wxDefaultPosition), extension(ext)
{
}
ControlButton::ControlButton(wxWindow* const parent, ControlButton::ControlButton(wxWindow* const parent,
ControllerInterface::ControlReference* const _ref, ControllerInterface::ControlReference* const _ref,
const std::string& name, const unsigned int width, const std::string& name, const unsigned int width,
@ -918,6 +928,12 @@ ControlGroupBox::~ControlGroupBox()
delete padSetting; delete padSetting;
} }
bool ControlGroupBox::HasBitmapHeading() const
{
return control_group->type == GROUP_TYPE_STICK || control_group->type == GROUP_TYPE_TILT ||
control_group->type == GROUP_TYPE_CURSOR || control_group->type == GROUP_TYPE_FORCE;
}
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent,
InputConfigDialog* eventsink) InputConfigDialog* eventsink)
: wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->ui_name))), : wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->ui_name))),
@ -1238,6 +1254,16 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config
m_update_timer.Start(PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS); m_update_timer.Start(PREVIEW_UPDATE_TIME, wxTIMER_CONTINUOUS);
} }
InputEventFilter::InputEventFilter()
{
wxEvtHandler::AddFilter(this);
}
InputEventFilter::~InputEventFilter()
{
wxEvtHandler::RemoveFilter(this);
}
int InputEventFilter::FilterEvent(wxEvent& event) int InputEventFilter::FilterEvent(wxEvent& event)
{ {
if (m_block && ShouldCatchEventType(event.GetEventType())) if (m_block && ShouldCatchEventType(event.GetEventType()))
@ -1248,3 +1274,16 @@ int InputEventFilter::FilterEvent(wxEvent& event)
return Event_Skip; return Event_Skip;
} }
void InputEventFilter::BlockEvents(bool block)
{
m_block = block;
}
bool InputEventFilter::ShouldCatchEventType(wxEventType type)
{
return type == wxEVT_KEY_DOWN || type == wxEVT_KEY_UP || type == wxEVT_CHAR ||
type == wxEVT_CHAR_HOOK || type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP ||
type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_DOWN ||
type == wxEVT_RIGHT_UP;
}

View File

@ -38,7 +38,8 @@ class wxTextCtrl;
class PadSetting class PadSetting
{ {
protected: protected:
PadSetting(wxControl* const _control) : wxcontrol(_control) { wxcontrol->SetClientData(this); } PadSetting(wxControl* const _control);
public: public:
virtual void UpdateGUI() = 0; virtual void UpdateGUI() = 0;
virtual void UpdateValue() = 0; virtual void UpdateValue() = 0;
@ -82,19 +83,14 @@ public:
class InputEventFilter : public wxEventFilter class InputEventFilter : public wxEventFilter
{ {
public: public:
InputEventFilter() { wxEvtHandler::AddFilter(this); } InputEventFilter();
~InputEventFilter() { wxEvtHandler::RemoveFilter(this); } ~InputEventFilter();
int FilterEvent(wxEvent& event) override; int FilterEvent(wxEvent& event) override;
void BlockEvents(bool block) { m_block = block; } void BlockEvents(bool block);
private: private:
static bool ShouldCatchEventType(wxEventType type) static bool ShouldCatchEventType(wxEventType type);
{
return type == wxEVT_KEY_DOWN || type == wxEVT_KEY_UP || type == wxEVT_CHAR ||
type == wxEVT_CHAR_HOOK || type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP ||
type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_DOWN ||
type == wxEVT_RIGHT_UP;
}
bool m_block = false; bool m_block = false;
}; };
@ -148,11 +144,7 @@ private:
class ExtensionButton : public wxButton class ExtensionButton : public wxButton
{ {
public: public:
ExtensionButton(wxWindow* const parent, ControllerEmu::Extension* const ext) ExtensionButton(wxWindow* const parent, ControllerEmu::Extension* const ext);
: wxButton(parent, wxID_ANY, _("Configure"), wxDefaultPosition), extension(ext)
{
}
ControllerEmu::Extension* const extension; ControllerEmu::Extension* const extension;
}; };
@ -178,11 +170,7 @@ public:
InputConfigDialog* eventsink); InputConfigDialog* eventsink);
~ControlGroupBox(); ~ControlGroupBox();
bool HasBitmapHeading() const bool HasBitmapHeading() const;
{
return control_group->type == GROUP_TYPE_STICK || control_group->type == GROUP_TYPE_TILT ||
control_group->type == GROUP_TYPE_CURSOR || control_group->type == GROUP_TYPE_FORCE;
}
std::vector<PadSetting*> options; std::vector<PadSetting*> options;