diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 1d8a1e26e..555918765 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -149,7 +149,10 @@ set(SLIC3R_GUI_SOURCES ) if (APPLE) - list(APPEND SLIC3R_GUI_SOURCES Utils/RetinaHelperImpl.mm) + list(APPEND SLIC3R_GUI_SOURCES + Utils/RetinaHelperImpl.mm + Utils/MacDarkMode.mm + ) endif () add_library(libslic3r_gui STATIC ${SLIC3R_GUI_SOURCES}) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 0ffdd576f..87f58aa1a 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -34,6 +34,7 @@ #include "../Utils/PresetUpdater.hpp" #include "../Utils/PrintHost.hpp" +#include "../Utils/MacDarkMode.hpp" #include "ConfigWizard.hpp" #include "slic3r/Config/Snapshot.hpp" #include "ConfigSnapshotDialog.hpp" @@ -284,10 +285,24 @@ unsigned GUI_App::get_colour_approx_luma(const wxColour &colour) )); } +bool GUI_App::dark_mode() +{ + const unsigned luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + return luma < 128; +} + +bool GUI_App::dark_mode_menus() +{ +#if __APPLE__ + return mac_dark_mode(); +#else + return dark_mode(); +#endif +} + void GUI_App::init_label_colours() { - auto luma = get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - if (luma >= 128) { + if (dark_mode()) { m_color_label_modified = wxColour(252, 77, 1); m_color_label_sys = wxColour(26, 132, 57); } diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index d3c9e0afa..5ee0c1509 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -94,7 +94,9 @@ public: GUI_App(); - unsigned get_colour_approx_luma(const wxColour &colour); + static unsigned get_colour_approx_luma(const wxColour &colour); + static bool dark_mode(); + static bool dark_mode_menus(); void init_label_colours(); void update_label_colours_from_appconfig(); void init_fonts(); diff --git a/src/slic3r/Utils/MacDarkMode.hpp b/src/slic3r/Utils/MacDarkMode.hpp new file mode 100644 index 000000000..cfdc02888 --- /dev/null +++ b/src/slic3r/Utils/MacDarkMode.hpp @@ -0,0 +1,15 @@ +#ifndef slic3r_MacDarkMode_hpp_ +#define slic3r_MacDarkMode_hpp_ + +namespace Slic3r { +namespace GUI { + +#if __APPLE__ +extern bool mac_dark_mode(); +#endif + + +} // namespace GUI +} // namespace Slic3r + +#endif // MacDarkMode_h diff --git a/src/slic3r/Utils/MacDarkMode.mm b/src/slic3r/Utils/MacDarkMode.mm new file mode 100644 index 000000000..4177ee371 --- /dev/null +++ b/src/slic3r/Utils/MacDarkMode.mm @@ -0,0 +1,22 @@ +#import "MacDarkMode.hpp" + +#import + + +@implementation MacDarkMode + +namespace Slic3r { +namespace GUI { + +bool mac_dark_mode() +{ + NSString *style = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; + return style && [style isEqualToString:@"Dark"]; + +} + + +} +} + +@end