FIX:adapt to multicolour and semi transparent materials
JIRA:5683,5765,5768,5784,5800 Change-Id: I7c5844279abb316e92714b847e6a88f98c61dfa8
This commit is contained in:
parent
b55bffabb8
commit
eb033ccf79
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.5 0H0V12.5V25H12.5H25V12.5V0H12.5ZM12.5 0C19.4033 0 25 5.59644 25 12.5C25 19.4036 19.4033 25 12.5 25C5.59668 25 0 19.4036 0 12.5C0 5.59644 5.59668 0 12.5 0Z" fill="#2D2D31"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 331 B |
|
@ -1123,6 +1123,7 @@ ColorPicker::ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos /*=
|
||||||
Bind(wxEVT_PAINT, &ColorPicker::paintEvent, this);
|
Bind(wxEVT_PAINT, &ColorPicker::paintEvent, this);
|
||||||
|
|
||||||
m_bitmap_border = create_scaled_bitmap("color_picker_border", nullptr, 25);
|
m_bitmap_border = create_scaled_bitmap("color_picker_border", nullptr, 25);
|
||||||
|
m_bitmap_border_dark = create_scaled_bitmap("color_picker_border_dark", nullptr, 25);
|
||||||
m_bitmap_transparent = create_scaled_bitmap("transparent_color_picker", nullptr, 25);
|
m_bitmap_transparent = create_scaled_bitmap("transparent_color_picker", nullptr, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1131,12 +1132,14 @@ ColorPicker::~ColorPicker(){}
|
||||||
void ColorPicker::msw_rescale()
|
void ColorPicker::msw_rescale()
|
||||||
{
|
{
|
||||||
m_bitmap_border = create_scaled_bitmap("color_picker_border", nullptr, 25);
|
m_bitmap_border = create_scaled_bitmap("color_picker_border", nullptr, 25);
|
||||||
|
m_bitmap_border_dark = create_scaled_bitmap("color_picker_border_dark", nullptr, 25);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPicker::set_color(wxColour col)
|
void ColorPicker::set_color(wxColour col)
|
||||||
{
|
{
|
||||||
if (m_colour != col&&col.Alpha()!=0&&col.Alpha()!=255) {
|
if (m_colour != col && col.Alpha() != 0 && col.Alpha() != 255 && col.Alpha() != 254) {
|
||||||
transparent_changed = true;
|
transparent_changed = true;
|
||||||
}
|
}
|
||||||
m_colour = col;
|
m_colour = col;
|
||||||
|
@ -1186,23 +1189,23 @@ void ColorPicker::doRender(wxDC& dc)
|
||||||
if (alpha == 0) {
|
if (alpha == 0) {
|
||||||
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
||||||
}
|
}
|
||||||
else if (alpha != 0 && alpha != 255) {
|
else if (alpha != 254 && alpha != 255) {
|
||||||
if (transparent_changed) {
|
if (transparent_changed) {
|
||||||
std::string rgb = (m_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString();
|
std::string rgb = (m_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString();
|
||||||
if (rgb.size() == 8) {
|
if (rgb.size() == 8) {
|
||||||
//delete alpha value
|
//delete alpha value
|
||||||
rgb = rgb.substr(0, rgb.size() - 2);
|
rgb = rgb.substr(0, rgb.size() - 2);
|
||||||
}
|
}
|
||||||
float alpha_f = 0.3 * m_colour.Alpha() / 255.0;
|
float alpha_f = 0.7 * m_colour.Alpha() / 255.0;
|
||||||
std::vector<std::string> replace;
|
std::vector<std::string> replace;
|
||||||
replace.push_back(rgb);
|
replace.push_back(rgb);
|
||||||
std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f);
|
std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f);
|
||||||
replace.push_back(fill_replace);
|
replace.push_back(fill_replace);
|
||||||
m_bitmap_transparent = ScalableBitmap(this, "transparent_color_picker", 25, false, false, true, replace).bmp();
|
m_bitmap_transparent = ScalableBitmap(this, "transparent_color_picker", 25, false, false, true, replace).bmp();
|
||||||
transparent_changed = false;
|
transparent_changed = false;
|
||||||
}
|
|
||||||
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
dc.SetPen(wxPen(m_colour));
|
dc.SetPen(wxPen(m_colour));
|
||||||
dc.SetBrush(wxBrush(m_colour));
|
dc.SetBrush(wxBrush(m_colour));
|
||||||
|
@ -1220,10 +1223,6 @@ void ColorPicker::doRender(wxDC& dc)
|
||||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||||
dc.DrawCircle(size.x / 2, size.y / 2, radius);
|
dc.DrawCircle(size.x / 2, size.y / 2, radius);
|
||||||
|
|
||||||
//transparent
|
|
||||||
if (alpha == 0) {
|
|
||||||
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
|
||||||
}
|
|
||||||
if (m_cols.size() > 1) {
|
if (m_cols.size() > 1) {
|
||||||
if (ctype == 0) {
|
if (ctype == 0) {
|
||||||
int left = FromDIP(0);
|
int left = FromDIP(0);
|
||||||
|
@ -1240,8 +1239,13 @@ void ColorPicker::doRender(wxDC& dc)
|
||||||
dc.GradientFillLinear(rect, m_cols[i], m_cols[i + 1], wxEAST);
|
dc.GradientFillLinear(rect, m_cols[i], m_cols[i + 1], wxEAST);
|
||||||
left += gwidth;
|
left += gwidth;
|
||||||
}
|
}
|
||||||
|
if (wxGetApp().dark_mode()) {
|
||||||
|
dc.DrawBitmap(m_bitmap_border_dark, wxPoint(0, 0));
|
||||||
|
}
|
||||||
|
else {
|
||||||
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
float ev_angle = 360.0 / m_cols.size();
|
float ev_angle = 360.0 / m_cols.size();
|
||||||
float startAngle = 270.0;
|
float startAngle = 270.0;
|
||||||
|
@ -1256,10 +1260,15 @@ void ColorPicker::doRender(wxDC& dc)
|
||||||
startAngle += ev_angle;
|
startAngle += ev_angle;
|
||||||
startAngle = startAngle > 360.0 ? startAngle - 360.0 : startAngle;
|
startAngle = startAngle > 360.0 ? startAngle - 360.0 : startAngle;
|
||||||
}
|
}
|
||||||
|
if (wxGetApp().dark_mode()) {
|
||||||
|
dc.DrawBitmap(m_bitmap_border_dark, wxPoint(0, 0));
|
||||||
|
}
|
||||||
|
else {
|
||||||
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_is_empty) {
|
if (m_is_empty) {
|
||||||
dc.SetTextForeground(*wxBLACK);
|
dc.SetTextForeground(*wxBLACK);
|
||||||
|
|
|
@ -34,6 +34,7 @@ class ColorPicker : public wxWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxBitmap m_bitmap_border;
|
wxBitmap m_bitmap_border;
|
||||||
|
wxBitmap m_bitmap_border_dark;
|
||||||
wxBitmap m_bitmap_transparent;
|
wxBitmap m_bitmap_transparent;
|
||||||
|
|
||||||
wxColour m_colour;
|
wxColour m_colour;
|
||||||
|
|
|
@ -264,6 +264,9 @@ void AMSSetting::update_insert_material_read_mode(bool selected)
|
||||||
|
|
||||||
void AMSSetting::update_ams_img(std::string ams_icon_str)
|
void AMSSetting::update_ams_img(std::string ams_icon_str)
|
||||||
{
|
{
|
||||||
|
if (wxGetApp().dark_mode()&& ams_icon_str=="extra_icon") {
|
||||||
|
ams_icon_str += "_dark";
|
||||||
|
}
|
||||||
m_am_img->SetBitmap(create_scaled_bitmap(ams_icon_str, nullptr, 126));
|
m_am_img->SetBitmap(create_scaled_bitmap(ams_icon_str, nullptr, 126));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -863,7 +863,7 @@ void AMSLib::render_generic_text(wxDC &dc)
|
||||||
dc.SetFont(::Label::Body_13);
|
dc.SetFont(::Label::Body_13);
|
||||||
dc.SetTextForeground(temp_text_colour);
|
dc.SetTextForeground(temp_text_colour);
|
||||||
auto alpha = m_info.material_colour.Alpha();
|
auto alpha = m_info.material_colour.Alpha();
|
||||||
if (alpha != 0 && alpha != 255) {
|
if (alpha != 0 && alpha != 255 && alpha != 254) {
|
||||||
dc.SetTextForeground(*wxBLACK);
|
dc.SetTextForeground(*wxBLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1108,6 +1108,9 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
||||||
// selected
|
// selected
|
||||||
if (m_selected) {
|
if (m_selected) {
|
||||||
dc.SetPen(wxPen(tmp_lib_colour, 2, wxSOLID));
|
dc.SetPen(wxPen(tmp_lib_colour, 2, wxSOLID));
|
||||||
|
if (tmp_lib_colour.Alpha() == 0) {
|
||||||
|
dc.SetPen(wxPen(wxColour(tmp_lib_colour.Red(), tmp_lib_colour.Green(),tmp_lib_colour.Blue(),128), 2, wxSOLID));
|
||||||
|
}
|
||||||
dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
|
dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
|
||||||
if (m_radius == 0) {
|
if (m_radius == 0) {
|
||||||
dc.DrawRectangle(0, 0, size.x, size.y);
|
dc.DrawRectangle(0, 0, size.x, size.y);
|
||||||
|
@ -1139,18 +1142,38 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw remain
|
//draw remain
|
||||||
|
auto alpha = m_info.material_colour.Alpha();
|
||||||
int height = size.y - FromDIP(8);
|
int height = size.y - FromDIP(8);
|
||||||
int curr_height = height * float(m_info.material_remain * 1.0 / 100.0); dc.SetFont(::Label::Body_13);
|
int curr_height = height * float(m_info.material_remain * 1.0 / 100.0);
|
||||||
|
dc.SetFont(::Label::Body_13);
|
||||||
|
|
||||||
int top = height - curr_height;
|
int top = height - curr_height;
|
||||||
|
|
||||||
if (curr_height >= FromDIP(6)) {
|
if (curr_height >= FromDIP(6)) {
|
||||||
|
|
||||||
//transparent
|
//transparent
|
||||||
auto alpha = m_info.material_colour.Alpha();
|
|
||||||
if (alpha == 0) {
|
if (alpha == 0) {
|
||||||
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
||||||
}
|
}
|
||||||
|
else if (alpha != 255 && alpha != 254) {
|
||||||
|
if (transparent_changed) {
|
||||||
|
std::string rgb = (tmp_lib_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString();
|
||||||
|
if (rgb.size() == 9) {
|
||||||
|
//delete alpha value
|
||||||
|
rgb = rgb.substr(0, rgb.size() - 2);
|
||||||
|
}
|
||||||
|
float alpha_f = 0.7 * tmp_lib_colour.Alpha() / 255.0;
|
||||||
|
std::vector<std::string> replace;
|
||||||
|
replace.push_back(rgb);
|
||||||
|
std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f);
|
||||||
|
replace.push_back(fill_replace);
|
||||||
|
m_bitmap_transparent = ScalableBitmap(this, "transparent_ams_lib", 68, false, false, true, replace);
|
||||||
|
transparent_changed = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
||||||
|
}
|
||||||
//gradient
|
//gradient
|
||||||
if (m_info.material_cols.size() > 1) {
|
if (m_info.material_cols.size() > 1) {
|
||||||
int left = FromDIP(4);
|
int left = FromDIP(4);
|
||||||
|
@ -1206,34 +1229,29 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
auto brush = dc.GetBrush();
|
||||||
|
if (alpha != 0 && alpha != 255 && alpha != 254) dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius);
|
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius);
|
||||||
#else
|
#else
|
||||||
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius - 1);
|
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius - 1);
|
||||||
if (alpha != 0 && alpha != 255) {
|
|
||||||
if (transparent_changed) {
|
|
||||||
std::string rgb = (tmp_lib_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString();
|
|
||||||
if (rgb.size() == 8) {
|
|
||||||
//delete alpha value
|
|
||||||
rgb= rgb.substr(0, rgb.size() - 2);
|
|
||||||
}
|
|
||||||
float alpha_f = 0.3 * tmp_lib_colour.Alpha() / 255.0;
|
|
||||||
std::vector<std::string> replace;
|
|
||||||
replace.push_back(rgb);
|
|
||||||
std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f);
|
|
||||||
replace.push_back(fill_replace);
|
|
||||||
m_bitmap_transparent = ScalableBitmap(this, "transparent_ams_lib", 68, false, false, true, replace);
|
|
||||||
transparent_changed = false;
|
|
||||||
}
|
|
||||||
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
dc.SetBrush(brush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (top > 2) {
|
if (top > 2) {
|
||||||
if (curr_height >= FromDIP(6)) {
|
if (curr_height >= FromDIP(6)) {
|
||||||
dc.DrawRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), FromDIP(2));
|
dc.DrawRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), FromDIP(2));
|
||||||
|
if (alpha != 255 && alpha != 254) {
|
||||||
|
dc.SetPen(wxPen(*wxWHITE));
|
||||||
|
dc.SetBrush(wxBrush(*wxWHITE));
|
||||||
|
#ifdef __APPLE__
|
||||||
|
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) , size.x - FromDIP(8), top, m_radius);
|
||||||
|
#else
|
||||||
|
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) , size.x - FromDIP(8), top, m_radius - 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) {
|
if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) {
|
||||||
dc.SetPen(wxPen(wxColour(130, 129, 128), 1, wxSOLID));
|
dc.SetPen(wxPen(wxColour(130, 129, 128), 1, wxSOLID));
|
||||||
dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
|
dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
|
||||||
|
@ -1295,7 +1313,7 @@ void AMSLib::Update(Caninfo info, bool refresh)
|
||||||
if (dev->get_selected_machine() && dev->get_selected_machine() != m_obj) {
|
if (dev->get_selected_machine() && dev->get_selected_machine() != m_obj) {
|
||||||
m_obj = dev->get_selected_machine();
|
m_obj = dev->get_selected_machine();
|
||||||
}
|
}
|
||||||
if (info.material_colour.Alpha() != 0 && info.material_colour.Alpha() != 255 && m_info.material_colour != info.material_colour) {
|
if (info.material_colour.Alpha() != 0 && info.material_colour.Alpha() != 255 && info.material_colour.Alpha() != 254 && m_info.material_colour != info.material_colour) {
|
||||||
transparent_changed = true;
|
transparent_changed = true;
|
||||||
}
|
}
|
||||||
m_info = info;
|
m_info = info;
|
||||||
|
@ -2612,6 +2630,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
||||||
m_vams_top_sizer->Add(m_vams_lib, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(4));
|
m_vams_top_sizer->Add(m_vams_lib, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, FromDIP(4));
|
||||||
m_vams_top_sizer->Add(m_vams_road, 0, wxALL, 0);
|
m_vams_top_sizer->Add(m_vams_road, 0, wxALL, 0);
|
||||||
|
|
||||||
|
|
||||||
//extra road
|
//extra road
|
||||||
|
|
||||||
vams_panel->SetSizer(m_vams_top_sizer);
|
vams_panel->SetSizer(m_vams_top_sizer);
|
||||||
|
@ -2889,6 +2908,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
||||||
CreateAms();
|
CreateAms();
|
||||||
SetSelection(0);
|
SetSelection(0);
|
||||||
EnterNoneAMSMode();
|
EnterNoneAMSMode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSControl::on_retry()
|
void AMSControl::on_retry()
|
||||||
|
|
|
@ -124,7 +124,7 @@ enum FilamentStepType {
|
||||||
#define AMS_ITEM_CUBE_SIZE wxSize(FromDIP(14), FromDIP(14))
|
#define AMS_ITEM_CUBE_SIZE wxSize(FromDIP(14), FromDIP(14))
|
||||||
#define AMS_ITEM_SIZE wxSize(FromDIP(82), FromDIP(27))
|
#define AMS_ITEM_SIZE wxSize(FromDIP(82), FromDIP(27))
|
||||||
#define AMS_ITEM_HUMIDITY_SIZE wxSize(FromDIP(120), FromDIP(27))
|
#define AMS_ITEM_HUMIDITY_SIZE wxSize(FromDIP(120), FromDIP(27))
|
||||||
#define AMS_CAN_LIB_SIZE wxSize(FromDIP(58), FromDIP(80))
|
#define AMS_CAN_LIB_SIZE wxSize(FromDIP(58), FromDIP(75))
|
||||||
#define AMS_CAN_ROAD_SIZE wxSize(FromDIP(66), FromDIP(70))
|
#define AMS_CAN_ROAD_SIZE wxSize(FromDIP(66), FromDIP(70))
|
||||||
#define AMS_CAN_ITEM_HEIGHT_SIZE FromDIP(27)
|
#define AMS_CAN_ITEM_HEIGHT_SIZE FromDIP(27)
|
||||||
#define AMS_CANS_SIZE wxSize(FromDIP(284), FromDIP(196))
|
#define AMS_CANS_SIZE wxSize(FromDIP(284), FromDIP(196))
|
||||||
|
|
Loading…
Reference in New Issue