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

@ -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