Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clientgui/BOINCGUIApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ bool CBOINCGUIApp::OnInit() {
#if SUPPORTDARKMODE
wxSystemAppearance appearance = wxSystemSettings::GetAppearance();
m_isDarkMode = appearance.IsDark();
#if defined(__WXMSW__)
// wxWidgets' IsDark() returns false on Win 11 now even if dark mode is enabled
// so we need to additionally check AreAppsDark()
m_isDarkMode = m_isDarkMode || appearance.AreAppsDark();
MSWEnableDarkMode(wxApp::DarkMode_Auto);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is needed? I do remember when I tested the dark mode, I didn't have this enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it according to docs. Yes, without it just ignores OS settings

#endif
#endif

s_bSkipExitConfirmation = false;
Expand Down
2 changes: 1 addition & 1 deletion clientgui/BOINCGUIApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// BOINC to adjust standard UI items for Dark Mode, be sure to guard
// those changes so they do not affect the Mac implementation.
//
#if (defined(__WXMAC__) || defined(__WXGTK__))
#if (defined(__WXMAC__) || defined(__WXGTK__) || defined(__WXMSW__))
#define SUPPORTDARKMODE true
#else
#define SUPPORTDARKMODE false
Expand Down
22 changes: 19 additions & 3 deletions clientgui/BOINCListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,23 @@ void CBOINCListCtrl::DrawProgressBars()
int n = (int)m_iRowsNeedingProgressBars.GetCount();
if (n <= 0) return;

wxColour progressColor = isDarkMode ? wxColour(0, 64, 128) : wxColour(192, 217, 217);
wxColour progressColor;
wxColour remainderColor;
wxColour textColor;

if (isDarkMode) {
progressColor = wxColour(96, 96, 96);
remainderColor = wxColour(24, 24, 24);
textColor = wxColour(230, 230, 230);
} else {
progressColor = wxColour(192, 217, 217);
remainderColor = *wxWHITE;
textColor = *wxBLACK;
}

wxBrush progressBrush(progressColor);
wxBrush remainderBrush(remainderColor);
wxPen remainderPen(remainderColor);

numItems = GetItemCount();
if (numItems) {
Expand Down Expand Up @@ -606,12 +621,13 @@ void CBOINCListCtrl::DrawProgressBars()
dc.SetPen(bkgd);
dc.SetBrush(bkgd);
#else
dc.SetPen(isDarkMode ? *wxBLACK_PEN : *wxWHITE_PEN);
dc.SetBrush(isDarkMode ? *wxBLACK_BRUSH : *wxWHITE_BRUSH);
dc.SetPen(remainderPen);
dc.SetBrush(remainderBrush);
#endif
dc.DrawRectangle( rr );

dc.SetPen(*wxBLACK_PEN);
dc.SetTextForeground(textColor);
dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
if (xx > (r.width - 7)) {
dc.DrawText(progressString, r.x, r.y);
Expand Down
8 changes: 2 additions & 6 deletions clientgui/NoticeListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@ bool CNoticeListCtrl::Create( wxWindow* parent ) {
SetSizer(topsizer);

m_itemCount = 0;
bool isWindowsDarkMode = false;
#ifdef __WXMSW__
const wxSystemAppearance appearance = wxSystemSettings::GetAppearance();
isWindowsDarkMode = appearance.IsSystemDark();
#endif
if (wxGetApp().GetIsDarkMode() || isWindowsDarkMode){

if (wxGetApp().GetIsDarkMode()){
#if wxUSE_WEBVIEW
m_noticesBody = wxT("<html><style>body{background-color:black;color:white;}</style><head></head><body></body></html>");
#else
Expand Down
27 changes: 14 additions & 13 deletions clientgui/ViewResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,28 @@ END_EVENT_TABLE ()


CViewResources::CViewResources()
: m_BOINCwasEmpty(false)
, m_isDarkTheme(wxGetApp().GetIsDarkMode())
{}

CViewResources::CViewResources(wxNotebook* pNotebook) :
CBOINCBaseView(pNotebook)
, m_BOINCwasEmpty(false)
, m_isDarkTheme(wxGetApp().GetIsDarkMode())
{
bool isDarkMode = wxGetApp().GetIsDarkMode();
m_BOINCwasEmpty=false;

wxGridSizer* itemGridSizer = new wxGridSizer(2, 0, 3);
wxASSERT(itemGridSizer);

// create pie chart ctrl for total disk usage
m_pieCtrlTotal = new wxPieCtrl(this, ID_PIECTRL_RESOURCEUTILIZATIONVIEWTOTAL, wxDefaultPosition, wxDefaultSize);
wxASSERT(m_pieCtrlTotal);
m_pieCtrlTotal->ApplyTheme(m_isDarkTheme);

// setup the legend
m_pieCtrlTotal->SetTransparent(true);
m_pieCtrlTotal->SetHorLegendBorder(10);
m_pieCtrlTotal->SetLabelFont(*wxSWISS_FONT);
m_pieCtrlTotal->SetLabelColour(isDarkMode ? *wxWHITE : *wxBLACK);
m_pieCtrlTotal->SetLabelColour(m_isDarkTheme ? *wxWHITE : *wxBLACK);
m_pieCtrlTotal->SetLabel(_("Total disk usage"));

// initialize pie control
Expand All @@ -75,12 +77,13 @@ CViewResources::CViewResources(wxNotebook* pNotebook) :
// create pie chart ctrl for BOINC disk usage
m_pieCtrlBOINC = new wxPieCtrl(this, ID_PIECTRL_RESOURCEUTILIZATIONVIEW, wxDefaultPosition, wxDefaultSize);
wxASSERT(m_pieCtrlBOINC);
m_pieCtrlBOINC->ApplyTheme(m_isDarkTheme);

//setup the legend
m_pieCtrlBOINC->SetTransparent(true);
m_pieCtrlBOINC->SetHorLegendBorder(10);
m_pieCtrlBOINC->SetLabelFont(*wxSWISS_FONT);
m_pieCtrlTotal->SetLabelColour(isDarkMode ? *wxWHITE : *wxBLACK);
m_pieCtrlBOINC->SetLabelColour(m_isDarkTheme ? *wxWHITE : *wxBLACK);
m_pieCtrlBOINC->SetLabel(_("Disk usage by BOINC projects"));

// initialize pie control
Expand Down Expand Up @@ -173,7 +176,6 @@ void CViewResources::OnListRender() {
wxString diskspace;
static double project_total=0.0;
unsigned int i;
bool isDarkMode = wxGetApp().GetIsDarkMode();

wxASSERT(pDoc);
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
Expand Down Expand Up @@ -228,7 +230,7 @@ void CViewResources::OnListRender() {
wxPiePart part;
part.SetLabel(_("no projects: 0 bytes used"));
part.SetValue(1);
part.SetColour(isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0));
part.SetColour(m_isDarkTheme ? wxColour(255, 255, 255) : wxColour(0,0,0));
m_pieCtrlBOINC->m_Series.Add(part);
m_pieCtrlBOINC->Refresh();
m_BOINCwasEmpty=true;
Expand Down Expand Up @@ -263,8 +265,7 @@ void CViewResources::OnListRender() {
FormatDiskSpace(boinc_total, diskspace);
part.SetLabel(_("used by BOINC: ") + diskspace);
part.SetValue(boinc_total);
part.SetColour(isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0));
part.SetColour(isDarkMode ? *wxWHITE : *wxBLACK);
part.SetColour(m_isDarkTheme ? *wxWHITE : *wxBLACK);
m_pieCtrlTotal->m_Series.Add(part);

if (pDoc->disk_usage.d_allowed > 0) {
Expand All @@ -274,15 +275,15 @@ void CViewResources::OnListRender() {
FormatDiskSpace(avail, diskspace);
part.SetLabel(_("free, available to BOINC: ") + diskspace);
part.SetValue(avail == 0 ? 1 : avail);
part.SetColour(isDarkMode ? wxColour(108, 108, 108) : wxColour(128, 128, 128));
part.SetColour(m_isDarkTheme ? wxColour(108, 108, 108) : wxColour(128, 128, 128));
m_pieCtrlTotal->m_Series.Add(part);

double not_avail = free - avail;
if (not_avail > 0) {
FormatDiskSpace(not_avail, diskspace);
part.SetLabel(_("free, not available to BOINC: ") + diskspace);
part.SetValue(not_avail);
part.SetColour(isDarkMode ? wxColour(172,172,172) : wxColour(238,238,238));
part.SetColour(m_isDarkTheme ? wxColour(172,172,172) : wxColour(238,238,238));
m_pieCtrlTotal->m_Series.Add(part);
}
} else {
Expand All @@ -292,7 +293,7 @@ void CViewResources::OnListRender() {
FormatDiskSpace(free, diskspace);
part.SetLabel(_("free: ") + diskspace);
part.SetValue(free);
part.SetColour(isDarkMode ? wxColour(172,172,172) : wxColour(238,238,238));
part.SetColour(m_isDarkTheme ? wxColour(172,172,172) : wxColour(238,238,238));
m_pieCtrlTotal->m_Series.Add(part);
}

Expand All @@ -301,7 +302,7 @@ void CViewResources::OnListRender() {
FormatDiskSpace(used_by_others, diskspace);
part.SetLabel(_("used by other programs: ") + diskspace);
part.SetValue(used_by_others);
part.SetColour(isDarkMode ? wxColour(140,140,140) : wxColour(192,192,192));
part.SetColour(m_isDarkTheme ? wxColour(140,140,140) : wxColour(192,192,192));
m_pieCtrlTotal->m_Series.Add(part);
m_pieCtrlTotal->Refresh();
}
Expand Down
1 change: 1 addition & 0 deletions clientgui/ViewResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CViewResources : public CBOINCBaseView
wxPieCtrl* m_pieCtrlTotal;

bool m_BOINCwasEmpty;
bool m_isDarkTheme;

virtual void UpdateSelection();

Expand Down
87 changes: 59 additions & 28 deletions clientgui/ViewStatistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,65 @@ CPaintStatistics::CPaintStatistics(wxWindow* parent, wxWindowID id, const wxPoin
m_LegendDraw = true;

// Default colours
m_pen_MarkerLineColour = wxColour(0, 0, 0);
m_pen_ZoomRectColour = wxColour (128, 64, 95);
m_brush_ZoomRectColour = wxColour(24, 31, 0);
m_brush_AxisColour = wxColour(192, 224, 255);
m_pen_AxisColour = wxColour(64, 128, 192);
m_pen_AxisColourZoom = wxColour(255, 64, 0);
m_pen_AxisColourAutoZoom = wxColour(64, 128, 192);
m_pen_AxisXColour = wxColour(64, 128, 192);
m_pen_AxisYColour = wxColour(64, 128, 192);
m_pen_AxisXTextColour = isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0);
m_pen_AxisYTextColour = isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0);

m_brush_LegendColour = isDarkMode ? wxColour(0, 64, 128) : wxColour(235, 255, 255);
m_brush_LegendSelectColour = wxColour(192, 224, 255);
m_pen_LegendSelectColour = wxColour(64, 128, 192);
m_pen_LegendSelectTextColour = isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0);
m_pen_LegendColour = wxColour(64, 128, 192);
m_pen_LegendTextColour = isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0);
m_brush_MainColour = isDarkMode ? wxColour(0,0,0) : wxColour(255, 255, 255);
m_pen_MainColour = wxColour(64, 128, 192);

m_pen_HeadTextColour = isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0);
m_pen_ProjectHeadTextColour = isDarkMode ? wxColour(255, 255, 255) : wxColour(0,0,0);

m_pen_GraphTotalColour = wxColour(255, 0, 0);
m_pen_GraphRACColour = wxColour(0, 160, 0);
m_pen_GraphTotalHostColour = wxColour(0, 0, 255);
m_pen_GraphRACHostColour = wxColour(0, 0, 0);
if (isDarkMode) {
m_pen_MarkerLineColour = wxColour(220, 220, 220);
m_pen_ZoomRectColour = wxColour(180, 200, 220);
m_brush_ZoomRectColour = wxColour(32, 48, 64);
m_brush_AxisColour = wxColour(24, 24, 24);
m_pen_AxisColour = wxColour(96, 128, 160);
m_pen_AxisColourZoom = wxColour(255, 128, 64);
m_pen_AxisColourAutoZoom = wxColour(96, 128, 160);
m_pen_AxisXColour = wxColour(80, 80, 80);
m_pen_AxisYColour = wxColour(80, 80, 80);
m_pen_AxisXTextColour = wxColour(255, 255, 255);
m_pen_AxisYTextColour = wxColour(255, 255, 255);

m_brush_LegendColour = wxColour(32, 48, 64);
m_brush_LegendSelectColour = wxColour(64, 96, 128);
m_pen_LegendSelectColour = wxColour(128, 170, 212);
m_pen_LegendSelectTextColour = wxColour(255, 255, 255);
m_pen_LegendColour = wxColour(96, 128, 160);
m_pen_LegendTextColour = wxColour(255, 255, 255);
m_brush_MainColour = wxColour(0, 0, 0);
m_pen_MainColour = wxColour(96, 128, 160);

m_pen_HeadTextColour = wxColour(255, 255, 255);
m_pen_ProjectHeadTextColour = wxColour(255, 255, 255);

m_pen_GraphTotalColour = wxColour(255, 0, 0);
m_pen_GraphRACColour = wxColour(0, 200, 0);
m_pen_GraphTotalHostColour = wxColour(0, 128, 255);
m_pen_GraphRACHostColour = wxColour(255, 200, 0);
} else {
m_pen_MarkerLineColour = wxColour(0, 0, 0);
m_pen_ZoomRectColour = wxColour(128, 64, 95);
m_brush_ZoomRectColour = wxColour(24, 31, 0);
m_brush_AxisColour = wxColour(192, 224, 255);
m_pen_AxisColour = wxColour(64, 128, 192);
m_pen_AxisColourZoom = wxColour(255, 64, 0);
m_pen_AxisColourAutoZoom = wxColour(64, 128, 192);
m_pen_AxisXColour = wxColour(64, 128, 192);
m_pen_AxisYColour = wxColour(64, 128, 192);
m_pen_AxisXTextColour = wxColour(0, 0, 0);
m_pen_AxisYTextColour = wxColour(0, 0, 0);

m_brush_LegendColour = wxColour(235, 255, 255);
m_brush_LegendSelectColour = wxColour(192, 224, 255);
m_pen_LegendSelectColour = wxColour(64, 128, 192);
m_pen_LegendSelectTextColour = wxColour(0, 0, 0);
m_pen_LegendColour = wxColour(64, 128, 192);
m_pen_LegendTextColour = wxColour(0, 0, 0);
m_brush_MainColour = wxColour(255, 255, 255);
m_pen_MainColour = wxColour(64, 128, 192);

m_pen_HeadTextColour = wxColour(0, 0, 0);
m_pen_ProjectHeadTextColour = wxColour(0, 0, 0);

m_pen_GraphTotalColour = wxColour(255, 0, 0);
m_pen_GraphRACColour = wxColour(0, 160, 0);
m_pen_GraphTotalHostColour = wxColour(0, 0, 255);
m_pen_GraphRACHostColour = wxColour(0, 0, 0);
}

m_dc_bmp.Create(1, 1);
m_full_repaint = true;
Expand Down
17 changes: 9 additions & 8 deletions clientgui/common/wxPieCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,11 @@ wxPieCtrl::wxPieCtrl(wxWindow * parent, wxWindowID id, wxPoint pos,
wxSize sz, long style, wxString name)
:wxWindow(parent, id, pos, sz, style, name)
{
bool isDarkMode = wxGetApp().GetIsDarkMode();

if (isDarkMode) SetBackgroundColour(*wxBLACK);
ApplyTheme(wxGetApp().GetIsDarkMode());

m_ShowEdges=true;
m_CanRepaint=true;
m_BackColour = isDarkMode ? *wxBLACK : *wxWHITE;
m_padding=10;

m_TitleColour = isDarkMode ? wxColour(255,255,255) : wxColour(0,0,0);
m_LabelColour = isDarkMode ? *wxWHITE : *wxBLACK;
m_LegendBackColour = isDarkMode ? wxColour(0, 0, 255) : wxColour(255,255,0);
m_TitleFont = *wxSWISS_FONT;
m_TitleFont.SetWeight(wxFONTWEIGHT_BOLD);
m_LabelFont = *wxSWISS_FONT;
Expand Down Expand Up @@ -96,6 +89,14 @@ wxPieCtrl::~wxPieCtrl() {
#endif
}

void wxPieCtrl::ApplyTheme(bool isDarkMode) {
m_BackColour = isDarkMode ? *wxBLACK : *wxWHITE;
SetBackgroundColour(m_BackColour);
m_TitleColour = isDarkMode ? wxColour(255, 255, 255) : wxColour(0, 0, 0);
m_LabelColour = isDarkMode ? *wxWHITE : *wxBLACK;
m_LegendBackColour = isDarkMode ? wxColour(0, 0, 255) : wxColour(255, 255, 0);
}

/* getter and setter */

void wxPieCtrl::SetPadding(int pad) {
Expand Down
2 changes: 2 additions & 0 deletions clientgui/common/wxPieCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ using wxWindow::SetTransparent;
/// Sets the colour used for displaying legend box background
void SetLegendBackColour(wxColour colour);

void ApplyTheme(bool isDarkMode);

void SetLabel(const wxString& label);


Expand Down