Skip to content

Commit

Permalink
Add MSW dark mode support
Browse files Browse the repository at this point in the history
Requires buidling with wx 3.3
  • Loading branch information
Blake-Madden committed Sep 9, 2024
1 parent 37bfa87 commit 09a1496
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/gui/i18napp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,38 @@ void I18NFrame::InitControls()
wxArtProvider::GetBitmap(L"ID_ABOUT", wxART_OTHER, wxSize{ 32, 32 }));
}

if (wxSystemSettings::GetAppearance().IsDark())
{
m_ribbon->GetArtProvider()->SetColourScheme(
wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE),
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxColour(253, 211, 155));

m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_BUTTON_BAR_LABEL_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_TOP_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(
wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_GRADIENT_TOP_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_COLOUR,
*wxBLACK);
m_ribbon->GetArtProvider()->SetColour(
wxRIBBON_ART_BUTTON_BAR_LABEL_HIGHLIGHT_GRADIENT_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_TAB_ACTIVE_LABEL_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_PANEL_LABEL_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_PANEL_MINIMISED_LABEL_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_PANEL_HOVER_LABEL_COLOUR, *wxBLACK);
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_TAB_LABEL_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
m_ribbon->GetArtProvider()->SetColour(wxRIBBON_ART_TAB_HOVER_LABEL_COLOUR, *wxBLACK);
}

m_ribbon->Realize();

wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
Expand Down Expand Up @@ -580,9 +612,6 @@ void I18NFrame::OnOpen([[maybe_unused]] wxCommandEvent&)

m_activeProjectOptions.Load(m_activeProjectFilePath);

child = child->GetNext();
}

Process();
}

Expand Down Expand Up @@ -814,6 +843,10 @@ bool I18NApp::OnInit()
m_defaultOptions.Load(m_optionsFilePath);
}

#if wxCHECK_VERSION(3, 3, 0) && defined(__WXMSW__)
MSWEnableDarkMode();
#endif

// create the main application window
I18NFrame* frame = new I18NFrame(GetAppName());
frame->InitControls();
Expand Down

0 comments on commit 09a1496

Please sign in to comment.