MSW_DarkMode: Next Improvements

* Refreshed title bar for all Dialogs and MainFrame
* Refreshed header of the DataViewCtrl and ListView
* Refresh tooltips
* Redraw SpinCtrls
* Use system menu with is colored in respect to the color mode
* Preferences: Added parameter "Use system menu for application" and moved to the "Dark mode" tab with "Enable Dark mode parameter"
This commit is contained in:
YuSanka 2021-11-01 16:24:31 +01:00
parent 7520e2f193
commit aff9e1f7ea
10 changed files with 123 additions and 33 deletions

View file

@ -3,6 +3,7 @@
#include "GUI_Init.hpp"
#include "GUI_ObjectList.hpp"
#include "GUI_ObjectManipulation.hpp"
#include "GUI_Factories.hpp"
#include "format.hpp"
#include "I18N.hpp"
@ -1020,11 +1021,7 @@ bool GUI_App::on_init_inner()
wxInitAllImageHandlers();
#ifdef _MSW_DARK_MODE
if (bool dark_mode = app_config->get("dark_color_mode") == "1") {
NppDarkMode::InitDarkMode();
if (dark_mode != NppDarkMode::IsDarkMode())
NppDarkMode::SetDarkMode(dark_mode);
}
NppDarkMode::InitDarkMode(app_config->get("dark_color_mode") == "1", app_config->get("sys_menu_enabled") == "1");
#endif
SplashScreen* scrn = nullptr;
if (app_config->get("show_splash_screen") == "1") {
@ -1347,10 +1344,9 @@ void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
{
#ifdef _WIN32
UpdateDarkUI(dvc, highlited ? dark_mode() : false);
wxItemAttr attr(dark_mode() ? m_color_highlight_default : m_color_label_default,
m_color_window_default,
m_normal_font);
dvc->SetHeaderAttr(attr);
#ifdef _MSW_DARK_MODE
dvc->RefreshHeaderDarkMode(&m_normal_font);
#endif //_MSW_DARK_MODE
if (dvc->HasFlag(wxDV_ROW_LINES))
dvc->SetAlternateRowColour(m_color_highlight_default);
if (dvc->GetBorder() != wxBORDER_SIMPLE)
@ -1574,12 +1570,44 @@ void fatal_error(wxWindow* parent)
}
#ifdef _WIN32
#ifdef _MSW_DARK_MODE
static void update_scrolls(wxWindow* window)
{
wxWindowList::compatibility_iterator node = window->GetChildren().GetFirst();
while (node)
{
wxWindow* win = node->GetData();
if (dynamic_cast<wxScrollHelper*>(win) ||
dynamic_cast<wxTreeCtrl*>(win) ||
dynamic_cast<wxTextCtrl*>(win))
NppDarkMode::SetDarkExplorerTheme(win->GetHWND());
update_scrolls(win);
node = node->GetNext();
}
}
#endif //_MSW_DARK_MODE
#ifdef _MSW_DARK_MODE
void GUI_App::force_menu_update()
{
NppDarkMode::SetSystemMenuForApp(app_config->get("sys_menu_enabled") == "1");
}
#endif //_MSW_DARK_MODE
void GUI_App::force_colors_update()
{
#ifdef _MSW_DARK_MODE
NppDarkMode::SetDarkMode(app_config->get("dark_color_mode") == "1");
if (WXHWND wxHWND = wxToolTip::GetToolTipCtrl())
NppDarkMode::SetDarkExplorerTheme((HWND)wxHWND);
NppDarkMode::SetDarkTitleBar(mainframe->GetHWND());
#endif //_MSW_DARK_MODE
m_force_colors_update = true;
}
#endif
#endif //_WIN32
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
@ -1587,11 +1615,14 @@ void GUI_App::update_ui_from_settings()
{
update_label_colours();
#ifdef _WIN32
// Upadte UU colors before Update UI from settings
// Upadte UI colors before Update UI from settings
if (m_force_colors_update) {
m_force_colors_update = false;
mainframe->force_color_changed();
mainframe->diff_dialog.force_color_changed();
#ifdef _MSW_DARK_MODE
update_scrolls(mainframe);
#endif //_MSW_DARK_MODE
}
#endif
mainframe->update_ui_from_settings();