mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-15 19:37:01 +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)
|
||||
: 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 );
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ LoggingWindow::LoggingWindow(wxFrame* parent)
|
|||
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 );
|
||||
|
||||
this->SetSizer( sizer );
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@
|
|||
|
||||
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)
|
||||
{
|
||||
m_timer = new wxTimer(this);
|
||||
this->Bind(wxEVT_TIMER, &wxLogCtrl::OnTimer, this);
|
||||
this->Bind(EVT_ON_LIST_UPDATED, &wxLogCtrl::OnActiveListUpdated, this);
|
||||
m_timer->Start(250);
|
||||
|
||||
m_alternateRowColoursEnabled = alternateRowColours;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
wxColour background_colour;
|
||||
if((start + i) % 2 == 0)
|
||||
background_colour = COLOR_WHITE;
|
||||
else
|
||||
background_colour = 0xFFFDF9F2;
|
||||
wxColour background_colour = GetBackgroundColour();
|
||||
if((start + i) % 2 != 0 && m_alternateRowColoursEnabled)
|
||||
background_colour = GetAlternateRowColour();
|
||||
|
||||
DrawLineBackground(dc, position, background_colour);
|
||||
|
||||
dc.SetTextForeground(COLOR_BLACK);
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
dc.DrawText(it->get().second, position);
|
||||
|
||||
NextLine(position, &start_position);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
class wxLogCtrl : public TextList
|
||||
{
|
||||
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();
|
||||
|
||||
void SetActiveFilter(const std::string& active_filter);
|
||||
|
|
@ -23,6 +23,22 @@ private:
|
|||
|
||||
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::thread m_update_worker;
|
||||
bool m_filter_messages = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue