NEW:added dark mode

Change-Id: I3f61f1d93020e0a9dfba2c7d6cf6bf5194effcfa
This commit is contained in:
tao wang 2022-11-04 11:28:05 +08:00 committed by Lane.Wei
parent 6ae575d885
commit 6f4e80bbb6
78 changed files with 2021 additions and 398 deletions

View file

@ -15,6 +15,7 @@ AMSMaterialsSetting::AMSMaterialsSetting(wxWindow *parent, wxWindowID id)
: DPIDialog(parent, id, _L("AMS Materials Setting"), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
{
create();
wxGetApp().UpdateDlgDarkUI(this);
}
void AMSMaterialsSetting::create()
@ -63,12 +64,13 @@ void AMSMaterialsSetting::create()
m_clrData->SetChooseFull(true);
m_clrData->SetChooseAlpha(false);
m_clr_picker = new Button(this, "", "");
m_clr_picker = new wxButton(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,wxBU_AUTODRAW);
m_clr_picker->SetCanFocus(false);
m_clr_picker->SetSize(FromDIP(50), FromDIP(25));
m_clr_picker->SetMinSize(wxSize(FromDIP(50), FromDIP(25)));
m_clr_picker->SetCornerRadius(FromDIP(6));
m_clr_picker->SetBorderColor(wxColour(172, 172, 172));
//m_clr_picker->SetCornerRadius(FromDIP(6));
//m_clr_picker->SetBorderColor(wxColour(172, 172, 172));
m_clr_picker->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
m_clr_picker->Bind(wxEVT_BUTTON, &AMSMaterialsSetting::on_clr_picker, this);
m_sizer_colour->Add(m_clr_picker, 0, 0, 0);
@ -197,7 +199,7 @@ void AMSMaterialsSetting::create()
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
m_button_confirm->SetBackgroundColor(m_btn_bg_green);
m_button_confirm->SetBorderColor(wxColour(0, 174, 66));
m_button_confirm->SetTextColor(AMS_MATERIALS_SETTING_GREY200);
m_button_confirm->SetTextColor(wxColour("#FFFFFE"));
m_button_confirm->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
m_button_confirm->SetCornerRadius(FromDIP(12));
m_button_confirm->Bind(wxEVT_BUTTON, &AMSMaterialsSetting::on_select_ok, this);
@ -233,16 +235,16 @@ void AMSMaterialsSetting::create()
SetSizer(m_sizer_main);
Layout();
Fit();
Bind(wxEVT_PAINT, &AMSMaterialsSetting::paintEvent, this);
COMBOBOX_FILAMENT->Connect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(AMSMaterialsSetting::on_select_filament), NULL, this);
Bind(wxEVT_PAINT, &AMSMaterialsSetting::paintEvent, this);
COMBOBOX_FILAMENT->Connect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(AMSMaterialsSetting::on_select_filament), NULL, this);
}
void AMSMaterialsSetting::paintEvent(wxPaintEvent &evt)
{
auto size = GetSize();
wxPaintDC dc(this);
dc.SetPen(wxPen(wxColour(38, 46, 48), 1, wxSOLID));
dc.SetPen(wxPen(StateColor::darkModeColorFor(wxColour(38, 46, 48)), 1, wxSOLID));
dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
dc.DrawRectangle(0, 0, size.x, size.y);
}
@ -363,7 +365,7 @@ void AMSMaterialsSetting::on_clr_picker(wxCommandEvent & event)
show_flag = true;
if (clr_dialog->ShowModal() == wxID_OK) {
m_clrData = &(clr_dialog->GetColourData());
m_clr_picker->SetBackgroundColor(m_clrData->GetColour());
m_clr_picker->SetBackgroundColour(m_clrData->GetColour());
}
}
@ -379,7 +381,7 @@ bool AMSMaterialsSetting::Show(bool show)
void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_min, wxString temp_max)
{
m_clr_picker->SetBackgroundColor(m_clrData->GetColour());
m_clr_picker->SetBackgroundColour(m_clrData->GetColour());
if (!m_is_third) {
m_button_confirm->Hide();

View file

@ -83,7 +83,7 @@ protected:
Button * m_button_confirm;
wxStaticText* m_tip_readonly;
Button * m_button_close;
Button * m_clr_picker;
wxButton * m_clr_picker;
wxColourData * m_clrData;
#ifdef __APPLE__
wxComboBox *m_comboBox_filament_mac;

View file

@ -1,4 +1,5 @@
#include "AMSSetting.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
namespace Slic3r { namespace GUI {
@ -7,6 +8,7 @@ AMSSetting::AMSSetting(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
: DPIDialog(parent, id, wxEmptyString, pos, size, style)
{
create();
wxGetApp().UpdateDlgDarkUI(this);
}
AMSSetting::~AMSSetting() {}
@ -14,13 +16,16 @@ void AMSSetting::create()
{
wxBoxSizer *m_sizer_main;
m_sizer_main = new wxBoxSizer(wxVERTICAL);
SetBackgroundColour(*wxWHITE);
auto m_static_ams_settings = new wxStaticText(this, wxID_ANY, _L("AMS Settings"), wxDefaultPosition, wxDefaultSize, 0);
m_static_ams_settings->SetFont(::Label::Head_14);
m_static_ams_settings->SetForegroundColour(AMS_SETTING_GREY800);
m_sizer_main->Add(0,0,0,wxTOP,FromDIP(10));
m_sizer_main->Add(m_static_ams_settings, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(24));
m_panel_body = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxTAB_TRAVERSAL);
m_panel_body->SetBackgroundColour(*wxWHITE);
wxBoxSizer *m_sizerl_body;
m_sizerl_body = new wxBoxSizer(wxVERTICAL);
@ -188,6 +193,7 @@ void AMSSetting::create()
m_sizer_main->Fit(this);
this->Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
void AMSSetting::update_insert_material_read_mode(bool selected)

View file

@ -214,9 +214,7 @@ AboutDialog::AboutDialog()
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE)
{
SetFont(wxGetApp().normal_font());
wxColour bgr_clr = wxGetApp().get_window_default_clr();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
SetBackgroundColour(bgr_clr);
SetBackgroundColour(*wxWHITE);
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
@ -259,8 +257,8 @@ AboutDialog::AboutDialog()
#endif
version_font.SetPointSize(FromDIP(16));
version->SetFont(version_font);
version->SetForegroundColour(wxColour(255, 255, 255));
version->SetBackgroundColour(wxColour(0, 174, 66));
version->SetForegroundColour(wxColour("#FFFFFE"));
version->SetBackgroundColour(wxColour("#00AF42"));
vesizer->Add(version, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, FromDIP(5));
vesizer->Add(0, 0, 1, wxEXPAND, FromDIP(5));
}
@ -282,6 +280,7 @@ AboutDialog::AboutDialog()
{
auto staticText = new wxStaticText( this, wxID_ANY, wxEmptyString,wxDefaultPosition,wxSize(FromDIP(520), -1), wxALIGN_LEFT );
staticText->SetForegroundColour(wxColour(107, 107, 107));
staticText->SetBackgroundColour(*wxWHITE);
staticText->SetMinSize(wxSize(FromDIP(520), -1));
staticText->SetFont(Label::Body_12);
if (is_zh) {
@ -366,6 +365,7 @@ AboutDialog::AboutDialog()
ver_sizer->Add( 0, 0, 0, wxTOP, FromDIP(30));
button_portions->Bind(wxEVT_BUTTON, &AboutDialog::onCopyrightBtn, this);
wxGetApp().UpdateDlgDarkUI(this);
SetSizer(main_sizer);
Layout();
Fit();
@ -393,7 +393,6 @@ void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
SetMinSize(size);
Fit();
Refresh();
}

View file

@ -42,6 +42,7 @@ wxDEFINE_EVENT(EVT_SET_FINISH_MAPPING, wxCommandEvent);
SetBackgroundColour(*wxWHITE);
Bind(wxEVT_PAINT, &MaterialItem::paintEvent, this);
wxGetApp().UpdateDarkUI(this);
}
MaterialItem::~MaterialItem() {}
@ -482,7 +483,7 @@ void AmsMapingPopup::paintEvent(wxPaintEvent &evt)
#ifdef __WINDOWS__
SetDoubleBuffered(true);
#endif //__WINDOWS__
SetBackgroundColour(*wxWHITE);
SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
Bind(wxEVT_PAINT, &MappingItem::paintEvent, this);
}

View file

@ -52,7 +52,7 @@ AuFile::AuFile(wxWindow *parent, fs::path file_path, wxString file_name, Auxilia
wxSize panel_size = m_type == MODEL_PICTURE ? AUFILE_PICTURES_PANEL_SIZE : AUFILE_PANEL_SIZE;
wxPanel::Create(parent, id, pos, panel_size, style);
SetBackgroundColour(AUFILE_GREY300);
SetBackgroundColour(StateColor::darkModeColorFor(AUFILE_GREY300));
wxBoxSizer *sizer_body = new wxBoxSizer(wxVERTICAL);
SetSize(panel_size);
@ -102,12 +102,14 @@ AuFile::AuFile(wxWindow *parent, fs::path file_path, wxString file_name, Auxilia
auto m_text_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(panel_size.x, AUFILE_TEXT_HEIGHT), wxTAB_TRAVERSAL);
m_text_panel->SetBackgroundColour(AUFILE_GREY300);
m_text_panel->SetBackgroundColour(StateColor::darkModeColorFor(AUFILE_GREY300));
wxBoxSizer *m_text_sizer = new wxBoxSizer(wxHORIZONTAL);
m_text_name = new wxStaticText(m_text_panel, wxID_ANY, m_file_name, wxDefaultPosition, wxSize(panel_size.x, -1), wxST_ELLIPSIZE_END);
m_text_name->Wrap(panel_size.x - FromDIP(10));
m_text_name->SetFont(::Label::Body_14);
m_text_name->SetForegroundColour(StateColor::darkModeColorFor(*wxBLACK));
m_input_name = new ::TextInput(m_text_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxSize(panel_size.x - FromDIP(28), FromDIP(32)), wxTE_PROCESS_ENTER);
m_input_name->GetTextCtrl()->SetFont(::Label::Body_13);
@ -205,7 +207,7 @@ void AuFile::PaintBackground(wxDC &dc)
{
auto pen_width = FromDIP(2);
dc.SetPen(wxPen(AUFILE_GREY500, pen_width));
dc.SetBrush(AUFILE_GREY200);
dc.SetBrush(StateColor::darkModeColorFor(AUFILE_GREY200));
dc.DrawRoundedRectangle(pen_width / 2, pen_width / 2, size.x - pen_width / 2, size.y - pen_width / 2, AUFILE_ROUNDING);
auto line_length = FromDIP(50);
@ -238,7 +240,7 @@ void AuFile::PaintForeground(wxDC &dc)
if (m_type == AddFileButton) {
auto pen_width = FromDIP(2);
dc.SetPen(wxPen(AUFILE_BRAND, pen_width));
dc.SetBrush(AUFILE_BRAND_TRANSPARENT);
dc.SetBrush(StateColor::darkModeColorFor(AUFILE_BRAND_TRANSPARENT));
dc.DrawRoundedRectangle(pen_width / 2, pen_width / 2, size.x - pen_width / 2, size.y - pen_width / 2, AUFILE_ROUNDING);
auto line_length = FromDIP(50);
@ -818,7 +820,7 @@ void AuxiliaryPanel::init_tabpanel()
wxBoxSizer *sizer_side_tools = new wxBoxSizer(wxVERTICAL);
sizer_side_tools->Add(m_side_tools, 1, wxEXPAND, 0);
m_tabpanel = new Tabbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, sizer_side_tools, wxNB_LEFT | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
m_tabpanel->SetBackgroundColour(*wxWHITE);
m_tabpanel->SetBackgroundColour(wxColour("#FEFFFF"));
m_tabpanel->Bind(wxEVT_BOOKCTRL_PAGE_CHANGED, [this](wxBookCtrlEvent &e) { ; });
m_designer_panel = new DesignerPanel(m_tabpanel, AuxiliaryFolderType::DESIGNER);

View file

@ -42,10 +42,12 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
m_sizer_bottom->Add(m_prog, 1, wxALIGN_CENTER, 0);
StateColor btn_bd_white(std::pair<wxColour, int>(*wxWHITE, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
m_cancelbutton = new Button(m_self, _L("Cancel"));
m_cancelbutton->SetMinSize(wxSize(m_self->FromDIP(64), m_self->FromDIP(24)));
m_cancelbutton->SetTextColor(wxColour(107, 107, 107));
m_cancelbutton->SetBackgroundColor(wxColour(255, 255, 255));
m_cancelbutton->SetBorderColor(btn_bd_white);
m_cancelbutton->SetCornerRadius(m_self->FromDIP(12));
m_cancelbutton->Bind(wxEVT_BUTTON,
[this](wxCommandEvent &evt) {

View file

@ -139,7 +139,7 @@ void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const Co
main_sizer->Add(m_panel, 1, wxEXPAND);
main_sizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, 10);
wxGetApp().UpdateDlgDarkUI(this, true);
wxGetApp().UpdateDlgDarkUI(this);
SetSizer(main_sizer);
SetMinSize(GetSize());
@ -200,7 +200,7 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
Line line{ "", "" };
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
wxButton* shape_btn = new wxButton(parent, wxID_ANY, _L("Load shape from STL..."));
Button* shape_btn = new Button(parent, _L("Load shape from STL..."));
wxSizer* shape_sizer = new wxBoxSizer(wxHORIZONTAL);
shape_sizer->Add(shape_btn, 1, wxEXPAND);
@ -269,7 +269,7 @@ void BedShapePanel::activate_options_page(ConfigOptionsGroupShp options_group)
wxPanel* BedShapePanel::init_texture_panel()
{
wxPanel* panel = new wxPanel(this);
wxGetApp().UpdateDarkUI(panel, true);
panel->SetBackgroundColour(*wxWHITE);
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(panel, _L("Texture"));
optgroup->label_width = 10;
@ -280,7 +280,17 @@ wxPanel* BedShapePanel::init_texture_panel()
Line line{ "", "" };
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
wxButton* load_btn = new wxButton(parent, wxID_ANY, _L("Load..."));
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
StateColor btn_bd_white(std::pair<wxColour, int>(*wxWHITE, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
Button* load_btn = new Button(parent, _L("Load..."));
load_btn->SetBackgroundColor(btn_bg_white);
load_btn->SetBorderColor(btn_bd_white);
load_btn->SetBackgroundColour(*wxWHITE);
wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
load_sizer->Add(load_btn, 1, wxEXPAND);
@ -289,10 +299,16 @@ wxPanel* BedShapePanel::init_texture_panel()
wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL);
filename_sizer->Add(filename_lbl, 1, wxEXPAND);
wxButton* remove_btn = new wxButton(parent, wxID_ANY, _L("Remove"));
Button* remove_btn = new Button(parent, _L("Remove"));
remove_btn->SetBackgroundColor(btn_bg_white);
remove_btn->SetBorderColor(btn_bd_white);
remove_btn->SetBackgroundColour(*wxWHITE);
wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
remove_sizer->Add(remove_btn, 1, wxEXPAND);
wxGetApp().UpdateDarkUI(load_btn);
wxGetApp().UpdateDarkUI(remove_btn);
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(filename_sizer, 1, wxEXPAND);
sizer->Add(load_sizer, 1, wxEXPAND);
@ -340,7 +356,7 @@ wxPanel* BedShapePanel::init_texture_panel()
wxPanel* BedShapePanel::init_model_panel()
{
wxPanel* panel = new wxPanel(this);
wxGetApp().UpdateDarkUI(panel, true);
panel->SetBackgroundColour(*wxWHITE);
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(panel, _L("Model"));
optgroup->label_width = 10;
@ -348,10 +364,21 @@ wxPanel* BedShapePanel::init_model_panel()
update_shape();
};
Line line{ "", "" };
line.full_width = 1;
line.widget = [this](wxWindow* parent) {
wxButton* load_btn = new wxButton(parent, wxID_ANY, _L("Load..."));
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Disabled), std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
StateColor btn_bd_white(std::pair<wxColour, int>(*wxWHITE, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
Button* load_btn = new Button(parent, _L("Load..."));
load_btn->SetBackgroundColor(btn_bg_white);
load_btn->SetBorderColor(btn_bd_white);
load_btn->SetBackgroundColour(*wxWHITE);
wxSizer* load_sizer = new wxBoxSizer(wxHORIZONTAL);
load_sizer->Add(load_btn, 1, wxEXPAND);
@ -359,10 +386,16 @@ wxPanel* BedShapePanel::init_model_panel()
wxSizer* filename_sizer = new wxBoxSizer(wxHORIZONTAL);
filename_sizer->Add(filename_lbl, 1, wxEXPAND);
wxButton* remove_btn = new wxButton(parent, wxID_ANY, _L("Remove"));
Button* remove_btn = new Button(parent, _L("Remove"));
remove_btn->SetBackgroundColor(btn_bg_white);
remove_btn->SetBorderColor(btn_bd_white);
remove_btn->SetBackgroundColour(*wxWHITE);
wxSizer* remove_sizer = new wxBoxSizer(wxHORIZONTAL);
remove_sizer->Add(remove_btn, 1, wxEXPAND);
wxGetApp().UpdateDarkUI(load_btn);
wxGetApp().UpdateDarkUI(remove_btn);
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(filename_sizer, 1, wxEXPAND);
sizer->Add(load_sizer, 1, wxEXPAND);

View file

@ -38,6 +38,7 @@ namespace GUI {
wxBoxSizer *m_sizere_left_v= new wxBoxSizer(wxVERTICAL);
auto m_printer_img = new wxStaticBitmap(m_panel_left, wxID_ANY, create_scaled_bitmap("printer_thumbnail", nullptr, 96), wxDefaultPosition, wxSize(FromDIP(100), FromDIP(96)), 0);
m_printer_img->SetBackgroundColour(BIND_DIALOG_GREY200);
m_printer_name = new wxStaticText(m_panel_left, wxID_ANY, wxEmptyString);
m_printer_name->SetBackgroundColour(BIND_DIALOG_GREY200);
m_printer_name->SetFont(::Label::Head_14);
@ -133,7 +134,7 @@ namespace GUI {
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
m_button_bind->SetBackgroundColor(btn_bg_green);
m_button_bind->SetBorderColor(wxColour(0, 174, 66));
m_button_bind->SetTextColor(*wxWHITE);
m_button_bind->SetTextColor(wxColour("#FFFFFE"));
m_button_bind->SetSize(BIND_DIALOG_BUTTON_SIZE);
m_button_bind->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
m_button_bind->SetCornerRadius(FromDIP(12));
@ -182,6 +183,8 @@ namespace GUI {
this->Connect(EVT_BIND_MACHINE_SUCCESS, wxCommandEventHandler(BindMachineDialog::on_bind_success), NULL, this);
this->Connect(EVT_BIND_UPDATE_MESSAGE, wxCommandEventHandler(BindMachineDialog::on_update_message), NULL, this);
m_simplebook->SetSelection(1);
wxGetApp().UpdateDlgDarkUI(this);
}
BindMachineDialog::~BindMachineDialog()
@ -299,8 +302,8 @@ UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
wxBoxSizer *m_sizere_left_h = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *m_sizere_left_v= new wxBoxSizer(wxVERTICAL);
auto m_printer_img = new wxStaticBitmap(m_panel_left, wxID_ANY, create_scaled_bitmap("printer_thumbnail", nullptr, 96), wxDefaultPosition, wxSize(FromDIP(100), FromDIP(96)),
0);
auto m_printer_img = new wxStaticBitmap(m_panel_left, wxID_ANY, create_scaled_bitmap("printer_thumbnail", nullptr, 96), wxDefaultPosition, wxSize(FromDIP(100), FromDIP(96)),0);
m_printer_img->SetBackgroundColour(BIND_DIALOG_GREY200);
m_printer_name = new wxStaticText(m_panel_left, wxID_ANY, wxEmptyString);
m_printer_name->SetFont(::Label::Head_14);
m_printer_name->SetBackgroundColour(BIND_DIALOG_GREY200);
@ -392,7 +395,7 @@ UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
m_button_unbind->SetBackgroundColor(btn_bg_green);
m_button_unbind->SetBorderColor(wxColour(0, 174, 66));
m_button_unbind->SetTextColor(*wxWHITE);
m_button_unbind->SetTextColor(wxColour("#FFFFFE"));
m_button_unbind->SetSize(BIND_DIALOG_BUTTON_SIZE);
m_button_unbind->SetMinSize(BIND_DIALOG_BUTTON_SIZE);
m_button_unbind->SetCornerRadius(FromDIP(12));
@ -426,6 +429,7 @@ UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
Bind(wxEVT_SHOW, &UnBindMachineDialog::on_show, this);
m_button_unbind->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_unbind_printer), NULL, this);
m_button_cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(UnBindMachineDialog::on_cancel), NULL, this);
wxGetApp().UpdateDlgDarkUI(this);
}
UnBindMachineDialog::~UnBindMachineDialog()

View file

@ -326,6 +326,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
replaces["\"#262E30\""] = "\"#EFEFF0\"";
replaces["\"#323A3D\""] = "\"#B3B3B5\"";
replaces["\"#808080\""] = "\"#818183\"";
//replaces["\"#ACACAC\""] = "\"#54545A\"";
replaces["\"#CECECE\""] = "\"#54545B\"";
replaces["\"#6B6B6B\""] = "\"#818182\"";
}
//if (!new_color.empty())
// replaces["\"#ED6B21\""] = "\"" + new_color + "\"";

View file

@ -17,13 +17,13 @@
#include <wx/listbook.h>
#include <wx/window.h>
#ifdef _WIN32
#ifdef __WINDOWS__
#include <wx/msw/dcclient.h>
#include <wx/msw/private.h>
#ifdef _MSW_DARK_MODE
#include <wx/msw/dark_mode.h>
#include "dark_mode.hpp"
#endif //_MSW_DARK_MODE
#endif
#endif //__WINDOWS__
#include "libslic3r/libslic3r.h"
#include "libslic3r/PrintConfig.hpp"
@ -254,11 +254,11 @@ void BitmapComboBox::DrawBackground_(wxDC& dc, const wxRect& rect, int WXUNUSED(
dc.SetTextForeground(flags & ODCB_PAINTING_DISABLED ? wxColour(108,108,108) : wxGetApp().get_label_clr_default());
wxColour selCol = flags & ODCB_PAINTING_DISABLED ?
#ifdef _MSW_DARK_MODE
wxRGBToColour(NppDarkMode::GetSofterBackgroundColor()) :
#else
//#ifdef _MSW_DARK_MODE
//wxRGBToColour(NppDarkMode::GetSofterBackgroundColor()) :
//#else
wxGetApp().get_highlight_default_clr() :
#endif
//#endif
wxGetApp().get_window_default_clr();
dc.SetPen(selCol);
dc.SetBrush(selCol);

View file

@ -147,7 +147,7 @@ CalibrationDialog::CalibrationDialog(Plater *plater)
m_calibration_btn = new Button(cali_right_panel, _L("Start Calibration"));
m_calibration_btn->SetBackgroundColor(btn_bg_green);
m_calibration_btn->SetBorderColor(btn_bd_green);
m_calibration_btn->SetTextColor(*wxWHITE);
m_calibration_btn->SetTextColor(wxColour("#FFFFFE"));
m_calibration_btn->SetSize(wxSize(FromDIP(128), FromDIP(26)));
m_calibration_btn->SetMinSize(wxSize(FromDIP(128), FromDIP(26)));
@ -174,6 +174,7 @@ CalibrationDialog::CalibrationDialog(Plater *plater)
Fit();
m_calibration_btn->Bind(wxEVT_LEFT_DOWN, &CalibrationDialog::on_start_calibration, this);
wxGetApp().UpdateDlgDarkUI(this);
}
CalibrationDialog::~CalibrationDialog() {}

View file

@ -345,9 +345,14 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
if (titles.size() > 1 || is_variants) {
// It only makes sense to add the All / None buttons if there's multiple printers
// All Standard button is added when there are more variants for at least one printer
auto *sel_all_std = new wxButton(this, wxID_ANY, titles.size() > 1 ? _L("All standard") : _L("Standard"));
auto *sel_all = new wxButton(this, wxID_ANY, _L("All"));
auto *sel_none = new wxButton(this, wxID_ANY, _L("None"));
auto *sel_all_std = new Button(this, titles.size() > 1 ? _L("All standard") : _L("Standard"));
auto *sel_all = new Button(this, _L("All"));
auto *sel_none = new Button(this, _L("None"));
wxGetApp().UpdateDarkUI(sel_all_std);
wxGetApp().UpdateDarkUI(sel_all);
wxGetApp().UpdateDarkUI(sel_none);
if (is_variants)
sel_all_std->Bind(wxEVT_BUTTON, [this](const wxCommandEvent& event) { this->select_all(true, false); });
sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true, true); });
@ -450,13 +455,12 @@ ConfigWizardPage::ConfigWizardPage(ConfigWizard *parent, wxString title, wxStrin
, shortname(std::move(shortname))
, indent(indent)
{
wxGetApp().UpdateDarkUI(this);
auto *sizer = new wxBoxSizer(wxVERTICAL);
auto *text = new wxStaticText(this, wxID_ANY, std::move(title), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
const auto font = GetFont().MakeBold().Scaled(1.5);
text->SetFont(font);
text->SetForegroundColour(*wxBLACK);
sizer->Add(text, 0, wxALIGN_LEFT, 0);
sizer->AddSpacer(10);
@ -474,6 +478,8 @@ ConfigWizardPage::ConfigWizardPage(ConfigWizard *parent, wxString title, wxStrin
this->Layout();
event.Skip();
});
wxGetApp().UpdateDarkUI(this);
}
ConfigWizardPage::~ConfigWizardPage() {}
@ -640,6 +646,7 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
, list_vendor(new StringList(this))
, list_profile(new PresetList(this))
{
SetBackgroundColour(*wxWHITE);
append_spacer(VERTICAL_SPACING);
const int em = parent->em_unit();
@ -651,8 +658,6 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
list_vendor->SetMinSize(wxSize(13*em, list_h));
list_profile->SetMinSize(wxSize(23*em, list_h));
grid = new wxFlexGridSizer(4, em/2, em);
grid->AddGrowableCol(3, 1);
grid->AddGrowableRow(1, 1);
@ -668,8 +673,13 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
grid->Add(list_profile, 1, wxEXPAND);
auto *btn_sizer = new wxBoxSizer(wxHORIZONTAL);
auto *sel_all = new wxButton(this, wxID_ANY, _L("All"));
auto *sel_none = new wxButton(this, wxID_ANY, _L("None"));
auto *sel_all = new Button(this, _L("All"));
auto *sel_none = new Button(this, _L("None"));
wxGetApp().UpdateDarkUI(sel_all);
wxGetApp().UpdateDarkUI(sel_none);
btn_sizer->Add(sel_all, 0, wxRIGHT, em / 2);
btn_sizer->Add(sel_none);
@ -678,6 +688,7 @@ PageMaterials::PageMaterials(ConfigWizard *parent, Materials *materials, wxStrin
wxGetApp().UpdateDarkUI(list_vendor);
wxGetApp().UpdateDarkUI(sel_all);
wxGetApp().UpdateDarkUI(sel_none);
wxGetApp().UpdateDarkUI(list_profile);
grid->Add(new wxBoxSizer(wxHORIZONTAL));
grid->Add(new wxBoxSizer(wxHORIZONTAL));
@ -756,16 +767,16 @@ void PageMaterials::reload_presets()
void PageMaterials::set_compatible_printers_html_window(const std::vector<std::string>& printer_names, bool all_printers)
{
const auto bgr_clr =
#if defined(__APPLE__)
html_window->GetParent()->GetBackgroundColour();
#else
#if defined(_WIN32)
wxGetApp().get_window_default_clr();
#else
wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
#endif
#endif
const auto bgr_clr = html_window->GetParent()->GetBackgroundColour();
//#if defined(__APPLE__)
// html_window->GetParent()->GetBackgroundColour();
//#else
//#if defined(_WIN32)
// html_window->GetParent()->GetBackgroundColour();
//#else
// wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
//#endif
//#endif
const auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
const auto text_clr = wxGetApp().get_label_clr_default();//wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
const auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
@ -1049,7 +1060,7 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
sel_vendor_prev = sel_vendor;
}
wxGetApp().UpdateDarkUI(list_profile);
//wxGetApp().UpdateDarkUI(list_profile);
}
void PageMaterials::sort_list_data(StringList* list, bool add_All_item, bool material_type_ordering)
@ -1219,6 +1230,7 @@ PageCustom::PageCustom(ConfigWizard *parent)
append(cb_custom);
append(label);
append(tc_profile_name);
wxGetApp().UpdateDarkUI(this);
}
PageFirmware::PageFirmware(ConfigWizard *parent)
@ -2640,7 +2652,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
, p(new priv(this))
{
this->SetFont(wxGetApp().normal_font());
SetBackgroundColour(*wxWHITE);
p->load_vendors();
//BBS: add bed exclude areas
p->custom_config.reset(DynamicPrintConfig::new_from_defaults_keys({
@ -2661,14 +2673,19 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
p->hscroll_sizer = new wxBoxSizer(wxHORIZONTAL);
p->hscroll->SetSizer(p->hscroll_sizer);
wxGetApp().UpdateDarkUI(p->hscroll);
topsizer->Add(p->index, 0, wxEXPAND);
topsizer->AddSpacer(INDEX_MARGIN);
topsizer->Add(p->hscroll, 1, wxEXPAND);
p->btn_prev = new wxButton(this, wxID_ANY, _L("< &Back"));
p->btn_next = new wxButton(this, wxID_ANY, _L("&Next >"));
p->btn_finish = new wxButton(this, wxID_APPLY, _L("&Finish"));
p->btn_cancel = new wxButton(this, wxID_CANCEL, _L("Cancel")); // Note: The label needs to be present, otherwise we get accelerator bugs on Mac
p->btn_prev = new Button(this, _L("<Back"));
p->btn_next = new Button(this, _L("Next>"));
p->btn_finish = new Button(this,_L("Finish"));
p->btn_finish->SetId(wxID_APPLY);
p->btn_cancel = new Button(this, _L("Cancel")); // Note: The label needs to be present, otherwise we get accelerator bugs on Mac
p->btn_cancel->SetId(wxID_CANCEL);
p->btnsizer->AddStretchSpacer();
p->btnsizer->Add(p->btn_prev, 0, wxLEFT, BTN_SPACING);
p->btnsizer->Add(p->btn_next, 0, wxLEFT, BTN_SPACING);
@ -2747,6 +2764,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent)
this->Bind(wxEVT_SHOW, [this, vsizer](const wxShowEvent& e) {
;
});
wxGetApp().UpdateDlgDarkUI(this);
}
ConfigWizard::~ConfigWizard() {}

View file

@ -27,6 +27,7 @@
#include "BedShapeDialog.hpp"
#include "GUI.hpp"
#include "wxExtensions.hpp"
#include "Widgets/Button.hpp"
namespace fs = boost::filesystem;
@ -549,10 +550,10 @@ struct ConfigWizard::priv
ConfigWizardPage *page_current = nullptr;
ConfigWizardIndex *index = nullptr;
//wxButton *btn_sel_all = nullptr;
wxButton *btn_prev = nullptr;
wxButton *btn_next = nullptr;
wxButton *btn_finish = nullptr;
wxButton *btn_cancel = nullptr;
Button *btn_prev = nullptr;
Button *btn_next = nullptr;
Button *btn_finish = nullptr;
Button *btn_cancel = nullptr;
//PagePrinters *page_fff = nullptr;
//PagePrinters *page_msla = nullptr;

View file

@ -1,4 +1,5 @@
#include "ConnectPrinter.hpp"
#include "GUI_App.hpp"
#include <slic3r/GUI/I18N.hpp>
#include <slic3r/GUI/Widgets/Label.hpp>
#include "libslic3r/AppConfig.hpp"
@ -8,7 +9,7 @@ ConnectPrinterDialog::ConnectPrinterDialog(wxWindow *parent, wxWindowID id, cons
: DPIDialog(parent, id, _L("ConnectPrinter(LAN)"), pos, size, style)
{
init_bitmap();
SetBackgroundColour(*wxWHITE);
this->SetSizeHints(wxDefaultSize, wxDefaultSize);
wxBoxSizer *main_sizer;
@ -50,6 +51,7 @@ ConnectPrinterDialog::ConnectPrinterDialog(wxWindow *parent, wxWindowID id, cons
m_button_confirm->SetFont(Label::Body_12);
m_button_confirm->SetMinSize(wxSize(-1, FromDIP(24)));
m_button_confirm->SetCornerRadius(FromDIP(12));
m_button_confirm->SetTextColor(wxColour("#FFFFFE"));
StateColor btn_bg(
std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed),
@ -101,6 +103,7 @@ ConnectPrinterDialog::ConnectPrinterDialog(wxWindow *parent, wxWindowID id, cons
m_textCtrl_code->Bind(wxEVT_TEXT, &ConnectPrinterDialog::on_input_enter, this);
m_button_confirm->Bind(wxEVT_BUTTON, &ConnectPrinterDialog::on_button_confirm, this);
wxGetApp().UpdateDlgDarkUI(this);
}
ConnectPrinterDialog::~ConnectPrinterDialog() {}

View file

@ -114,6 +114,7 @@ DownloadProgressDialog::DownloadProgressDialog(wxString title)
CentreOnParent();
Bind(wxEVT_CLOSE_WINDOW, &DownloadProgressDialog::on_close, this);
wxGetApp().UpdateDlgDarkUI(this);
}
wxString DownloadProgressDialog::format_text(wxStaticText* st, wxString str, int warp)

View file

@ -98,9 +98,13 @@
#ifdef __WXMSW__
#include <dbt.h>
#include <shlobj.h>
#ifdef __WINDOWS__
#ifdef _MSW_DARK_MODE
#include <wx/msw/dark_mode.h>
#include "dark_mode.hpp"
#endif // _MSW_DARK_MODE
#endif // __WINDOWS__
#endif
#ifdef _WIN32
#include <boost/dll/runtime_symbol_info.hpp>
@ -2089,16 +2093,39 @@ bool GUI_App::on_init_inner()
// If load_language() fails, the application closes.
load_language(wxString(), true);
#ifdef SUPPORT_DARK_MODE
#ifdef _MSW_DARK_MODE
NppDarkMode::InitDarkMode(app_config->get("dark_color_mode") == "1", app_config->get("sys_menu_enabled") == "1");
#endif
bool init_dark_color_mode = app_config->get("dark_color_mode") == "1";
bool init_sys_menu_enabled = app_config->get("sys_menu_enabled") == "1";
#ifdef __WINDOWS__
NppDarkMode::InitDarkMode(init_dark_color_mode, init_sys_menu_enabled);
#endif // __WINDOWS__
#endif
// initialize label colors and fonts
init_label_colours();
init_fonts();
#ifdef _MSW_DARK_MODE
// app_config can be updated in check_older_app_config(), so check if dark_color_mode and sys_menu_enabled was changed
if (bool new_dark_color_mode = app_config->get("dark_color_mode") == "1";
init_dark_color_mode != new_dark_color_mode) {
#ifdef __WINDOWS__
NppDarkMode::SetDarkMode(new_dark_color_mode);
#endif // __WINDOWS__
init_label_colours();
//update_label_colours_from_appconfig();
}
if (bool new_sys_menu_enabled = app_config->get("sys_menu_enabled") == "1";
init_sys_menu_enabled != new_sys_menu_enabled)
#ifdef __WINDOWS__
NppDarkMode::SetSystemMenuForApp(new_sys_menu_enabled);
#endif
#endif
if (m_last_config_version) {
int last_major = m_last_config_version->maj();
int last_minor = m_last_config_version->min();
@ -2639,7 +2666,17 @@ void GUI_App::init_label_colours()
void GUI_App::update_label_colours_from_appconfig()
{
;
if (app_config->has("label_clr_sys")) {
auto str = app_config->get("label_clr_sys");
if (str != "")
m_color_label_sys = wxColour(str);
}
if (app_config->has("label_clr_modified")) {
auto str = app_config->get("label_clr_modified");
if (str != "")
m_color_label_modified = wxColour(str);
}
}
void GUI_App::update_label_colours()
@ -2655,81 +2692,79 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
return;
}
#ifdef _WIN32
if (wxButton* btn = dynamic_cast<wxButton*>(window)) {
if (!(btn->GetWindowStyle() & wxNO_BORDER)) {
btn->SetWindowStyle(btn->GetWindowStyle() | wxNO_BORDER);
highlited = true;
}
// hovering for buttons
{
auto focus_button = [this, btn](const bool focus) {
btn->SetForegroundColour(focus ? m_color_hovered_btn_label : m_color_label_default);
btn->Refresh();
btn->Update();
};
if (Button* btn = dynamic_cast<Button*>(window)) {
if (btn->GetWindowStyleFlag() & wxBU_AUTODRAW)
return;
}
btn->Bind(wxEVT_ENTER_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(true); event.Skip(); });
btn->Bind(wxEVT_LEAVE_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(false); event.Skip(); });
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) {
window->SetBackgroundColour(bg_col);
}
original_col = window->GetForegroundColour();
auto fg_col = StateColor::darkModeColorFor(original_col);
if (fg_col != original_col) {
window->SetForegroundColour(fg_col);
}
}
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);
else {
auto original_col = window->GetBackgroundColour();
auto bg_col = StateColor::lightModeColorFor(original_col);
if (!just_font)
window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
window->SetForegroundColour(m_color_label_default);
#endif
if (bg_col != original_col) {
window->SetBackgroundColour(bg_col);
}
original_col = window->GetForegroundColour();
auto fg_col = StateColor::lightModeColorFor(original_col);
if (fg_col != original_col) {
window->SetForegroundColour(fg_col);
}
}
}
// recursive function for scaling fonts for all controls in Window
#ifdef _WIN32
static void update_dark_children_ui(wxWindow* window, bool just_buttons_update = false)
{
bool is_btn = dynamic_cast<wxButton*>(window) != nullptr;
if (!(just_buttons_update && !is_btn))
wxGetApp().UpdateDarkUI(window, is_btn);
/*bool is_btn = dynamic_cast<wxButton*>(window) != nullptr;
is_btn = false;*/
wxGetApp().UpdateDarkUI(window);
auto children = window->GetChildren();
for (auto child : children) {
update_dark_children_ui(child);
}
}
#endif
// Note: Don't use this function for Dialog contains ScalableButtons
void GUI_App::UpdateDlgDarkUI(wxDialog* dlg, bool just_buttons_update/* = false*/)
void GUI_App::UpdateDarkUIWin(wxWindow* win)
{
//BBS disable DarkUI mode
return;
update_dark_children_ui(win);
}
#ifdef _WIN32
update_dark_children_ui(dlg, just_buttons_update);
void GUI_App::UpdateDlgDarkUI(wxDialog* dlg)
{
#ifdef __WINDOWS__
NppDarkMode::SetDarkExplorerTheme(dlg->GetHWND());
NppDarkMode::SetDarkTitleBar(dlg->GetHWND());
#endif
update_dark_children_ui(dlg);
}
void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
{
//BBS disable DarkUI mode
return;
#ifdef _WIN32
#ifdef __WINDOWS__
UpdateDarkUI(dvc, highlited ? dark_mode() : false);
#ifdef _MSW_DARK_MODE
dvc->RefreshHeaderDarkMode(&m_normal_font);
//dvc->RefreshHeaderDarkMode(&m_normal_font);
#endif //_MSW_DARK_MODE
if (dvc->HasFlag(wxDV_ROW_LINES))
dvc->SetAlternateRowColour(m_color_highlight_default);
@ -2740,10 +2775,7 @@ void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
void GUI_App::UpdateAllStaticTextDarkUI(wxWindow* parent)
{
//BBS disable DarkUI mode
return;
#ifdef _WIN32
#ifdef __WINDOWS__
wxGetApp().UpdateDarkUI(parent);
auto children = parent->GetChildren();
@ -3027,8 +3059,7 @@ void fatal_error(wxWindow* parent)
// exit 1; // #ys_FIXME
}
#ifdef _WIN32
#ifdef __WINDOWS__
#ifdef _MSW_DARK_MODE
static void update_scrolls(wxWindow* window)
{
@ -3054,35 +3085,46 @@ void GUI_App::force_menu_update()
NppDarkMode::SetSystemMenuForApp(app_config->get("sys_menu_enabled") == "1");
}
#endif //_MSW_DARK_MODE
#endif //__WINDOWS__
void GUI_App::force_colors_update()
{
#ifdef _MSW_DARK_MODE
#ifdef __WINDOWS__
NppDarkMode::SetDarkMode(app_config->get("dark_color_mode") == "1");
if (WXHWND wxHWND = wxToolTip::GetToolTipCtrl())
NppDarkMode::SetDarkExplorerTheme((HWND)wxHWND);
NppDarkMode::SetDarkTitleBar(mainframe->GetHWND());
//NppDarkMode::SetDarkExplorerTheme((HWND)mainframe->m_settings_dialog.GetHWND());
//NppDarkMode::SetDarkTitleBar(mainframe->m_settings_dialog.GetHWND());
//mainframe->m_settings_dialog.Refresh();
//mainframe->m_settings_dialog.Update();
#endif // __WINDOWS__
#endif //_MSW_DARK_MODE
m_force_colors_update = true;
}
#endif //_WIN32
// 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()
{
update_label_colours();
#ifdef _WIN32
// Upadte UI colors before Update UI from settings
if (m_force_colors_update) {
m_force_colors_update = false;
//UpdateDlgDarkUI(&mainframe->m_settings_dialog);
//mainframe->m_settings_dialog.Refresh();
//mainframe->m_settings_dialog.Update();
#ifdef __WINDOWS__
mainframe->force_color_changed();
mainframe->diff_dialog.force_color_changed();
#ifdef _MSW_DARK_MODE
update_scrolls(mainframe);
update_scrolls(&mainframe->m_settings_dialog);
#endif //_MSW_DARK_MODE
update_dark_children_ui(mainframe);
}
#endif
mainframe->update_ui_from_settings();
}

View file

@ -31,6 +31,11 @@
#define TIMEOUT_CONNECT 15
#define TIMEOUT_RESPONSE 15
#define BE_UNACTED_ON 0x00200001
#ifndef _MSW_DARK_MODE
#define _MSW_DARK_MODE 1
#endif // _MSW_DARK_MODE
class wxMenuItem;
class wxMenuBar;
class wxTopLevelWindow;
@ -220,14 +225,15 @@ private:
bool m_opengl_initialized{ false };
#endif
//#ifdef _WIN32
wxColour m_color_label_modified;
wxColour m_color_label_sys;
wxColour m_color_label_default;
wxColour m_color_window_default;
// BBS
//#ifdef _WIN32
wxColour m_color_highlight_label_default;
wxColour m_color_hovered_btn_label;
wxColour m_color_default_btn_label;
wxColour m_color_highlight_default;
wxColour m_color_selected_btn_bg;
bool m_force_colors_update { false };
@ -274,7 +280,7 @@ private:
boost::thread m_sync_update_thread;
bool enable_sync = false;
bool m_is_dark_mode{ false };
bool m_adding_script_handler { false };
public:
std::string get_local_models_path();
@ -317,8 +323,9 @@ public:
void update_label_colours();
// update color mode for window
void UpdateDarkUI(wxWindow *window, bool highlited = false, bool just_font = false);
void UpdateDarkUIWin(wxWindow* win);
// update color mode for whole dialog including all children
void UpdateDlgDarkUI(wxDialog* dlg, bool just_buttons_update = false);
void UpdateDlgDarkUI(wxDialog* dlg);
// update color mode for DataViewControl
void UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited = false);
// update color mode for panel including all static texts controls

View file

@ -2674,7 +2674,7 @@ ObjectTablePanel::ObjectTablePanel( wxWindow* parent, wxWindowID id, const wxPoi
{
//m_bg_colour = wxColour(0xfa, 0xfa, 0xfa);
m_float_validator.SetRange(0, 100);
m_bg_colour = wxColour(0xff, 0xff, 0xff);
m_bg_colour = wxColour("#FFFFFF");
//m_hover_colour = wxColour(61, 70, 72);
SetBackgroundColour(m_bg_colour);
@ -2854,8 +2854,8 @@ void ObjectTablePanel::load_data()
m_object_grid->SetColLabelValue(ObjectGridTable::col_speed_perimeter, _L("Outer wall speed"));
m_object_grid->SetColLabelValue(ObjectGridTable::col_speed_perimeter_reset, "");
m_object_grid->SetLabelFont(Label::Head_13);
m_object_grid->SetLabelTextColour(wxColour(0x30,0x3a,0x3c));
m_object_grid->SetLabelBackgroundColour(wxColour(0xff, 0xff, 0xff));
m_object_grid->SetLabelTextColour(StateColor::darkModeColorFor(wxColour("#303A3C")));
m_object_grid->SetLabelBackgroundColour( wxColour("#FFFFFF"));
#else
m_object_grid->HideColLabels();
#endif
@ -2866,7 +2866,6 @@ void ObjectTablePanel::load_data()
m_object_grid->EnableDragGridSize(false);
m_object_grid->EnableDragRowSize(false);
/*set the first row as label*/
//format
wxGridCellAttr *attr;
@ -2894,7 +2893,7 @@ void ObjectTablePanel::load_data()
//m_object_grid->SetSelectionForeground(wxColour(0xDB,0xFD,0xE7));
//m_object_grid->SetSelectionBackground(*wxWHITE);
m_object_grid->SetDefaultCellBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
for (int col = 0; col < cols; col++)
{
ObjectGridTable::ObjectGridCol* grid_col = m_object_grid_table->get_grid_col(col);
@ -2907,7 +2906,8 @@ void ObjectTablePanel::load_data()
m_object_grid->SetCellAlignment(row, col, grid_col->horizontal_align, wxALIGN_CENTRE );
m_object_grid->SetCellOverflow(row, col, false);
//m_object_grid->SetCellBackgroundColour (row, col, *wxLIGHT_GREY);
m_object_grid->SetCellBackgroundColour (row, col, *wxWHITE);
m_object_grid->SetCellBackgroundColour (row, col, StateColor::darkModeColorFor(*wxWHITE));
m_object_grid->SetCellTextColour(row, col,StateColor::darkModeColorFor(wxColour(*wxBLACK)));
//set the render and editor
if (grid_col->b_icon) {
m_object_grid->SetCellRenderer(row, col, new GridCellIconRenderer());
@ -3306,6 +3306,7 @@ ObjectTableDialog::ObjectTableDialog(wxWindow* parent, Plater* platerObj, Model
SetSizer(m_main_sizer);
Fit();
Layout();
wxGetApp().UpdateDlgDarkUI(this);
}
ObjectTableDialog::~ObjectTableDialog()

View file

@ -259,12 +259,12 @@ bool check_dark_mode() {
void update_dark_ui(wxWindow* window)
{
#ifdef SUPPORT_DARK_MODE
bool is_dark = wxGetApp().app_config->get("dark_color_mode") == "1";// ? true : check_dark_mode();// #ysDarkMSW - Allow it when we deside to support the sustem colors for application
bool is_dark = wxGetApp().app_config->get("dark_color_mode") == "1";
#else
bool is_dark = false;
#endif
window->SetBackgroundColour(is_dark ? wxColour(43, 43, 43) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
window->SetForegroundColour(is_dark ? wxColour(250, 250, 250) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
//window->SetBackgroundColour(is_dark ? wxColour(43, 43, 43) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
//window->SetForegroundColour(is_dark ? wxColour(250, 250, 250) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
}
#endif

View file

@ -85,37 +85,38 @@ KBShortcutsDialog::KBShortcutsDialog()
event.SetInt(0);
event.SetEventObject(this);
wxPostEvent(this, event);
wxGetApp().UpdateDlgDarkUI(this);
}
void KBShortcutsDialog::OnSelectTabel(wxCommandEvent &event)
{
auto id = event.GetInt();
auto id = event.GetInt();
SelectHash::iterator i = m_hash_selector.begin();
while (i != m_hash_selector.end()) {
Select *sel = i->second;
if (id == sel->m_index) {
sel->m_tab_button->SetBackgroundColour(wxColour(255, 255, 255));
sel->m_tab_text->SetBackgroundColour(wxColour(255, 255, 255));
sel->m_tab_button->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#FFFFFF")));
sel->m_tab_text->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#FFFFFF")));
sel->m_tab_text->SetFont(::Label::Head_13);
sel->m_tab_button->Refresh();
sel->m_tab_text->Refresh();
m_simplebook->SetSelection(id);
} else {
sel->m_tab_button->SetBackgroundColour(wxColour(248, 248, 248));
sel->m_tab_text->SetBackgroundColour(wxColour(248, 248, 248));
sel->m_tab_button->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#F8F8F8")));
sel->m_tab_text->SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#F8F8F8")));
sel->m_tab_text->SetFont(::Label::Body_13);
sel->m_tab_button->Refresh();
sel->m_tab_text->Refresh();
}
i++;
}
wxGetApp().UpdateDlgDarkUI(this);
}
wxWindow *KBShortcutsDialog::create_button(int id, wxString text)
{
auto tab_button = new wxWindow(m_panel_selects, wxID_ANY, wxDefaultPosition, wxSize( FromDIP(150), FromDIP(28)), wxTAB_TRAVERSAL);
tab_button->SetBackgroundColour(wxColour(248, 248, 248));
wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
@ -302,7 +303,6 @@ void KBShortcutsDialog::fill_shortcuts()
wxPanel* KBShortcutsDialog::create_page(wxWindow* parent, const ShortcutsItem& shortcuts, const wxFont& font, const wxFont& bold_font)
{
wxPanel* main_page = new wxPanel(parent);
wxGetApp().UpdateDarkUI(main_page);
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
if (!shortcuts.first.second.empty()) {
@ -327,11 +327,13 @@ wxPanel* KBShortcutsDialog::create_page(wxWindow* parent, const ShortcutsItem& s
for (int i = 0; i < items_count; ++i) {
const auto &[shortcut, description] = shortcuts.second[i];
auto key = new wxStaticText(scrollable_panel, wxID_ANY, _(shortcut));
key->SetForegroundColour(wxColour(50, 58, 61));
key->SetFont(bold_font);
grid_sizer->Add(key, 0, wxALIGN_CENTRE_VERTICAL);
auto desc = new wxStaticText(scrollable_panel, wxID_ANY, _(description));
desc->SetFont(font);
desc->SetForegroundColour(wxColour(50, 58, 61));
desc->Wrap(FromDIP(600));
grid_sizer->Add(desc, 0, wxALIGN_CENTRE_VERTICAL);
}

View file

@ -554,6 +554,11 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
}
evt.Skip();
});
#ifdef _MSW_DARK_MODE
wxGetApp().UpdateDarkUIWin(this);
#endif // _MSW_DARK_MODE
}
#ifdef __WIN32__
@ -1635,26 +1640,23 @@ void MainFrame::update_side_button_style()
m_slice_btn->SetCornerRadius(FromDIP(12));
m_slice_btn->SetExtraSize(wxSize(FromDIP(38), FromDIP(10)));
m_slice_btn->SetMinSize(wxSize(-1, FromDIP(24)));
m_slice_btn->SetBottomColour(wxColour(0x3B4446));
m_slice_option_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Center);
m_slice_option_btn->SetCornerRadius(FromDIP(12));
m_slice_option_btn->SetExtraSize(wxSize(FromDIP(10), FromDIP(10)));
m_slice_option_btn->SetIconOffset(FromDIP(2));
m_slice_option_btn->SetMinSize(wxSize(FromDIP(24), FromDIP(24)));
m_slice_option_btn->SetBottomColour(wxColour(0x3B4446));
m_print_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Left, FromDIP(15));
m_print_btn->SetCornerRadius(FromDIP(12));
m_print_btn->SetExtraSize(wxSize(FromDIP(38), FromDIP(10)));
m_print_btn->SetMinSize(wxSize(-1, FromDIP(24)));
m_print_btn->SetBottomColour(wxColour(0x3B4446));
m_print_option_btn->SetTextLayout(SideButton::EHorizontalOrientation::HO_Center);
m_print_option_btn->SetCornerRadius(FromDIP(12));
m_print_option_btn->SetExtraSize(wxSize(FromDIP(10), FromDIP(10)));
m_print_option_btn->SetIconOffset(FromDIP(2));
m_print_option_btn->SetMinSize(wxSize(FromDIP(24), FromDIP(24)));
m_print_option_btn->SetBottomColour(wxColour(0x3B4446));
}
void MainFrame::update_slice_print_status(SlicePrintEventType event, bool can_slice, bool can_print)
@ -1759,6 +1761,12 @@ void MainFrame::on_sys_color_changed()
// update label colors in respect to the system mode
wxGetApp().init_label_colours();
#ifdef __APPLE__
wxGetApp().force_colors_update();
wxGetApp().update_ui_from_settings();
#endif //__APPLE__
#ifdef __WXMSW__
wxGetApp().UpdateDarkUI(m_tabpanel);
// m_statusbar->update_dark_ui();
@ -2756,12 +2764,12 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
if (m_tabpanel->GetSelection() != (int)new_selection)
m_tabpanel->SetSelection(new_selection);
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu()) {
/*if (wxGetApp().tabs_as_menu()) {
if (Tab* cur_tab = dynamic_cast<Tab*>(m_tabpanel->GetPage(new_selection)))
update_marker_for_tabs_menu((m_layout == ESettingsLayout::Old ? m_menubar : m_settings_dialog.menubar()), cur_tab->title(), m_layout == ESettingsLayout::Old);
else if (tab == 0 && m_layout == ESettingsLayout::Old)
m_plater->get_current_canvas3D()->render();
}
}*/
#endif
if (tab == MainFrame::tp3DEditor && m_layout == ESettingsLayout::Old)
m_plater->canvas3D()->render();
@ -3106,7 +3114,7 @@ std::string MainFrame::get_dir_name(const wxString &full_name) const
// ----------------------------------------------------------------------------
SettingsDialog::SettingsDialog(MainFrame* mainframe)
:DPIFrame(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "settings_dialog"),
:DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "settings_dialog"),
//: DPIDialog(mainframe, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize,
// wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"),
m_main_frame(mainframe)
@ -3141,9 +3149,9 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu()) {
// menubar
m_menubar = new wxMenuBar();
add_tabs_as_menu(m_menubar, mainframe, this);
this->SetMenuBar(m_menubar);
//m_menubar = new wxMenuBar();
//add_tabs_as_menu(m_menubar, mainframe, this);
//this->SetMenuBar(m_menubar);
}
#endif

View file

@ -64,7 +64,7 @@ struct PresetTab {
// SettingsDialog
// ----------------------------------------------------------------------------
class SettingsDialog : public DPIFrame//DPIDialog
class SettingsDialog : public DPIDialog//DPIDialog
{
//wxNotebook* m_tabpanel { nullptr };
Notebook* m_tabpanel{ nullptr };

View file

@ -195,7 +195,7 @@ MonitorPanel::~MonitorPanel()
sizer_side_tools->Add(m_connection_info, 0, wxEXPAND, 0);
sizer_side_tools->Add(m_side_tools, 1, wxEXPAND, 0);
m_tabpanel = new Tabbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, sizer_side_tools, wxNB_LEFT | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
m_tabpanel->SetBackgroundColour(*wxWHITE);
m_tabpanel->SetBackgroundColour(wxColour("#FEFFFF"));
m_tabpanel->Bind(wxEVT_BOOKCTRL_PAGE_CHANGED, [this](wxBookCtrlEvent& e) {
;
});

View file

@ -67,8 +67,8 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he
main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BORDER);
apply_style(style);
SetSizerAndFit(main_sizer);
wxGetApp().UpdateDlgDarkUI(this);
}
MsgDialog::~MsgDialog()
@ -164,7 +164,7 @@ Button* MsgDialog::add_button(wxWindowID btn_id, bool set_focus /*= false*/, con
);
StateColor btn_text_green(
std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Normal)
std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal)
);
StateColor btn_bg_white(
@ -239,6 +239,7 @@ void MsgDialog::finalize()
static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxString msg, bool monospaced_font = false, bool is_marked_msg = false)
{
wxHtmlWindow* html = new wxHtmlWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
html->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
// count lines in the message
int msg_lines = 0;
@ -260,11 +261,7 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont monospace = wxGetApp().code_font();
#if 1
wxColour text_clr = wxGetApp().get_label_clr_default();
#else
wxColour text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
#endif
wxColour bgr_clr = parent->GetBackgroundColour(); //wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
@ -318,7 +315,7 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin
msg_escaped = std::string("<pre><code>") + msg_escaped + "</code></pre>";
html->SetPage("<html><body bgcolor=\"" + bgr_clr_str + "\"><font color=\"" + text_clr_str + "\">" + wxString::FromUTF8(msg_escaped.data()) + "</font></body></html>");
content_sizer->Add(html, 1, wxEXPAND);
wxGetApp().UpdateDarkUI(html);
wxGetApp().UpdateDarkUIWin(html);
}
// ErrorDialog
@ -362,6 +359,7 @@ MessageDialog::MessageDialog(wxWindow* parent,
{
add_msg_content(this, content_sizer, message);
finalize();
wxGetApp().UpdateDlgDarkUI(this);
}

View file

@ -20,7 +20,7 @@ ButtonsListCtrl::ButtonsListCtrl(wxWindow *parent, wxBoxSizer* side_tools) :
#ifdef __WINDOWS__
SetDoubleBuffered(true);
#endif //__WINDOWS__
wxColour default_btn_bg("#3B4446"); // Gradient #414B4E
wxColour default_btn_bg = wxColour("#3B4446"); // Gradient #414B4E
SetBackgroundColour(default_btn_bg);
int em = em_unit(this);// Slic3r::GUI::wxGetApp().em_unit();
@ -48,6 +48,9 @@ ButtonsListCtrl::ButtonsListCtrl(wxWindow *parent, wxBoxSizer* side_tools) :
// BBS: disable custom paint
//this->Bind(wxEVT_PAINT, &ButtonsListCtrl::OnPaint, this);
Bind(wxEVT_SYS_COLOUR_CHANGED, [this](auto& e){
auto a = 10;
});
}
void ButtonsListCtrl::OnPaint(wxPaintEvent&)
@ -139,8 +142,7 @@ void ButtonsListCtrl::SetSelection(int sel)
std::pair{wxColour(59, 68, 70), (int) StateColor::Normal});
m_pageButtons[m_selection]->SetBackgroundColor(bg_color);
StateColor text_color = StateColor(
std::pair{wxColour(255, 255, 255), (int) StateColor::Hovered},
std::pair{wxColour(238,238, 238), (int) StateColor::Normal}
std::pair{wxColour(254,254, 254), (int) StateColor::Normal}
);
m_pageButtons[m_selection]->SetSelected(false);
m_pageButtons[m_selection]->SetTextColor(text_color);
@ -153,8 +155,7 @@ void ButtonsListCtrl::SetSelection(int sel)
m_pageButtons[m_selection]->SetBackgroundColor(bg_color);
StateColor text_color = StateColor(
std::pair{wxColour(255, 255, 255), (int) StateColor::Hovered},
std::pair{wxColour(255, 255, 255), (int) StateColor::Normal}
std::pair{wxColour(254, 254, 254), (int) StateColor::Normal}
);
m_pageButtons[m_selection]->SetSelected(true);
m_pageButtons[m_selection]->SetTextColor(text_color);
@ -177,8 +178,7 @@ bool ButtonsListCtrl::InsertPage(size_t n, const wxString &text, bool bSelect /*
btn->SetBackgroundColor(bg_color);
StateColor text_color = StateColor(
std::pair{wxColour(255, 255, 255), (int) StateColor::Hovered},
std::pair{wxColour(238,238, 238), (int) StateColor::Normal});
std::pair{wxColour(254,254, 254), (int) StateColor::Normal});
btn->SetTextColor(text_color);
btn->SetInactiveIcon(inactive_bmp_name);
btn->SetSelected(false);

View file

@ -55,6 +55,8 @@ ParamsDialog::ParamsDialog(wxWindow * parent)
Hide();
#endif
});
wxGetApp().UpdateDlgDarkUI(this);
}
void ParamsDialog::Popup()

View file

@ -80,6 +80,8 @@ TipsDialog::TipsDialog(wxWindow *parent, const wxString &title, const wxString &
Layout();
Fit();
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
wxBoxSizer *TipsDialog::create_item_checkbox(wxString title, wxWindow *parent, wxString tooltip, std::string param)

View file

@ -46,9 +46,6 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent) :
DPIDialog(parent, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
SetFont(wxGetApp().normal_font());
#ifndef _WIN32
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif
// input the preset name
Tab *tab = wxGetApp().get_tab(Preset::TYPE_PRINTER);
@ -87,7 +84,8 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent) :
input_sizer->Add(m_input_area, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, BORDER_W);
input_sizer->Add(m_valid_label, 0, wxEXPAND | wxLEFT | wxRIGHT, BORDER_W);
SetBackgroundColour(*wxWHITE);
m_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
m_optgroup = new ConfigOptionsGroup(this, _L("Print Host upload"), m_config);
build_printhost_settings(m_optgroup);
@ -98,7 +96,7 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent) :
btnOK->Bind(wxEVT_BUTTON, &PhysicalPrinterDialog::OnOK, this);
wxGetApp().UpdateDarkUI(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)));
(static_cast<wxButton*>(this->FindWindowById(wxID_CANCEL, this)))->Hide();
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
@ -110,6 +108,7 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent) :
SetSizer(topSizer);
topSizer->SetSizeHints(this);
this->CenterOnParent();
wxGetApp().UpdateDlgDarkUI(this);
}
PhysicalPrinterDialog::~PhysicalPrinterDialog()

View file

@ -536,6 +536,7 @@ Sidebar::Sidebar(Plater *parent)
// Bed type selection
wxBoxSizer* bed_type_sizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* bed_type_title = new wxStaticText(p->m_panel_printer_content, wxID_ANY, _L("Bed type"));
//bed_type_title->SetBackgroundColour();
bed_type_title->Wrap(-1);
bed_type_title->SetFont(Label::Body_14);
m_bed_type_list = new ComboBox(p->m_panel_printer_content, wxID_ANY, wxString(""), wxDefaultPosition, {-1, FromDIP(24)}, 0, nullptr, wxCB_READONLY);
@ -1433,7 +1434,7 @@ void Sidebar::collapse(bool collapse)
#ifdef _MSW_DARK_MODE
void Sidebar::show_mode_sizer(bool show)
{
p->mode_sizer->Show(show);
//p->mode_sizer->Show(show);
}
#endif
@ -7755,7 +7756,7 @@ public:
wxStaticText *m_fname_title;
wxStaticText *m_fname_f;
wxStaticText *m_fname_s;
RoundedRectangle * m_panel_select;
StaticBox * m_panel_select;
Button * m_confirm;
Button * m_cancel;
@ -7832,7 +7833,13 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, 5);
m_panel_select = new RoundedRectangle(this, wxColour(248, 248, 248), wxDefaultPosition, PROJECT_DROP_DIALOG_SELECT_PLANE_SIZE, 6);
m_panel_select = new StaticBox(this, wxID_ANY, wxDefaultPosition, PROJECT_DROP_DIALOG_SELECT_PLANE_SIZE);
StateColor box_colour(std::pair<wxColour, int>(wxColour("#F8F8F8"), StateColor::Normal));
StateColor box_border_colour(std::pair<wxColour, int>(wxColour(*wxWHITE), StateColor::Normal));
m_panel_select->SetBackgroundColor(box_colour);
m_panel_select->SetBorderColor(box_border_colour);
m_panel_select->SetCornerRadius(5);
wxBoxSizer *m_sizer_select_h = new wxBoxSizer(wxHORIZONTAL);
@ -7875,7 +7882,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
m_confirm->SetBackgroundColor(btn_bg_green);
m_confirm->SetBorderColor(wxColour(0, 174, 66));
m_confirm->SetTextColor(wxColour(255, 255, 255));
m_confirm->SetTextColor(wxColour("#FFFFFE"));
m_confirm->SetSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
m_confirm->SetMinSize(PROJECT_DROP_DIALOG_BUTTON_SIZE);
m_confirm->SetCornerRadius(FromDIP(12));
@ -7921,6 +7928,8 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
m_fname_f->SetLabel(fstring);
m_fname_s->SetLabel(bstring);
wxGetApp().UpdateDlgDarkUI(this);
}
wxBoxSizer *ProjectDropDialog ::create_item_radiobox(wxString title, wxWindow *parent, int select_id, int groupid)
@ -10191,7 +10200,7 @@ void Plater::clone_selection()
selection.clone(res);
}
void Plater::search(bool plater_is_active, Preset::Type type, wxWindow *tag, wxTextCtrl *etag, wxWindow *stag)
void Plater::search(bool plater_is_active, Preset::Type type, wxWindow *tag, TextInput *etag, wxWindow *stag)
{
if (plater_is_active) {
if (is_preview_shown())

View file

@ -426,7 +426,7 @@ public:
//BBS: add clone logic
void clone_selection();
void center_selection();
void search(bool plater_is_active, Preset::Type type, wxWindow *tag, wxTextCtrl *etag, wxWindow *stag);
void search(bool plater_is_active, Preset::Type type, wxWindow *tag, TextInput *etag, wxWindow *stag);
void mirror(Axis axis);
void split_object();
void split_volume();

View file

@ -17,14 +17,18 @@
#include <wx/listimpl.cpp>
#include <map>
#ifdef __WINDOWS__
#ifdef _MSW_DARK_MODE
#include "dark_mode.hpp"
#endif // _MSW_DARK_MODE
#endif //__WINDOWS__
namespace Slic3r { namespace GUI {
WX_DEFINE_LIST(RadioSelectorList);
wxDEFINE_EVENT(EVT_PREFERENCES_SELECT_TAB, wxCommandEvent);
// @class: PreferencesDialog
// @ret: items
// @birth: created by onion
wxBoxSizer *PreferencesDialog::create_item_title(wxString title, wxWindow *parent, wxString tooltip)
{
wxBoxSizer *m_sizer_title = new wxBoxSizer(wxHORIZONTAL);
@ -371,9 +375,11 @@ wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow
input_title->Wrap(-1);
auto input = new ::TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, DESIGN_INPUT_SIZE, wxTE_PROCESS_ENTER);
input->GetTextCtrl()->SetFont(::Label::Body_13);
StateColor input_bg(std::pair<wxColour, int>(wxColour("#F0F0F1"), StateColor::Disabled));
input->SetBackgroundColor(input_bg);
input->GetTextCtrl()->SetValue(app_config->get(param));
auto second_title = new wxStaticText(parent, wxID_ANY, _L("Second"), wxDefaultPosition, DESIGN_TITLE_SIZE, 0);
second_title->SetForegroundColour(DESIGN_GRAY900_COLOR);
second_title->SetFont(::Label::Body_13);
@ -408,8 +414,10 @@ wxBoxSizer *PreferencesDialog::create_item_backup_input(wxString title, wxWindow
if (app_config->get("backup_switch") == "true") {
input->Enable(true);
input->Refresh();
} else {
input->Enable(false);
input->Refresh();
}
if (param == "backup_interval") { m_backup_interval_textinput = input; }
@ -445,6 +453,59 @@ wxBoxSizer *PreferencesDialog::create_item_switch(wxString title, wxWindow *pare
return m_sizer_switch;
}
wxBoxSizer* PreferencesDialog::create_item_darkmode_checkbox(wxString title, wxWindow* parent, wxString tooltip, int padding_left, std::string param)
{
wxBoxSizer* m_sizer_checkbox = new wxBoxSizer(wxHORIZONTAL);
m_sizer_checkbox->Add(0, 0, 0, wxEXPAND | wxLEFT, 23);
auto checkbox = new ::CheckBox(parent);
checkbox->SetValue((app_config->get(param) == "1") ? true : false);
m_dark_mode_ckeckbox = checkbox;
m_sizer_checkbox->Add(checkbox, 0, wxALIGN_CENTER, 0);
m_sizer_checkbox->Add(0, 0, 0, wxEXPAND | wxLEFT, 8);
auto checkbox_title = new wxStaticText(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0);
checkbox_title->SetForegroundColour(DESIGN_GRAY900_COLOR);
checkbox_title->SetFont(::Label::Body_13);
auto size = checkbox_title->GetTextExtent(title);
checkbox_title->SetMinSize(wxSize(size.x + FromDIP(40), -1));
checkbox_title->Wrap(-1);
m_sizer_checkbox->Add(checkbox_title, 0, wxALIGN_CENTER | wxALL, 3);
//// save config
checkbox->Bind(wxEVT_TOGGLEBUTTON, [this, checkbox, param](wxCommandEvent& e) {
app_config->set(param, checkbox->GetValue() ? "1" : "0");
app_config->save();
//dark mode
#ifdef _MSW_DARK_MODE
wxGetApp().force_colors_update();
wxGetApp().update_ui_from_settings();
set_dark_mode();
#endif
e.Skip();
});
checkbox->SetToolTip(tooltip);
return m_sizer_checkbox;
}
void PreferencesDialog::set_dark_mode()
{
#ifdef __WINDOWS__
#ifdef _MSW_DARK_MODE
NppDarkMode::SetDarkExplorerTheme(this->GetHWND());
NppDarkMode::SetDarkTitleBar(this->GetHWND());
wxGetApp().UpdateDlgDarkUI(this);
#endif
#endif
}
wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string param)
{
wxBoxSizer *m_sizer_checkbox = new wxBoxSizer(wxHORIZONTAL);
@ -609,6 +670,7 @@ PreferencesDialog::PreferencesDialog(wxWindow *parent, wxWindowID id, const wxSt
{
SetBackgroundColour(*wxWHITE);
create();
wxGetApp().UpdateDlgDarkUI(this);
}
void PreferencesDialog::create()
@ -637,9 +699,6 @@ void PreferencesDialog::create()
#if !BBL_RELEASE_TO_PUBLIC
auto debug_page = create_debug_page();
#endif
/* create_gui_page();
create_sync_page();
create_shortcuts_page();*/
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(28));
m_sizer_body->Add(general_page, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(38));
@ -769,6 +828,10 @@ wxWindow* PreferencesDialog::create_general_page()
auto title_downloads = create_item_title(_L("Downloads"), page, _L("Downloads"));
auto item_downloads = create_item_downloads(page,50,"download_path");
//dark mode
auto title_darkmode = create_item_title(_L("Dark Mode"), page, _L("Dark Mode"));
auto item_darkmode = create_item_darkmode_checkbox(_L("Enable Dark mode"), page,_L("Enable Dark mode"), 50, "dark_color_mode");
sizer_page->Add(title_general_settings, 0, wxEXPAND, 0);
sizer_page->Add(item_language, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_region, 0, wxTOP, FromDIP(3));
@ -785,11 +848,13 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(title_backup, 0, wxTOP| wxEXPAND, FromDIP(20));
sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3));
sizer_page->Add(item_backup_interval, 0, wxTOP,FromDIP(3));
//sizer_page->Add(0, 0, 0, wxTOP, 26);
sizer_page->Add(title_downloads, 0, wxTOP| wxEXPAND, FromDIP(20));
sizer_page->Add(item_downloads, 0, wxEXPAND, FromDIP(3));
sizer_page->Add(title_darkmode, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_darkmode, 0, wxEXPAND, FromDIP(3));
page->SetSizer(sizer_page);
page->Layout();
@ -903,9 +968,19 @@ wxBoxSizer* PreferencesDialog::create_debug_page()
on_select_radio("product_host");
}
wxButton *debug_button = new wxButton(m_scrolledWindow, wxID_ANY, _L("debug save button"), wxDefaultPosition, wxDefaultSize, 0);
debug_button->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
StateColor btn_bg_white(std::pair<wxColour, int>(AMS_CONTROL_DISABLE_COLOUR, StateColor::Disabled), std::pair<wxColour, int>(AMS_CONTROL_DISABLE_COLOUR, StateColor::Pressed),
std::pair<wxColour, int>(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_WHITE_COLOUR, StateColor::Normal));
StateColor btn_bd_white(std::pair<wxColour, int>(AMS_CONTROL_WHITE_COLOUR, StateColor::Disabled), std::pair<wxColour, int>(wxColour(38, 46, 48), StateColor::Enabled));
Button* debug_button = new Button(m_scrolledWindow, _L("debug save button"));
debug_button->SetBackgroundColor(btn_bg_white);
debug_button->SetBorderColor(btn_bd_white);
debug_button->SetFont(Label::Body_13);
debug_button->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) {
// success message box
MessageDialog dialog(this, _L("save debug settings"), _L("DEBUG settings have saved successfully!"), wxNO_DEFAULT | wxYES_NO | wxICON_INFORMATION);
switch (dialog.ShowModal()) {

View file

@ -90,6 +90,7 @@ public:
// debug mode
::CheckBox * m_developer_mode_ckeckbox = {nullptr};
::CheckBox * m_dump_video_ckeckbox = {nullptr};
::CheckBox * m_dark_mode_ckeckbox = {nullptr};
::TextInput *m_backup_interval_textinput = {nullptr};
wxString m_developer_mode_def;
@ -107,7 +108,9 @@ public:
wxBoxSizer *create_item_language_combobox(wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string param, std::vector<const wxLanguageInfo *> vlist);
wxBoxSizer *create_item_loglevel_combobox(wxString title, wxWindow *parent, wxString tooltip, std::vector<wxString> vlist);
wxBoxSizer *create_item_checkbox(wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string param);
wxWindow* create_item_downloads(wxWindow* parent, int padding_left, std::string param);
wxBoxSizer *create_item_darkmode_checkbox(wxString title, wxWindow *parent, wxString tooltip, int padding_left, std::string param);
void set_dark_mode();
wxWindow* create_item_downloads(wxWindow* parent, int padding_left, std::string param);
wxBoxSizer* create_item_backup_checkbox(wxString title, wxWindow* parent, wxString tooltip, int padding_left, std::string param);
wxBoxSizer *create_item_backup_input(wxString title, wxWindow *parent, wxString tooltip, std::string param);
wxBoxSizer *create_item_multiple_combobox(

View file

@ -315,6 +315,8 @@ PrintHostQueueDialog::PrintHostQueueDialog(wxWindow *parent)
if (selected == wxNOT_FOUND) { return; }
GUI::show_error(nullptr, job_list->GetTextValue(selected, COL_ERRORMSG));
});
wxGetApp().UpdateDlgDarkUI(this);
}
void PrintHostQueueDialog::append_job(const PrintHostJob &job)

View file

@ -1,6 +1,6 @@
#include "PrintOptionsDialog.hpp"
#include "I18N.hpp"
#include "GUI_App.hpp"
#include "libslic3r/Utils.hpp"
#define DLG_SIZE (wxSize(FromDIP(360), FromDIP(160)))
@ -60,6 +60,8 @@ PrintOptionsDialog::PrintOptionsDialog(wxWindow* parent)
}
evt.Skip();
});
wxGetApp().UpdateDlgDarkUI(this);
}
PrintOptionsDialog::~PrintOptionsDialog()

View file

@ -133,6 +133,7 @@ PublishDialog::PublishDialog(Plater *plater)
});
Bind(wxEVT_CLOSE_WINDOW, &PublishDialog::on_close, this);
wxGetApp().UpdateDlgDarkUI(this);
}
void PublishDialog::cancel()

View file

@ -1,4 +1,5 @@
#include "RecenterDialog.hpp"
#include "GUI_App.hpp"
#include <slic3r/GUI/I18N.hpp>
#include <wx/dcgraph.h>
#include <wx/dcmemory.h>
@ -67,6 +68,8 @@ RecenterDialog::RecenterDialog(wxWindow* parent, wxWindowID id, const wxString&
this->Bind(wxEVT_PAINT, &RecenterDialog::OnPaint, this);
m_button_confirm->Bind(wxEVT_BUTTON, &RecenterDialog::on_button_confirm, this);
m_button_close->Bind(wxEVT_BUTTON, &RecenterDialog::on_button_close, this);
wxGetApp().UpdateDlgDarkUI(this);
}
RecenterDialog::~RecenterDialog() {}

View file

@ -73,6 +73,7 @@ ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/)
m_sizer_main->Fit(this);
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
ReleaseNoteDialog::~ReleaseNoteDialog() {}
@ -221,6 +222,7 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
m_sizer_main->Fit(this);
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
UpdateVersionDialog::~UpdateVersionDialog() {}

View file

@ -74,18 +74,22 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
// combo_sizer->Add(m_combo, 1, wxEXPAND, BORDER_W);
m_input_area = new RoundedRectangle(m_parent, wxColor(172, 172, 172), wxDefaultPosition, wxSize(-1,-1), 3, 1);
StateColor box_border_colour(std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Normal));
m_input_area = new StaticBox(m_parent, wxID_ANY, wxDefaultPosition, SAVE_PRESET_DIALOG_INPUT_SIZE, wxBORDER_NONE);
m_input_area->SetMinSize(SAVE_PRESET_DIALOG_INPUT_SIZE);
m_input_area->SetBorderColor(box_border_colour);
m_input_area->SetBackgroundColor(box_border_colour);
m_input_area->SetCornerRadius(FromDIP(3));
wxBoxSizer *input_sizer_h = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *input_sizer_v = new wxBoxSizer(wxVERTICAL);
m_input_ctrl = new wxTextCtrl(m_input_area, -1, from_u8(preset_name), wxDefaultPosition, wxSize(SAVE_PRESET_DIALOG_INPUT_SIZE.x, -1), 0 | wxBORDER_NONE);
m_input_ctrl->SetBackgroundColour(SAVE_PRESET_DIALOG_DEF_COLOUR);
m_input_ctrl = new wxTextCtrl(m_input_area, -1, from_u8(preset_name), wxDefaultPosition, wxSize(SAVE_PRESET_DIALOG_INPUT_SIZE.x - 2, SAVE_PRESET_DIALOG_INPUT_SIZE.y - 2), 0 | wxBORDER_NONE);
//m_input_ctrl->SetBackgroundColour(GetParent()->GetBackgroundColour());
m_input_ctrl->Bind(wxEVT_TEXT, [this](wxCommandEvent &) { update(); });
input_sizer_v->Add(m_input_ctrl, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 12);
input_sizer_v->Add(m_input_ctrl, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, 1);
input_sizer_h->Add(input_sizer_v, 0, wxALIGN_CENTER, 0);
m_input_area->SetSizer(input_sizer_h);
@ -295,12 +299,14 @@ SavePresetDialog::SavePresetDialog(wxWindow *parent, Preset::Type type, std::str
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
build(std::vector<Preset::Type>{type}, suffix);
wxGetApp().UpdateDlgDarkUI(this);
}
SavePresetDialog::SavePresetDialog(wxWindow *parent, std::vector<Preset::Type> types, std::string suffix)
: DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
build(types, suffix);
wxGetApp().UpdateDlgDarkUI(this);
}
SavePresetDialog::~SavePresetDialog()
@ -337,7 +343,7 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
m_confirm->SetBackgroundColor(btn_bg_green);
m_confirm->SetBorderColor(wxColour(0, 174, 66));
m_confirm->SetTextColor(wxColour(255, 255, 255));
m_confirm->SetTextColor(wxColour("#FFFFFE"));
m_confirm->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
m_confirm->SetCornerRadius(FromDIP(12));
m_confirm->Bind(wxEVT_BUTTON, &SavePresetDialog::accept, this);
@ -349,7 +355,6 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
m_cancel = new Button(this, _L("Cancel"));
m_cancel->SetMinSize(SAVE_PRESET_DIALOG_BUTTON_SIZE);
m_cancel->SetTextColor(wxColour(107, 107, 107));
m_cancel->SetCornerRadius(FromDIP(12));
m_cancel->Bind(wxEVT_BUTTON, &SavePresetDialog::on_select_cancel, this);
btns->Add(m_cancel, 0, wxEXPAND, 0);

View file

@ -10,6 +10,7 @@
#include "Widgets/Button.hpp"
#include "Widgets/RoundedRectangle.hpp"
#include "Widgets/Label.hpp"
#include "Widgets/TextInput.hpp"
class wxString;
class wxStaticText;
@ -17,7 +18,7 @@ class wxComboBox;
class wxStaticBitmap;
#define SAVE_PRESET_DIALOG_DEF_COLOUR wxColour(255, 255, 255)
#define SAVE_PRESET_DIALOG_INPUT_SIZE wxSize(FromDIP(360), FromDIP(32))
#define SAVE_PRESET_DIALOG_INPUT_SIZE wxSize(FromDIP(360), FromDIP(24))
#define SAVE_PRESET_DIALOG_BUTTON_SIZE wxSize(FromDIP(60), FromDIP(24))
namespace Slic3r {
@ -55,7 +56,7 @@ class SavePresetDialog : public DPIDialog
//BBS: add project embedded preset relate logic
bool save_to_project() const { return m_save_to_project; }
RoundedRectangle* m_input_area {nullptr};
StaticBox* m_input_area {nullptr};
Preset::Type m_type;
ValidationType m_valid_type;
std::string m_preset_name;

View file

@ -361,7 +361,7 @@ Option OptionsSearcher::get_option(const std::string &opt_key, const wxString &l
return create_option(opt_key, label, type, gc);
}
void OptionsSearcher::show_dialog(Preset::Type type, wxWindow *parent, wxTextCtrl *input, wxWindow* ssearch_btn)
void OptionsSearcher::show_dialog(Preset::Type type, wxWindow *parent, TextInput *input, wxWindow* ssearch_btn)
{
if (parent == nullptr || input == nullptr) return;
auto search_dialog = new SearchDialog(this, type, parent, input, ssearch_btn);
@ -397,7 +397,7 @@ SearchItem::SearchItem(wxWindow *parent, wxString text, int index, SearchDialog*
m_text = text;
m_index = index;
SetBackgroundColour(wxColour(255, 255, 255));
SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#FFFFFF")));
Bind(wxEVT_ENTER_WINDOW, &SearchItem::on_mouse_enter, this);
Bind(wxEVT_LEAVE_WINDOW, &SearchItem::on_mouse_leave, this);
Bind(wxEVT_LEFT_DOWN, &SearchItem::on_mouse_left_down, this);
@ -414,7 +414,7 @@ wxSize SearchItem::DrawTextString(wxDC &dc, const wxString &text, const wxPoint
}
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(wxColour(43, 52, 54));
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#323A3C")));
dc.DrawText(text, pt);
return dc.GetTextExtent(text);
}
@ -486,19 +486,19 @@ void SearchItem::OnPaint(wxPaintEvent &event)
void SearchItem::on_mouse_enter(wxMouseEvent &evt)
{
SetBackgroundColour(wxColour(238, 238, 238));
SetBackgroundColour(StateColor::darkModeColorFor(wxColour(238, 238, 238)));
Refresh();
}
void SearchItem::on_mouse_leave(wxMouseEvent &evt)
{
SetBackgroundColour(wxColour(255, 255, 255));
SetBackgroundColour(StateColor::darkModeColorFor(wxColour(255, 255, 255)));
Refresh();
}
void SearchItem::on_mouse_left_down(wxMouseEvent &evt)
{
SetBackgroundColour(wxColour(228, 228, 228));
SetBackgroundColour(StateColor::darkModeColorFor(wxColour(228, 228, 228)));
Refresh();
}
@ -521,7 +521,7 @@ static const std::map<const char, int> icon_idxs = {
{ImGui::PrintIconMarker, 0}, {ImGui::PrinterIconMarker, 1}, {ImGui::PrinterSlaIconMarker, 2}, {ImGui::FilamentIconMarker, 3}, {ImGui::MaterialIconMarker, 4},
};
SearchDialog::SearchDialog(OptionsSearcher *searcher, Preset::Type type, wxWindow *parent, wxTextCtrl *input, wxWindow *search_btn)
SearchDialog::SearchDialog(OptionsSearcher *searcher, Preset::Type type, wxWindow *parent, TextInput *input, wxWindow *search_btn)
: wxPopupTransientWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), searcher(searcher)
{
m_event_tag = parent;
@ -602,6 +602,7 @@ SearchDialog::SearchDialog(OptionsSearcher *searcher, Preset::Type type, wxWindo
// SetSizer(topSizer);
// topSizer->SetSizeHints(this);
GUI::wxGetApp().UpdateDarkUIWin(this);
}
SearchDialog::~SearchDialog() {}
@ -618,7 +619,7 @@ void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/)
//const std::string &line = searcher->search_string();
//search_line->SetValue(line.empty() ? default_string : from_u8(line));
search_line->SetValue(wxString(""));
search_line->GetTextCtrl()->SetValue(wxString(""));
//const std::string &line = searcher->search_string();
//searcher->search(into_u8(line), true);
wxPopupTransientWindow::Popup();
@ -666,8 +667,8 @@ void SearchDialog::ProcessSelection(wxDataViewItem selection)
void SearchDialog::OnInputText(wxCommandEvent &)
{
search_line->SetInsertionPointEnd();
wxString input_string = search_line->GetValue();
search_line->GetTextCtrl()->SetInsertionPointEnd();
wxString input_string = search_line->GetTextCtrl()->GetValue();
if (input_string == default_string) input_string.Clear();
searcher->search(into_u8(input_string), true, search_type);
update_list();
@ -675,7 +676,7 @@ void SearchDialog::OnInputText(wxCommandEvent &)
void SearchDialog::OnLeftUpInTextCtrl(wxEvent &event)
{
if (search_line->GetValue() == default_string) search_line->SetValue("");
if (search_line->GetTextCtrl()->GetValue() == default_string) search_line->GetTextCtrl()->SetValue("");
event.Skip();
}
@ -725,13 +726,13 @@ void SearchDialog::update_list()
m_scrolledWindow->Destroy();
m_scrolledWindow = new ScrolledWindow(m_client_panel, wxID_ANY, wxDefaultPosition, wxSize(POPUP_WIDTH * em - (em + em / 2), POPUP_HEIGHT * em - em), wxVSCROLL, 6, 6);
m_scrolledWindow->SetMarginColor(m_bg_colour);
m_scrolledWindow->SetScrollbarColor(m_thumb_color);
m_scrolledWindow->SetBackgroundColour(m_bg_colour);
m_scrolledWindow->SetMarginColor(StateColor::darkModeColorFor(m_bg_colour));
m_scrolledWindow->SetScrollbarColor(StateColor::darkModeColorFor(m_thumb_color));
m_scrolledWindow->SetBackgroundColour(StateColor::darkModeColorFor(m_bg_colour));
auto m_listsizer = new wxBoxSizer(wxVERTICAL);
auto m_listPanel = new wxWindow(m_scrolledWindow->GetPanel(), -1);
m_listPanel->SetBackgroundColour(m_bg_colour);
m_listPanel->SetBackgroundColour(StateColor::darkModeColorFor(m_bg_colour));
m_listPanel->SetSize(wxSize(m_scrolledWindow->GetSize().GetWidth(), -1));
const std::vector<FoundOption> &filters = searcher->found_options();

View file

@ -19,6 +19,7 @@
#include "GUI_Utils.hpp"
#include "libslic3r/Preset.hpp"
#include "Widgets/ScrolledWindow.hpp"
#include "Widgets/TextInput.hpp"
namespace Slic3r {
@ -143,7 +144,7 @@ public:
}
void sort_options_by_label() { sort_options(); }
void show_dialog(Preset::Type type, wxWindow *parent, wxTextCtrl *input, wxWindow *ssearch_btn);
void show_dialog(Preset::Type type, wxWindow *parent, TextInput *input, wxWindow *ssearch_btn);
void dlg_sys_color_changed();
void dlg_msw_rescale();
};
@ -204,7 +205,7 @@ public:
const int POPUP_WIDTH = 38;
const int POPUP_HEIGHT = 40;
wxTextCtrl * search_line{nullptr};
TextInput * search_line{nullptr};
Preset::Type search_type = Preset::TYPE_INVALID;
wxDataViewCtrl * search_list{nullptr};
@ -228,7 +229,7 @@ public:
void update_list();
public:
SearchDialog(OptionsSearcher *searcher, Preset::Type type, wxWindow *parent, wxTextCtrl *input, wxWindow *search_btn);
SearchDialog(OptionsSearcher *searcher, Preset::Type type, wxWindow *parent, TextInput *input, wxWindow *search_btn);
~SearchDialog();
void MSWDismissUnfocusedPopup();

View file

@ -158,7 +158,7 @@ MachineObjectPanel::MachineObjectPanel(wxWindow *parent, wxWindowID id, const wx
wxPanel::Create(parent, id, pos, SELECT_MACHINE_ITEM_SIZE, style, name);
Bind(wxEVT_PAINT, &MachineObjectPanel::OnPaint, this);
SetBackgroundColour(*wxWHITE);
SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
m_unbind_img = ScalableBitmap(this, "unbind", 18);
m_edit_name_img = ScalableBitmap(this, "edit_button", 18);
@ -251,7 +251,7 @@ void MachineObjectPanel::doRender(wxDC &dc)
left += dwbitmap.GetBmpSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(SELECT_MACHINE_GREY900);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
wxString dev_name = "";
if (m_info) {
dev_name = from_u8(m_info->dev_name);
@ -280,7 +280,7 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_show_bind) {
if (m_bind_state == ALLOW_UNBIND) {
left = size.x - m_unbind_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_select_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2);
dc.DrawBitmap(m_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2);
}
}
@ -650,7 +650,7 @@ void SelectMachinePopup::update_other_devices()
m_placeholder_panel->Layout();
placeholder_sizer->Fit(m_placeholder_panel);
m_placeholder_panel->SetBackgroundColour(*wxWHITE);
m_placeholder_panel->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
m_sizer_other_devices->Add(m_placeholder_panel, 0, wxEXPAND, 0);
//m_sizer_other_devices->Layout();
@ -1113,7 +1113,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_button_refresh = new Button(this, _L("Refresh"));
m_button_refresh->SetBackgroundColor(btn_bg_enable);
m_button_refresh->SetBorderColor(btn_bg_enable);
m_button_refresh->SetTextColor(*wxWHITE);
m_button_refresh->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_refresh->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_refresh->SetCornerRadius(FromDIP(10));
@ -1172,7 +1172,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_button_ensure = new Button(m_panel_prepare, _L("Send"));
m_button_ensure->SetBackgroundColor(btn_bg_enable);
m_button_ensure->SetBorderColor(btn_bg_enable);
m_button_ensure->SetTextColor(*wxWHITE);
m_button_ensure->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ensure->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_ensure->SetCornerRadius(FromDIP(12));
@ -1263,6 +1263,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
init_timer();
// CenterOnParent();
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
wxWindow *SelectMachineDialog::create_ams_checkbox(wxString title, wxWindow *parent, wxString tooltip)
@ -1282,7 +1283,7 @@ wxWindow *SelectMachineDialog::create_ams_checkbox(wxString title, wxWindow *par
auto text = new wxStaticText(checkbox, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, 0);
text->SetFont(::Label::Body_13);
text->SetForegroundColour(wxColour(107, 107, 107));
text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#323A3C")));
text->Wrap(-1);
sizer_checkbox->Add(text, 0, wxALIGN_CENTER, FromDIP(5));
@ -1337,7 +1338,7 @@ wxWindow *SelectMachineDialog::create_item_checkbox(wxString title, wxWindow *pa
auto text = new wxStaticText(checkbox, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
text->SetFont(::Label::Body_13);
text->SetForegroundColour(wxColour(107, 107, 107));
text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#323A3C")));
text->Wrap(-1);
text->SetMinSize(wxSize(FromDIP(120), -1));
text->SetMaxSize(wxSize(FromDIP(120), -1));
@ -2954,6 +2955,7 @@ EditDevNameDialog::EditDevNameDialog(Plater *plater /*= nullptr*/)
Layout();
Fit();
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
EditDevNameDialog::~EditDevNameDialog() {}

View file

@ -158,8 +158,8 @@ protected:
void on_mouse_left_up(wxMouseEvent &evt);
};
#define SELECT_MACHINE_POPUP_SIZE wxSize(FromDIP(218), FromDIP(364))
#define SELECT_MACHINE_LIST_SIZE wxSize(FromDIP(214), FromDIP(360))
#define SELECT_MACHINE_POPUP_SIZE wxSize(FromDIP(214), FromDIP(364))
#define SELECT_MACHINE_LIST_SIZE wxSize(FromDIP(210), FromDIP(360))
#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(180), FromDIP(35))
#define SELECT_MACHINE_GREY900 wxColour(38, 46, 48)
#define SELECT_MACHINE_GREY600 wxColour(144,144,144)

View file

@ -221,7 +221,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_button_refresh = new Button(this, _L("Refresh"));
m_button_refresh->SetBackgroundColor(btn_bg_enable);
m_button_refresh->SetBorderColor(btn_bg_enable);
m_button_refresh->SetTextColor(*wxWHITE);
m_button_refresh->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_refresh->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_refresh->SetCornerRadius(FromDIP(10));
@ -251,7 +251,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_button_ensure = new Button(m_panel_prepare, _L("Send"));
m_button_ensure->SetBackgroundColor(btn_bg_enable);
m_button_ensure->SetBorderColor(btn_bg_enable);
m_button_ensure->SetTextColor(*wxWHITE);
m_button_ensure->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ensure->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_ensure->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_ensure->SetCornerRadius(FromDIP(12));
@ -398,6 +398,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
init_timer();
// CenterOnParent();
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
void SendToPrinterDialog::prepare_mode()

View file

@ -39,7 +39,7 @@ static const wxColour BUTTON_PRESS_COL = wxColour(172, 172, 172);
static const wxColour BUTTON_HOVER_COL = wxColour(0, 174, 66);
static const wxColour DISCONNECT_TEXT_COL = wxColour(172, 172, 172);
static const wxColour NORMAL_TEXT_COL = wxColour(50, 58, 61);
static const wxColour NORMAL_TEXT_COL = wxColour(48,58,60);
static const wxColour NORMAL_FAN_TEXT_COL = wxColour(107, 107, 107);
static const wxColour WARNING_INFO_BG_COL = wxColour(255, 111, 0);
static const wxColour STAGE_TEXT_COL = wxColour(0, 174, 66);
@ -585,7 +585,7 @@ wxBoxSizer *StatusBasePanel::create_machine_control_page(wxWindow *parent)
m_options_btn = new Button(m_panel_control_title, _L("Print Options"));
m_options_btn->SetBackgroundColor(btn_bg_green);
m_options_btn->SetBorderColor(btn_bd_green);
m_options_btn->SetTextColor(*wxWHITE);
m_options_btn->SetTextColor(wxColour("#FFFFFE"));
m_options_btn->SetSize(wxSize(FromDIP(128), FromDIP(26)));
m_options_btn->SetMinSize(wxSize(-1, FromDIP(26)));
@ -593,7 +593,7 @@ wxBoxSizer *StatusBasePanel::create_machine_control_page(wxWindow *parent)
m_calibration_btn = new Button(m_panel_control_title, _L("Calibration"));
m_calibration_btn->SetBackgroundColor(btn_bg_green);
m_calibration_btn->SetBorderColor(btn_bd_green);
m_calibration_btn->SetTextColor(*wxWHITE);
m_calibration_btn->SetTextColor(wxColour("#FFFFFE"));
m_calibration_btn->SetSize(wxSize(FromDIP(128), FromDIP(26)));
m_calibration_btn->SetMinSize(wxSize(-1, FromDIP(26)));
@ -623,7 +623,14 @@ wxBoxSizer *StatusBasePanel::create_machine_control_page(wxWindow *parent)
wxBoxSizer *StatusBasePanel::create_temp_axis_group(wxWindow *parent)
{
auto sizer = new wxBoxSizer(wxVERTICAL);
auto box = new RoundedRectangle(parent, wxColour(0xEE, 0xEE, 0xEE), wxDefaultPosition, wxSize(FromDIP(510), -1), 5, 1);
auto box = new StaticBox(parent);
StateColor box_colour(std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
StateColor box_border_colour(std::pair<wxColour, int>(STATUS_PANEL_BG, StateColor::Normal));
box->SetBackgroundColor(box_colour);
box->SetBorderColor(box_border_colour);
box->SetCornerRadius(5);
box->SetMinSize(wxSize(FromDIP(530), -1));
box->SetMaxSize(wxSize(FromDIP(530), -1));
@ -632,7 +639,7 @@ wxBoxSizer *StatusBasePanel::create_temp_axis_group(wxWindow *parent)
wxBoxSizer *m_temp_ctrl = create_temp_control(box);
content_sizer->Add(m_temp_ctrl, 0, wxEXPAND | wxALL, FromDIP(5));
m_temp_extruder_line = new StaticLine(box, true);
m_temp_extruder_line = new StaticLine(box, true);
m_temp_extruder_line->SetLineColour(STATIC_BOX_LINE_COL);
content_sizer->Add(m_temp_extruder_line, 0, wxEXPAND, 1);
content_sizer->Add(FromDIP(9), 0, 0, wxEXPAND, 1);
@ -665,9 +672,13 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
m_tempCtrl_nozzle->SetMinTemp(nozzle_temp_range[0]);
m_tempCtrl_nozzle->SetMaxTemp(nozzle_temp_range[1]);
m_tempCtrl_nozzle->SetBorderWidth(FromDIP(2));
m_tempCtrl_nozzle->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
m_tempCtrl_nozzle->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
StateColor tempinput_text_colour(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal));
StateColor tempinput_border_colour(std::make_pair(*wxWHITE, (int)StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int)StateColor::Focused),
std::make_pair(BUTTON_HOVER_COL, (int)StateColor::Hovered), std::make_pair(*wxWHITE, (int)StateColor::Normal));
m_tempCtrl_nozzle->SetTextColor(tempinput_text_colour);
m_tempCtrl_nozzle->SetBorderColor(tempinput_border_colour);
sizer->Add(m_tempCtrl_nozzle, 0, wxEXPAND | wxALL, 1);
@ -683,9 +694,8 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
m_tempCtrl_bed->SetMaxTemp(bed_temp_range[1]);
m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE);
m_tempCtrl_bed->SetBorderWidth(FromDIP(2));
m_tempCtrl_bed->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
m_tempCtrl_bed->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
m_tempCtrl_bed->SetTextColor(tempinput_text_colour);
m_tempCtrl_bed->SetBorderColor(tempinput_border_colour);
sizer->Add(m_tempCtrl_bed, 0, wxEXPAND | wxALL, 1);
auto line = new StaticLine(parent);
@ -698,9 +708,9 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
m_tempCtrl_frame->SetReadOnly(true);
m_tempCtrl_frame->SetMinSize(TEMP_CTRL_MIN_SIZE);
m_tempCtrl_frame->SetBorderWidth(FromDIP(2));
m_tempCtrl_frame->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_TEXT_COL, (int) StateColor::Normal)));
m_tempCtrl_frame->SetBorderColor(StateColor(std::make_pair(*wxWHITE, (int) StateColor::Disabled), std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Focused),
std::make_pair(BUTTON_HOVER_COL, (int) StateColor::Hovered), std::make_pair(*wxWHITE, (int) StateColor::Normal)));
m_tempCtrl_frame->SetTextColor(tempinput_text_colour);
m_tempCtrl_frame->SetBorderColor(tempinput_border_colour);
sizer->Add(m_tempCtrl_frame, 0, wxEXPAND | wxALL, 1);
line = new StaticLine(parent);
line->SetLineColour(STATIC_BOX_LINE_COL);
@ -977,7 +987,16 @@ wxBoxSizer *StatusBasePanel::create_ams_group(wxWindow *parent)
{
auto sizer = new wxBoxSizer(wxVERTICAL);
auto sizer_box = new wxBoxSizer(wxVERTICAL);
m_ams_control_box = new RoundedRectangle(parent, wxColour(0xEE, 0xEE, 0xEE), wxDefaultPosition, wxDefaultSize, 5, 1);
m_ams_control_box = new StaticBox(parent);
StateColor box_colour(std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
StateColor box_border_colour(std::pair<wxColour, int>(STATUS_PANEL_BG, StateColor::Normal));
m_ams_control_box->SetBackgroundColor(box_colour);
m_ams_control_box->SetBorderColor(box_border_colour);
m_ams_control_box->SetCornerRadius(5);
m_ams_control_box->SetMinSize(wxSize(FromDIP(530), -1));
m_ams_control_box->SetBackgroundColour(*wxWHITE);
#if !BBL_RELEASE_TO_PUBLIC
@ -2393,7 +2412,7 @@ void StatusPanel::on_switch_speed(wxCommandEvent &event)
#else
wxPopupTransientWindow *popUp = new wxPopupTransientWindow(m_switch_speed);
#endif
popUp->SetBackgroundColour(0xeeeeee);
popUp->SetBackgroundColour(StateColor::darkModeColorFor(0xeeeee));
StepCtrl *step = new StepCtrl(popUp, wxID_ANY);
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(step, 1, wxEXPAND, 0);

View file

@ -171,7 +171,7 @@ protected:
wxStaticText * m_ams_debug;
bool m_show_ams_group{false};
AMSControl* m_ams_control;
RoundedRectangle* m_ams_control_box;
StaticBox* m_ams_control_box;
wxStaticBitmap *m_ams_extruder_img;
wxStaticBitmap* m_bitmap_extruder_img;
wxPanel * m_panel_separator_right;

View file

@ -258,16 +258,24 @@ void Tab::create_preset_tab()
m_btn_search->SetToolTip(_L("Search in preset"));
//search input
m_search_item = new RoundedRectangle(m_top_panel, wxColour(238, 238, 238), wxDefaultPosition, wxSize(m_top_panel->GetSize().GetWidth(), 3 * wxGetApp().em_unit()), 8);
auto search_sizer = new wxBoxSizer(wxHORIZONTAL);
m_search_input = new wxTextCtrl(m_search_item, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 | wxBORDER_NONE);
m_search_item = new StaticBox(m_top_panel);
StateColor box_colour(std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
StateColor box_border_colour(std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Normal));
m_search_item->SetBackgroundColor(box_colour);
m_search_item->SetBorderColor(box_border_colour);
m_search_item->SetCornerRadius(5);
//StateColor::darkModeColorFor(wxColour(238, 238, 238)), wxDefaultPosition, wxSize(m_top_panel->GetSize().GetWidth(), 3 * wxGetApp().em_unit()), 8);
auto search_sizer = new wxBoxSizer(wxHORIZONTAL);
m_search_input = new TextInput(m_search_item, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 | wxBORDER_NONE);
m_search_input->SetBackgroundColour(wxColour(238, 238, 238));
m_search_input->SetForegroundColour(wxColour(43, 52, 54));
m_search_input->SetFont(wxGetApp().bold_font());
search_sizer->Add(new wxWindow(m_search_item, wxID_ANY, wxDefaultPosition, wxSize(0, 0)), 0, wxEXPAND | wxLEFT, 16);
search_sizer->Add(m_search_input, 1, wxEXPAND | wxALL, wxGetApp().em_unit() / 2);
search_sizer->Add(new wxWindow(m_search_item, wxID_ANY, wxDefaultPosition, wxSize(0, 0)), 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(6));
search_sizer->Add(m_search_input, 1, wxEXPAND | wxALL, FromDIP(2));
//bbl for linux
//search_sizer->Add(new wxWindow(m_search_input, wxID_ANY, wxDefaultPosition, wxSize(0, 0)), 0, wxEXPAND | wxLEFT, 16);
@ -655,14 +663,14 @@ void Tab::OnActivate()
// Because of DarkMode we use our own Notebook (inherited from wxSiplebook) instead of wxNotebook
// And it looks like first Layout of the page doesn't update a size of the m_presets_choice
// So we have to set correct size explicitely
if (wxSize ok_sz = wxSize(35 * m_em_unit, m_presets_choice->GetBestSize().y);
/* if (wxSize ok_sz = wxSize(35 * m_em_unit, m_presets_choice->GetBestSize().y);
ok_sz != m_presets_choice->GetSize()) {
m_presets_choice->SetMinSize(ok_sz);
m_presets_choice->SetSize(ok_sz);
GetSizer()->GetItem(size_t(0))->GetSizer()->Layout();
if (wxGetApp().tabs_as_menu())
m_presets_choice->update();
}
}*/
#endif // _MSW_DARK_MODE
Refresh();

View file

@ -39,6 +39,7 @@
#include "Notebook.hpp"
#include "ParamsPanel.hpp"
#include "Widgets/RoundedRectangle.hpp"
#include "Widgets/TextInput.hpp"
class TabCtrl;
@ -182,8 +183,8 @@ protected:
ScalableButton* m_undo_to_sys_btn;
//ScalableButton* m_question_btn;
ScalableButton* m_btn_search;
RoundedRectangle * m_search_item;
wxTextCtrl * m_search_input;
StaticBox * m_search_item;
TextInput * m_search_input;
// Cached bitmaps.
// A "flag" icon to be displayned next to the preset name in the Tab's combo box.

View file

@ -15,7 +15,7 @@ END_EVENT_TABLE()
static wxColour BORDER_HOVER_COL = wxColour(0, 174, 66);
const static wxColour TAB_BUTTON_BG = wxColour(255, 255, 255, 255);
const static wxColour TAB_BUTTON_BG = wxColour("#FEFFFF");
const static wxColour TAB_BUTTON_SEL = wxColour(219, 253, 213, 255);
TabButton::TabButton()
@ -24,13 +24,13 @@ TabButton::TabButton()
{
background_color = StateColor(
std::make_pair(TAB_BUTTON_SEL, (int) StateColor::Checked),
std::make_pair(*wxWHITE, (int) StateColor::Hovered),
std::make_pair(*wxWHITE, (int) StateColor::Normal));
std::make_pair(wxColour("#FEFFFF"), (int) StateColor::Hovered),
std::make_pair(wxColour("#FEFFFF"), (int) StateColor::Normal));
border_color = StateColor(
std::make_pair(*wxWHITE, (int) StateColor::Checked),
std::make_pair(wxColour("#FEFFFF"), (int) StateColor::Checked),
std::make_pair(BORDER_HOVER_COL, (int) StateColor::Hovered),
std::make_pair(*wxWHITE, (int) StateColor::Normal));
std::make_pair(wxColour("#FEFFFF"), (int)StateColor::Normal));
}
TabButton::TabButton(wxWindow *parent, wxString text, ScalableBitmap &bmp, long style, int iconSize)

View file

@ -14,7 +14,7 @@
wxDEFINE_EVENT(wxCUSTOMEVT_TABBOOK_SEL_CHANGED, wxCommandEvent);
const static wxColour TAB_BUTTON_BG = wxColour(255, 255, 255, 255);
const static wxColour TAB_BUTTON_BG = wxColour("#FEFFFF");
const static wxColour TAB_BUTTON_SEL = wxColour(219, 253, 213, 255);
static const wxFont& TAB_BUTTON_FONT = Label::Body_14;

View file

@ -798,6 +798,7 @@ UnsavedChangesDialog::UnsavedChangesDialog(const wxString &caption, const wxStri
{
build(Preset::TYPE_INVALID, nullptr, "", header);
this->CenterOnScreen();
wxGetApp().UpdateDlgDarkUI(this);
}
UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, bool no_transfer)
@ -812,17 +813,17 @@ UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type, PresetCollection *
m_buttons &= ~ActionButtons::TRANSFER;
build(type, dependent_presets, new_selected_preset);
this->CenterOnScreen();
wxGetApp().UpdateDlgDarkUI(this);
}
void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_presets, const std::string &new_selected_preset, const wxString &header)
{
SetBackgroundColour(*wxWHITE);
// icon
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL);
m_top_line = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
@ -947,7 +948,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
if (focus) {
(*btn)->SetBackgroundColor(btn_bg_green);
(*btn)->SetBorderColor(wxColour(0, 174, 66));
(*btn)->SetTextColor(wxColour(255, 255, 255));
(*btn)->SetTextColor(wxColour("#FFFFFE"));
} else {
(*btn)->SetTextColor(wxColour(107, 107, 107));
}
@ -1767,7 +1768,7 @@ DiffPresetDialog::DiffPresetDialog(MainFrame* mainframe)
int border = 10;
int em = em_unit();
SetBackgroundColour(*wxWHITE);
assert(wxGetApp().preset_bundle);
m_preset_bundle_left = std::make_unique<PresetBundle>(*wxGetApp().preset_bundle);
@ -1853,6 +1854,7 @@ DiffPresetDialog::DiffPresetDialog(MainFrame* mainframe)
this->SetMinSize(wxSize(80 * em, 30 * em));
this->SetSizer(topSizer);
topSizer->SetSizeHints(this);
wxGetApp().UpdateDlgDarkUI(this);
}
void DiffPresetDialog::update_controls_visibility(Preset::Type type /* = Preset::TYPE_INVALID*/)
@ -1893,6 +1895,7 @@ void DiffPresetDialog::show(Preset::Type type /* = Preset::TYPE_INVALID*/)
Fit();
update_tree();
wxGetApp().UpdateDlgDarkUI(this);
// if this dialog is shown it have to be Hide and show again to be placed on the very Top of windows
if (IsShown())

View file

@ -237,6 +237,7 @@ MsgUpdateConfig::MsgUpdateConfig(const std::vector<Update> &updates, bool force_
m_sizer_main->Fit(this);
Centre(wxBOTH);
wxGetApp().UpdateDlgDarkUI(this);
}
void MsgUpdateConfig::on_dpi_changed(const wxRect &suggested_rect) {}

View file

@ -150,7 +150,7 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
StateColor btn_text(std::pair<wxColour, int>(wxColour(144, 144, 144), StateColor::Disabled), std::pair<wxColour, int>(wxColour(255, 255, 255), StateColor::Enabled));
m_button_upgrade_firmware->SetBackgroundColor(btn_bg);
m_button_upgrade_firmware->SetBorderColor(btn_bd);
m_button_upgrade_firmware->SetTextColor(btn_text);
m_button_upgrade_firmware->SetTextColor(wxColour("#FFFFFE"));
m_button_upgrade_firmware->SetFont(Label::Body_10);
m_button_upgrade_firmware->SetMinSize(wxSize(FromDIP(-1), FromDIP(24)));
m_button_upgrade_firmware->SetCornerRadius(FromDIP(12));
@ -212,6 +212,7 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
m_staticText_release_note->Bind(wxEVT_LEFT_DOWN, &MachineInfoPanel::on_show_release_note, this);
m_button_upgrade_firmware->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MachineInfoPanel::on_upgrade_firmware), NULL, this);
wxGetApp().UpdateDarkUIWin(this);
}
@ -231,6 +232,7 @@ wxPanel *MachineInfoPanel::create_caption_panel(wxWindow *parent)
m_caption_sizer->Add(m_upgrade_status_img, 0, wxALIGN_CENTER_VERTICAL | wxALL, FromDIP(5));
m_caption_text = new wxStaticText(caption_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize);
m_caption_text->SetForegroundColour("#262E30");
m_caption_text->Wrap(-1);
m_caption_sizer->Add(m_caption_text, 1, wxALIGN_CENTER_VERTICAL | wxALL, FromDIP(5));
@ -868,14 +870,17 @@ bool UpgradePanel::Show(bool show)
ams_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
m_staticText_ams = new wxStaticText(this, wxID_ANY, "-", wxDefaultPosition, wxDefaultSize, 0);
m_staticText_ams->SetForegroundColour("#262E30");
m_staticText_ams->SetFont(Label::Head_14);
m_staticText_ams->Wrap(-1);
auto m_staticText_ams_sn = new wxStaticText(this, wxID_ANY, _L("Serial:"), wxDefaultPosition, wxDefaultSize, 0);
m_staticText_ams_sn->SetForegroundColour("#262E30");
m_staticText_ams_sn->Wrap(-1);
m_staticText_ams_sn->SetFont(Label::Head_14);
m_staticText_ams_sn_val = new wxStaticText(this, wxID_ANY, "-", wxDefaultPosition, wxDefaultSize, 0);
m_staticText_ams_sn_val->SetForegroundColour("#262E30");
m_staticText_ams_sn_val->Wrap(-1);
wxBoxSizer *m_ams_ver_sizer = new wxBoxSizer(wxHORIZONTAL);
@ -890,9 +895,11 @@ bool UpgradePanel::Show(bool show)
auto m_staticText_ams_ver = new wxStaticText(this, wxID_ANY, _L("Version:"), wxDefaultPosition, wxDefaultSize, 0);
m_staticText_ams_ver->Wrap(-1);
m_staticText_ams_ver->SetFont(Label::Head_14);
m_staticText_ams_ver->SetForegroundColour("#262E30");
m_ams_ver_sizer->Add(m_staticText_ams_ver, 0, wxALL, FromDIP(5));
m_staticText_ams_ver_val = new wxStaticText(this, wxID_ANY, "-", wxDefaultPosition, wxDefaultSize, 0);
m_staticText_ams_ver_val->SetForegroundColour("#262E30");
m_staticText_ams_ver_val->Wrap(-1);
ams_sizer->Add(m_staticText_ams, 0, wxALIGN_RIGHT | wxALL, FromDIP(5));

View file

@ -109,6 +109,7 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
SetStartPage(BBL_REGION);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", finished");
wxGetApp().UpdateDlgDarkUI(this);
}
GuideFrame::~GuideFrame()

View file

@ -226,7 +226,7 @@ void AMSrefresh::paintEvent(wxPaintEvent &evt)
wxSize size = GetSize();
wxPaintDC dc(this);
auto colour = AMS_CONTROL_GRAY700;
auto colour = StateColor::darkModeColorFor(AMS_CONTROL_GRAY700);
if (!wxWindow::IsEnabled()) { colour = AMS_CONTROL_GRAY500; }
auto pot = wxPoint((size.x - m_bitmap_selected.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2);
@ -347,7 +347,7 @@ void AMSextruderImage::doRender(wxDC &dc)
auto size = GetSize();
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(m_colour);
dc.DrawRectangle(0, 0, size.x, size.y - FromDIP(5));
dc.DrawRectangle(0, FromDIP(18), size.x, size.y - FromDIP(18) - FromDIP(5));
dc.DrawBitmap(m_ams_extruder.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2));
}
@ -358,7 +358,6 @@ AMSextruderImage::AMSextruderImage(wxWindow *parent, wxWindowID id, const wxPoin
SetBackgroundColour(*wxWHITE);
m_ams_extruder = ScalableBitmap(this, "monitor_ams_extruder",55);
SetSize(AMS_EXTRUDER_BITMAP_SIZE);
SetMinSize(AMS_EXTRUDER_BITMAP_SIZE);
SetMaxSize(AMS_EXTRUDER_BITMAP_SIZE);
@ -393,7 +392,7 @@ void AMSextruder::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL);
m_bitmap_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, AMS_EXTRUDER_BITMAP_SIZE, wxTAB_TRAVERSAL);
m_bitmap_panel->SetBackgroundColour(wxColour(AMS_EXTRUDER_DEF_COLOUR));
m_bitmap_panel->SetBackgroundColour(AMS_EXTRUDER_DEF_COLOUR);
m_bitmap_panel->SetDoubleBuffered(true);
m_bitmap_sizer = new wxBoxSizer(wxHORIZONTAL);
@ -1080,8 +1079,8 @@ void AMSItem::render(wxDC &dc)
void AMSItem::doRender(wxDC &dc)
{
wxSize size = GetSize();
dc.SetPen(wxPen(m_background_colour));
dc.SetBrush(wxBrush(m_background_colour));
dc.SetPen(wxPen(StateColor::darkModeColorFor(m_background_colour)));
dc.SetBrush(wxBrush(StateColor::darkModeColorFor(m_background_colour)));
dc.DrawRoundedRectangle(0, 0, size.x, size.y, 3);
auto left = m_padding;
@ -1219,6 +1218,7 @@ void AmsCans::Update(AMSinfo info)
void AmsCans::AddCan(Caninfo caninfo, int canindex, int maxcan)
{
auto amscan = new wxWindow(this, wxID_ANY);
amscan->SetBackgroundColour(AMS_CONTROL_DEF_BLOCK_BK_COLOUR);
wxBoxSizer *m_sizer_ams = new wxBoxSizer(wxVERTICAL);
m_sizer_ams->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(14));
auto m_panel_refresh = new AMSrefresh(amscan, wxID_ANY, m_can_count + 1, caninfo);
@ -1445,7 +1445,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_panel_can = new StaticBox(m_amswin, wxID_ANY, wxDefaultPosition, AMS_CANS_SIZE, wxBORDER_NONE);
m_panel_can->SetMinSize(AMS_CANS_SIZE);
m_panel_can->SetCornerRadius(FromDIP(10));
m_panel_can->SetBackgroundColor(AMS_CONTROL_DEF_BLOCK_BK_COLOUR);
m_panel_can->SetBackgroundColor(StateColor(std::pair<wxColour, int>(AMS_CONTROL_DEF_BLOCK_BK_COLOUR, StateColor::Normal)));
m_sizer_cans = new wxBoxSizer(wxHORIZONTAL);
@ -1515,7 +1515,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_button_extruder_feed = new Button(m_amswin, _L("Load Filament"));
m_button_extruder_feed->SetBackgroundColor(btn_bg_green);
m_button_extruder_feed->SetBorderColor(btn_bd_green);
m_button_extruder_feed->SetTextColor(btn_text_green);
m_button_extruder_feed->SetTextColor(wxColour("#FFFFFE"));
m_button_extruder_feed->SetFont(Label::Body_13);
m_button_extruder_back = new Button(m_amswin, _L("Unload Filament"));
@ -1575,12 +1575,14 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_button_guide = new Button(m_amswin, _L("Guide"));
m_button_guide->SetFont(Label::Body_13);
m_button_guide->SetCornerRadius(FromDIP(12));
m_button_guide->SetBorderColor(btn_bd_white);
m_button_guide->SetMinSize(wxSize(-1, FromDIP(24)));
m_button_guide->SetBackgroundColor(btn_bg_white);
m_button_retry = new Button(m_amswin, _L("Retry"));
m_button_retry->SetFont(Label::Body_13);
m_button_retry->SetCornerRadius(FromDIP(12));
m_button_retry->SetBorderColor(btn_bd_white);
m_button_retry->SetMinSize(wxSize(-1, FromDIP(24)));
m_button_retry->SetBackgroundColor(btn_bg_white);

View file

@ -3,10 +3,11 @@
#include <wx/dcgraph.h>
StateColor blank_bg(StateColor(std::make_pair(wxColour("#FFFFFF"), (int)StateColor::Normal)));
static const wxColour BUTTON_BG_COL = wxColour("#EEEEEE");
static const wxColour BUTTON_IN_BG_COL = wxColour("#CECECE");
static const wxColour bd = wxColour(0, 174, 66);
static const wxColour BUTTON_BG_COL = wxColour(238, 238, 238);
static const wxColour BUTTON_IN_BG_COL = wxColour(206, 206, 206);
static const wxColour blank_bg = wxColour(0xFFFFFF);
static const wxColour text_num_color = wxColour(0x898989);
static const wxColour BUTTON_PRESS_COL = wxColour(172, 172, 172);
static const double sqrt2 = std::sqrt(2);
@ -155,16 +156,16 @@ void AxisCtrlButton::render(wxDC& dc)
wxGraphicsPath outer_path = gc->CreatePath();
outer_path.AddCircle(0, 0, r_outer);
outer_path.AddCircle(0, 0, r_inner);
gc->SetPen(BUTTON_BG_COL);
gc->SetBrush(BUTTON_BG_COL);
gc->SetPen(StateColor::darkModeColorFor(BUTTON_BG_COL));
gc->SetBrush(StateColor::darkModeColorFor(BUTTON_BG_COL));
gc->DrawPath(outer_path);
//draw the inner ring
wxGraphicsPath inner_path = gc->CreatePath();
inner_path.AddCircle(0, 0, r_inner);
inner_path.AddCircle(0, 0, r_blank);
gc->SetPen(BUTTON_IN_BG_COL);
gc->SetBrush(BUTTON_IN_BG_COL);
gc->SetPen(StateColor::darkModeColorFor(BUTTON_IN_BG_COL));
gc->SetBrush(StateColor::darkModeColorFor(BUTTON_IN_BG_COL));
gc->DrawPath(inner_path);
//draw an arc in corresponding position
@ -187,8 +188,8 @@ void AxisCtrlButton::render(wxDC& dc)
}
//draw rectangle gap
gc->SetPen(blank_bg);
gc->SetBrush(blank_bg);
gc->SetPen(blank_bg.colorForStates(StateColor::Normal));
gc->SetBrush(blank_bg.colorForStates(StateColor::Normal));
gc->PushState();
gc->Rotate(-PI / 4);
gc->DrawRectangle(-sqrt2 * size.x / 2, -sqrt2 * gap / 2, sqrt2 * size.x, sqrt2 * gap);
@ -205,8 +206,8 @@ void AxisCtrlButton::render(wxDC& dc)
gc->SetPen(wxPen(border_color.colorForStates(states), 2));
gc->SetBrush(wxBrush(background_color.colorForStates(states)));
} else {
gc->SetPen(BUTTON_BG_COL);
gc->SetBrush(BUTTON_BG_COL);
gc->SetPen(StateColor::darkModeColorFor(BUTTON_BG_COL));
gc->SetBrush(StateColor::darkModeColorFor(BUTTON_BG_COL));
}
gc->DrawPath(home_path);

View file

@ -77,6 +77,7 @@ ProgressDialog::ProgressDialog(const wxString &title, const wxString &message, i
Create(title, message, maximum, parent, style);
Bind(wxEVT_PAINT, &ProgressDialog::OnPaint, this);
Bind(wxEVT_CLOSE_WINDOW, &ProgressDialog::OnClose, this);
wxGetApp().UpdateDlgDarkUI(this);
}
void ProgressDialog::OnPaint(wxPaintEvent &evt) {}

View file

@ -33,15 +33,17 @@ SideButton::SideButton(wxWindow* parent, wxString text, wxString icon, long stly
border_color.append(0x00AE42, StateColor::Normal);
text_color.append(0xACACAC, StateColor::Disabled);
text_color.append(0xFFFFFF, StateColor::Pressed);
text_color.append(0xFFFFFF, StateColor::Hovered);
text_color.append(0xFFFFFF, StateColor::Normal);
text_color.append(0xFEFEFE, StateColor::Pressed);
text_color.append(0xFEFEFE, StateColor::Hovered);
text_color.append(0xFEFEFE, StateColor::Normal);
background_color.append(0x6B6B6B, StateColor::Disabled);
background_color.append(wxColour(23, 129, 63), StateColor::Pressed);
background_color.append(wxColour(48, 221, 112), StateColor::Hovered);
background_color.append(0x00AE42, StateColor::Normal);
SetBottomColour(wxColour("#3B4446"));
state_handler.attach({ &border_color, &text_color, &background_color });
state_handler.update_binds();
@ -194,7 +196,7 @@ void SideButton::dorender(wxDC& dc, wxDC& text_dc)
// draw background
dc.SetPen(wxNullPen);
dc.SetBrush(bottom_color);
dc.SetBrush(StateColor::darkModeColorFor(bottom_color));
dc.DrawRectangle(0, 0, size.x, size.y);
int states = state_handler.states();

View file

@ -2,6 +2,7 @@
#include <wx/dcmemory.h>
#include <wx/dcgraph.h>
#include "Label.hpp"
#include "StateColor.hpp"
#include "../wxExtensions.hpp"
#include "../I18N.hpp"
#include "../GUI.hpp"
@ -12,7 +13,7 @@ namespace Slic3r { namespace GUI {
wxPanel::Create(parent, id, pos, wxSize(0, FromDIP(50)));
Bind(wxEVT_PAINT, &SideTools::OnPaint, this);
SetBackgroundColour(*wxWHITE);
SetBackgroundColour(wxColour("#FEFFFF"));
m_printing_img = ScalableBitmap(this, "printer", 16);
m_arrow_img = ScalableBitmap(this, "monitor_arrow", 14);
@ -155,11 +156,11 @@ void SideTools::doRender(wxDC &dc)
left += (m_arrow_img.GetBmpSize().x + FromDIP(6));
dc.SetFont(::Label::Body_14);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(SIDE_TOOLS_GREY900);
dc.SetTextForeground(StateColor::darkModeColorFor(SIDE_TOOLS_GREY900));
auto sizet = dc.GetTextExtent(m_dev_name);
auto text_end = size.x - m_wifi_none_img.GetBmpSize().x - 20;
std::string finally_name = m_dev_name.ToStdString();
if (sizet.x > (text_end - left)) {
auto limit_width = text_end - left - dc.GetTextExtent("...").x - 20;

View file

@ -33,7 +33,11 @@ static std::map<wxColour, wxColour> gDarkColors{
{"#A6A9AA", "#2D2D29"},
{"#363636", "#B2B3B5"},
{"#F0F0F1", "#404040"},
{"#9E9E9E", "#53545A"},
{"#D7E8DE", "#1F2B27"},
//{"#F0F0F0", "#3E3E44"},
};
std::map<wxColour, wxColour> const & StateColor::GetDarkMap()
{
return gDarkColors;
@ -64,7 +68,7 @@ wxColour StateColor::lightModeColorFor(wxColour const &color)
auto iter = gLightColors.find(color);
wxFAIL(iter != gLightColors.end());
if (iter != gLightColors.end()) return iter->second;
return *wxRED;
return color;
}
wxColour StateColor::darkModeColorFor(wxColour const &color) { return darkModeColorFor2(color); }

View file

@ -19,7 +19,7 @@ END_EVENT_TABLE()
TempInput::TempInput()
: label_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled),std::make_pair(0x323A3D, (int) StateColor::Normal))
: label_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled),std::make_pair(0x323A3C, (int) StateColor::Normal))
, text_color(std::make_pair(wxColour(0xAC,0xAC,0xAC), (int) StateColor::Disabled), std::make_pair(0x6B6B6B, (int) StateColor::Normal))
{
hover = false;
@ -46,6 +46,7 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString
state_handler.attach({&label_color, &text_color});
state_handler.update_binds();
text_ctrl = new wxTextCtrl(this, wxID_ANY, text, {5, 5}, wxDefaultSize, wxTE_PROCESS_ENTER | wxBORDER_NONE, wxTextValidator(wxFILTER_NUMERIC), wxTextCtrlNameStr);
text_ctrl->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
text_ctrl->SetMaxLength(3);
state_handler.attach_child(text_ctrl);
text_ctrl->Bind(wxEVT_SET_FOCUS, [this](auto &e) {
@ -417,6 +418,8 @@ void TempInput::render(wxDC &dc)
} else {
pt.y = (size.y - labelSize.y) / 2;
}
dc.SetTextForeground(StateColor::darkModeColorFor("#323A3C"));
dc.DrawText(text, pt);
// separator

View file

@ -184,6 +184,8 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
else
e.Skip();
});
wxGetApp().UpdateDlgDarkUI(this);
}
void WipingPanel::create_panels(wxWindow* parent, const int num) {

View file

@ -0,0 +1,821 @@
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/settings.h"
#include "wx/font.h"
#include "wx/msw/colour.h"
#include "dark_mode.hpp"
#include "dark_mode/dark_mode.hpp"
#include "dark_mode/UAHMenuBar.hpp"
#include <Shlwapi.h>
#include "windowsx.h"
#include "stdlib.h"
#ifdef __GNUC__
#include <cmath>
#define WINAPI_LAMBDA WINAPI
#else
#define WINAPI_LAMBDA
#endif
#ifdef __BORLANDC__
#pragma comment(lib, "uxtheme.lib")
#endif
namespace NppDarkMode
{
bool IsEnabled()
{
return g_darkModeEnabled;
}
bool IsSupported()
{
return g_darkModeSupported;
}
bool IsSystemMenuEnabled()
{
return g_SystemMenuEnabled;
}
COLORREF InvertLightness(COLORREF c)
{
WORD h = 0;
WORD s = 0;
WORD l = 0;
ColorRGBToHLS(c, &h, &l, &s);
l = 240 - l;
COLORREF invert_c = ColorHLSToRGB(h, l, s);
return invert_c;
}
COLORREF InvertLightnessSofter(COLORREF c)
{
WORD h = 0;
WORD s = 0;
WORD l = 0;
ColorRGBToHLS(c, &h, &l, &s);
l = std::min(240 - l, 211);
COLORREF invert_c = ColorHLSToRGB(h, l, s);
return invert_c;
}
COLORREF GetBackgroundColor()
{
return IsEnabled() ? RGB(0x2B, 0x2B, 0x2B) : wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR).GetRGB();
}
COLORREF GetSofterBackgroundColor()
{
return IsEnabled() ? RGB(0x40, 0x40, 0x40) : RGB(0xD9, 0xD9, 0xD9); //RGB(0x78, 0x78, 0x78);
}
COLORREF GetTextColor()
{
return IsEnabled() ? RGB(0xF0, 0xF0, 0xF0) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT).GetRGB();
}
COLORREF GetHotTextColor()
{
return IsEnabled() ? RGB(0xFF, 0xFF, 0xFF) : wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVEBORDER).GetRGB();
}
COLORREF GetSofterTextColor()
{
return IsEnabled() ? RGB(0xF0, 0xF0, 0xF0) : RGB(0x64, 0x64, 0x64);
}
COLORREF GetDarkerTextColor()
{
return RGB(0xC0, 0xC0, 0xC0);
}
COLORREF GetEdgeColor()
{
return RGB(0x80, 0x80, 0x80);
}
HBRUSH GetBackgroundBrush()
{
static HBRUSH g_hbrBackground = ::CreateSolidBrush(GetBackgroundColor());
return g_hbrBackground;
}
HPEN GetDarkerTextPen()
{
static HPEN g_hpDarkerText = ::CreatePen(PS_SOLID, 1, GetDarkerTextColor());
return g_hpDarkerText;
}
HPEN GetEdgePen()
{
static HPEN g_hpEdgePen = ::CreatePen(PS_SOLID, 1, GetEdgeColor());
return g_hpEdgePen;
}
HBRUSH GetSofterBackgroundBrush()
{
static HBRUSH g_hbrSofterBackground = ::CreateSolidBrush(GetSofterBackgroundColor());
return g_hbrSofterBackground;
}
// handle events
bool OnSettingChange(HWND hwnd, LPARAM lParam) // true if dark mode toggled
{
bool toggled = false;
if (IsColorSchemeChangeMessage(lParam))
{
bool darkModeWasEnabled = g_darkModeEnabled;
g_darkModeEnabled = _ShouldAppsUseDarkMode() && !IsHighContrast();
NppDarkMode::RefreshTitleBarThemeColor(hwnd);
if (!!darkModeWasEnabled != !!g_darkModeEnabled) {
toggled = true;
RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);
}
}
return toggled;
}
// processes messages related to UAH / custom menubar drawing.
// return true if handled, false to continue with normal processing in your wndproc
bool UAHWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lr)
{
if (!IsEnabled())
return false;
static HTHEME g_menuTheme = nullptr;
UNREFERENCED_PARAMETER(wParam);
switch (message)
{
case WM_UAHDRAWMENU:
{
UAHMENU* pUDM = (UAHMENU*)lParam;
RECT rc = { 0 };
// get the menubar rect
{
MENUBARINFO mbi = { sizeof(mbi) };
GetMenuBarInfo(hWnd, OBJID_MENU, 0, &mbi);
RECT rcWindow;
GetWindowRect(hWnd, &rcWindow);
// the rcBar is offset by the window rect
rc = mbi.rcBar;
OffsetRect(&rc, -rcWindow.left, -rcWindow.top);
rc.top -= 1;
}
FillRect(pUDM->hdc, &rc, GetBackgroundBrush());
*lr = 0;
return true;
}
case WM_UAHDRAWMENUITEM:
{
UAHDRAWMENUITEM* pUDMI = (UAHDRAWMENUITEM*)lParam;
// get the menu item string
wchar_t menuString[256] = { 0 };
MENUITEMINFO mii = { sizeof(mii), MIIM_STRING };
{
mii.dwTypeData = menuString;
mii.cch = (sizeof(menuString) / 2) - 1;
GetMenuItemInfo(pUDMI->um.hmenu, pUDMI->umi.iPosition, TRUE, &mii);
}
// get the item state for drawing
DWORD dwFlags = DT_CENTER | DT_SINGLELINE | DT_VCENTER;
int iTextStateID = MPI_NORMAL;
int iBackgroundStateID = MPI_NORMAL;
{
if ((pUDMI->dis.itemState & ODS_INACTIVE) | (pUDMI->dis.itemState & ODS_DEFAULT)) {
// normal display
iTextStateID = MPI_NORMAL;
iBackgroundStateID = MPI_NORMAL;
}
if (pUDMI->dis.itemState & ODS_HOTLIGHT) {
// hot tracking
iTextStateID = MPI_HOT;
iBackgroundStateID = MPI_HOT;
}
if (pUDMI->dis.itemState & ODS_SELECTED) {
// clicked -- MENU_POPUPITEM has no state for this, though MENU_BARITEM does
iTextStateID = MPI_HOT;
iBackgroundStateID = MPI_HOT;
}
if ((pUDMI->dis.itemState & ODS_GRAYED) || (pUDMI->dis.itemState & ODS_DISABLED)) {
// disabled / grey text
iTextStateID = MPI_DISABLED;
iBackgroundStateID = MPI_DISABLED;
}
if (pUDMI->dis.itemState & ODS_NOACCEL) {
dwFlags |= DT_HIDEPREFIX;
}
}
if (!g_menuTheme) {
g_menuTheme = OpenThemeData(hWnd, L"Menu");
}
if (iBackgroundStateID == MPI_NORMAL || iBackgroundStateID == MPI_DISABLED) {
FillRect(pUDMI->um.hdc, &pUDMI->dis.rcItem, NppDarkMode::GetBackgroundBrush());
}
else if (iBackgroundStateID == MPI_HOT) {
FillRect(pUDMI->um.hdc, &pUDMI->dis.rcItem, NppDarkMode::GetSofterBackgroundBrush());
}
else {
DrawThemeBackground(g_menuTheme, pUDMI->um.hdc, MENU_POPUPITEM, iBackgroundStateID, &pUDMI->dis.rcItem, nullptr);
}
DTTOPTS dttopts = { sizeof(dttopts) };
if (iTextStateID == MPI_NORMAL || iTextStateID == MPI_HOT) {
dttopts.dwFlags |= DTT_TEXTCOLOR;
dttopts.crText = NppDarkMode::GetTextColor();
}
DrawThemeTextEx(g_menuTheme, pUDMI->um.hdc, MENU_POPUPITEM, iTextStateID, menuString, mii.cch, dwFlags, &pUDMI->dis.rcItem, &dttopts);
*lr = 0;
return true;
}
case WM_THEMECHANGED:
{
if (g_menuTheme) {
CloseThemeData(g_menuTheme);
g_menuTheme = nullptr;
}
// continue processing in main wndproc
return false;
}
default:
return false;
}
}
void DrawUAHMenuNCBottomLine(HWND hWnd)
{
MENUBARINFO mbi = { sizeof(mbi) };
if (!GetMenuBarInfo(hWnd, OBJID_MENU, 0, &mbi))
{
return;
}
RECT rcClient = { 0 };
GetClientRect(hWnd, &rcClient);
MapWindowPoints(hWnd, nullptr, (POINT*)&rcClient, 2);
RECT rcWindow = { 0 };
GetWindowRect(hWnd, &rcWindow);
OffsetRect(&rcClient, -rcWindow.left, -rcWindow.top);
// the rcBar is offset by the window rect
RECT rcAnnoyingLine = rcClient;
rcAnnoyingLine.bottom = rcAnnoyingLine.top;
rcAnnoyingLine.top--;
HDC hdc = GetWindowDC(hWnd);
FillRect(hdc, &rcAnnoyingLine, GetBackgroundBrush());
ReleaseDC(hWnd, hdc);
}
// from DarkMode.h
void InitDarkMode(bool set_dark_mode, bool set_sys_menu)
{
::InitDarkMode();
g_SystemMenuEnabled = set_sys_menu;
SetDarkMode(set_dark_mode);
}
void SetDarkMode(bool dark_mode)
{
g_darkModeEnabled = dark_mode;
if (!IsSupported())
return;
AllowDarkModeForApp(dark_mode);
if (g_SystemMenuEnabled && _FlushMenuThemes)
_FlushMenuThemes();
FixDarkScrollBar();
}
void SetSystemMenuForApp(bool set_sys_menu)
{
if (IsSupported())
g_SystemMenuEnabled = set_sys_menu;
}
void AllowDarkModeForApp(bool allow)
{
if (IsSupported())
::AllowDarkModeForApp(allow);
}
bool AllowDarkModeForWindow(HWND hWnd, bool allow)
{
if (IsSupported())
return ::AllowDarkModeForWindow(hWnd, allow);
return false;
}
void RefreshTitleBarThemeColor(HWND hWnd)
{
if (IsSupported())
::RefreshTitleBarThemeColor(hWnd);
}
void EnableDarkScrollBarForWindowAndChildren(HWND hwnd)
{
if (IsSupported())
::EnableDarkScrollBarForWindowAndChildren(hwnd);
}
void SetDarkTitleBar(HWND hwnd)
{
if (!IsSupported())
return;
::AllowDarkModeForWindow(hwnd, IsEnabled());
::RefreshTitleBarThemeColor(hwnd);
SetDarkExplorerTheme(hwnd);
}
void SetDarkExplorerTheme(HWND hwnd)
{
if (IsSupported())
SetWindowTheme(hwnd, IsEnabled() ? L"DarkMode_Explorer" : nullptr, nullptr);
}
void SetDarkListView(HWND hwnd)
{
if (!IsSupported())
return;
bool useDark = IsEnabled();
if (HWND hHeader = ListView_GetHeader(hwnd)) {
_AllowDarkModeForWindow(hHeader, useDark);
SetWindowTheme(hHeader, useDark ? L"ItemsView" : nullptr, nullptr);
}
_AllowDarkModeForWindow(hwnd, useDark);
SetWindowTheme(hwnd, L"Explorer", nullptr);
}
void SetDarkListViewHeader(HWND hHeader)
{
if (!IsSupported())
return;
bool useDark = IsEnabled();
_AllowDarkModeForWindow(hHeader, useDark);
SetWindowTheme(hHeader, useDark ? L"ItemsView" : nullptr, nullptr);
}
int scaled(HWND hwnd, int val)
{
float scale = 1.0;
// Both GetDpiForWindow and GetDpiForSystem shall be supported since Windows 10, version 1607
if (_GetDpiForWindow && _GetDpiForSystem)
scale = float(_GetDpiForWindow(hwnd)) / _GetDpiForSystem();
return std::round(scale * val);
}
struct ButtonData
{
HTHEME hTheme = nullptr;
int iStateID = 0;
POINT mouse_pos{ -1,-1 };
~ButtonData()
{
closeTheme();
}
bool ensureTheme(HWND hwnd)
{
if (!hTheme)
{
hTheme = OpenThemeData(hwnd, L"Button");
}
return hTheme != nullptr;
}
void closeTheme()
{
if (hTheme)
{
CloseThemeData(hTheme);
hTheme = nullptr;
}
}
};
void renderButton(HWND hwnd, HDC hdc, HTHEME hTheme, int iPartID, int iStateID)
{
RECT rcClient = { 0 };
DWORD nStyle = GetWindowLong(hwnd, GWL_STYLE);
/* WCHAR szText[256] = { 0 };
DWORD nState = static_cast<DWORD>(SendMessage(hwnd, BM_GETSTATE, 0, 0));
DWORD uiState = static_cast<DWORD>(SendMessage(hwnd, WM_QUERYUISTATE, 0, 0));
HFONT hFont = nullptr;
HFONT hOldFont = nullptr;
HFONT hCreatedFont = nullptr;
LOGFONT lf = { 0 };
if (SUCCEEDED(GetThemeFont(hTheme, hdc, iPartID, iStateID, TMT_FONT, &lf)))
{
hCreatedFont = CreateFontIndirect(&lf);
hFont = hCreatedFont;
}
if (!hFont) {
hFont = reinterpret_cast<HFONT>(SendMessage(hwnd, WM_GETFONT, 0, 0));
}
hOldFont = static_cast<HFONT>(SelectObject(hdc, hFont));
DWORD dtFlags = DT_LEFT; // DT_LEFT is 0
dtFlags |= (nStyle & BS_MULTILINE) ? DT_WORDBREAK : DT_SINGLELINE;
dtFlags |= ((nStyle & BS_CENTER) == BS_CENTER) ? DT_CENTER : (nStyle & BS_RIGHT) ? DT_RIGHT : 0;
dtFlags |= ((nStyle & BS_VCENTER) == BS_VCENTER) ? DT_VCENTER : (nStyle & BS_BOTTOM) ? DT_BOTTOM : 0;
dtFlags |= (uiState & UISF_HIDEACCEL) ? DT_HIDEPREFIX : 0;
if (!(nStyle & BS_MULTILINE) && !(nStyle & BS_BOTTOM) && !(nStyle & BS_TOP))
{
dtFlags |= DT_VCENTER;
}
GetClientRect(hwnd, &rcClient);
GetWindowText(hwnd, szText, _countof(szText));
SIZE szBox = { 13, 13 };
GetThemePartSize(hTheme, hdc, iPartID, iStateID, NULL, TS_DRAW, &szBox);
RECT rcText = rcClient;
GetThemeBackgroundContentRect(hTheme, hdc, iPartID, iStateID, &rcClient, &rcText);
RECT rcBackground = rcClient;
if (dtFlags & DT_SINGLELINE)
{
rcBackground.top += (rcText.bottom - rcText.top - szBox.cy) / 2;
}
rcBackground.bottom = rcBackground.top + szBox.cy;
rcBackground.right = rcBackground.left + szBox.cx;
rcText.left = rcBackground.right + 3;
DrawThemeParentBackground(hwnd, hdc, &rcClient);
DrawThemeBackground(hTheme, hdc, iPartID, iStateID, &rcBackground, nullptr);
DTTOPTS dtto = { sizeof(DTTOPTS), DTT_TEXTCOLOR };
dtto.crText = iPartID == SBP_ARROWBTN ? GetSofterTextColor() : GetTextColor();
if (nStyle & WS_DISABLED)
{
dtto.crText = GetSofterBackgroundColor();
}
*/
GetClientRect(hwnd, &rcClient);
DrawThemeParentBackground(hwnd, hdc, &rcClient);
if (iPartID == SBP_ARROWBTN)
{
{
HBRUSH hbrush = ::CreateSolidBrush(RGB(0x64, 0x64, 0x64));
::FrameRect(hdc, &rcClient, hbrush);
::DeleteObject(hbrush);
}
COLORREF color = nStyle & WS_DISABLED ? GetSofterBackgroundColor() : GetSofterTextColor();
HPEN hPen = CreatePen(PS_SOLID, 1, color);
HPEN hOldPen = SelectPen(hdc, hPen);
HBRUSH hBrush = CreateSolidBrush(color);
HBRUSH hOldBrush = SelectBrush(hdc, hBrush);
// Up arrow
RECT rcFocus = rcClient;
rcFocus.bottom *= 0.5;
rcFocus.left += 1;
InflateRect(&rcFocus, -1, -1);
int triangle_edge = int(0.25 * (rcClient.right - rcClient.left));
int left_pos = triangle_edge + 1;
int shift_from_center = 0.5 * triangle_edge;
int bottom_pos = rcFocus.bottom - shift_from_center;
rcFocus.bottom += 1;
POINT vertices_up[] = { {left_pos, bottom_pos }, {left_pos + triangle_edge, bottom_pos - triangle_edge}, {left_pos + 2*triangle_edge, bottom_pos} };
Polygon(hdc, vertices_up, 3);
if (iStateID == ARROWBTNSTATES::ABS_UPHOT)
DrawFocusRect(hdc, &rcFocus);
// Down arrow
rcFocus = rcClient;
rcFocus.top = 0.5 * rcFocus.bottom;
rcFocus.left += 1;
InflateRect(&rcFocus, -1, -1);
int top_pos = rcFocus.top + shift_from_center;
POINT vertices_down[] = { {left_pos, top_pos }, {left_pos + triangle_edge, top_pos + triangle_edge}, {left_pos + 2 * triangle_edge, top_pos} };
Polygon(hdc, vertices_down, 3);
if (iStateID == ARROWBTNSTATES::ABS_DOWNHOT)
DrawFocusRect(hdc, &rcFocus);
SelectBrush(hdc, hOldBrush);
DeleteObject(hBrush);
SelectPen(hdc, hOldPen);
DeleteObject(hPen);
}
/* else
DrawThemeTextEx(hTheme, hdc, iPartID, iStateID, szText, -1, dtFlags, &rcText, &dtto);
if ((nState & BST_FOCUS) && !(uiState & UISF_HIDEFOCUS))
{
RECT rcTextOut = rcText;
dtto.dwFlags |= DTT_CALCRECT;
DrawThemeTextEx(hTheme, hdc, iPartID, iStateID, szText, -1, dtFlags | DT_CALCRECT, &rcTextOut, &dtto);
RECT rcFocus = rcTextOut;
rcFocus.bottom++;
rcFocus.left--;
rcFocus.right++;
DrawFocusRect(hdc, &rcFocus);
}
if (hCreatedFont) DeleteObject(hCreatedFont);
SelectObject(hdc, hOldFont);
*/ }
void paintButton(HWND hwnd, HDC hdc, ButtonData& buttonData)
{
DWORD nState = static_cast<DWORD>(SendMessage(hwnd, BM_GETSTATE, 0, 0));
DWORD nStyle = GetWindowLong(hwnd, GWL_STYLE);
DWORD nButtonStyle = nStyle & 0xF;
int iPartID = BP_CHECKBOX;
if (nButtonStyle == BS_CHECKBOX || nButtonStyle == BS_AUTOCHECKBOX)
{
iPartID = BP_CHECKBOX;
}
else if (nButtonStyle == BS_RADIOBUTTON || nButtonStyle == BS_AUTORADIOBUTTON)
{
iPartID = BP_RADIOBUTTON;
}
else if (nButtonStyle == BS_AUTO3STATE)
{
iPartID = SBP_ARROWBTN;
}
else
{
assert(false);
}
// states of BP_CHECKBOX and BP_RADIOBUTTON are the same
int iStateID = RBS_UNCHECKEDNORMAL;
if (nStyle & WS_DISABLED) iStateID = RBS_UNCHECKEDDISABLED;
else if (nState & BST_PUSHED) iStateID = RBS_UNCHECKEDPRESSED;
else if (nState & BST_HOT) iStateID = RBS_UNCHECKEDHOT;
if (nState & BST_CHECKED) iStateID += 4;
if (BufferedPaintRenderAnimation(hwnd, hdc))
{
return;
}
BP_ANIMATIONPARAMS animParams = { sizeof(animParams) };
animParams.style = BPAS_LINEAR;
if (iStateID != buttonData.iStateID)
{
GetThemeTransitionDuration(buttonData.hTheme, iPartID, buttonData.iStateID, iStateID, TMT_TRANSITIONDURATIONS, &animParams.dwDuration);
}
RECT rcClient = { 0 };
GetClientRect(hwnd, &rcClient);
HDC hdcFrom = nullptr;
HDC hdcTo = nullptr;
HANIMATIONBUFFER hbpAnimation = BeginBufferedAnimation(hwnd, hdc, &rcClient, BPBF_COMPATIBLEBITMAP, nullptr, &animParams, &hdcFrom, &hdcTo);
if (hbpAnimation)
{
if (hdcFrom)
{
renderButton(hwnd, hdcFrom, buttonData.hTheme, iPartID, buttonData.iStateID);
}
if (hdcTo)
{
if (iPartID == SBP_ARROWBTN && (buttonData.iStateID == ARROWBTNSTATES::ABS_DOWNHOT || buttonData.iStateID == ARROWBTNSTATES::ABS_UPHOT) )
iStateID = buttonData.iStateID;
renderButton(hwnd, hdcTo, buttonData.hTheme, iPartID, iStateID);
}
buttonData.iStateID = iStateID;
EndBufferedAnimation(hbpAnimation, TRUE);
}
else
{
renderButton(hwnd, hdc, buttonData.hTheme, iPartID, iStateID);
buttonData.iStateID = iStateID;
}
}
constexpr UINT_PTR g_buttonSubclassID = 42;
LRESULT CALLBACK ButtonSubclass(
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
UINT_PTR uIdSubclass,
DWORD_PTR dwRefData
)
{
UNREFERENCED_PARAMETER(uIdSubclass);
auto pButtonData = reinterpret_cast<ButtonData*>(dwRefData);
auto paint = [pButtonData](HWND hWnd, WPARAM wParam)
{
PAINTSTRUCT ps = { 0 };
HDC hdc = reinterpret_cast<HDC>(wParam);
if (!hdc)
{
hdc = BeginPaint(hWnd, &ps);
}
paintButton(hWnd, hdc, *pButtonData);
if (ps.hdc)
{
EndPaint(hWnd, &ps);
}
};
switch (uMsg)
{
case WM_UPDATEUISTATE:
if (HIWORD(wParam) & (UISF_HIDEACCEL | UISF_HIDEFOCUS))
{
InvalidateRect(hWnd, nullptr, FALSE);
}
break;
case WM_NCDESTROY:
RemoveWindowSubclass(hWnd, ButtonSubclass, g_buttonSubclassID);
delete pButtonData;
break;
case WM_ERASEBKGND:
if (IsEnabled() && pButtonData->ensureTheme(hWnd))
{
return TRUE;
}
else
{
break;
}
case WM_THEMECHANGED:
pButtonData->closeTheme();
break;
case WM_PRINTCLIENT:
case WM_PAINT:
if (pButtonData->ensureTheme(hWnd))
{
paint(hWnd, wParam);
return 0;
}
break;
case WM_MOUSEMOVE:
{
DWORD nStyle = GetWindowLong(hWnd, GWL_STYLE);
DWORD nButtonStyle = nStyle & 0xF;
if (nButtonStyle == BS_AUTO3STATE)
{
int xPos = GET_X_LPARAM(lParam);
int yPos = GET_Y_LPARAM(lParam);
RECT rcClient = { 0 };
GetClientRect(hWnd, &rcClient);
int iStateID = 0;
if (xPos <= rcClient.top || xPos >= rcClient.bottom ||
yPos <= rcClient.left || yPos >= rcClient.right)
iStateID = ARROWBTNSTATES::ABS_UPNORMAL;
else
iStateID = yPos > 0.5 * rcClient.bottom ? ARROWBTNSTATES::ABS_DOWNHOT : ARROWBTNSTATES::ABS_UPHOT;
if (pButtonData->iStateID != iStateID)
{
pButtonData->iStateID = iStateID;
paint(hWnd, wParam);
}
return 0;
}
break;
}
case WM_KEYUP:
case WM_CHAR:
case WM_KEYDOWN:
case WM_VSCROLL:
{
DWORD nState = GET_KEYSTATE_WPARAM(wParam);
if (nState == VK_UP || nState == VK_DOWN) {
int iStateID = nState == VK_DOWN ? ARROWBTNSTATES::ABS_DOWNHOT : ARROWBTNSTATES::ABS_UPHOT;
if (pButtonData->iStateID != iStateID)
{
pButtonData->iStateID = iStateID;
paint(hWnd, wParam);
}
return 0;
}
break;
}
case WM_SIZE:
case WM_DESTROY:
BufferedPaintStopAllAnimations(hWnd);
break;
case WM_ENABLE:
if (IsEnabled())
{
// skip the button's normal wndproc so it won't redraw out of wm_paint
LRESULT lr = DefWindowProc(hWnd, uMsg, wParam, lParam);
InvalidateRect(hWnd, nullptr, FALSE);
return lr;
}
break;
}
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
void subclassButtonControl(HWND hwnd)
{
DWORD_PTR pButtonData = reinterpret_cast<DWORD_PTR>(new ButtonData());
SetWindowSubclass(hwnd, ButtonSubclass, g_buttonSubclassID, pButtonData);
}
void AutoSubclassAndThemeChildControls(HWND hwndParent, bool subclass, bool theme)
{
if (!IsSupported())
return;
struct Params
{
const wchar_t* themeClassName = nullptr;
bool subclass = false;
bool theme = false;
};
Params p{
IsEnabled() ? L"DarkMode_Explorer" : nullptr
, subclass
, theme
};
EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) WINAPI_LAMBDA{
auto & p = *reinterpret_cast<Params*>(lParam);
const size_t classNameLen = 16;
TCHAR className[classNameLen] = { 0 };
GetClassName(hwnd, className, classNameLen);
if (wcscmp(className, UPDOWN_CLASS) == 0)
{
auto nButtonStyle = ::GetWindowLongPtr(hwnd, GWL_STYLE) & 0xF;
if (nButtonStyle == BS_AUTO3STATE && p.subclass)
{
subclassButtonControl(hwnd);
}
return TRUE;
}
return TRUE;
}, reinterpret_cast<LPARAM>(&p));
}
}

View file

@ -0,0 +1,50 @@
#pragma once
#include <Windows.h>
namespace NppDarkMode
{
bool IsEnabled();
bool IsSupported();
bool IsSystemMenuEnabled();
COLORREF InvertLightness(COLORREF c);
COLORREF InvertLightnessSofter(COLORREF c);
COLORREF GetBackgroundColor();
COLORREF GetSofterBackgroundColor();
COLORREF GetTextColor();
COLORREF GetDarkerTextColor();
COLORREF GetEdgeColor();
HBRUSH GetBackgroundBrush();
HBRUSH GetSofterBackgroundBrush();
// handle events
bool OnSettingChange(HWND hwnd, LPARAM lParam); // true if dark mode toggled
// processes messages related to UAH / custom menubar drawing.
// return true if handled, false to continue with normal processing in your wndproc
bool UAHWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lr);
void DrawUAHMenuNCBottomLine(HWND hWnd);
// from DarkMode.h
void InitDarkMode(bool set_dark_mode, bool set_sys_menu);
void SetDarkMode(bool set_dark_mode);
void SetSystemMenuForApp(bool set_sys_menu);
void AllowDarkModeForApp(bool allow);
bool AllowDarkModeForWindow(HWND hWnd, bool allow);
void RefreshTitleBarThemeColor(HWND hWnd);
// enhancements to DarkMode.h
void EnableDarkScrollBarForWindowAndChildren(HWND hwnd);
void SetDarkTitleBar(HWND hwnd);
void SetDarkExplorerTheme(HWND hwnd);
void SetDarkListView(HWND hwnd);
void SetDarkListViewHeader(HWND hwnd);
void AutoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
}

View file

@ -0,0 +1,94 @@
// This file contains code from
// https://github.com/stevemk14ebr/PolyHook_2_0/blob/master/sources/IatHook.cpp
// which is licensed under the MIT License.
// See PolyHook_2_0-LICENSE for more information.
#pragma once
#include <stdint.h>
template <typename T, typename T1, typename T2>
constexpr T RVA2VA(T1 base, T2 rva)
{
return reinterpret_cast<T>(reinterpret_cast<ULONG_PTR>(base) + rva);
}
template <typename T>
constexpr T DataDirectoryFromModuleBase(void *moduleBase, size_t entryID)
{
auto dosHdr = reinterpret_cast<PIMAGE_DOS_HEADER>(moduleBase);
auto ntHdr = RVA2VA<PIMAGE_NT_HEADERS>(moduleBase, dosHdr->e_lfanew);
auto dataDir = ntHdr->OptionalHeader.DataDirectory;
return RVA2VA<T>(moduleBase, dataDir[entryID].VirtualAddress);
}
PIMAGE_THUNK_DATA FindAddressByName(void *moduleBase, PIMAGE_THUNK_DATA impName, PIMAGE_THUNK_DATA impAddr, const char *funcName)
{
for (; impName->u1.Ordinal; ++impName, ++impAddr)
{
if (IMAGE_SNAP_BY_ORDINAL(impName->u1.Ordinal))
continue;
auto import = RVA2VA<PIMAGE_IMPORT_BY_NAME>(moduleBase, impName->u1.AddressOfData);
if (strcmp(import->Name, funcName) != 0)
continue;
return impAddr;
}
return nullptr;
}
PIMAGE_THUNK_DATA FindAddressByOrdinal(void *moduleBase, PIMAGE_THUNK_DATA impName, PIMAGE_THUNK_DATA impAddr, uint16_t ordinal)
{
UNREFERENCED_PARAMETER(moduleBase);
for (; impName->u1.Ordinal; ++impName, ++impAddr)
{
if (IMAGE_SNAP_BY_ORDINAL(impName->u1.Ordinal) && IMAGE_ORDINAL(impName->u1.Ordinal) == ordinal)
return impAddr;
}
return nullptr;
}
PIMAGE_THUNK_DATA FindIatThunkInModule(void *moduleBase, const char *dllName, const char *funcName)
{
auto imports = DataDirectoryFromModuleBase<PIMAGE_IMPORT_DESCRIPTOR>(moduleBase, IMAGE_DIRECTORY_ENTRY_IMPORT);
for (; imports->Name; ++imports)
{
if (_stricmp(RVA2VA<LPCSTR>(moduleBase, imports->Name), dllName) != 0)
continue;
auto origThunk = RVA2VA<PIMAGE_THUNK_DATA>(moduleBase, imports->OriginalFirstThunk);
auto thunk = RVA2VA<PIMAGE_THUNK_DATA>(moduleBase, imports->FirstThunk);
return FindAddressByName(moduleBase, origThunk, thunk, funcName);
}
return nullptr;
}
PIMAGE_THUNK_DATA FindDelayLoadThunkInModule(void *moduleBase, const char *dllName, const char *funcName)
{
auto imports = DataDirectoryFromModuleBase<PIMAGE_DELAYLOAD_DESCRIPTOR>(moduleBase, IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT);
for (; imports->DllNameRVA; ++imports)
{
if (_stricmp(RVA2VA<LPCSTR>(moduleBase, imports->DllNameRVA), dllName) != 0)
continue;
auto impName = RVA2VA<PIMAGE_THUNK_DATA>(moduleBase, imports->ImportNameTableRVA);
auto impAddr = RVA2VA<PIMAGE_THUNK_DATA>(moduleBase, imports->ImportAddressTableRVA);
return FindAddressByName(moduleBase, impName, impAddr, funcName);
}
return nullptr;
}
PIMAGE_THUNK_DATA FindDelayLoadThunkInModule(void *moduleBase, const char *dllName, uint16_t ordinal)
{
auto imports = DataDirectoryFromModuleBase<PIMAGE_DELAYLOAD_DESCRIPTOR>(moduleBase, IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT);
for (; imports->DllNameRVA; ++imports)
{
if (_stricmp(RVA2VA<LPCSTR>(moduleBase, imports->DllNameRVA), dllName) != 0)
continue;
auto impName = RVA2VA<PIMAGE_THUNK_DATA>(moduleBase, imports->ImportNameTableRVA);
auto impAddr = RVA2VA<PIMAGE_THUNK_DATA>(moduleBase, imports->ImportAddressTableRVA);
return FindAddressByOrdinal(moduleBase, impName, impAddr, ordinal);
}
return nullptr;
}

View file

@ -0,0 +1,74 @@
#pragma once
// MIT license, see LICENSE
// Copyright(c) 2021 adzm / Adam D. Walling
// processes messages related to UAH / custom menubar drawing.
// return true if handled, false to continue with normal processing in your wndproc
bool UAHDarkModeWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* lr);
// window messages related to menu bar drawing
#define WM_UAHDESTROYWINDOW 0x0090 // handled by DefWindowProc
#define WM_UAHDRAWMENU 0x0091 // lParam is UAHMENU
#define WM_UAHDRAWMENUITEM 0x0092 // lParam is UAHDRAWMENUITEM
#define WM_UAHINITMENU 0x0093 // handled by DefWindowProc
#define WM_UAHMEASUREMENUITEM 0x0094 // lParam is UAHMEASUREMENUITEM
#define WM_UAHNCPAINTMENUPOPUP 0x0095 // handled by DefWindowProc
// describes the sizes of the menu bar or menu item
typedef union tagUAHMENUITEMMETRICS
{
// cx appears to be 14 / 0xE less than rcItem's width!
// cy 0x14 seems stable, i wonder if it is 4 less than rcItem's height which is always 24 atm
struct {
DWORD cx;
DWORD cy;
} rgsizeBar[2];
struct {
DWORD cx;
DWORD cy;
} rgsizePopup[4];
} UAHMENUITEMMETRICS;
// not really used in our case but part of the other structures
typedef struct tagUAHMENUPOPUPMETRICS
{
DWORD rgcx[4];
DWORD fUpdateMaxWidths : 2; // from kernel symbols, padded to full dword
} UAHMENUPOPUPMETRICS;
// hmenu is the main window menu; hdc is the context to draw in
typedef struct tagUAHMENU
{
HMENU hmenu;
HDC hdc;
DWORD dwFlags; // no idea what these mean, in my testing it's either 0x00000a00 or sometimes 0x00000a10
} UAHMENU;
// menu items are always referred to by iPosition here
typedef struct tagUAHMENUITEM
{
int iPosition; // 0-based position of menu item in menubar
UAHMENUITEMMETRICS umim;
UAHMENUPOPUPMETRICS umpm;
} UAHMENUITEM;
// the DRAWITEMSTRUCT contains the states of the menu items, as well as
// the position index of the item in the menu, which is duplicated in
// the UAHMENUITEM's iPosition as well
typedef struct UAHDRAWMENUITEM
{
DRAWITEMSTRUCT dis; // itemID looks uninitialized
UAHMENU um;
UAHMENUITEM umi;
} UAHDRAWMENUITEM;
// the MEASUREITEMSTRUCT is intended to be filled with the size of the item
// height appears to be ignored, but width can be modified
typedef struct tagUAHMEASUREMENUITEM
{
MEASUREITEMSTRUCT mis;
UAHMENU um;
UAHMENUITEM umi;
} UAHMEASUREMENUITEM;

View file

@ -0,0 +1,275 @@
#pragma once
#include "IatHook.hpp"
#include <Windows.h>
#include <Uxtheme.h>
#include <Vssym32.h>
#include <unordered_set>
#include <mutex>
enum IMMERSIVE_HC_CACHE_MODE
{
IHCM_USE_CACHED_VALUE,
IHCM_REFRESH
};
// 1903 18362
enum PreferredAppMode
{
Default,
AllowDark,
ForceDark,
ForceLight,
Max
};
enum WINDOWCOMPOSITIONATTRIB
{
WCA_UNDEFINED = 0,
WCA_NCRENDERING_ENABLED = 1,
WCA_NCRENDERING_POLICY = 2,
WCA_TRANSITIONS_FORCEDISABLED = 3,
WCA_ALLOW_NCPAINT = 4,
WCA_CAPTION_BUTTON_BOUNDS = 5,
WCA_NONCLIENT_RTL_LAYOUT = 6,
WCA_FORCE_ICONIC_REPRESENTATION = 7,
WCA_EXTENDED_FRAME_BOUNDS = 8,
WCA_HAS_ICONIC_BITMAP = 9,
WCA_THEME_ATTRIBUTES = 10,
WCA_NCRENDERING_EXILED = 11,
WCA_NCADORNMENTINFO = 12,
WCA_EXCLUDED_FROM_LIVEPREVIEW = 13,
WCA_VIDEO_OVERLAY_ACTIVE = 14,
WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15,
WCA_DISALLOW_PEEK = 16,
WCA_CLOAK = 17,
WCA_CLOAKED = 18,
WCA_ACCENT_POLICY = 19,
WCA_FREEZE_REPRESENTATION = 20,
WCA_EVER_UNCLOAKED = 21,
WCA_VISUAL_OWNER = 22,
WCA_HOLOGRAPHIC = 23,
WCA_EXCLUDED_FROM_DDA = 24,
WCA_PASSIVEUPDATEMODE = 25,
WCA_USEDARKMODECOLORS = 26,
WCA_LAST = 27
};
struct WINDOWCOMPOSITIONATTRIBDATA
{
WINDOWCOMPOSITIONATTRIB Attrib;
PVOID pvData;
SIZE_T cbData;
};
using fnRtlGetNtVersionNumbers = void (WINAPI *)(LPDWORD major, LPDWORD minor, LPDWORD build);
using fnSetWindowCompositionAttribute = BOOL (WINAPI *)(HWND hWnd, WINDOWCOMPOSITIONATTRIBDATA*);
using fnGetDpiForWindow = UINT (WINAPI*)(_In_ HWND hwnd);
using fnGetDpiForSystem = UINT(WINAPI*)();
// 1809 17763
using fnShouldAppsUseDarkMode = bool (WINAPI *)(); // ordinal 132
using fnAllowDarkModeForWindow = bool (WINAPI *)(HWND hWnd, bool allow); // ordinal 133
using fnAllowDarkModeForApp = bool (WINAPI *)(bool allow); // ordinal 135, in 1809
using fnFlushMenuThemes = void (WINAPI *)(); // ordinal 136
using fnRefreshImmersiveColorPolicyState = void (WINAPI *)(); // ordinal 104
using fnIsDarkModeAllowedForWindow = bool (WINAPI *)(HWND hWnd); // ordinal 137
using fnGetIsImmersiveColorUsingHighContrast = bool (WINAPI *)(IMMERSIVE_HC_CACHE_MODE mode); // ordinal 106
using fnOpenNcThemeData = HTHEME(WINAPI *)(HWND hWnd, LPCWSTR pszClassList); // ordinal 49
// 1903 18362
using fnShouldSystemUseDarkMode = bool (WINAPI *)(); // ordinal 138
using fnSetPreferredAppMode = PreferredAppMode (WINAPI *)(PreferredAppMode appMode); // ordinal 135, in 1903
using fnIsDarkModeAllowedForApp = bool (WINAPI *)(); // ordinal 139
fnSetWindowCompositionAttribute _SetWindowCompositionAttribute = nullptr;
fnGetDpiForWindow _GetDpiForWindow = nullptr;
fnGetDpiForSystem _GetDpiForSystem = nullptr;
fnShouldAppsUseDarkMode _ShouldAppsUseDarkMode = nullptr;
fnAllowDarkModeForWindow _AllowDarkModeForWindow = nullptr;
fnAllowDarkModeForApp _AllowDarkModeForApp = nullptr;
fnFlushMenuThemes _FlushMenuThemes = nullptr;
fnRefreshImmersiveColorPolicyState _RefreshImmersiveColorPolicyState = nullptr;
fnIsDarkModeAllowedForWindow _IsDarkModeAllowedForWindow = nullptr;
fnGetIsImmersiveColorUsingHighContrast _GetIsImmersiveColorUsingHighContrast = nullptr;
fnOpenNcThemeData _OpenNcThemeData = nullptr;
// 1903 18362
fnShouldSystemUseDarkMode _ShouldSystemUseDarkMode = nullptr;
fnSetPreferredAppMode _SetPreferredAppMode = nullptr;
bool g_darkModeSupported = false;
bool g_darkModeEnabled = false;
bool g_SystemMenuEnabled = true;
DWORD g_buildNumber = 0;
bool AllowDarkModeForWindow(HWND hWnd, bool allow)
{
if (g_darkModeSupported)
return _AllowDarkModeForWindow(hWnd, allow);
return false;
}
bool IsHighContrast()
{
HIGHCONTRASTW highContrast = { sizeof(highContrast) };
if (SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(highContrast), &highContrast, FALSE))
return highContrast.dwFlags & HCF_HIGHCONTRASTON;
return false;
}
void RefreshTitleBarThemeColor(HWND hWnd)
{
BOOL dark = FALSE;
if (_IsDarkModeAllowedForWindow(hWnd) &&
_ShouldAppsUseDarkMode() &&
!IsHighContrast())
{
dark = TRUE;
}
if (g_buildNumber < 18362)
SetPropW(hWnd, L"UseImmersiveDarkModeColors", reinterpret_cast<HANDLE>(static_cast<INT_PTR>(dark)));
else if (_SetWindowCompositionAttribute)
{
WINDOWCOMPOSITIONATTRIBDATA data = { WCA_USEDARKMODECOLORS, &dark, sizeof(dark) };
_SetWindowCompositionAttribute(hWnd, &data);
}
}
bool IsColorSchemeChangeMessage(LPARAM lParam)
{
bool is = false;
if (lParam && (0 == lstrcmpi(reinterpret_cast<LPCWCH>(lParam), L"ImmersiveColorSet")))
{
_RefreshImmersiveColorPolicyState();
is = true;
}
_GetIsImmersiveColorUsingHighContrast(IHCM_REFRESH);
return is;
}
bool IsColorSchemeChangeMessage(UINT message, LPARAM lParam)
{
if (message == WM_SETTINGCHANGE)
return IsColorSchemeChangeMessage(lParam);
return false;
}
void AllowDarkModeForApp(bool allow)
{
if (_AllowDarkModeForApp)
_AllowDarkModeForApp(allow);
else if (_SetPreferredAppMode)
_SetPreferredAppMode(allow ? ForceDark : ForceLight);
}
// limit dark scroll bar to specific windows and their children
std::unordered_set<HWND> g_darkScrollBarWindows;
std::mutex g_darkScrollBarMutex;
void EnableDarkScrollBarForWindowAndChildren(HWND hwnd)
{
std::lock_guard<std::mutex> lock(g_darkScrollBarMutex);
g_darkScrollBarWindows.insert(hwnd);
}
bool IsWindowOrParentUsingDarkScrollBar(HWND hwnd)
{
HWND hwndRoot = GetAncestor(hwnd, GA_ROOT);
std::lock_guard<std::mutex> lock(g_darkScrollBarMutex);
if (g_darkScrollBarWindows.count(hwnd)) {
return true;
}
if (hwnd != hwndRoot && g_darkScrollBarWindows.count(hwndRoot)) {
return true;
}
return false;
}
void FixDarkScrollBar()
{
HMODULE hComctl = LoadLibraryExW(L"comctl32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hComctl)
{
auto addr = FindDelayLoadThunkInModule(hComctl, "uxtheme.dll", 49); // OpenNcThemeData
if (addr)
{
DWORD oldProtect;
if (VirtualProtect(addr, sizeof(IMAGE_THUNK_DATA), PAGE_READWRITE, &oldProtect))
{
auto MyOpenThemeData = [](HWND hWnd, LPCWSTR classList) -> HTHEME {
if (wcscmp(classList, L"ScrollBar") == 0) {
hWnd = nullptr;
classList = L"Explorer::ScrollBar";
}
if (wcscmp(classList, L"MENU") == 0) {
hWnd = nullptr;
classList = L"Explorer::Menu";
}
return _OpenNcThemeData(hWnd, classList);
};
addr->u1.Function = reinterpret_cast<ULONG_PTR>(static_cast<fnOpenNcThemeData>(MyOpenThemeData));
VirtualProtect(addr, sizeof(IMAGE_THUNK_DATA), oldProtect, &oldProtect);
}
}
}
}
constexpr bool CheckBuildNumber(DWORD buildNumber)
{
return (buildNumber == 17763 || // 1809
buildNumber == 18362 || // 1903
buildNumber == 18363 || // 1909
buildNumber >= 19041); // Windows 10 any version > 2004 and newer
}
void InitDarkMode()
{
auto RtlGetNtVersionNumbers = reinterpret_cast<fnRtlGetNtVersionNumbers>(GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetNtVersionNumbers"));
if (RtlGetNtVersionNumbers)
{
DWORD major, minor;
RtlGetNtVersionNumbers(&major, &minor, &g_buildNumber);
g_buildNumber &= ~0xF0000000;
if (major == 10 && minor == 0 && CheckBuildNumber(g_buildNumber))
{
HMODULE hUxtheme = LoadLibraryExW(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hUxtheme)
{
_OpenNcThemeData = reinterpret_cast<fnOpenNcThemeData>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(49)));
_RefreshImmersiveColorPolicyState = reinterpret_cast<fnRefreshImmersiveColorPolicyState>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(104)));
_GetIsImmersiveColorUsingHighContrast = reinterpret_cast<fnGetIsImmersiveColorUsingHighContrast>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(106)));
_ShouldAppsUseDarkMode = reinterpret_cast<fnShouldAppsUseDarkMode>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(132)));
_AllowDarkModeForWindow = reinterpret_cast<fnAllowDarkModeForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(133)));
auto ord135 = GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135));
if (g_buildNumber < 18362)
_AllowDarkModeForApp = reinterpret_cast<fnAllowDarkModeForApp>(ord135);
else
_SetPreferredAppMode = reinterpret_cast<fnSetPreferredAppMode>(ord135);
_FlushMenuThemes = reinterpret_cast<fnFlushMenuThemes>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136)));
_IsDarkModeAllowedForWindow = reinterpret_cast<fnIsDarkModeAllowedForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(137)));
_SetWindowCompositionAttribute = reinterpret_cast<fnSetWindowCompositionAttribute>(GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetWindowCompositionAttribute"));
_GetDpiForWindow = reinterpret_cast<fnGetDpiForWindow>(GetProcAddress(GetModuleHandleW(L"user32.dll"), "GetDpiForWindow"));
_GetDpiForSystem = reinterpret_cast<fnGetDpiForSystem>(GetProcAddress(GetModuleHandleW(L"user32.dll"), "GetDpiForSystem"));
if (_OpenNcThemeData &&
_RefreshImmersiveColorPolicyState &&
_ShouldAppsUseDarkMode &&
_AllowDarkModeForWindow &&
(_AllowDarkModeForApp || _SetPreferredAppMode) &&
_FlushMenuThemes &&
_IsDarkModeAllowedForWindow)
{
g_darkModeSupported = true;
}
}
}
}
}