From da6eacbde26722644487d932339f5afd73ad3992 Mon Sep 17 00:00:00 2001 From: apoorv569 Date: Fri, 14 May 2021 14:16:42 +0530 Subject: [PATCH] Moved the keybind support to a separate branch. --- src/App.cpp | 163 ---------------------------------------------------- src/App.hpp | 4 -- 2 files changed, 167 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index 9bb7378..c6dbb79 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -1,14 +1,8 @@ #include "App.hpp" -#include "ControlID_Enums.hpp" #include #include -#include #include -#include -#include -#include -#include #include wxIMPLEMENT_APP(App); @@ -46,160 +40,3 @@ bool App::OnInit() m_Frame->Show(true); return true; } - -int App::FilterEvent(wxEvent& event) -{ - if(event.GetEventType() == wxEVT_KEY_DOWN) - { - wxWindow* focusedWindow = wxWindow::FindFocus(); - if(focusedWindow != NULL) - { - const wxString& className = focusedWindow->GetClassInfo()->GetClassName(); - - wxLogDebug("Focused window: %s", className); - - // if SearchCtrl or TreeCtrl has focus, let all keys through - if(className == wxT("wxSearchCtrl")) - { - wxLogDebug("SearchCtrl focused skipping key filtering"); - return wxEventFilter::Event_Skip; - } - else if(className == wxT("wxTreeCtrl")) - { - wxLogDebug("TreeCtrl focused skipping key filtering"); - return wxEventFilter::Event_Skip; - } - } - - wxKeyEvent* keyEvent = wxDynamicCast(&event, wxKeyEvent); - - if(keyEvent != NULL) - { - switch (keyEvent->GetKeyCode()) - { - case WXK_SPACE: - { - wxCommandEvent playEvent(wxEVT_BUTTON); - - playEvent.SetId(BC_Play); - playEvent.SetEventObject(m_Frame->m_PlayButton); - - m_Frame->OnClickPlay(playEvent); - - wxLogDebug("Space pressed"); - - return wxEventFilter::Event_Processed; - - break; - } - case 'A': - { - wxCommandEvent autoplayEvent(wxEVT_CHECKBOX); - autoplayEvent.SetId(BC_Autoplay); - - autoplayEvent.SetEventObject(m_Frame->m_AutoPlayCheck); - - if (m_Frame->m_AutoPlayCheck->GetValue()) - m_Frame->m_AutoPlayCheck->SetValue(false); - else - m_Frame->m_AutoPlayCheck->SetValue(true); - - m_Frame->OnCheckAutoplay(autoplayEvent); - - wxLogDebug("A pressed"); - - return wxEventFilter::Event_Processed; - - break; - } - case 'L': - { - wxCommandEvent loopEvent(wxEVT_TOGGLEBUTTON); - - loopEvent.SetId(BC_Loop); - loopEvent.SetEventObject(m_Frame->m_LoopButton); - - if (m_Frame->m_LoopButton->GetValue()) - m_Frame->m_LoopButton->SetValue(false); - else - m_Frame->m_LoopButton->SetValue(true); - - m_Frame->OnClickLoop(loopEvent); - - wxLogDebug("L pressed"); - - return wxEventFilter::Event_Processed; - - break; - } - case 'M': - { - wxCommandEvent muteEvent(wxEVT_TOGGLEBUTTON); - - muteEvent.SetId(BC_Mute); - muteEvent.SetEventObject(m_Frame->m_MuteButton); - - if (m_Frame->m_MuteButton->GetValue()) - m_Frame->m_MuteButton->SetValue(false); - else - m_Frame->m_MuteButton->SetValue(true); - - m_Frame->OnClickMute(muteEvent); - - wxLogDebug("M pressed"); - - return wxEventFilter::Event_Processed; - - break; - } - case 'O': - { - wxCommandEvent settingsEvent(wxEVT_BUTTON); - - settingsEvent.SetId(BC_Settings); - settingsEvent.SetEventObject(m_Frame->m_SettingsButton); - - m_Frame->OnClickSettings(settingsEvent); - - wxLogDebug("O pressed"); - - return wxEventFilter::Event_Processed; - - break; - } - case 'P': - { - wxCommandEvent playEvent(wxEVT_BUTTON); - - playEvent.SetId(BC_Play); - playEvent.SetEventObject(m_Frame->m_PlayButton); - - m_Frame->OnClickPlay(playEvent); - - wxLogDebug("P pressed"); - - return wxEventFilter::Event_Processed; - - break; - } - case 'S': - { - wxCommandEvent stopEvent(wxEVT_BUTTON); - - stopEvent.SetId(BC_Stop); - stopEvent.SetEventObject(m_Frame->m_StopButton); - - m_Frame->OnClickStop(stopEvent); - - wxLogDebug("S pressed"); - - return wxEventFilter::Event_Processed; - - break; - } - } - } - } - - return -1; -} diff --git a/src/App.hpp b/src/App.hpp index 5f3eaf4..c8d70f9 100644 --- a/src/App.hpp +++ b/src/App.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include "MainFrame.hpp" @@ -16,7 +15,4 @@ class App : public wxApp private: virtual bool OnInit(); - - private: - int FilterEvent(wxEvent& event); };