mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-16 22:37:01 +00:00
UI+build: Isolate wxWidgets code from non-GUI code (#1633)
This commit is contained in:
parent
5f3c2816ec
commit
67de63bed6
199 changed files with 2414 additions and 2091 deletions
86
src/gui/wxgui/LoggingWindow.cpp
Normal file
86
src/gui/wxgui/LoggingWindow.cpp
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#include "wxgui/LoggingWindow.h"
|
||||
|
||||
#include "Cemu/Logging/CemuLogging.h"
|
||||
#include "wxgui/helpers/wxLogEvent.h"
|
||||
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
wxDEFINE_EVENT(EVT_LOG, wxLogEvent);
|
||||
|
||||
LoggingWindow::LoggingWindow(wxFrame* parent)
|
||||
: wxFrame(parent, wxID_ANY, _("Logging window"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL)
|
||||
{
|
||||
auto* sizer = new wxBoxSizer( wxVERTICAL );
|
||||
{
|
||||
auto filter_row = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
filter_row->Add(new wxStaticText( this, wxID_ANY, _("Filter")), 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
wxString choices[] = {"Unsupported APIs calls", "Coreinit Logging", "Coreinit File-Access", "Coreinit Thread-Synchronization", "Coreinit Memory", "Coreinit MP", "Coreinit Thread", "nn::nfp", "GX2", "Audio", "Input", "Socket", "Save", "H264", "Graphic pack patches", "Texture cache", "Texture readback", "OpenGL debug output", "Vulkan validation layer"};
|
||||
m_filter = new wxComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, std::size(choices), choices, 0 );
|
||||
m_filter->Bind(wxEVT_COMBOBOX, &LoggingWindow::OnFilterChange, this);
|
||||
m_filter->Bind(wxEVT_TEXT, &LoggingWindow::OnFilterChange, this);
|
||||
filter_row->Add(m_filter, 1, wxALL, 5 );
|
||||
|
||||
m_filter_message = new wxCheckBox(this, wxID_ANY, _("Filter messages"));
|
||||
m_filter_message->Bind(wxEVT_CHECKBOX, &LoggingWindow::OnFilterMessageChange, this);
|
||||
filter_row->Add(m_filter_message, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
sizer->Add( filter_row, 0, wxEXPAND, 5 );
|
||||
}
|
||||
|
||||
m_log_list = new wxLogCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxScrolledWindowStyle|wxVSCROLL);//( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
|
||||
sizer->Add( m_log_list, 1, wxALL | wxEXPAND, 5 );
|
||||
|
||||
this->SetSizer( sizer );
|
||||
this->Layout();
|
||||
|
||||
this->Bind(EVT_LOG, &LoggingWindow::OnLogMessage, this);
|
||||
|
||||
cemuLog_setCallbacks(this);
|
||||
}
|
||||
|
||||
LoggingWindow::~LoggingWindow()
|
||||
{
|
||||
this->Unbind(EVT_LOG, &LoggingWindow::OnLogMessage, this);
|
||||
|
||||
cemuLog_clearCallbacks();
|
||||
}
|
||||
|
||||
void LoggingWindow::Log(std::string_view filter, std::string_view message)
|
||||
{
|
||||
wxLogEvent event(std::string {filter}, std::string{ message });
|
||||
OnLogMessage(event);
|
||||
|
||||
//const auto log_event = new wxLogEvent(filter, message);
|
||||
//wxQueueEvent(s_instance, log_event);
|
||||
}
|
||||
|
||||
void LoggingWindow::Log(std::string_view filter, std::wstring_view message)
|
||||
{
|
||||
wxLogEvent event(std::string {filter}, std::wstring{ message });
|
||||
OnLogMessage(event);
|
||||
|
||||
//const auto log_event = new wxLogEvent(filter, message);
|
||||
//wxQueueEvent(s_instance, log_event);
|
||||
}
|
||||
|
||||
void LoggingWindow::OnLogMessage(wxLogEvent& event)
|
||||
{
|
||||
m_log_list->PushEntry(event.GetFilter(), event.GetMessage());
|
||||
}
|
||||
|
||||
void LoggingWindow::OnFilterChange(wxCommandEvent& event)
|
||||
{
|
||||
m_log_list->SetActiveFilter(m_filter->GetValue().utf8_string());
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void LoggingWindow::OnFilterMessageChange(wxCommandEvent& event)
|
||||
{
|
||||
m_log_list->SetFilterMessage(m_filter_message->GetValue());
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue