MSW specific: Implementation of the own notebook control

* MSW specific: First implementation of the Notebook control to support Dark/Light color modes

* MSW specific: Set mode sizer to the Notebook control.

* MSW specific: Added icons to the Notepad control
 + There is no need to restart application after the changing of the color mode

* Fixed non-MSW build

* Updated color for SavePresetDialog
+ Added wrapper to wxMessageBox for mom-MSW platforms
This commit is contained in:
Oleksandra Yushchenko 2021-06-29 16:23:45 +02:00 committed by GitHub
parent 7fce368cca
commit 4652733201
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 703 additions and 135 deletions

View file

@ -72,6 +72,7 @@
#include "DesktopIntegrationDialog.hpp"
#include "BitmapCache.hpp"
#include "Notebook.hpp"
#ifdef __WXMSW__
#include <dbt.h>
@ -929,8 +930,6 @@ bool GUI_App::on_init_inner()
if (scrn && is_editor())
scrn->SetText(_L("Preparing settings tabs") + dots);
m_tabs_as_menu = dark_mode() || app_config->get("tabs_as_menu") == "1";
mainframe = new MainFrame();
// hide settings tabs after first Layout
if (is_editor())
@ -1043,6 +1042,7 @@ void GUI_App::init_label_colours()
m_color_highlight_label_default = is_dark_mode ? wxColour(230, 230, 230): wxSystemSettings::GetColour(/*wxSYS_COLOUR_HIGHLIGHTTEXT*/wxSYS_COLOUR_WINDOWTEXT);
m_color_highlight_default = is_dark_mode ? wxColour(78, 78, 78) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
m_color_hovered_btn_label = is_dark_mode ? wxColour(253, 111, 40) : wxColour(252, 77, 1);
m_color_selected_btn_bg = is_dark_mode ? wxColour(95, 73, 62) : wxColour(228, 220, 216);
#else
m_color_label_default = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
#endif
@ -1090,24 +1090,22 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
btn->Bind(wxEVT_LEAVE_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(false); event.Skip(); });
}
}
else if (dark_mode()) {
if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
if (text->GetBorder() != wxBORDER_SIMPLE)
text->SetWindowStyle(text->GetWindowStyle() | wxBORDER_SIMPLE);
}
else if (wxCheckListBox* list = dynamic_cast<wxCheckListBox*>(window)) {
list->SetWindowStyle(list->GetWindowStyle() | wxBORDER_SIMPLE);
list->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
for (size_t i = 0; i < list->GetCount(); i++)
if (wxOwnerDrawn* item = list->GetItem(i)) {
item->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
item->SetTextColour(m_color_label_default);
}
return;
}
else if (dynamic_cast<wxListBox*>(window))
window->SetWindowStyle(window->GetWindowStyle() | wxBORDER_SIMPLE);
else if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
if (text->GetBorder() != wxBORDER_SIMPLE)
text->SetWindowStyle(text->GetWindowStyle() | wxBORDER_SIMPLE);
}
else if (wxCheckListBox* list = dynamic_cast<wxCheckListBox*>(window)) {
list->SetWindowStyle(list->GetWindowStyle() | wxBORDER_SIMPLE);
list->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
for (size_t i = 0; i < list->GetCount(); i++)
if (wxOwnerDrawn* item = list->GetItem(i)) {
item->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
item->SetTextColour(m_color_label_default);
}
return;
}
else if (dynamic_cast<wxListBox*>(window))
window->SetWindowStyle(window->GetWindowStyle() | wxBORDER_SIMPLE);
if (!just_font)
window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
@ -1138,8 +1136,6 @@ void GUI_App::UpdateDlgDarkUI(wxDialog* dlg)
void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
{
#ifdef _WIN32
if (!dark_mode())
return;
UpdateDarkUI(dvc, highlited);
wxItemAttr attr(dark_mode() ? m_color_highlight_default : m_color_label_default,
m_color_window_default,
@ -1155,8 +1151,6 @@ void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
void GUI_App::UpdateAllStaticTextDarkUI(wxWindow* parent)
{
#ifdef _WIN32
if (!dark_mode())
return;
wxGetApp().UpdateDarkUI(parent);
auto children = parent->GetChildren();
@ -1222,6 +1216,11 @@ void GUI_App::set_label_clr_sys(const wxColour& clr)
app_config->save();
}
bool GUI_App::tabs_as_menu() const
{
return app_config->get("tabs_as_menu") == "1"; // || dark_mode();
}
wxSize GUI_App::get_min_size() const
{
return wxSize(76*m_em_unit, 49 * m_em_unit);
@ -1366,6 +1365,14 @@ void fatal_error(wxWindow* parent)
// exit 1; // #ys_FIXME
}
#ifdef _WIN32
void GUI_App::force_colors_update()
{
NppDarkMode::SetDarkMode(app_config->get("dark_color_mode") == "1");
m_force_colors_update = true;
}
#endif
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
void GUI_App::update_ui_from_settings()
@ -1373,13 +1380,13 @@ void GUI_App::update_ui_from_settings()
update_label_colours();
mainframe->update_ui_from_settings();
#if 0 //#ifdef _WIN32 // #ysDarkMSW - Use to force dark colors for SystemLightMode
if (m_force_sys_colors_update) {
m_force_sys_colors_update = false;
mainframe->force_sys_color_changed();
mainframe->diff_dialog.force_sys_color_changed();
#ifdef _WIN32
if (m_force_colors_update) {
m_force_colors_update = false;
mainframe->force_color_changed();
mainframe->diff_dialog.force_color_changed();
if (m_wizard)
m_wizard->force_sys_color_changed();
m_wizard->force_color_changed();
}
#endif
}
@ -1763,6 +1770,11 @@ void GUI_App::update_mode()
{
sidebar().update_mode();
#ifdef _MSW_DARK_MODE
if (!wxGetApp().tabs_as_menu())
dynamic_cast<Notebook*>(mainframe->m_tabpanel)->UpdateMode();
#endif
for (auto tab : tabs_list)
tab->update_mode();
@ -1902,13 +1914,6 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
this->plater_->refresh_print();
if (dlg.recreate_GUI()) {
#ifdef _MSW_DARK_MODE
if (dlg.color_mode_changed()) {
NppDarkMode::SetDarkMode(app_config->get("dark_color_mode") == "1");
init_label_colours();
}
#endif
m_tabs_as_menu = dark_mode() || app_config->get("tabs_as_menu") == "1";
recreate_GUI(_L("Restart application") + dots);
return;
}