Fix Dark Mode issues on Linux(via LAB) (#5044)

* GUI_App.cpp: trailing whitespace cleanup

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>

* StateColor.hpp: trailing whitespace cleanup

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>

* implementing LAB color routines

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>

* Fixes 3667: light/dark fixes for Unsaved Changes dialog

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>

* Fixes: 3675 - set dark mode colors for tabs

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>

* GUI_App: use LAB for fallback and sanity checks

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>

---------

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Jamin Collins 2024-04-23 06:46:55 -07:00 committed by GitHub
parent d163cea8f8
commit 315eee3493
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 166 additions and 15 deletions

View file

@ -959,7 +959,7 @@ void GUI_App::post_init()
if (app_config->get("stealth_mode") == "false")
hms_query = new HMSQuery();
m_show_gcode_window = app_config->get_bool("show_gcode_window");
if (m_networking_need_update) {
//updating networking
@ -2807,7 +2807,7 @@ void GUI_App::init_label_colours()
m_color_label_modified = is_dark_mode ? wxColour("#F1754E") : wxColour("#F1754E");
m_color_label_sys = is_dark_mode ? wxColour("#B2B3B5") : wxColour("#363636");
#ifdef _WIN32
#if defined(_WIN32) || defined(__linux__) || defined(__APPLE__)
m_color_label_default = is_dark_mode ? wxColour(250, 250, 250) : m_color_label_sys; // wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
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);
@ -2920,22 +2920,38 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
/*if (m_is_dark_mode != dark_mode() )
m_is_dark_mode = dark_mode();*/
if (m_is_dark_mode) {
auto original_col = window->GetBackgroundColour();
auto bg_col = StateColor::darkModeColorFor(original_col);
if (bg_col != original_col) {
auto orig_col = window->GetBackgroundColour();
auto bg_col = StateColor::darkModeColorFor(orig_col);
// there are cases where the background color of an item is bright, specifically:
// * the background color of a button: #009688 -- 73
if (bg_col != orig_col) {
window->SetBackgroundColour(bg_col);
}
original_col = window->GetForegroundColour();
auto fg_col = StateColor::darkModeColorFor(original_col);
orig_col = window->GetForegroundColour();
auto fg_col = StateColor::darkModeColorFor(orig_col);
auto fg_l = StateColor::GetLightness(fg_col);
if (fg_col != original_col) {
window->SetForegroundColour(fg_col);
auto color_difference = StateColor::GetColorDifference(bg_col, fg_col);
// fallback and sanity check with LAB
// color difference of less than 2 or 3 is not normally visible, and even less than 30-40 doesn't stand out
if (color_difference < 10) {
fg_col = StateColor::SetLightness(fg_col, 90);
}
// some of the stock colors have a lightness of ~49
if (fg_l < 45) {
fg_col = StateColor::SetLightness(fg_col, 70);
}
// at this point it shouldn't be possible that fg_col is the same as bg_col, but let's be safe
if (fg_col == bg_col) {
fg_col = StateColor::SetLightness(fg_col, 70);
}
window->SetForegroundColour(fg_col);
}
else {
auto original_col = window->GetBackgroundColour();
@ -3891,7 +3907,7 @@ void GUI_App::on_http_error(wxCommandEvent &evt)
MessageDialog msg_dlg(nullptr, _L("The version of Orca Slicer is too low and needs to be updated to the latest version before it can be used normally"), "", wxAPPLY | wxOK);
if (msg_dlg.ShowModal() == wxOK) {
}
}
// request login