UI: Fix some light themed elements in input window when using dark mode

This commit is contained in:
Crementif 2025-07-15 17:39:32 +02:00
parent 72b4d521cf
commit e60f1666bd
6 changed files with 57 additions and 50 deletions

View file

@ -21,33 +21,35 @@ void wxInputDraw::OnRender(wxDC& dc)
{
dc.Clear();
glm::vec2 position;
const wxPen *black, *red, *grey;
const wxBrush *black_brush, *red_brush, *grey_brush;
if(IsEnabled())
{
position = m_position;
glm::vec2 position = m_position;
black = wxBLACK_PEN;
red = wxRED_PEN;
grey = wxGREY_PEN;
wxPen black = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxPen red = *wxRED_PEN;
wxPen grey = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
wxPen green = wxSystemSettings::SelectLightDark(0x336600, 0x99FF99);
black_brush = wxBLACK_BRUSH;
red_brush = wxRED_BRUSH;
grey_brush = wxGREY_BRUSH;
}
else
wxBrush black_brush = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
wxBrush red_brush = *wxRED_BRUSH;
wxBrush grey_brush = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
wxBrush green_brush = wxSystemSettings::SelectLightDark(0x336600, 0x99FF99);
if(!IsEnabled())
{
position = {};
black = red = wxMEDIUM_GREY_PEN;
grey = wxLIGHT_GREY_PEN;
black.SetColour(black.GetColour());
red.SetColour(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
grey.SetColour(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT).MakeDisabled());
black_brush = red_brush = wxMEDIUM_GREY_BRUSH;
grey_brush = wxLIGHT_GREY_BRUSH;
black_brush = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
red_brush = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT).MakeDisabled();
grey_brush = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT).MakeDisabled();
}
dc.SetBackgroundMode(wxSOLID);
dc.SetBackground(*wxWHITE_BRUSH);
dc.SetBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
dc.Clear();
const auto size = GetSize();
const auto min_size = (float)std::min(size.GetWidth(), size.GetHeight()) - 1.0f;
@ -55,16 +57,16 @@ void wxInputDraw::OnRender(wxDC& dc)
// border
const wxRect border{0, 0, (int)min_size, (int)min_size};
dc.SetPen(*black);
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
dc.DrawRectangle(border);
dc.SetPen(IsEnabled() ? wxPen(wxColour(0x336600)) : *grey); // dark green
dc.SetPen(IsEnabled() ? green.GetColour() : grey.GetColour());
dc.DrawCircle((int)middle.x, (int)middle.y, (int)middle.x);
if (m_deadzone > 0)
{
dc.SetPen(*grey);
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.SetPen(grey);
dc.SetBrush(grey_brush);
const auto deadzone_size = m_deadzone * min_size / 2.0f;
dc.DrawCircle(
static_cast<int>(middle.x),
@ -73,25 +75,25 @@ void wxInputDraw::OnRender(wxDC& dc)
if (length(position) >= m_deadzone)
{
dc.SetPen(*red);
dc.SetBrush(*red_brush);
dc.SetPen(red);
dc.SetBrush(red_brush);
if (std::abs(1.0f - length(position)) < 0.05f)
{
dc.SetPen(wxPen(wxColour(0x336600)));
dc.SetBrush(wxColour(0x336600));
dc.SetPen(green);
dc.SetBrush(green_brush);
}
}
else
{
dc.SetPen(*black);
dc.SetBrush(*black_brush);
dc.SetPen(black);
dc.SetBrush(black_brush);
}
}
else
{
dc.SetPen(*red);
dc.SetBrush(*red_brush);
dc.SetPen(red);
dc.SetBrush(red_brush);
}
// draw axis

View file

@ -1,6 +1,8 @@
#include "wxgui/wxgui.h"
#include "wxgui/debugger/DebuggerWindow2.h"
#include "wxHelper.h"
#include <filesystem>
#include "config/ActiveSettings.h"
@ -220,20 +222,20 @@ void DebuggerWindow2::CreateToolBar()
m_toolbar = wxFrame::CreateToolBar(wxTB_HORIZONTAL, wxID_ANY);
m_toolbar->SetToolBitmapSize(wxSize(16, 16));
wxBitmap goto_bitmap = LoadThemedBitmapFromPNG(DEBUGGER_GOTO_png, sizeof(DEBUGGER_GOTO_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxBitmap goto_bitmap = wxHelper::LoadThemedBitmapFromPNG(DEBUGGER_GOTO_png, sizeof(DEBUGGER_GOTO_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_toolbar->AddTool(TOOL_ID_GOTO, wxEmptyString, goto_bitmap, wxNullBitmap, wxITEM_NORMAL, _("GoTo (CTRL + G)"), "test", NULL);
m_toolbar->AddSeparator();
wxBitmap bp_bitmap = LoadThemedBitmapFromPNG(DEBUGGER_BP_RED_png, sizeof(DEBUGGER_BP_RED_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxBitmap bp_bitmap = wxHelper::LoadThemedBitmapFromPNG(DEBUGGER_BP_RED_png, sizeof(DEBUGGER_BP_RED_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_toolbar->AddTool(TOOL_ID_BP, wxEmptyString, bp_bitmap, wxNullBitmap, wxITEM_NORMAL, _("Toggle Breakpoint (F9)"), wxEmptyString, NULL);
m_toolbar->AddSeparator();
m_pause = LoadThemedBitmapFromPNG(DEBUGGER_PAUSE_png, sizeof(DEBUGGER_PAUSE_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_run = LoadThemedBitmapFromPNG(DEBUGGER_PLAY_png, sizeof(DEBUGGER_PLAY_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_pause = wxHelper::LoadThemedBitmapFromPNG(DEBUGGER_PAUSE_png, sizeof(DEBUGGER_PAUSE_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_run = wxHelper::LoadThemedBitmapFromPNG(DEBUGGER_PLAY_png, sizeof(DEBUGGER_PLAY_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_toolbar->AddTool(TOOL_ID_PAUSE, wxEmptyString, m_pause, wxNullBitmap, wxITEM_NORMAL, _("Break (F5)"), wxEmptyString, NULL);
wxBitmap step_into_bitmap = LoadThemedBitmapFromPNG(DEBUGGER_STEP_INTO_png, sizeof(DEBUGGER_STEP_INTO_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxBitmap step_over_bitmap = LoadThemedBitmapFromPNG(DEBUGGER_STEP_OVER_png, sizeof(DEBUGGER_STEP_OVER_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxBitmap step_into_bitmap = wxHelper::LoadThemedBitmapFromPNG(DEBUGGER_STEP_INTO_png, sizeof(DEBUGGER_STEP_INTO_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
wxBitmap step_over_bitmap = wxHelper::LoadThemedBitmapFromPNG(DEBUGGER_STEP_OVER_png, sizeof(DEBUGGER_STEP_OVER_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_toolbar->AddTool(TOOL_ID_STEP_INTO, wxEmptyString, step_into_bitmap, wxNullBitmap, wxITEM_NORMAL, _("Step Into (F11)"), wxEmptyString, NULL);
m_toolbar->AddTool(TOOL_ID_STEP_OVER, wxEmptyString, step_over_bitmap, wxNullBitmap, wxITEM_NORMAL, _("Step Over (F10)"), wxEmptyString, NULL);
m_toolbar->AddSeparator();

View file

@ -1,6 +1,7 @@
#include "wxgui/wxgui.h"
#include "wxgui/debugger/DisasmCtrl.h"
#include "wxHelper.h"
#include "Cafe/OS/RPL/rpl_structs.h"
#include "Cafe/OS/RPL/rpl.h"
#include "Cafe/OS/RPL/rpl_symbol_storage.h"
@ -12,7 +13,6 @@
#include "Cemu/ExpressionParser/ExpressionParser.h"
#include "Cafe/HW/Espresso/Debugger/DebugSymbolStorage.h"
#include <wx/mstream.h> // for wxMemoryInputStream
wxDEFINE_EVENT(wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS, wxCommandEvent);
@ -105,7 +105,7 @@ static void InitSyntaxColors()
// theme the current instruction pointer arrow
wxMemoryInputStream strm(arrowRightPNG, sizeof(arrowRightPNG));
g_ipArrowBitmap = LoadThemedBitmapFromPNG(arrowRightPNG, sizeof(arrowRightPNG), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
g_ipArrowBitmap = wxHelper::LoadThemedBitmapFromPNG(arrowRightPNG, sizeof(arrowRightPNG), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
}

View file

@ -70,9 +70,9 @@ InputSettings2::InputSettings2(wxWindow* parent)
g_inputConfigWindowHasFocus = true;
m_connected = wxBITMAP_PNG_FROM_DATA(INPUT_CONNECTED);
m_disconnected = wxBITMAP_PNG_FROM_DATA(INPUT_DISCONNECTED);
m_low_battery = wxBITMAP_PNG_FROM_DATA(INPUT_LOW_BATTERY);
m_connected = wxHelper::LoadThemedBitmapFromPNG(INPUT_CONNECTED_png, sizeof(INPUT_CONNECTED_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_disconnected = wxHelper::LoadThemedBitmapFromPNG(INPUT_DISCONNECTED_png, sizeof(INPUT_DISCONNECTED_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_low_battery = wxHelper::LoadThemedBitmapFromPNG(INPUT_LOW_BATTERY_png, sizeof(INPUT_LOW_BATTERY_png), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
auto* sizer = new wxBoxSizer(wxVERTICAL);

View file

@ -14,15 +14,9 @@ class wxComboBox;
class InputPanel : public wxPanel
{
public:
#if BOOST_OS_WINDOWS
const wxColour kKeyColourNormalMode = 0xfafafa;
const wxColour kKeyColourEditMode = 0x99ccff;
const wxColour kKeyColourActiveMode = 0xE0E0E0;
#else
const wxColour kKeyColourNormalMode = GetBackgroundColour();
const wxColour kKeyColourEditMode = GetBackgroundColour();
const wxColour kKeyColourActiveMode = wxHelper::CalculateAccentColour(kKeyColourNormalMode);
#endif
const wxColour kKeyColourEditMode = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
const wxColour kKeyColourActiveMode = wxHelper::CalculateAccentColour(GetBackgroundColour());
InputPanel(wxWindow* parent);

View file

@ -1,5 +1,7 @@
#pragma once
#include <wx/string.h>
#include <wx/bitmap.h>
#include <wx/mstream.h>
namespace wxHelper
{
@ -33,4 +35,11 @@ namespace wxHelper
return bgColourSecondary;
}
static wxBitmap LoadThemedBitmapFromPNG(const uint8* data, size_t size, const wxColour& tint)
{
wxMemoryInputStream strm(data, size);
wxImage img(strm, wxBITMAP_TYPE_PNG);
img.Replace(0x00, 0x00, 0x00, tint.Red(), tint.Green(), tint.Blue());
return wxBitmap(img);
}
};