mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-16 13:36:59 +00:00
UI: fix dark mode in logging window
This commit is contained in:
parent
ba9c19e802
commit
1f688f4e7f
3 changed files with 26 additions and 10 deletions
|
|
@ -12,7 +12,7 @@ wxDEFINE_EVENT(EVT_LOG, wxLogEvent);
|
||||||
LoggingWindow::LoggingWindow(wxFrame* parent)
|
LoggingWindow::LoggingWindow(wxFrame* parent)
|
||||||
: wxFrame(parent, wxID_ANY, _("Logging window"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL)
|
: wxFrame(parent, wxID_ANY, _("Logging window"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL)
|
||||||
{
|
{
|
||||||
auto* sizer = new wxBoxSizer( wxVERTICAL );
|
auto* sizer = new wxBoxSizer( wxVERTICAL );
|
||||||
{
|
{
|
||||||
auto filter_row = new wxBoxSizer( wxHORIZONTAL );
|
auto filter_row = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ LoggingWindow::LoggingWindow(wxFrame* parent)
|
||||||
sizer->Add( filter_row, 0, wxEXPAND, 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 );
|
m_log_list = new wxLogCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxScrolledWindowStyle|wxVSCROLL, true);//( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
|
||||||
sizer->Add( m_log_list, 1, wxALL | wxEXPAND, 5 );
|
sizer->Add( m_log_list, 1, wxALL | wxEXPAND, 5 );
|
||||||
|
|
||||||
this->SetSizer( sizer );
|
this->SetSizer( sizer );
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,15 @@
|
||||||
|
|
||||||
wxDEFINE_EVENT(EVT_ON_LIST_UPDATED, wxEvent);
|
wxDEFINE_EVENT(EVT_ON_LIST_UPDATED, wxEvent);
|
||||||
|
|
||||||
wxLogCtrl::wxLogCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
wxLogCtrl::wxLogCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, bool alternateRowColours)
|
||||||
: TextList(parent, id, pos, size, style)
|
: TextList(parent, id, pos, size, style)
|
||||||
{
|
{
|
||||||
m_timer = new wxTimer(this);
|
m_timer = new wxTimer(this);
|
||||||
this->Bind(wxEVT_TIMER, &wxLogCtrl::OnTimer, this);
|
this->Bind(wxEVT_TIMER, &wxLogCtrl::OnTimer, this);
|
||||||
this->Bind(EVT_ON_LIST_UPDATED, &wxLogCtrl::OnActiveListUpdated, this);
|
this->Bind(EVT_ON_LIST_UPDATED, &wxLogCtrl::OnActiveListUpdated, this);
|
||||||
m_timer->Start(250);
|
m_timer->Start(250);
|
||||||
|
|
||||||
|
m_alternateRowColoursEnabled = alternateRowColours;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogCtrl::~wxLogCtrl()
|
wxLogCtrl::~wxLogCtrl()
|
||||||
|
|
@ -93,15 +95,13 @@ void wxLogCtrl::OnDraw(wxDC& dc, sint32 start, sint32 count, const wxPoint& star
|
||||||
|
|
||||||
for (sint32 i = 0; i <= count && it != m_active_entries.cend(); ++i, ++it)
|
for (sint32 i = 0; i <= count && it != m_active_entries.cend(); ++i, ++it)
|
||||||
{
|
{
|
||||||
wxColour background_colour;
|
wxColour background_colour = GetBackgroundColour();
|
||||||
if((start + i) % 2 == 0)
|
if((start + i) % 2 != 0 && m_alternateRowColoursEnabled)
|
||||||
background_colour = COLOR_WHITE;
|
background_colour = GetAlternateRowColour();
|
||||||
else
|
|
||||||
background_colour = 0xFFFDF9F2;
|
|
||||||
|
|
||||||
DrawLineBackground(dc, position, background_colour);
|
DrawLineBackground(dc, position, background_colour);
|
||||||
|
|
||||||
dc.SetTextForeground(COLOR_BLACK);
|
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||||
dc.DrawText(it->get().second, position);
|
dc.DrawText(it->get().second, position);
|
||||||
|
|
||||||
NextLine(position, &start_position);
|
NextLine(position, &start_position);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
class wxLogCtrl : public TextList
|
class wxLogCtrl : public TextList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxLogCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
|
wxLogCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, bool alternateRowColours = false);
|
||||||
~wxLogCtrl();
|
~wxLogCtrl();
|
||||||
|
|
||||||
void SetActiveFilter(const std::string& active_filter);
|
void SetActiveFilter(const std::string& active_filter);
|
||||||
|
|
@ -23,6 +23,22 @@ private:
|
||||||
|
|
||||||
wxTimer* m_timer;
|
wxTimer* m_timer;
|
||||||
|
|
||||||
|
bool m_alternateRowColoursEnabled = false;
|
||||||
|
wxColour m_alternateRowColour;
|
||||||
|
|
||||||
|
wxColour GetAlternateRowColour()
|
||||||
|
{
|
||||||
|
if (m_alternateRowColour.IsOk())
|
||||||
|
return m_alternateRowColour;
|
||||||
|
|
||||||
|
// Depending on the background, alternate row colour should be a bit
|
||||||
|
// darker or brighter.
|
||||||
|
const wxColour bgColour = GetBackgroundColour();
|
||||||
|
int alpha = bgColour.GetRGB() > 0x808080 ? 97 : 110;
|
||||||
|
m_alternateRowColour = bgColour.ChangeLightness(alpha);
|
||||||
|
return m_alternateRowColour;
|
||||||
|
}
|
||||||
|
|
||||||
std::string m_active_filter;
|
std::string m_active_filter;
|
||||||
std::thread m_update_worker;
|
std::thread m_update_worker;
|
||||||
bool m_filter_messages = false;
|
bool m_filter_messages = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue