NEW:Adaptation of semi transparent materials
JIRA: XXXX Change-Id: Ie32d8ce67c37b85eb6d7d6594cb514a696307e68
This commit is contained in:
parent
e21a808d73
commit
ba445bf630
|
@ -1,4 +1,4 @@
|
|||
<svg width="50" height="68" viewBox="0 0 50 68" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M50 64C50 66.2091 48.2091 68 46 68H4C1.79086 68 0 66.2091 0 64V4C0 1.79086 1.79086 0 4 0H46C48.2091 0 50 1.79086 50 4V64Z" fill="#FEFFFE"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.84619 4V0H7.69234V4H3.84619ZM0 4V8H3.84615V4H0ZM23.0767 4V8H19.231V4H23.0767ZM19.231 64V68H23.0771V64H26.9229V60H23.0771V56H26.9229V52H23.0771V48H26.9229V44H23.0771V40H26.9229V36H23.0771V32H26.9229V28H23.0771V24H26.9229V20H23.0771V16H26.9229V12H23.0771V8H26.9229V4H23.0771V0H19.231L19.231 4H15.3848V8H19.231V12H15.3848V16H19.231V20H15.3848V24H19.231L19.231 28H15.3848V32H19.231V36H15.3848V40H19.231V44H15.3848V48H19.231V52H15.3848V56H19.231L19.231 60H15.3848V64H19.231ZM19.231 64V60H23.0767V64H19.231ZM19.231 56V52H23.0767V56H19.231ZM19.231 48V44H23.0767V48H19.231ZM19.231 40V36H23.0767V40H19.231ZM19.231 32L19.231 28H23.0767V32H19.231ZM19.231 24V20H23.0767V24H19.231ZM19.231 16H23.0767V12H19.231V16ZM0 40V36H3.84615V40H0ZM0 16V12H3.84615V16H0ZM0 48V44H3.84615V48H0ZM0 24V20H3.84615V24H0ZM0 56V52H3.84615V56H0ZM3.84619 28V24H7.69234V28H3.84619ZM26.9233 24V28H30.769V32H26.9233V36H30.769V40H26.9233V44H30.769V48H26.9233V52H30.769V56H26.9233V60H30.769V64H26.9233V68H30.7694V64H34.6152V68H38.4613V64H34.6152V60H38.4613V56H34.6152V52H38.4613V48H34.6152V44H38.4613V40H34.6152V36H38.4613V32H34.6152L34.6152 28H38.4613V24H34.6152V20H38.4613V16H34.6152V12H38.4613V8H34.6152V4H38.4613V0H34.6152L34.6152 4H30.7694V0H26.9233V4H30.769V8H26.9233V12H30.769V16H26.9233V20H30.769V24H26.9233ZM34.6152 8H30.7694V12H34.6152V8ZM34.6152 16H30.7694V20H34.6152V16ZM34.6152 24L34.6152 28H30.7694V24H34.6152ZM34.6152 32V36H30.7694V32H34.6152ZM34.6152 40H30.7694V44H34.6152V40ZM34.6152 48H30.7694V52H34.6152V48ZM34.6152 56L34.6152 60H30.7694V56H34.6152ZM3.84619 60V56H7.69234V60H3.84619ZM3.84619 64V68H7.69234V64H3.84619ZM0 32V28H3.84615V32H0ZM0 64V60H3.84615V64H0ZM3.84619 36V32H7.69234V36H3.84619ZM3.84619 12V8H7.69234V12H3.84619ZM3.84619 44V40H7.69234V44H3.84619ZM3.84619 20V16H7.69234V20H3.84619ZM3.84619 52V48H7.69234V52H3.84619ZM7.69238 8V4H11.5386V8H7.69238ZM7.69238 40V36H11.5386V40H7.69238ZM7.69238 16V12H11.5386V16H7.69238ZM7.69238 48V44H11.5386V48H7.69238ZM7.69238 24V20H11.5386V24H7.69238ZM7.69238 56V52H11.5386V56H7.69238ZM11.5386 28V24H15.3847V28H11.5386ZM11.5386 60V56H15.3847V60H11.5386ZM11.5386 64V68H15.3847V64H11.5386ZM7.69238 32V28H11.5386V32H7.69238ZM7.69238 64V60H11.5386V64H7.69238ZM11.5386 4V0H15.3847V4H11.5386ZM11.5386 36V32H15.3847V36H11.5386ZM11.5386 12V8H15.3847V12H11.5386ZM11.5386 44V40H15.3847V44H11.5386ZM11.5386 20V16H15.3847V20H11.5386ZM11.5386 52V48H15.3847V52H11.5386ZM38.4614 4V8H42.3076V12H38.4614V16H42.3076V20H38.4614V24H42.3076L42.3076 28H38.4614V32H42.3076V36H38.4614V40H42.3076V44H38.4614V48H42.3076V52H38.4614V56H42.3076L42.3076 60H38.4614V64H42.3076V68H46.1537V64H42.3076V60H46.1537V56H42.3076V52H46.1537V48H42.3076V44H46.1537V40H42.3076V36H46.1537V32H42.3076L42.3076 28H46.1537V24H42.3076V20H46.1537V16H42.3076V12H46.1537V8H42.3076V4H46.1537V0H42.3076L42.3076 4H38.4614ZM46.1538 32V28H50V32H46.1538ZM46.1538 60V64H50V60H46.1538ZM46.1538 8V4H50V8H46.1538ZM46.1538 36V40H50V36H46.1538ZM46.1538 16V12H50V16H46.1538ZM46.1538 44V48H50V44H46.1538ZM46.1538 24V20H50V24H46.1538ZM46.1538 52V56H50V52H46.1538Z" fill="#D9D9D9"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.84619 4V0H7.69234V4H3.84619ZM0 4V8H3.84615V4H0ZM23.0767 4V8H19.231V4H23.0767ZM19.231 64V68H23.0771V64H26.9229V60H23.0771V56H26.9229V52H23.0771V48H26.9229V44H23.0771V40H26.9229V36H23.0771V32H26.9229V28H23.0771V24H26.9229V20H23.0771V16H26.9229V12H23.0771V8H26.9229V4H23.0771V0H19.231L19.231 4H15.3848V8H19.231V12H15.3848V16H19.231V20H15.3848V24H19.231L19.231 28H15.3848V32H19.231V36H15.3848V40H19.231V44H15.3848V48H19.231V52H15.3848V56H19.231L19.231 60H15.3848V64H19.231ZM19.231 64V60H23.0767V64H19.231ZM19.231 56V52H23.0767V56H19.231ZM19.231 48V44H23.0767V48H19.231ZM19.231 40V36H23.0767V40H19.231ZM19.231 32L19.231 28H23.0767V32H19.231ZM19.231 24V20H23.0767V24H19.231ZM19.231 16H23.0767V12H19.231V16ZM0 40V36H3.84615V40H0ZM0 16V12H3.84615V16H0ZM0 48V44H3.84615V48H0ZM0 24V20H3.84615V24H0ZM0 56V52H3.84615V56H0ZM3.84619 28V24H7.69234V28H3.84619ZM26.9233 24V28H30.769V32H26.9233V36H30.769V40H26.9233V44H30.769V48H26.9233V52H30.769V56H26.9233V60H30.769V64H26.9233V68H30.7694V64H34.6152V68H38.4613V64H34.6152V60H38.4613V56H34.6152V52H38.4613V48H34.6152V44H38.4613V40H34.6152V36H38.4613V32H34.6152L34.6152 28H38.4613V24H34.6152V20H38.4613V16H34.6152V12H38.4613V8H34.6152V4H38.4613V0H34.6152L34.6152 4H30.7694V0H26.9233V4H30.769V8H26.9233V12H30.769V16H26.9233V20H30.769V24H26.9233ZM34.6152 8H30.7694V12H34.6152V8ZM34.6152 16H30.7694V20H34.6152V16ZM34.6152 24L34.6152 28H30.7694V24H34.6152ZM34.6152 32V36H30.7694V32H34.6152ZM34.6152 40H30.7694V44H34.6152V40ZM34.6152 48H30.7694V52H34.6152V48ZM34.6152 56L34.6152 60H30.7694V56H34.6152ZM3.84619 60V56H7.69234V60H3.84619ZM3.84619 64V68H7.69234V64H3.84619ZM0 32V28H3.84615V32H0ZM0 64V60H3.84615V64H0ZM3.84619 36V32H7.69234V36H3.84619ZM3.84619 12V8H7.69234V12H3.84619ZM3.84619 44V40H7.69234V44H3.84619ZM3.84619 20V16H7.69234V20H3.84619ZM3.84619 52V48H7.69234V52H3.84619ZM7.69238 8V4H11.5386V8H7.69238ZM7.69238 40V36H11.5386V40H7.69238ZM7.69238 16V12H11.5386V16H7.69238ZM7.69238 48V44H11.5386V48H7.69238ZM7.69238 24V20H11.5386V24H7.69238ZM7.69238 56V52H11.5386V56H7.69238ZM11.5386 28V24H15.3847V28H11.5386ZM11.5386 60V56H15.3847V60H11.5386ZM11.5386 64V68H15.3847V64H11.5386ZM7.69238 32V28H11.5386V32H7.69238ZM7.69238 64V60H11.5386V64H7.69238ZM11.5386 4V0H15.3847V4H11.5386ZM11.5386 36V32H15.3847V36H11.5386ZM11.5386 12V8H15.3847V12H11.5386ZM11.5386 44V40H15.3847V44H11.5386ZM11.5386 20V16H15.3847V20H11.5386ZM11.5386 52V48H15.3847V52H11.5386ZM38.4614 4V8H42.3076V12H38.4614V16H42.3076V20H38.4614V24H42.3076L42.3076 28H38.4614V32H42.3076V36H38.4614V40H42.3076V44H38.4614V48H42.3076V52H38.4614V56H42.3076L42.3076 60H38.4614V64H42.3076V68H46.1537V64H42.3076V60H46.1537V56H42.3076V52H46.1537V48H42.3076V44H46.1537V40H42.3076V36H46.1537V32H42.3076L42.3076 28H46.1537V24H42.3076V20H46.1537V16H42.3076V12H46.1537V8H42.3076V4H46.1537V0H42.3076L42.3076 4H38.4614ZM46.1538 32V28H50V32H46.1538ZM46.1538 60V64H50V60H46.1538ZM46.1538 8V4H50V8H46.1538ZM46.1538 36V40H50V36H46.1538ZM46.1538 16V12H50V16H46.1538ZM46.1538 44V48H50V44H46.1538ZM46.1538 24V20H50V24H46.1538ZM46.1538 52V56H50V52H46.1538Z" fill="#D9D9D9" fill-opacity="1.0"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
@ -1,4 +1,4 @@
|
|||
<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M25 12.5C25 5.59644 19.4036 0 12.5 0V0C5.59644 0 0 5.59644 0 12.5V12.5C0 19.4036 5.59644 25 12.5 25V25C19.4036 25 25 19.4036 25 12.5V12.5Z" fill="#FEFFFE"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.250045 15C0.0860757 14.1922 0 13.3562 0 12.5C0 11.6438 0.0860756 10.8078 0.250045 10H5V15H0.250045ZM5 22.5009C4.05303 21.7896 3.21038 20.947 2.49908 20H5V22.5009ZM15 24.75C14.1922 24.9139 13.3562 25 12.5 25C11.6438 25 10.8078 24.9139 10 24.75V20H15V24.75ZM22.5009 20C21.7896 20.947 20.947 21.7896 20 22.5009V20H22.5009ZM25 12.5C25 13.3562 24.9139 14.1922 24.75 15H20V10H24.75C24.9139 10.8078 25 11.6438 25 12.5ZM20 2.49908C20.947 3.21038 21.7896 4.05303 22.5009 5H20V2.49908ZM10 0.250045C10.8078 0.0860756 11.6438 0 12.5 0C13.3562 0 14.1922 0.0860757 15 0.250045V5H10V0.250045ZM5 2.49908C4.05303 3.21038 3.21038 4.05303 2.49908 5H5V10H10V15H5V20H10V15H15V20H20V15H15V10H20V5H15V10H10V5H5V2.49908Z" fill="#D9D9D9"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.250045 15C0.0860757 14.1922 0 13.3562 0 12.5C0 11.6438 0.0860756 10.8078 0.250045 10H5V15H0.250045ZM5 22.5009C4.05303 21.7896 3.21038 20.947 2.49908 20H5V22.5009ZM15 24.75C14.1922 24.9139 13.3562 25 12.5 25C11.6438 25 10.8078 24.9139 10 24.75V20H15V24.75ZM22.5009 20C21.7896 20.947 20.947 21.7896 20 22.5009V20H22.5009ZM25 12.5C25 13.3562 24.9139 14.1922 24.75 15H20V10H24.75C24.9139 10.8078 25 11.6438 25 12.5ZM20 2.49908C20.947 3.21038 21.7896 4.05303 22.5009 5H20V2.49908ZM10 0.250045C10.8078 0.0860756 11.6438 0 12.5 0C13.3562 0 14.1922 0.0860757 15 0.250045V5H10V0.250045ZM5 2.49908C4.05303 3.21038 3.21038 4.05303 2.49908 5H5V10H10V15H5V20H10V15H15V20H20V15H15V10H20V5H15V10H10V5H5V2.49908Z" fill="#D9D9D9" fill-opacity="1.0"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
@ -1136,6 +1136,9 @@ void ColorPicker::msw_rescale()
|
|||
|
||||
void ColorPicker::set_color(wxColour col)
|
||||
{
|
||||
if (m_colour != col&&col.Alpha()!=0&&col.Alpha()!=255) {
|
||||
transparent_changed = true;
|
||||
}
|
||||
m_colour = col;
|
||||
Refresh();
|
||||
}
|
||||
|
@ -1177,13 +1180,29 @@ void ColorPicker::doRender(wxDC& dc)
|
|||
{
|
||||
wxSize size = GetSize();
|
||||
auto alpha = m_colour.Alpha();
|
||||
|
||||
auto radius = m_show_full ? size.x / 2 - FromDIP(1) : size.x / 2;
|
||||
if (m_selected) radius -= FromDIP(1);
|
||||
|
||||
if (alpha == 0) {
|
||||
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
||||
}
|
||||
else if (alpha != 0 && alpha != 255) {
|
||||
if (transparent_changed) {
|
||||
std::string rgb = (m_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 * m_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_color_picker", 25, false, false, true, replace).bmp();
|
||||
transparent_changed = false;
|
||||
}
|
||||
dc.DrawBitmap(m_bitmap_transparent, 0, 0);
|
||||
}
|
||||
else {
|
||||
dc.SetPen(wxPen(m_colour));
|
||||
dc.SetBrush(wxBrush(m_colour));
|
||||
|
@ -1237,6 +1256,7 @@ void ColorPicker::doRender(wxDC& dc)
|
|||
startAngle += ev_angle;
|
||||
startAngle = startAngle > 360.0 ? startAngle - 360.0 : startAngle;
|
||||
}
|
||||
dc.DrawBitmap(m_bitmap_border, wxPoint(0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
bool m_is_empty{false};
|
||||
int ctype;
|
||||
|
||||
bool transparent_changed{false};
|
||||
|
||||
ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||
~ColorPicker();
|
||||
|
||||
|
|
|
@ -384,6 +384,78 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
|
|||
return this->insert_raw_rgba(bitmap_key, width, height, data.data(), grayscale);
|
||||
}
|
||||
|
||||
wxBitmap* BitmapCache::load_svg2(const std::string& bitmap_name, unsigned target_width, unsigned target_height,
|
||||
const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::vector<std::string>& array_new_color /*= vector<std::string>()*/, const float scale_in_center/* = 0*/)
|
||||
{
|
||||
|
||||
std::map<std::string, std::string> replaces;
|
||||
if (array_new_color.size() == 2) {
|
||||
replaces["#D9D9D9"] = array_new_color[0];
|
||||
replaces["fill-opacity=\"1.0"] = array_new_color[1];
|
||||
}
|
||||
|
||||
|
||||
NSVGimage* image = nullptr;
|
||||
image = nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces);
|
||||
|
||||
if (image == nullptr)
|
||||
return nullptr;
|
||||
|
||||
if (target_height == 0 && target_width == 0)
|
||||
target_height = image->height;
|
||||
|
||||
target_height != 0 ? target_height *= m_scale : target_width *= m_scale;
|
||||
|
||||
float svg_scale = target_height != 0 ?
|
||||
(float)target_height / image->height : target_width != 0 ?
|
||||
(float)target_width / image->width : 1;
|
||||
|
||||
int width = (int)(svg_scale * image->width + 0.5f);
|
||||
int height = (int)(svg_scale * image->height + 0.5f);
|
||||
int n_pixels = width * height;
|
||||
if (n_pixels <= 0) {
|
||||
::nsvgDelete(image);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NSVGrasterizer* rast = ::nsvgCreateRasterizer();
|
||||
if (rast == nullptr) {
|
||||
::nsvgDelete(image);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> data(n_pixels * 4, 0);
|
||||
// BBS: support resize by fill border
|
||||
if (scale_in_center > 0 && scale_in_center < svg_scale) {
|
||||
int w = (int)(image->width * scale_in_center);
|
||||
int h = (int)(image->height * scale_in_center);
|
||||
::nsvgRasterize(rast, image, 0, 0, scale_in_center, data.data() + int(height - h) / 2 * width * 4 + int(width - w) / 2 * 4, w, h, width * 4);
|
||||
}
|
||||
else
|
||||
::nsvgRasterize(rast, image, 0, 0, svg_scale, data.data(), width, height, width * 4);
|
||||
::nsvgDeleteRasterizer(rast);
|
||||
::nsvgDelete(image);
|
||||
|
||||
const unsigned char * raw_data = data.data();
|
||||
wxImage wx_image(width, height);
|
||||
wx_image.InitAlpha();
|
||||
unsigned char* rgb = wx_image.GetData();
|
||||
unsigned char* alpha = wx_image.GetAlpha();
|
||||
unsigned int pixels = width * height;
|
||||
for (unsigned int i = 0; i < pixels; ++i) {
|
||||
*rgb++ = *raw_data++;
|
||||
*rgb++ = *raw_data++;
|
||||
*rgb++ = *raw_data++;
|
||||
*alpha++ = *raw_data++;
|
||||
}
|
||||
|
||||
if (grayscale)
|
||||
wx_image = wx_image.ConvertToGreyscale(m_gs, m_gs, m_gs);
|
||||
auto result = new wxBitmap(wxImage_to_wxBitmap_with_alpha(std::move(wx_image), m_scale));
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
|
||||
wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false*/, size_t border_width /*= 0*/, bool dark_mode/* = false*/)
|
||||
{
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
static NSVGimage* nsvgParseFromFileWithReplace(const char* filename, const char* units, float dpi, const std::map<std::string, std::string>& replaces);
|
||||
// Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width.
|
||||
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::string& new_color = "", const float scale_in_center = 0.f);
|
||||
//Load background image of semi transparent material with color,
|
||||
wxBitmap* load_svg2(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::vector<std::string>& array_new_color = std::vector<std::string>(), const float scale_in_center = 0.0f);
|
||||
|
||||
wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
|
||||
wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
|
||||
|
|
|
@ -3512,6 +3512,7 @@ void StatusPanel::on_filament_edit(wxCommandEvent &event)
|
|||
}
|
||||
else {
|
||||
m_filament_setting_dlg->set_color(color);
|
||||
m_filament_setting_dlg->set_colors(cols);
|
||||
}
|
||||
|
||||
m_filament_setting_dlg->m_is_third = !MachineObject::is_bbl_filament(tray_it->second->tag_uid);
|
||||
|
|
|
@ -862,6 +862,10 @@ void AMSLib::render_generic_text(wxDC &dc)
|
|||
|
||||
dc.SetFont(::Label::Body_13);
|
||||
dc.SetTextForeground(temp_text_colour);
|
||||
auto alpha = m_info.material_colour.Alpha();
|
||||
if (alpha != 0 && alpha != 255) {
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
}
|
||||
|
||||
auto libsize = GetSize();
|
||||
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND
|
||||
|
@ -908,6 +912,7 @@ void AMSLib::render_generic_text(wxDC &dc)
|
|||
auto pot_top = wxPoint((libsize.x - line_top_tsize.x) / 2, (libsize.y - line_top_tsize.y) / 2 - line_top_tsize.y + FromDIP(6));
|
||||
dc.DrawText(line_top, pot_top);
|
||||
|
||||
|
||||
auto pot_bottom = wxPoint((libsize.x - line_bottom_tsize.x) / 2, (libsize.y - line_bottom_tsize.y) / 2 + FromDIP(4));
|
||||
dc.DrawText(line_bottom, pot_bottom);
|
||||
}
|
||||
|
@ -1135,7 +1140,7 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
|||
|
||||
//draw remain
|
||||
int height = size.y - FromDIP(8);
|
||||
int curr_height = height * float(m_info.material_remain * 1.0 / 100.0);
|
||||
int curr_height = height * float(m_info.material_remain * 1.0 / 100.0); dc.SetFont(::Label::Body_13);
|
||||
|
||||
int top = height - curr_height;
|
||||
|
||||
|
@ -1146,8 +1151,7 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
|||
if (alpha == 0) {
|
||||
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
|
||||
}
|
||||
|
||||
|
||||
//gradient
|
||||
if (m_info.material_cols.size() > 1) {
|
||||
int left = FromDIP(4);
|
||||
float total_width = size.x - FromDIP(8);
|
||||
|
@ -1206,6 +1210,23 @@ void AMSLib::render_generic_lib(wxDC &dc)
|
|||
dc.DrawRoundedRectangle(FromDIP(4), FromDIP(4) + top, size.x - FromDIP(8), curr_height, m_radius);
|
||||
#else
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -1274,7 +1295,9 @@ void AMSLib::Update(Caninfo info, bool refresh)
|
|||
if (dev->get_selected_machine() && dev->get_selected_machine() != m_obj) {
|
||||
m_obj = dev->get_selected_machine();
|
||||
}
|
||||
|
||||
if (info.material_colour.Alpha() != 0 && info.material_colour.Alpha() != 255 && m_info.material_colour != info.material_colour) {
|
||||
transparent_changed = true;
|
||||
}
|
||||
m_info = info;
|
||||
Layout();
|
||||
if (refresh) Refresh();
|
||||
|
|
|
@ -339,6 +339,7 @@ protected:
|
|||
bool m_hover = {false};
|
||||
bool m_show_kn = {false};
|
||||
bool m_support_cali = {false};
|
||||
bool transparent_changed = {false};
|
||||
|
||||
double m_radius = {4};
|
||||
wxColour m_border_color;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include "BitmapCache.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
|
@ -432,10 +431,14 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
|
|||
const bool grayscale/* = false*/,
|
||||
const std::string& new_color/* = std::string()*/, // color witch will used instead of orange
|
||||
const bool menu_bitmap/* = false*/,
|
||||
const bool resize/* = false*/)
|
||||
const bool resize/* = false*/,
|
||||
const bool bitmap2/* = false*/,
|
||||
const vector<std::string>& array_new_color/* = vector<std::string>*/)//used for semi transparent material)
|
||||
{
|
||||
static Slic3r::GUI::BitmapCache cache;
|
||||
|
||||
if (bitmap2) {
|
||||
return create_scaled_bitmap2(bmp_name_in, cache, win, px_cnt, grayscale, resize, array_new_color);
|
||||
}
|
||||
unsigned int width = 0;
|
||||
unsigned int height = (unsigned int) (win->FromDIP(px_cnt) + 0.5f);
|
||||
|
||||
|
@ -462,6 +465,25 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
|
|||
return *bmp;
|
||||
}
|
||||
|
||||
wxBitmap create_scaled_bitmap2(const std::string& bmp_name_in, Slic3r::GUI::BitmapCache& cache, wxWindow* win/* = nullptr*/ ,
|
||||
const int px_cnt/* = 16*/, const bool grayscale/* = false*/ , const bool resize/* = false*/ ,
|
||||
const vector<std::string>& array_new_color/* = vector<std::string>()*/) // color witch will used instead of orange
|
||||
{
|
||||
unsigned int width = 0;
|
||||
unsigned int height = (unsigned int)(win->FromDIP(px_cnt) + 0.5f);
|
||||
|
||||
std::string bmp_name = bmp_name_in;
|
||||
boost::replace_last(bmp_name, ".png", "");
|
||||
|
||||
wxBitmap* bmp = cache.load_svg2(bmp_name, width, height, grayscale, false, array_new_color, resize ? em_unit(win) * 0.1f : 0.f);
|
||||
if (bmp == nullptr) {
|
||||
// No SVG found
|
||||
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
|
||||
}
|
||||
return *bmp;
|
||||
}
|
||||
|
||||
|
||||
wxBitmap* get_default_extruder_color_icon(bool thin_icon/* = false*/)
|
||||
{
|
||||
static Slic3r::GUI::BitmapCache bmp_cache;
|
||||
|
@ -858,11 +880,13 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent,
|
|||
const std::string& icon_name/* = ""*/,
|
||||
const int px_cnt/* = 16*/,
|
||||
const bool grayscale/* = false*/,
|
||||
const bool resize/* = false*/):
|
||||
const bool resize/* = false*/,
|
||||
const bool bitmap2/* = false*/,
|
||||
const std::vector<std::string>& new_color/* = vector<std::string>*/) :
|
||||
m_parent(parent), m_icon_name(icon_name),
|
||||
m_px_cnt(px_cnt), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border
|
||||
{
|
||||
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, m_grayscale, std::string(), false, resize);
|
||||
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, m_grayscale, std::string(), false, resize, bitmap2, new_color);
|
||||
if (px_cnt == 0) {
|
||||
m_px_cnt = m_bmp.GetHeight(); // scale
|
||||
unsigned int height = (unsigned int) (parent->FromDIP(m_px_cnt) + 0.5f);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "BitmapCache.hpp"
|
||||
#include "Widgets/PopupWindow.hpp"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
|
@ -60,7 +60,13 @@ wxBitmap create_menu_bitmap(const std::string& bmp_name);
|
|||
wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullptr,
|
||||
const int px_cnt = 16, const bool grayscale = false,
|
||||
const std::string& new_color = std::string(), // color witch will used instead of orange
|
||||
const bool menu_bitmap = false, const bool resize = false);
|
||||
const bool menu_bitmap = false, const bool resize = false,
|
||||
const bool bitmap2 = false,// for create_scaled_bitmap2
|
||||
const std::vector<std::string>& array_new_color = std::vector<std::string>());
|
||||
//used for semi transparent material
|
||||
wxBitmap create_scaled_bitmap2(const std::string& bmp_name_in, Slic3r::GUI::BitmapCache& cache, wxWindow* win = nullptr,
|
||||
const int px_cnt = 16, const bool grayscale = false, const bool resize = false,
|
||||
const std::vector<std::string>& array_new_color = std::vector<std::string>()); // color witch will used instead of orange
|
||||
#else
|
||||
wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullptr,
|
||||
const int px_cnt = 16, const bool grayscale = false, const bool resize = false);
|
||||
|
@ -154,7 +160,9 @@ public:
|
|||
const std::string& icon_name = "",
|
||||
const int px_cnt = 16,
|
||||
const bool grayscale = false,
|
||||
const bool resize = false); // BBS: support resize by fill border
|
||||
const bool resize = false,
|
||||
const bool bitmap2 = false,
|
||||
const std::vector<std::string>& new_color = std::vector<std::string>());// BBS: support resize by fill border
|
||||
|
||||
~ScalableBitmap() {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue