Using of wxWidgets 3.1.6 WIP:
* Create Cache of wxBitmapBundles instead of wxBitmaps * Use wxBitmapBundles instead of wxBitmap for most of Widgets * Use empty bitmabundles instead of wxNullBitmap for wxBitmapComboBoxes. * Updated wxWidgets.cmake * OSX specific: Discard BitmapComboBox overrides + some code cleaning
This commit is contained in:
parent
e21921f2eb
commit
066b567714
@ -223,9 +223,7 @@ AboutDialog::AboutDialog()
|
|||||||
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);
|
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);
|
||||||
|
|
||||||
// logo
|
// logo
|
||||||
// m_logo_bitmap = ScalableBitmap(this, wxGetApp().logo_name(), 192);
|
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
|
||||||
// m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp());
|
|
||||||
m_logo = new wxStaticBitmap(this, wxID_ANY, wxBitmapBundle::FromSVGFile(Slic3r::var(wxGetApp().logo_name()+".svg"), wxSize(192, 192)));
|
|
||||||
hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
|
hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
@ -60,7 +60,164 @@ static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height)
|
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vector<wxBitmapBundle*>& bmps)
|
||||||
|
{
|
||||||
|
wxVector<wxBitmap> bitmaps;
|
||||||
|
|
||||||
|
std::set<double> scales = {1.0};
|
||||||
|
#ifdef __APPLE__
|
||||||
|
scales.emplace(m_scale);
|
||||||
|
#else
|
||||||
|
size_t disp_cnt = wxDisplay::GetCount();
|
||||||
|
for (size_t disp = 0; disp < disp_cnt; ++disp)
|
||||||
|
scales.emplace(wxDisplay(disp).GetScaleFactor());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (double scale : scales) {
|
||||||
|
size_t width = 0;
|
||||||
|
size_t height = 0;
|
||||||
|
for (const wxBitmapBundle* bmp_bndl : bmps) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
wxSize size = bmp_bndl->GetPreferredBitmapSizeAtScale(1.0);
|
||||||
|
#else
|
||||||
|
wxSize size = bmp_bndl->GetPreferredBitmapSizeAtScale(scale);
|
||||||
|
#endif
|
||||||
|
width += size.GetWidth();
|
||||||
|
height = std::max<size_t>(height, size.GetHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string bitmap_key = name + "," +float_to_string_decimal_point(scale);
|
||||||
|
|
||||||
|
#ifdef __WXGTK2__
|
||||||
|
// Broken alpha workaround
|
||||||
|
wxImage image(width, height);
|
||||||
|
image.InitAlpha();
|
||||||
|
// Fill in with a white color.
|
||||||
|
memset(image.GetData(), 0x0ff, width * height * 3);
|
||||||
|
// Fill in with full transparency.
|
||||||
|
memset(image.GetAlpha(), 0, width * height);
|
||||||
|
size_t x = 0;
|
||||||
|
for (const wxBitmapBundle* bmp_bndl : bmps) {
|
||||||
|
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetPreferredBitmapSizeAtScale(scale));
|
||||||
|
if (bmp.GetWidth() > 0) {
|
||||||
|
if (bmp.GetDepth() == 32) {
|
||||||
|
wxAlphaPixelData data(bmp);
|
||||||
|
//FIXME The following method is missing from wxWidgets 3.1.1.
|
||||||
|
// It looks like the wxWidgets 3.0.3 called the wrapped bitmap's UseAlpha().
|
||||||
|
//data.UseAlpha();
|
||||||
|
if (data) {
|
||||||
|
for (int r = 0; r < bmp.GetHeight(); ++r) {
|
||||||
|
wxAlphaPixelData::Iterator src(data);
|
||||||
|
src.Offset(data, 0, r);
|
||||||
|
unsigned char* dst_pixels = image.GetData() + (x + r * width) * 3;
|
||||||
|
unsigned char* dst_alpha = image.GetAlpha() + x + r * width;
|
||||||
|
for (int c = 0; c < bmp.GetWidth(); ++c, ++src) {
|
||||||
|
*dst_pixels++ = src.Red();
|
||||||
|
*dst_pixels++ = src.Green();
|
||||||
|
*dst_pixels++ = src.Blue();
|
||||||
|
*dst_alpha++ = src.Alpha();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bmp.GetDepth() == 24) {
|
||||||
|
wxNativePixelData data(bmp);
|
||||||
|
if (data) {
|
||||||
|
for (int r = 0; r < bmp.GetHeight(); ++r) {
|
||||||
|
wxNativePixelData::Iterator src(data);
|
||||||
|
src.Offset(data, 0, r);
|
||||||
|
unsigned char* dst_pixels = image.GetData() + (x + r * width) * 3;
|
||||||
|
unsigned char* dst_alpha = image.GetAlpha() + x + r * width;
|
||||||
|
for (int c = 0; c < bmp.GetWidth(); ++c, ++src) {
|
||||||
|
*dst_pixels++ = src.Red();
|
||||||
|
*dst_pixels++ = src.Green();
|
||||||
|
*dst_pixels++ = src.Blue();
|
||||||
|
*dst_alpha++ = wxALPHA_OPAQUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x += bmp.GetWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
bitmaps.push_back(* this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image))));
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
wxBitmap* bitmap = this->insert(bitmap_key, width, height, scale);
|
||||||
|
wxMemoryDC memDC;
|
||||||
|
memDC.SelectObject(*bitmap);
|
||||||
|
memDC.SetBackground(*wxTRANSPARENT_BRUSH);
|
||||||
|
memDC.Clear();
|
||||||
|
size_t x = 0;
|
||||||
|
for (const wxBitmapBundle* bmp_bndl : bmps) {
|
||||||
|
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetPreferredBitmapSizeAtScale(scale));
|
||||||
|
|
||||||
|
if (bmp.GetWidth() > 0)
|
||||||
|
memDC.DrawBitmap(bmp, x, 0, true);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// we should "move" with step equal to non-scaled width
|
||||||
|
x += bmp.GetScaledWidth();
|
||||||
|
#else
|
||||||
|
x += bmp.GetWidth();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
bitmaps.push_back(*bitmap);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return insert_bndl(name, bitmaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* BitmapCache::insert_bndl(const std::string &bitmap_key, const char* data, size_t width, size_t height)
|
||||||
|
{
|
||||||
|
wxBitmapBundle* bndl = nullptr;
|
||||||
|
auto it = m_bndl_map.find(bitmap_key);
|
||||||
|
if (it == m_bndl_map.end()) {
|
||||||
|
bndl = new wxBitmapBundle(wxBitmapBundle::FromSVG(data, wxSize(width, height)));
|
||||||
|
m_bndl_map[bitmap_key] = bndl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bndl = it->second;
|
||||||
|
*bndl = wxBitmapBundle::FromSVG(data, wxSize(width, height));
|
||||||
|
}
|
||||||
|
return bndl;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& bitmap_key, const wxBitmapBundle& bmp)
|
||||||
|
{
|
||||||
|
wxBitmapBundle* bndl = nullptr;
|
||||||
|
auto it = m_bndl_map.find(bitmap_key);
|
||||||
|
if (it == m_bndl_map.end()) {
|
||||||
|
bndl = new wxBitmapBundle(bmp);
|
||||||
|
m_bndl_map[bitmap_key] = bndl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bndl = it->second;
|
||||||
|
*bndl = wxBitmapBundle(bmp);
|
||||||
|
}
|
||||||
|
return bndl;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& bitmap_key, const wxVector<wxBitmap>& bmps)
|
||||||
|
{
|
||||||
|
wxBitmapBundle* bndl = nullptr;
|
||||||
|
auto it = m_bndl_map.find(bitmap_key);
|
||||||
|
if (it == m_bndl_map.end()) {
|
||||||
|
bndl = new wxBitmapBundle(wxBitmapBundle::FromBitmaps(bmps));
|
||||||
|
m_bndl_map[bitmap_key] = bndl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bndl = it->second;
|
||||||
|
*bndl = wxBitmapBundle::FromBitmaps(bmps);
|
||||||
|
}
|
||||||
|
return bndl;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height, double scale/* = -1.0*/)
|
||||||
{
|
{
|
||||||
wxBitmap *bitmap = nullptr;
|
wxBitmap *bitmap = nullptr;
|
||||||
auto it = m_map.find(bitmap_key);
|
auto it = m_map.find(bitmap_key);
|
||||||
@ -76,7 +233,7 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_
|
|||||||
// So, We need to let the Mac OS wxBitmap implementation
|
// So, We need to let the Mac OS wxBitmap implementation
|
||||||
// know that the image may already be scaled appropriately for Retina,
|
// know that the image may already be scaled appropriately for Retina,
|
||||||
// and thereby that it's not supposed to upscale it.
|
// and thereby that it's not supposed to upscale it.
|
||||||
bitmap->CreateScaled(width, height, -1, m_scale);
|
bitmap->CreateScaled(width, height, -1, scale < 0.0 ? m_scale : scale);
|
||||||
#endif
|
#endif
|
||||||
m_map[bitmap_key] = bitmap;
|
m_map[bitmap_key] = bitmap;
|
||||||
} else {
|
} else {
|
||||||
@ -297,6 +454,93 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BitmapCache::nsvgGetDataFromFileWithReplace(const char* filename, std::string& data_str, const std::map<std::string, std::string>& replaces)
|
||||||
|
{
|
||||||
|
FILE* fp = NULL;
|
||||||
|
size_t size;
|
||||||
|
char* data = NULL;
|
||||||
|
|
||||||
|
fp = boost::nowide::fopen(filename, "rb");
|
||||||
|
if (!fp) goto error;
|
||||||
|
fseek(fp, 0, SEEK_END);
|
||||||
|
size = ftell(fp);
|
||||||
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
data = (char*)malloc(size + 1);
|
||||||
|
if (data == NULL) goto error;
|
||||||
|
if (fread(data, 1, size, fp) != size) goto error;
|
||||||
|
data[size] = '\0'; // Must be null terminated.
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
data_str.assign(data);
|
||||||
|
for (auto val : replaces)
|
||||||
|
boost::replace_all(data_str, val.first, val.second);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
return;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (fp) fclose(fp);
|
||||||
|
if (data) free(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height,
|
||||||
|
const bool dark_mode, const std::string& new_color /*= ""*/)
|
||||||
|
{
|
||||||
|
if (target_width == 0)
|
||||||
|
target_width = target_height;
|
||||||
|
std::string bitmap_key = bitmap_name + (target_height != 0 ?
|
||||||
|
"-h" + std::to_string(target_height) :
|
||||||
|
"-w" + std::to_string(target_width))
|
||||||
|
// + (m_scale != 1.0f ? "-s" + float_to_string_decimal_point(m_scale) : "")
|
||||||
|
+ (dark_mode ? "-dm" : "")
|
||||||
|
+ new_color;
|
||||||
|
|
||||||
|
auto it = m_bndl_map.find(bitmap_key);
|
||||||
|
if (it != m_bndl_map.end())
|
||||||
|
return it->second;
|
||||||
|
|
||||||
|
// map of color replaces
|
||||||
|
std::map<std::string, std::string> replaces;
|
||||||
|
if (dark_mode)
|
||||||
|
replaces["\"#808080\""] = "\"#FFFFFF\"";
|
||||||
|
if (!new_color.empty())
|
||||||
|
replaces["\"#ED6B21\""] = "\"" + new_color + "\"";
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
nsvgGetDataFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), str, replaces);
|
||||||
|
if (str.empty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return insert_bndl(bitmap_key, str.data(), target_width, target_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* BitmapCache::from_png(const std::string& bitmap_name, unsigned width, unsigned height)
|
||||||
|
{
|
||||||
|
std::string bitmap_key = bitmap_name + (height != 0 ?
|
||||||
|
"-h" + std::to_string(height) :
|
||||||
|
"-w" + std::to_string(width));
|
||||||
|
|
||||||
|
auto it = m_bndl_map.find(bitmap_key);
|
||||||
|
if (it != m_bndl_map.end())
|
||||||
|
return it->second;
|
||||||
|
|
||||||
|
wxImage image;
|
||||||
|
if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::var(bitmap_name + ".png")), wxBITMAP_TYPE_PNG) ||
|
||||||
|
image.GetWidth() == 0 || image.GetHeight() == 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if (height != 0 && unsigned(image.GetHeight()) != height)
|
||||||
|
width = unsigned(0.5f + float(image.GetWidth()) * height / image.GetHeight());
|
||||||
|
else if (width != 0 && unsigned(image.GetWidth()) != width)
|
||||||
|
height = unsigned(0.5f + float(image.GetHeight()) * width / image.GetWidth());
|
||||||
|
|
||||||
|
if (height != 0 && width != 0)
|
||||||
|
image.Rescale(width, height, wxIMAGE_QUALITY_BILINEAR);
|
||||||
|
|
||||||
|
return this->insert_bndl(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
|
||||||
|
}
|
||||||
|
|
||||||
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
|
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
|
||||||
const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::string& new_color /*= ""*/)
|
const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::string& new_color /*= ""*/)
|
||||||
{
|
{
|
||||||
@ -395,5 +639,84 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
|
|||||||
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
|
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
|
||||||
|
wxBitmapBundle BitmapCache::mksolid(size_t width_in, size_t height_in, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, size_t border_width /*= 0*/, bool dark_mode/* = false*/)
|
||||||
|
{
|
||||||
|
wxVector<wxBitmap> bitmaps;
|
||||||
|
|
||||||
|
std::set<double> scales = { 1.0 };
|
||||||
|
#ifdef __APPLE__
|
||||||
|
scales.emplace(m_scale);
|
||||||
|
#else
|
||||||
|
size_t disp_cnt = wxDisplay::GetCount();
|
||||||
|
for (size_t disp = 0; disp < disp_cnt; ++disp)
|
||||||
|
scales.emplace(wxDisplay(disp).GetScaleFactor());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (double scale : scales) {
|
||||||
|
size_t width = width_in * scale;
|
||||||
|
size_t height = height_in * scale;
|
||||||
|
|
||||||
|
wxImage image(width, height);
|
||||||
|
image.InitAlpha();
|
||||||
|
unsigned char* imgdata = image.GetData();
|
||||||
|
unsigned char* imgalpha = image.GetAlpha();
|
||||||
|
for (size_t i = 0; i < width * height; ++i) {
|
||||||
|
*imgdata++ = r;
|
||||||
|
*imgdata++ = g;
|
||||||
|
*imgdata++ = b;
|
||||||
|
*imgalpha++ = transparency;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add border, make white/light spools easier to see
|
||||||
|
if (border_width > 0) {
|
||||||
|
|
||||||
|
// Restrict to width of image
|
||||||
|
if (border_width > height) border_width = height - 1;
|
||||||
|
if (border_width > width) border_width = width - 1;
|
||||||
|
|
||||||
|
auto px_data = (uint8_t*)image.GetData();
|
||||||
|
auto a_data = (uint8_t*)image.GetAlpha();
|
||||||
|
|
||||||
|
for (size_t x = 0; x < width; ++x) {
|
||||||
|
for (size_t y = 0; y < height; ++y) {
|
||||||
|
if (x < border_width || y < border_width ||
|
||||||
|
x >= (width - border_width) || y >= (height - border_width)) {
|
||||||
|
const size_t idx = (x + y * width);
|
||||||
|
const size_t idx_rgb = (x + y * width) * 3;
|
||||||
|
px_data[idx_rgb] = px_data[idx_rgb + 1] = px_data[idx_rgb + 2] = dark_mode ? 245u : 110u;
|
||||||
|
a_data[idx] = 255u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bitmaps.push_back(wxImage_to_wxBitmap_with_alpha(std::move(image), scale));
|
||||||
|
}
|
||||||
|
return wxBitmapBundle::FromBitmaps(bitmaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* BitmapCache::mksolid_bndl(size_t width, size_t height, const std::string& color, size_t border_width, bool dark_mode)
|
||||||
|
{
|
||||||
|
std::string bitmap_key = (color.empty() ? "empty-w" : color) + "-h" + std::to_string(height) + "-w" + std::to_string(width) + (dark_mode ? "-dm" : "");
|
||||||
|
|
||||||
|
wxBitmapBundle* bndl = nullptr;
|
||||||
|
auto it = m_bndl_map.find(bitmap_key);
|
||||||
|
if (it == m_bndl_map.end()) {
|
||||||
|
if (color.empty())
|
||||||
|
bndl = new wxBitmapBundle(mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT, size_t(0)));
|
||||||
|
else {
|
||||||
|
ColorRGB rgb;// [3] ;
|
||||||
|
decode_color(color, rgb);
|
||||||
|
bndl = new wxBitmapBundle(mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, border_width, dark_mode));
|
||||||
|
}
|
||||||
|
m_bndl_map[bitmap_key] = bndl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return it->second;
|
||||||
|
|
||||||
|
return bndl;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -24,10 +24,18 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
double scale() { return m_scale; }
|
double scale() { return m_scale; }
|
||||||
|
|
||||||
|
wxBitmapBundle* find_bndl(const std::string &name) { auto it = m_bndl_map.find(name); return (it == m_bndl_map.end()) ? nullptr : it->second; }
|
||||||
|
const wxBitmapBundle* find_bndl(const std::string &name) const { return const_cast<BitmapCache*>(this)->find_bndl(name); }
|
||||||
wxBitmap* find(const std::string &name) { auto it = m_map.find(name); return (it == m_map.end()) ? nullptr : it->second; }
|
wxBitmap* find(const std::string &name) { auto it = m_map.find(name); return (it == m_map.end()) ? nullptr : it->second; }
|
||||||
const wxBitmap* find(const std::string &name) const { return const_cast<BitmapCache*>(this)->find(name); }
|
const wxBitmap* find(const std::string &name) const { return const_cast<BitmapCache*>(this)->find(name); }
|
||||||
|
|
||||||
wxBitmap* insert(const std::string &name, size_t width, size_t height);
|
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const char* data, size_t width, size_t height);
|
||||||
|
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const wxBitmapBundle &bmp);
|
||||||
|
wxBitmapBundle* insert_bndl(const std::string& bitmap_key, const wxVector<wxBitmap>& bmps);
|
||||||
|
wxBitmapBundle* insert_bndl(const std::string& name, const std::vector<wxBitmapBundle*>& bmps);
|
||||||
|
wxBitmapBundle* insert_raw_rgba_bndl(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
|
||||||
|
|
||||||
|
wxBitmap* insert(const std::string &name, size_t width, size_t height, double scale = -1.0);
|
||||||
wxBitmap* insert(const std::string &name, const wxBitmap &bmp);
|
wxBitmap* insert(const std::string &name, const wxBitmap &bmp);
|
||||||
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2);
|
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2);
|
||||||
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3);
|
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3);
|
||||||
@ -42,15 +50,24 @@ public:
|
|||||||
// And makes replases befor parsing
|
// And makes replases befor parsing
|
||||||
// replace_map containes old_value->new_value
|
// replace_map containes old_value->new_value
|
||||||
static NSVGimage* nsvgParseFromFileWithReplace(const char* filename, const char* units, float dpi, const std::map<std::string, std::string>& replaces);
|
static NSVGimage* nsvgParseFromFileWithReplace(const char* filename, const char* units, float dpi, const std::map<std::string, std::string>& replaces);
|
||||||
|
// Gets a data from SVG file and makes replases
|
||||||
|
// replace_map containes old_value->new_value
|
||||||
|
static void nsvgGetDataFromFileWithReplace(const char* filename, std::string& data_str, const std::map<std::string, std::string>& replaces);
|
||||||
|
wxBitmapBundle* from_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height, const bool dark_mode, const std::string& new_color = "");
|
||||||
|
wxBitmapBundle* from_png(const std::string& bitmap_name, unsigned width, unsigned height);
|
||||||
// Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width.
|
// 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 = "");
|
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 = "");
|
||||||
|
|
||||||
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, 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 ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
|
wxBitmap mksolid(size_t width, size_t height, const ColorRGB& rgb, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar(), wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
|
||||||
wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT); }
|
wxBitmap mkclear(size_t width, size_t height) { return mksolid(width, height, 0, 0, 0, wxALPHA_TRANSPARENT, true, 0); }
|
||||||
|
wxBitmapBundle mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, size_t border_width = 0, bool dark_mode = false);
|
||||||
|
wxBitmapBundle* mksolid_bndl(size_t width, size_t height, const std::string& color = std::string(), size_t border_width = 0, bool dark_mode = false);
|
||||||
|
wxBitmapBundle* mkclear_bndl(size_t width, size_t height) { return mksolid_bndl(width, height); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, wxBitmap*> m_map;
|
std::map<std::string, wxBitmap*> m_map;
|
||||||
|
std::map<std::string, wxBitmapBundle*> m_bndl_map;
|
||||||
double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs)
|
double m_gs = 0.2; // value, used for image.ConvertToGreyscale(m_gs, m_gs, m_gs)
|
||||||
double m_scale = 1.0; // value, used for correct scaling of SVG icons on Retina display
|
double m_scale = 1.0; // value, used for correct scaling of SVG icons on Retina display
|
||||||
};
|
};
|
||||||
|
@ -54,17 +54,6 @@ using Slic3r::GUI::format_wxstr;
|
|||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
/* For PresetComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
|
|
||||||
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
|
|
||||||
* "please scale this to such and such" but rather
|
|
||||||
* "the wxImage is already sized for backing scale such and such". )
|
|
||||||
* Unfortunately, the constructor changes the size of wxBitmap too.
|
|
||||||
* Thus We need to use unscaled size value for bitmaps that we use
|
|
||||||
* to avoid scaled size of control items.
|
|
||||||
* For this purpose control drawing methods and
|
|
||||||
* control size calculation methods (virtual) are overridden.
|
|
||||||
**/
|
|
||||||
|
|
||||||
BitmapComboBox::BitmapComboBox(wxWindow* parent,
|
BitmapComboBox::BitmapComboBox(wxWindow* parent,
|
||||||
wxWindowID id/* = wxID_ANY*/,
|
wxWindowID id/* = wxID_ANY*/,
|
||||||
const wxString& value/* = wxEmptyString*/,
|
const wxString& value/* = wxEmptyString*/,
|
||||||
@ -90,72 +79,6 @@ BitmapComboBox::~BitmapComboBox()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
bool BitmapComboBox::OnAddBitmap(const wxBitmap& bitmap)
|
|
||||||
{
|
|
||||||
if (bitmap.IsOk())
|
|
||||||
{
|
|
||||||
// we should use scaled! size values of bitmap
|
|
||||||
int width = (int)bitmap.GetScaledWidth();
|
|
||||||
int height = (int)bitmap.GetScaledHeight();
|
|
||||||
|
|
||||||
if (m_usedImgSize.x < 0)
|
|
||||||
{
|
|
||||||
// If size not yet determined, get it from this image.
|
|
||||||
m_usedImgSize.x = width;
|
|
||||||
m_usedImgSize.y = height;
|
|
||||||
|
|
||||||
// Adjust control size to vertically fit the bitmap
|
|
||||||
wxWindow* ctrl = GetControl();
|
|
||||||
ctrl->InvalidateBestSize();
|
|
||||||
wxSize newSz = ctrl->GetBestSize();
|
|
||||||
wxSize sz = ctrl->GetSize();
|
|
||||||
if (newSz.y > sz.y)
|
|
||||||
ctrl->SetSize(sz.x, newSz.y);
|
|
||||||
else
|
|
||||||
DetermineIndent();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxCHECK_MSG(width == m_usedImgSize.x && height == m_usedImgSize.y,
|
|
||||||
false,
|
|
||||||
"you can only add images of same size");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BitmapComboBox::OnDrawItem(wxDC& dc,
|
|
||||||
const wxRect& rect,
|
|
||||||
int item,
|
|
||||||
int flags) const
|
|
||||||
{
|
|
||||||
const wxBitmap& bmp = *(static_cast<wxBitmap*>(m_bitmaps[item]));
|
|
||||||
if (bmp.IsOk())
|
|
||||||
{
|
|
||||||
// we should use scaled! size values of bitmap
|
|
||||||
wxCoord w = bmp.GetScaledWidth();
|
|
||||||
wxCoord h = bmp.GetScaledHeight();
|
|
||||||
|
|
||||||
const int imgSpacingLeft = 4;
|
|
||||||
|
|
||||||
// Draw the image centered
|
|
||||||
dc.DrawBitmap(bmp,
|
|
||||||
rect.x + (m_usedImgSize.x - w) / 2 + imgSpacingLeft,
|
|
||||||
rect.y + (rect.height - h) / 2,
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString text = GetString(item);
|
|
||||||
if (!text.empty())
|
|
||||||
dc.DrawText(text,
|
|
||||||
rect.x + m_imgAreaWidth + 1,
|
|
||||||
rect.y + (rect.height - dc.GetCharHeight()) / 2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
int BitmapComboBox::Append(const wxString& item)
|
int BitmapComboBox::Append(const wxString& item)
|
||||||
@ -166,19 +89,11 @@ int BitmapComboBox::Append(const wxString& item)
|
|||||||
//2. But then set width to 0 value for no using of bitmap left and right spacing
|
//2. But then set width to 0 value for no using of bitmap left and right spacing
|
||||||
//3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
|
//3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
|
||||||
|
|
||||||
// wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1));
|
wxBitmapBundle bitmap = *get_empty_bmp_bundle(1, 16);
|
||||||
wxBitmap bitmap(1, 16);
|
|
||||||
{
|
|
||||||
// bitmap.SetWidth(0); is depricated now
|
|
||||||
// so, use next code
|
|
||||||
bitmap.UnShare();// AllocExclusive();
|
|
||||||
bitmap.GetGDIImageData()->m_width = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnAddBitmap(bitmap);
|
OnAddBitmap(bitmap);
|
||||||
|
|
||||||
const int n = wxComboBox::Append(item);
|
const int n = wxComboBox::Append(item);
|
||||||
if (n != wxNOT_FOUND)
|
|
||||||
DoSetItemBitmap(n, bitmap);
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +184,6 @@ void BitmapComboBox::DrawBackground_(wxDC& dc, const wxRect& rect, int WXUNUSED(
|
|||||||
|
|
||||||
void BitmapComboBox::Rescale()
|
void BitmapComboBox::Rescale()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
// Next workaround: To correct scaling of a BitmapCombobox
|
// Next workaround: To correct scaling of a BitmapCombobox
|
||||||
// we need to refill control with new bitmaps
|
// we need to refill control with new bitmaps
|
||||||
const wxString selection = this->GetValue();
|
const wxString selection = this->GetValue();
|
||||||
|
@ -29,28 +29,13 @@ BitmapComboBox(wxWindow* parent,
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int Append(const wxString& item);
|
int Append(const wxString& item);
|
||||||
#endif
|
#endif
|
||||||
int Append(const wxString& item, const wxBitmap& bitmap)
|
int Append(const wxString& item, const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
return wxBitmapComboBox::Append(item, bitmap);
|
return wxBitmapComboBox::Append(item, bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
/* For PresetComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
|
|
||||||
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
|
|
||||||
* "please scale this to such and such" but rather
|
|
||||||
* "the wxImage is already sized for backing scale such and such". )
|
|
||||||
* Unfortunately, the constructor changes the size of wxBitmap too.
|
|
||||||
* Thus We need to use unscaled size value for bitmaps that we use
|
|
||||||
* to avoid scaled size of control items.
|
|
||||||
* For this purpose control drawing methods and
|
|
||||||
* control size calculation methods (virtual) are overridden.
|
|
||||||
**/
|
|
||||||
bool OnAddBitmap(const wxBitmap& bitmap) override;
|
|
||||||
void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const override;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
bool MSWOnDraw(WXDRAWITEMSTRUCT* item) override;
|
bool MSWOnDraw(WXDRAWITEMSTRUCT* item) override;
|
||||||
void DrawBackground_(wxDC& dc, const wxRect& rect, int WXUNUSED(item), int flags) const;
|
void DrawBackground_(wxDC& dc, const wxRect& rect, int WXUNUSED(item), int flags) const;
|
||||||
|
@ -17,9 +17,6 @@ void ButtonsDescription::FillSizerWithTextColorDescriptions(wxSizer* sizer, wxWi
|
|||||||
wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(3, 5, 5);
|
wxFlexGridSizer* grid_sizer = new wxFlexGridSizer(3, 5, 5);
|
||||||
sizer->Add(grid_sizer, 0, wxEXPAND);
|
sizer->Add(grid_sizer, 0, wxEXPAND);
|
||||||
|
|
||||||
ScalableBitmap bmp_delete = ScalableBitmap(parent, "cross");
|
|
||||||
ScalableBitmap bmp_delete_focus = ScalableBitmap(parent, "cross_focus");
|
|
||||||
|
|
||||||
auto add_color = [grid_sizer, parent](wxColourPickerCtrl** color_picker, const wxColour& color, const wxColour& def_color, wxString label_text) {
|
auto add_color = [grid_sizer, parent](wxColourPickerCtrl** color_picker, const wxColour& color, const wxColour& def_color, wxString label_text) {
|
||||||
// wrap the label_text to the max 80 characters
|
// wrap the label_text to the max 80 characters
|
||||||
if (label_text.Len() > 80) {
|
if (label_text.Len() > 80) {
|
||||||
|
@ -1609,7 +1609,7 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
|
|||||||
#ifndef __WXOSX__
|
#ifndef __WXOSX__
|
||||||
SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
|
SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
|
||||||
#endif //__WXOSX__
|
#endif //__WXOSX__
|
||||||
SetMinSize(bg.bmp().GetSize());
|
SetMinSize(bg.GetSize());
|
||||||
|
|
||||||
const wxSize size = GetTextExtent("m");
|
const wxSize size = GetTextExtent("m");
|
||||||
em_w = size.x;
|
em_w = size.x;
|
||||||
@ -1734,8 +1734,8 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
|||||||
|
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
const auto bullet_w = bullet_black.bmp().GetSize().GetWidth();
|
const auto bullet_w = bullet_black.GetWidth();
|
||||||
const auto bullet_h = bullet_black.bmp().GetSize().GetHeight();
|
const auto bullet_h = bullet_black.GetHeight();
|
||||||
const int yoff_icon = bullet_h < em_h ? (em_h - bullet_h) / 2 : 0;
|
const int yoff_icon = bullet_h < em_h ? (em_h - bullet_h) / 2 : 0;
|
||||||
const int yoff_text = bullet_h > em_h ? (bullet_h - em_h) / 2 : 0;
|
const int yoff_text = bullet_h > em_h ? (bullet_h - em_h) / 2 : 0;
|
||||||
const int yinc = item_height();
|
const int yinc = item_height();
|
||||||
@ -1748,10 +1748,10 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
|||||||
unsigned x = em_w/2 + item.indent * em_w;
|
unsigned x = em_w/2 + item.indent * em_w;
|
||||||
|
|
||||||
if (i == item_active || (item_hover >= 0 && i == (size_t)item_hover)) {
|
if (i == item_active || (item_hover >= 0 && i == (size_t)item_hover)) {
|
||||||
dc.DrawBitmap(bullet_blue.bmp(), x, y + yoff_icon, false);
|
dc.DrawBitmap(bullet_blue.get_bitmap(), x, y + yoff_icon, false);
|
||||||
}
|
}
|
||||||
else if (i < item_active) { dc.DrawBitmap(bullet_black.bmp(), x, y + yoff_icon, false); }
|
else if (i < item_active) { dc.DrawBitmap(bullet_black.get_bitmap(), x, y + yoff_icon, false); }
|
||||||
else if (i > item_active) { dc.DrawBitmap(bullet_white.bmp(), x, y + yoff_icon, false); }
|
else if (i > item_active) { dc.DrawBitmap(bullet_white.get_bitmap(), x, y + yoff_icon, false); }
|
||||||
|
|
||||||
x += + bullet_w + em_w/2;
|
x += + bullet_w + em_w/2;
|
||||||
const auto text_size = dc.GetTextExtent(item.label);
|
const auto text_size = dc.GetTextExtent(item.label);
|
||||||
@ -1763,9 +1763,9 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//draw logo
|
//draw logo
|
||||||
if (int y = size.y - bg.GetBmpHeight(); y>=0) {
|
if (int y = size.y - bg.GetHeight(); y>=0) {
|
||||||
dc.DrawBitmap(bg.bmp(), 0, y, false);
|
dc.DrawBitmap(bg.get_bitmap(), 0, y, false);
|
||||||
index_width = std::max(index_width, bg.GetBmpWidth() + em_w / 2);
|
index_width = std::max(index_width, bg.GetWidth() + em_w / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetMinSize().x < index_width) {
|
if (GetMinSize().x < index_width) {
|
||||||
@ -1797,12 +1797,8 @@ void ConfigWizardIndex::msw_rescale()
|
|||||||
em_w = size.x;
|
em_w = size.x;
|
||||||
em_h = size.y;
|
em_h = size.y;
|
||||||
|
|
||||||
bg.msw_rescale();
|
SetMinSize(bg.GetSize());
|
||||||
SetMinSize(bg.bmp().GetSize());
|
|
||||||
|
|
||||||
bullet_black.msw_rescale();
|
|
||||||
bullet_blue.msw_rescale();
|
|
||||||
bullet_white.msw_rescale();
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ private:
|
|||||||
ssize_t item_hover;
|
ssize_t item_hover;
|
||||||
size_t last_page;
|
size_t last_page;
|
||||||
|
|
||||||
int item_height() const { return std::max(bullet_black.bmp().GetSize().GetHeight(), em_w) + em_w; }
|
int item_height() const { return std::max(bullet_black.GetHeight(), em_w) + em_w; }
|
||||||
|
|
||||||
void on_paint(wxPaintEvent &evt);
|
void on_paint(wxPaintEvent &evt);
|
||||||
void on_mouse_move(wxMouseEvent &evt);
|
void on_mouse_move(wxMouseEvent &evt);
|
||||||
|
@ -86,24 +86,24 @@ Control::Control( wxWindow *parent,
|
|||||||
|
|
||||||
m_bmp_thumb_higher = (style == wxSL_HORIZONTAL ? ScalableBitmap(this, "thumb_right") : ScalableBitmap(this, "thumb_up"));
|
m_bmp_thumb_higher = (style == wxSL_HORIZONTAL ? ScalableBitmap(this, "thumb_right") : ScalableBitmap(this, "thumb_up"));
|
||||||
m_bmp_thumb_lower = (style == wxSL_HORIZONTAL ? ScalableBitmap(this, "thumb_left") : ScalableBitmap(this, "thumb_down"));
|
m_bmp_thumb_lower = (style == wxSL_HORIZONTAL ? ScalableBitmap(this, "thumb_left") : ScalableBitmap(this, "thumb_down"));
|
||||||
m_thumb_size = m_bmp_thumb_lower.GetBmpSize();
|
m_thumb_size = m_bmp_thumb_lower.GetSize();
|
||||||
|
|
||||||
m_bmp_add_tick_on = ScalableBitmap(this, "colorchange_add");
|
m_bmp_add_tick_on = ScalableBitmap(this, "colorchange_add");
|
||||||
m_bmp_add_tick_off = ScalableBitmap(this, "colorchange_add_f");
|
m_bmp_add_tick_off = ScalableBitmap(this, "colorchange_add_f");
|
||||||
m_bmp_del_tick_on = ScalableBitmap(this, "colorchange_del");
|
m_bmp_del_tick_on = ScalableBitmap(this, "colorchange_del");
|
||||||
m_bmp_del_tick_off = ScalableBitmap(this, "colorchange_del_f");
|
m_bmp_del_tick_off = ScalableBitmap(this, "colorchange_del_f");
|
||||||
m_tick_icon_dim = m_bmp_add_tick_on.GetBmpWidth();
|
m_tick_icon_dim = m_bmp_add_tick_on.GetWidth();
|
||||||
|
|
||||||
m_bmp_one_layer_lock_on = ScalableBitmap(this, "lock_closed");
|
m_bmp_one_layer_lock_on = ScalableBitmap(this, "lock_closed");
|
||||||
m_bmp_one_layer_lock_off = ScalableBitmap(this, "lock_closed_f");
|
m_bmp_one_layer_lock_off = ScalableBitmap(this, "lock_closed_f");
|
||||||
m_bmp_one_layer_unlock_on = ScalableBitmap(this, "lock_open");
|
m_bmp_one_layer_unlock_on = ScalableBitmap(this, "lock_open");
|
||||||
m_bmp_one_layer_unlock_off = ScalableBitmap(this, "lock_open_f");
|
m_bmp_one_layer_unlock_off = ScalableBitmap(this, "lock_open_f");
|
||||||
m_lock_icon_dim = m_bmp_one_layer_lock_on.GetBmpWidth();
|
m_lock_icon_dim = m_bmp_one_layer_lock_on.GetWidth();
|
||||||
|
|
||||||
m_bmp_revert = ScalableBitmap(this, "undo");
|
m_bmp_revert = ScalableBitmap(this, "undo");
|
||||||
m_revert_icon_dim = m_bmp_revert.GetBmpWidth();
|
m_revert_icon_dim = m_bmp_revert.GetWidth();
|
||||||
m_bmp_cog = ScalableBitmap(this, "cog");
|
m_bmp_cog = ScalableBitmap(this, "cog");
|
||||||
m_cog_icon_dim = m_bmp_cog.GetBmpWidth();
|
m_cog_icon_dim = m_bmp_cog.GetWidth();
|
||||||
|
|
||||||
m_selection = ssUndef;
|
m_selection = ssUndef;
|
||||||
m_ticks.set_pause_print_msg(_utf8(L("Place bearings in slots and resume printing")));
|
m_ticks.set_pause_print_msg(_utf8(L("Place bearings in slots and resume printing")));
|
||||||
@ -155,26 +155,11 @@ void Control::msw_rescale()
|
|||||||
{
|
{
|
||||||
m_font = GUI::wxGetApp().normal_font();
|
m_font = GUI::wxGetApp().normal_font();
|
||||||
|
|
||||||
m_bmp_thumb_higher.msw_rescale();
|
m_thumb_size = m_bmp_thumb_lower.GetSize();
|
||||||
m_bmp_thumb_lower .msw_rescale();
|
m_tick_icon_dim = m_bmp_add_tick_on.GetWidth();
|
||||||
m_thumb_size = m_bmp_thumb_lower.bmp().GetSize();
|
m_lock_icon_dim = m_bmp_one_layer_lock_on.GetWidth();
|
||||||
|
m_revert_icon_dim = m_bmp_revert.GetWidth();
|
||||||
m_bmp_add_tick_on .msw_rescale();
|
m_cog_icon_dim = m_bmp_cog.GetWidth();
|
||||||
m_bmp_add_tick_off.msw_rescale();
|
|
||||||
m_bmp_del_tick_on .msw_rescale();
|
|
||||||
m_bmp_del_tick_off.msw_rescale();
|
|
||||||
m_tick_icon_dim = m_bmp_add_tick_on.bmp().GetSize().x;
|
|
||||||
|
|
||||||
m_bmp_one_layer_lock_on .msw_rescale();
|
|
||||||
m_bmp_one_layer_lock_off .msw_rescale();
|
|
||||||
m_bmp_one_layer_unlock_on .msw_rescale();
|
|
||||||
m_bmp_one_layer_unlock_off.msw_rescale();
|
|
||||||
m_lock_icon_dim = m_bmp_one_layer_lock_on.bmp().GetSize().x;
|
|
||||||
|
|
||||||
m_bmp_revert.msw_rescale();
|
|
||||||
m_revert_icon_dim = m_bmp_revert.bmp().GetSize().x;
|
|
||||||
m_bmp_cog.msw_rescale();
|
|
||||||
m_cog_icon_dim = m_bmp_cog.bmp().GetSize().x;
|
|
||||||
|
|
||||||
SLIDER_MARGIN = 4 + GUI::wxGetApp().em_unit();
|
SLIDER_MARGIN = 4 + GUI::wxGetApp().em_unit();
|
||||||
|
|
||||||
@ -189,22 +174,18 @@ void Control::sys_color_changed()
|
|||||||
{
|
{
|
||||||
GUI::wxGetApp().UpdateDarkUI(GetParent());
|
GUI::wxGetApp().UpdateDarkUI(GetParent());
|
||||||
|
|
||||||
m_bmp_add_tick_on .msw_rescale();
|
m_bmp_add_tick_on .sys_color_changed();
|
||||||
m_bmp_add_tick_off.msw_rescale();
|
m_bmp_add_tick_off.sys_color_changed();
|
||||||
m_bmp_del_tick_on .msw_rescale();
|
m_bmp_del_tick_on .sys_color_changed();
|
||||||
m_bmp_del_tick_off.msw_rescale();
|
m_bmp_del_tick_off.sys_color_changed();
|
||||||
m_tick_icon_dim = m_bmp_add_tick_on.GetBmpWidth();
|
|
||||||
|
|
||||||
m_bmp_one_layer_lock_on .msw_rescale();
|
m_bmp_one_layer_lock_on .sys_color_changed();
|
||||||
m_bmp_one_layer_lock_off .msw_rescale();
|
m_bmp_one_layer_lock_off .sys_color_changed();
|
||||||
m_bmp_one_layer_unlock_on .msw_rescale();
|
m_bmp_one_layer_unlock_on .sys_color_changed();
|
||||||
m_bmp_one_layer_unlock_off.msw_rescale();
|
m_bmp_one_layer_unlock_off.sys_color_changed();
|
||||||
m_lock_icon_dim = m_bmp_one_layer_lock_on.GetBmpWidth();
|
|
||||||
|
|
||||||
m_bmp_revert.msw_rescale();
|
m_bmp_revert.sys_color_changed();
|
||||||
m_revert_icon_dim = m_bmp_revert.GetBmpWidth();
|
m_bmp_cog .sys_color_changed();
|
||||||
m_bmp_cog.msw_rescale();
|
|
||||||
m_cog_icon_dim = m_bmp_cog.GetBmpWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Control::GetActiveValue() const
|
int Control::GetActiveValue() const
|
||||||
@ -604,9 +585,12 @@ void Control::draw_action_icon(wxDC& dc, const wxPoint pt_beg, const wxPoint pt_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap* icon = m_focus == fiActionIcon ? &m_bmp_add_tick_off.bmp() : &m_bmp_add_tick_on.bmp();
|
//wxBitmap* icon = m_focus == fiActionIcon ? &m_bmp_add_tick_off.bmp() : &m_bmp_add_tick_on.bmp();
|
||||||
|
//if (m_ticks.ticks.find(TickCode{tick}) != m_ticks.ticks.end())
|
||||||
|
// icon = m_focus == fiActionIcon ? &m_bmp_del_tick_off.bmp() : &m_bmp_del_tick_on.bmp();
|
||||||
|
ScalableBitmap* icon = m_focus == fiActionIcon ? &m_bmp_add_tick_off : &m_bmp_add_tick_on;
|
||||||
if (m_ticks.ticks.find(TickCode{tick}) != m_ticks.ticks.end())
|
if (m_ticks.ticks.find(TickCode{tick}) != m_ticks.ticks.end())
|
||||||
icon = m_focus == fiActionIcon ? &m_bmp_del_tick_off.bmp() : &m_bmp_del_tick_on.bmp();
|
icon = m_focus == fiActionIcon ? &m_bmp_del_tick_off : &m_bmp_del_tick_on;
|
||||||
|
|
||||||
wxCoord x_draw, y_draw;
|
wxCoord x_draw, y_draw;
|
||||||
is_horizontal() ? x_draw = pt_beg.x - 0.5*m_tick_icon_dim : y_draw = pt_beg.y - 0.5*m_tick_icon_dim;
|
is_horizontal() ? x_draw = pt_beg.x - 0.5*m_tick_icon_dim : y_draw = pt_beg.y - 0.5*m_tick_icon_dim;
|
||||||
@ -615,10 +599,12 @@ void Control::draw_action_icon(wxDC& dc, const wxPoint pt_beg, const wxPoint pt_
|
|||||||
else
|
else
|
||||||
is_horizontal() ? y_draw = pt_beg.y - m_tick_icon_dim-2 : x_draw = pt_end.x + 3;
|
is_horizontal() ? y_draw = pt_beg.y - m_tick_icon_dim-2 : x_draw = pt_end.x + 3;
|
||||||
|
|
||||||
if (m_draw_mode == dmSequentialFffPrint)
|
if (m_draw_mode == dmSequentialFffPrint) {
|
||||||
dc.DrawBitmap(create_scaled_bitmap("colorchange_add", nullptr, 16, true), x_draw, y_draw);
|
wxBitmap disabled_add = get_bmp_bundle("colorchange_add")->GetBitmapFor(this).ConvertToDisabled();
|
||||||
|
dc.DrawBitmap(disabled_add, x_draw, y_draw);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
dc.DrawBitmap(*icon, x_draw, y_draw);
|
dc.DrawBitmap((*icon).get_bitmap(), x_draw, y_draw);
|
||||||
|
|
||||||
//update rect of the tick action icon
|
//update rect of the tick action icon
|
||||||
m_rect_tick_action = wxRect(x_draw, y_draw, m_tick_icon_dim, m_tick_icon_dim);
|
m_rect_tick_action = wxRect(x_draw, y_draw, m_tick_icon_dim, m_tick_icon_dim);
|
||||||
@ -851,7 +837,7 @@ void Control::draw_thumb_item(wxDC& dc, const wxPoint& pos, const SelectedSlider
|
|||||||
{
|
{
|
||||||
wxCoord x_draw = pos.x - int(0.5 * m_thumb_size.x);
|
wxCoord x_draw = pos.x - int(0.5 * m_thumb_size.x);
|
||||||
wxCoord y_draw = pos.y - int(0.5 * m_thumb_size.y);
|
wxCoord y_draw = pos.y - int(0.5 * m_thumb_size.y);
|
||||||
dc.DrawBitmap(selection == ssLower ? m_bmp_thumb_lower.bmp() : m_bmp_thumb_higher.bmp(), x_draw, y_draw);
|
dc.DrawBitmap(selection == ssLower ? m_bmp_thumb_lower.get_bitmap() : m_bmp_thumb_higher.get_bitmap(), x_draw, y_draw);
|
||||||
|
|
||||||
// Update thumb rect
|
// Update thumb rect
|
||||||
update_thumb_rect(x_draw, y_draw, selection);
|
update_thumb_rect(x_draw, y_draw, selection);
|
||||||
@ -945,12 +931,12 @@ void Control::draw_ticks(wxDC& dc)
|
|||||||
|
|
||||||
// Draw icon for "Pause print", "Custom Gcode" or conflict tick
|
// Draw icon for "Pause print", "Custom Gcode" or conflict tick
|
||||||
if (!icon_name.empty()) {
|
if (!icon_name.empty()) {
|
||||||
wxBitmap icon = create_scaled_bitmap(icon_name);
|
wxBitmapBundle* icon = get_bmp_bundle(icon_name);
|
||||||
wxCoord x_draw, y_draw;
|
wxCoord x_draw, y_draw;
|
||||||
is_horizontal() ? x_draw = pos - 0.5 * m_tick_icon_dim : y_draw = pos - 0.5 * m_tick_icon_dim;
|
is_horizontal() ? x_draw = pos - 0.5 * m_tick_icon_dim : y_draw = pos - 0.5 * m_tick_icon_dim;
|
||||||
is_horizontal() ? y_draw = mid + 22 : x_draw = mid + m_thumb_size.x + 3;
|
is_horizontal() ? y_draw = mid + 22 : x_draw = mid + m_thumb_size.x + 3;
|
||||||
|
|
||||||
dc.DrawBitmap(icon, x_draw, y_draw);
|
dc.DrawBitmap(icon->GetBitmapFor(this), x_draw, y_draw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1262,9 +1248,12 @@ void Control::draw_one_layer_icon(wxDC& dc)
|
|||||||
if (m_draw_mode == dmSequentialGCodeView)
|
if (m_draw_mode == dmSequentialGCodeView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wxBitmap& icon = m_is_one_layer ?
|
//const wxBitmap& icon = m_is_one_layer ?
|
||||||
m_focus == fiOneLayerIcon ? m_bmp_one_layer_lock_off.bmp() : m_bmp_one_layer_lock_on.bmp() :
|
// m_focus == fiOneLayerIcon ? m_bmp_one_layer_lock_off.bmp() : m_bmp_one_layer_lock_on.bmp() :
|
||||||
m_focus == fiOneLayerIcon ? m_bmp_one_layer_unlock_off.bmp() : m_bmp_one_layer_unlock_on.bmp();
|
// m_focus == fiOneLayerIcon ? m_bmp_one_layer_unlock_off.bmp() : m_bmp_one_layer_unlock_on.bmp();
|
||||||
|
const ScalableBitmap& icon = m_is_one_layer ?
|
||||||
|
m_focus == fiOneLayerIcon ? m_bmp_one_layer_lock_off : m_bmp_one_layer_lock_on :
|
||||||
|
m_focus == fiOneLayerIcon ? m_bmp_one_layer_unlock_off : m_bmp_one_layer_unlock_on;
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
get_size(&width, &height);
|
get_size(&width, &height);
|
||||||
@ -1273,7 +1262,7 @@ void Control::draw_one_layer_icon(wxDC& dc)
|
|||||||
is_horizontal() ? x_draw = width-2 : x_draw = 0.5*width - 0.5*m_lock_icon_dim;
|
is_horizontal() ? x_draw = width-2 : x_draw = 0.5*width - 0.5*m_lock_icon_dim;
|
||||||
is_horizontal() ? y_draw = 0.5*height - 0.5*m_lock_icon_dim : y_draw = height-2;
|
is_horizontal() ? y_draw = 0.5*height - 0.5*m_lock_icon_dim : y_draw = height-2;
|
||||||
|
|
||||||
dc.DrawBitmap(icon, x_draw, y_draw);
|
dc.DrawBitmap(icon.bmp().GetBitmapFor(this), x_draw, y_draw);
|
||||||
|
|
||||||
//update rect of the lock/unlock icon
|
//update rect of the lock/unlock icon
|
||||||
m_rect_one_layer_icon = wxRect(x_draw, y_draw, m_lock_icon_dim, m_lock_icon_dim);
|
m_rect_one_layer_icon = wxRect(x_draw, y_draw, m_lock_icon_dim, m_lock_icon_dim);
|
||||||
@ -1291,7 +1280,7 @@ void Control::draw_revert_icon(wxDC& dc)
|
|||||||
is_horizontal() ? x_draw = width-2 : x_draw = 0.25*SLIDER_MARGIN;
|
is_horizontal() ? x_draw = width-2 : x_draw = 0.25*SLIDER_MARGIN;
|
||||||
is_horizontal() ? y_draw = 0.25*SLIDER_MARGIN: y_draw = height-2;
|
is_horizontal() ? y_draw = 0.25*SLIDER_MARGIN: y_draw = height-2;
|
||||||
|
|
||||||
dc.DrawBitmap(m_bmp_revert.bmp(), x_draw, y_draw);
|
dc.DrawBitmap(m_bmp_revert.get_bitmap(), x_draw, y_draw);
|
||||||
|
|
||||||
//update rect of the lock/unlock icon
|
//update rect of the lock/unlock icon
|
||||||
m_rect_revert_icon = wxRect(x_draw, y_draw, m_revert_icon_dim, m_revert_icon_dim);
|
m_rect_revert_icon = wxRect(x_draw, y_draw, m_revert_icon_dim, m_revert_icon_dim);
|
||||||
@ -1315,7 +1304,7 @@ void Control::draw_cog_icon(wxDC& dc)
|
|||||||
is_horizontal() ? y_draw = height - m_cog_icon_dim - 2 : y_draw = height - 2;
|
is_horizontal() ? y_draw = height - m_cog_icon_dim - 2 : y_draw = height - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.DrawBitmap(m_bmp_cog.bmp(), x_draw, y_draw);
|
dc.DrawBitmap(m_bmp_cog.get_bitmap(), x_draw, y_draw);
|
||||||
|
|
||||||
//update rect of the lock/unlock icon
|
//update rect of the lock/unlock icon
|
||||||
m_rect_cog_icon = wxRect(x_draw, y_draw, m_cog_icon_dim, m_cog_icon_dim);
|
m_rect_cog_icon = wxRect(x_draw, y_draw, m_cog_icon_dim, m_cog_icon_dim);
|
||||||
@ -1673,7 +1662,7 @@ void Control::append_change_extruder_menu_item(wxMenu* menu, bool switch_current
|
|||||||
if (extruders_cnt > 1) {
|
if (extruders_cnt > 1) {
|
||||||
std::array<int, 2> active_extruders = get_active_extruders_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value);
|
std::array<int, 2> active_extruders = get_active_extruders_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value);
|
||||||
|
|
||||||
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
|
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
|
||||||
|
|
||||||
wxMenu* change_extruder_menu = new wxMenu();
|
wxMenu* change_extruder_menu = new wxMenu();
|
||||||
|
|
||||||
@ -1684,7 +1673,7 @@ void Control::append_change_extruder_menu_item(wxMenu* menu, bool switch_current
|
|||||||
|
|
||||||
if (m_mode == MultiAsSingle)
|
if (m_mode == MultiAsSingle)
|
||||||
append_menu_item(change_extruder_menu, wxID_ANY, item_name, "",
|
append_menu_item(change_extruder_menu, wxID_ANY, item_name, "",
|
||||||
[this, i](wxCommandEvent&) { add_code_as_tick(ToolChange, i); }, *icons[i-1], menu,
|
[this, i](wxCommandEvent&) { add_code_as_tick(ToolChange, i); }, icons[i-1], menu,
|
||||||
[is_active_extruder]() { return !is_active_extruder; }, GUI::wxGetApp().plater());
|
[is_active_extruder]() { return !is_active_extruder; }, GUI::wxGetApp().plater());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1722,7 +1711,7 @@ void Control::append_add_color_change_menu_item(wxMenu* menu, bool switch_curren
|
|||||||
format_wxstr(_L("Switch code to Color change (%1%) for:"), gcode(ColorChange)) :
|
format_wxstr(_L("Switch code to Color change (%1%) for:"), gcode(ColorChange)) :
|
||||||
format_wxstr(_L("Add color change (%1%) for:"), gcode(ColorChange));
|
format_wxstr(_L("Add color change (%1%) for:"), gcode(ColorChange));
|
||||||
wxMenuItem* add_color_change_menu_item = menu->AppendSubMenu(add_color_change_menu, menu_name, "");
|
wxMenuItem* add_color_change_menu_item = menu->AppendSubMenu(add_color_change_menu, menu_name, "");
|
||||||
add_color_change_menu_item->SetBitmap(create_menu_bitmap("colorchange_add_m"));
|
add_color_change_menu_item->SetBitmap(*get_bmp_bundle("colorchange_add_m"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelR
|
|||||||
if (can_create_editor_ctrl && !can_create_editor_ctrl())
|
if (can_create_editor_ctrl && !can_create_editor_ctrl())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
std::vector<wxBitmap*> icons = get_extruder_color_icons();
|
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons();
|
||||||
if (icons.empty())
|
if (icons.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -264,9 +264,6 @@ void ExtruderSequenceDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||||||
{
|
{
|
||||||
SetFont(wxGetApp().normal_font());
|
SetFont(wxGetApp().normal_font());
|
||||||
|
|
||||||
m_bmp_add.msw_rescale();
|
|
||||||
m_bmp_del.msw_rescale();
|
|
||||||
|
|
||||||
const int em = em_unit();
|
const int em = em_unit();
|
||||||
|
|
||||||
m_intervals_grid_sizer->SetHGap(em);
|
m_intervals_grid_sizer->SetHGap(em);
|
||||||
|
@ -107,9 +107,9 @@ public:
|
|||||||
|
|
||||||
// ui items used for revert line value
|
// ui items used for revert line value
|
||||||
bool has_undo_ui() const { return m_undo_ui.undo_bitmap != nullptr; }
|
bool has_undo_ui() const { return m_undo_ui.undo_bitmap != nullptr; }
|
||||||
const wxBitmap& undo_bitmap() const { return m_undo_ui.undo_bitmap->bmp(); }
|
const wxBitmapBundle& undo_bitmap() const { return m_undo_ui.undo_bitmap->bmp(); }
|
||||||
const wxString* undo_tooltip() const { return m_undo_ui.undo_tooltip; }
|
const wxString* undo_tooltip() const { return m_undo_ui.undo_tooltip; }
|
||||||
const wxBitmap& undo_to_sys_bitmap() const { return m_undo_ui.undo_to_sys_bitmap->bmp(); }
|
const wxBitmapBundle& undo_to_sys_bitmap() const { return m_undo_ui.undo_to_sys_bitmap->bmp(); }
|
||||||
const wxString* undo_to_sys_tooltip() const { return m_undo_ui.undo_to_sys_tooltip; }
|
const wxString* undo_to_sys_tooltip() const { return m_undo_ui.undo_to_sys_tooltip; }
|
||||||
const wxColour* label_color() const { return m_undo_ui.label_color; }
|
const wxColour* label_color() const { return m_undo_ui.label_color; }
|
||||||
const bool blink() const { return m_undo_ui.blink; }
|
const bool blink() const { return m_undo_ui.blink; }
|
||||||
|
@ -331,7 +331,7 @@ private:
|
|||||||
// See https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/font.cpp
|
// See https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/font.cpp
|
||||||
// void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
|
// void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
|
||||||
wxNativeFontInfo nfi= *font.GetNativeFontInfo();
|
wxNativeFontInfo nfi= *font.GetNativeFontInfo();
|
||||||
float pointSizeNew = scale * font.GetPointSize();
|
float pointSizeNew = wxDisplay(this).GetScaleFactor() * scale * font.GetPointSize();
|
||||||
nfi.lf.lfHeight = nfi.GetLogFontHeightAtPPI(pointSizeNew, get_dpi_for_window(this));
|
nfi.lf.lfHeight = nfi.GetLogFontHeightAtPPI(pointSizeNew, get_dpi_for_window(this));
|
||||||
nfi.pointSize = pointSizeNew;
|
nfi.pointSize = pointSizeNew;
|
||||||
font = wxFont(nfi);
|
font = wxFont(nfi);
|
||||||
@ -1188,7 +1188,7 @@ bool GUI_App::on_init_inner()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create splash screen with updated bmp
|
// create splash screen with updated bmp
|
||||||
scrn = new SplashScreen(bmp.IsOk() ? bmp : create_scaled_bitmap("PrusaSlicer", nullptr, 400),
|
scrn = new SplashScreen(bmp.IsOk() ? bmp : get_bmp_bundle("PrusaSlicer", 400)->GetPreferredBitmapSizeAtScale(1.0),
|
||||||
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, splashscreen_pos);
|
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, splashscreen_pos);
|
||||||
|
|
||||||
if (!default_splashscreen_pos)
|
if (!default_splashscreen_pos)
|
||||||
|
@ -142,19 +142,11 @@ std::map<std::string, std::string> SettingsFactory::CATEGORY_ICON =
|
|||||||
{ L("Hollowing") , "hollowing" }
|
{ L("Hollowing") , "hollowing" }
|
||||||
};
|
};
|
||||||
|
|
||||||
//wxBitmap SettingsFactory::get_category_bitmap(const std::string& category_name, bool menu_bmp /*= true*/)
|
wxBitmapBundle* SettingsFactory::get_category_bitmap(const std::string& category_name)
|
||||||
wxBitmap SettingsFactory::get_category_bitmap_(const std::string& category_name, bool menu_bmp /*= true*/)
|
|
||||||
{
|
{
|
||||||
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
|
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
|
||||||
return wxNullBitmap;
|
return get_bmp_bundle("empty");
|
||||||
return /*menu_bmp ? create_menu_bitmap(CATEGORY_ICON.at(category_name)) : */create_scaled_bitmap(CATEGORY_ICON.at(category_name));
|
return get_bmp_bundle(CATEGORY_ICON.at(category_name));
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmapBundle SettingsFactory::get_category_bitmap(const std::string& category_name)
|
|
||||||
{
|
|
||||||
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
|
|
||||||
return wxNullBitmap;
|
|
||||||
return create_menu_bitmap(CATEGORY_ICON.at(category_name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
@ -437,13 +429,12 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<wxBitmap> MenuFactory::get_volume_bitmaps()
|
std::vector<wxBitmapBundle*> MenuFactory::get_volume_bitmaps()
|
||||||
{
|
{
|
||||||
std::vector<wxBitmap> volume_bmps;
|
std::vector<wxBitmapBundle*> volume_bmps;
|
||||||
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
|
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
|
||||||
for (auto item : ADD_VOLUME_MENU_ITEMS)
|
for (auto item : ADD_VOLUME_MENU_ITEMS)
|
||||||
// volume_bmps.push_back(create_menu_bitmap(item.second));
|
volume_bmps.push_back(get_bmp_bundle(item.second));
|
||||||
volume_bmps.push_back(create_scaled_bitmap(item.second, nullptr, 16, false, "", true));
|
|
||||||
return volume_bmps;
|
return volume_bmps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +614,7 @@ wxMenuItem* MenuFactory::append_menu_item_settings(wxMenu* menu_)
|
|||||||
|
|
||||||
// Add full settings list
|
// Add full settings list
|
||||||
auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name);
|
auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name);
|
||||||
menu_item->SetBitmap(create_menu_bitmap("cog"));
|
menu_item->SetBitmap(*get_bmp_bundle("cog"));
|
||||||
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_object_settings, item));
|
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_object_settings, item));
|
||||||
|
|
||||||
return menu->Append(menu_item);
|
return menu->Append(menu_item);
|
||||||
@ -768,7 +759,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
|
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
|
||||||
wxMenu* extruder_selection_menu = new wxMenu();
|
wxMenu* extruder_selection_menu = new wxMenu();
|
||||||
const wxString& name = sels.Count() == 1 ? names[0] : names[1];
|
const wxString& name = sels.Count() == 1 ? names[0] : names[1];
|
||||||
|
|
||||||
@ -787,7 +778,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
|
|||||||
(is_active_extruder ? " (" + _L("active") + ")" : "");
|
(is_active_extruder ? " (" + _L("active") + ")" : "");
|
||||||
|
|
||||||
append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
|
append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
|
||||||
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, *icons[icon_idx], menu,
|
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, icons[icon_idx], menu,
|
||||||
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
|
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1147,12 +1138,6 @@ void MenuFactory::update_default_menu()
|
|||||||
create_default_menu();
|
create_default_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuFactory::msw_rescale()
|
|
||||||
{
|
|
||||||
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu })
|
|
||||||
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// For this class is used code from stackoverflow:
|
// For this class is used code from stackoverflow:
|
||||||
// https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-template-to-check-for-a-functions-existence
|
// https://stackoverflow.com/questions/257288/is-it-possible-to-write-a-template-to-check-for-a-functions-existence
|
||||||
@ -1182,7 +1167,7 @@ static void update_menu_item_def_colors(T* item)
|
|||||||
void MenuFactory::sys_color_changed()
|
void MenuFactory::sys_color_changed()
|
||||||
{
|
{
|
||||||
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu }) {
|
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu }) {
|
||||||
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
|
sys_color_changed_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// but under MSW we have to update item's bachground color
|
// but under MSW we have to update item's bachground color
|
||||||
for (wxMenuItem* item : menu->GetMenuItems())
|
for (wxMenuItem* item : menu->GetMenuItems())
|
||||||
@ -1195,14 +1180,17 @@ void MenuFactory::sys_color_changed(wxMenuBar* menubar)
|
|||||||
{
|
{
|
||||||
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
|
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
|
||||||
wxMenu* menu = menubar->GetMenu(id);
|
wxMenu* menu = menubar->GetMenu(id);
|
||||||
msw_rescale_menu(menu);
|
sys_color_changed_menu(menu);
|
||||||
|
#ifndef __linux__
|
||||||
|
menu->SetupBitmaps();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// but under MSW we have to update item's bachground color
|
// but under MSW we have to update item's bachground color
|
||||||
for (wxMenuItem* item : menu->GetMenuItems())
|
for (wxMenuItem* item : menu->GetMenuItems())
|
||||||
update_menu_item_def_colors(item);
|
update_menu_item_def_colors(item);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
menubar->Refresh();
|
// menubar->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,9 +25,7 @@ struct SettingsFactory
|
|||||||
typedef std::map<std::string, std::vector<std::string>> Bundle;
|
typedef std::map<std::string, std::vector<std::string>> Bundle;
|
||||||
static std::map<std::string, std::string> CATEGORY_ICON;
|
static std::map<std::string, std::string> CATEGORY_ICON;
|
||||||
|
|
||||||
// static wxBitmap get_category_bitmap(const std::string& category_name, bool menu_bmp = true);
|
static wxBitmapBundle* get_category_bitmap(const std::string& category_name);
|
||||||
static wxBitmap get_category_bitmap_(const std::string& category_name, bool menu_bmp = true);
|
|
||||||
static wxBitmapBundle get_category_bitmap(const std::string& category_name);
|
|
||||||
static Bundle get_bundle(const DynamicPrintConfig* config, bool is_object_settings);
|
static Bundle get_bundle(const DynamicPrintConfig* config, bool is_object_settings);
|
||||||
static std::vector<std::string> get_options(bool is_part);
|
static std::vector<std::string> get_options(bool is_part);
|
||||||
};
|
};
|
||||||
@ -36,7 +34,7 @@ class MenuFactory
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const std::vector<std::pair<std::string, std::string>> ADD_VOLUME_MENU_ITEMS;
|
static const std::vector<std::pair<std::string, std::string>> ADD_VOLUME_MENU_ITEMS;
|
||||||
static std::vector<wxBitmap> get_volume_bitmaps();
|
static std::vector<wxBitmapBundle*> get_volume_bitmaps();
|
||||||
|
|
||||||
MenuFactory();
|
MenuFactory();
|
||||||
~MenuFactory() = default;
|
~MenuFactory() = default;
|
||||||
@ -45,7 +43,6 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
void update_object_menu();
|
void update_object_menu();
|
||||||
void update_default_menu();
|
void update_default_menu();
|
||||||
void msw_rescale();
|
|
||||||
void sys_color_changed();
|
void sys_color_changed();
|
||||||
|
|
||||||
static void sys_color_changed(wxMenuBar* menu_bar);
|
static void sys_color_changed(wxMenuBar* menu_bar);
|
||||||
|
@ -234,47 +234,47 @@ void ObjectLayers::UpdateAndShow(const bool show)
|
|||||||
|
|
||||||
void ObjectLayers::msw_rescale()
|
void ObjectLayers::msw_rescale()
|
||||||
{
|
{
|
||||||
m_bmp_delete.msw_rescale();
|
//m_bmp_delete.msw_rescale();
|
||||||
m_bmp_add.msw_rescale();
|
//m_bmp_add.msw_rescale();
|
||||||
|
|
||||||
m_grid_sizer->SetHGap(wxGetApp().em_unit());
|
//m_grid_sizer->SetHGap(wxGetApp().em_unit());
|
||||||
|
|
||||||
// rescale edit-boxes
|
//// rescale edit-boxes
|
||||||
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
|
//const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
|
||||||
for (int i = 0; i < cells_cnt; ++i) {
|
//for (int i = 0; i < cells_cnt; ++i) {
|
||||||
const wxSizerItem* item = m_grid_sizer->GetItem(i);
|
// const wxSizerItem* item = m_grid_sizer->GetItem(i);
|
||||||
if (item->IsWindow()) {
|
// if (item->IsWindow()) {
|
||||||
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(item->GetWindow());
|
// LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(item->GetWindow());
|
||||||
if (editor != nullptr)
|
// if (editor != nullptr)
|
||||||
editor->msw_rescale();
|
// editor->msw_rescale();
|
||||||
}
|
// }
|
||||||
else if (item->IsSizer()) // case when we have editor with buttons
|
// else if (item->IsSizer()) // case when we have editor with buttons
|
||||||
{
|
// {
|
||||||
wxSizerItem* e_item = item->GetSizer()->GetItem(size_t(0)); // editor
|
// wxSizerItem* e_item = item->GetSizer()->GetItem(size_t(0)); // editor
|
||||||
if (e_item->IsWindow()) {
|
// if (e_item->IsWindow()) {
|
||||||
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(e_item->GetWindow());
|
// LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(e_item->GetWindow());
|
||||||
if (editor != nullptr)
|
// if (editor != nullptr)
|
||||||
editor->msw_rescale();
|
// editor->msw_rescale();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (item->GetSizer()->GetItemCount() > 2) // if there are Add/Del buttons
|
// if (item->GetSizer()->GetItemCount() > 2) // if there are Add/Del buttons
|
||||||
for (size_t btn : {2, 3}) { // del_btn, add_btn
|
// for (size_t btn : {2, 3}) { // del_btn, add_btn
|
||||||
wxSizerItem* b_item = item->GetSizer()->GetItem(btn);
|
// wxSizerItem* b_item = item->GetSizer()->GetItem(btn);
|
||||||
if (b_item->IsWindow()) {
|
// if (b_item->IsWindow()) {
|
||||||
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
|
// auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
|
||||||
if (button != nullptr)
|
// if (button != nullptr)
|
||||||
button->msw_rescale();
|
// button->msw_rescale();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
m_grid_sizer->Layout();
|
m_grid_sizer->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectLayers::sys_color_changed()
|
void ObjectLayers::sys_color_changed()
|
||||||
{
|
{
|
||||||
m_bmp_delete.msw_rescale();
|
m_bmp_delete.sys_color_changed();
|
||||||
m_bmp_add.msw_rescale();
|
m_bmp_add.sys_color_changed();
|
||||||
|
|
||||||
// rescale edit-boxes
|
// rescale edit-boxes
|
||||||
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
|
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
|
||||||
@ -286,7 +286,7 @@ void ObjectLayers::sys_color_changed()
|
|||||||
if (b_item->IsWindow()) {
|
if (b_item->IsWindow()) {
|
||||||
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
|
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
|
||||||
if (button != nullptr)
|
if (button != nullptr)
|
||||||
button->msw_rescale();
|
button->sys_color_changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4239,9 +4239,6 @@ void ObjectList::msw_rescale()
|
|||||||
GetColumn(colExtruder)->SetWidth( 8 * em);
|
GetColumn(colExtruder)->SetWidth( 8 * em);
|
||||||
GetColumn(colEditing )->SetWidth( 3 * em);
|
GetColumn(colEditing )->SetWidth( 3 * em);
|
||||||
|
|
||||||
// rescale/update existing items with bitmaps
|
|
||||||
m_objects_model->Rescale();
|
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4249,7 +4246,10 @@ void ObjectList::sys_color_changed()
|
|||||||
{
|
{
|
||||||
wxGetApp().UpdateDVCDarkUI(this, true);
|
wxGetApp().UpdateDVCDarkUI(this, true);
|
||||||
|
|
||||||
msw_rescale();
|
// update existing items with bitmaps
|
||||||
|
m_objects_model->UpdateBitmaps();
|
||||||
|
|
||||||
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::ItemValueChanged(wxDataViewEvent &event)
|
void ObjectList::ItemValueChanged(wxDataViewEvent &event)
|
||||||
|
@ -126,7 +126,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
|||||||
// Load bitmaps to be used for the mirroring buttons:
|
// Load bitmaps to be used for the mirroring buttons:
|
||||||
m_mirror_bitmap_on = ScalableBitmap(parent, "mirroring_on");
|
m_mirror_bitmap_on = ScalableBitmap(parent, "mirroring_on");
|
||||||
m_mirror_bitmap_off = ScalableBitmap(parent, "mirroring_off");
|
m_mirror_bitmap_off = ScalableBitmap(parent, "mirroring_off");
|
||||||
m_mirror_bitmap_hidden = ScalableBitmap(parent, "mirroring_transparent.png");
|
m_mirror_bitmap_hidden = ScalableBitmap(parent, "mirroring_transparent");
|
||||||
|
|
||||||
const int border = wxOSX ? 0 : 4;
|
const int border = wxOSX ? 0 : 4;
|
||||||
const int em = wxGetApp().em_unit();
|
const int em = wxGetApp().em_unit();
|
||||||
@ -1009,7 +1009,7 @@ void ObjectManipulation::update_warning_icon_state(const MeshErrorsInfo& warning
|
|||||||
m_manifold_warning_bmp = ScalableBitmap(m_parent, warning_icon_name);
|
m_manifold_warning_bmp = ScalableBitmap(m_parent, warning_icon_name);
|
||||||
const wxString& tooltip = warning.tooltip;
|
const wxString& tooltip = warning.tooltip;
|
||||||
m_fix_throught_netfab_bitmap->SetBitmap(tooltip.IsEmpty() ? wxNullBitmap : m_manifold_warning_bmp.bmp());
|
m_fix_throught_netfab_bitmap->SetBitmap(tooltip.IsEmpty() ? wxNullBitmap : m_manifold_warning_bmp.bmp());
|
||||||
m_fix_throught_netfab_bitmap->SetMinSize(tooltip.IsEmpty() ? wxSize(0,0) : m_manifold_warning_bmp.bmp().GetSize());
|
m_fix_throught_netfab_bitmap->SetMinSize(tooltip.IsEmpty() ? wxSize(0,0) : m_manifold_warning_bmp.GetSize());
|
||||||
m_fix_throught_netfab_bitmap->SetToolTip(tooltip);
|
m_fix_throught_netfab_bitmap->SetToolTip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1336,25 +1336,10 @@ void ObjectManipulation::msw_rescale()
|
|||||||
m_item_name->SetMinSize(wxSize(20*em, wxDefaultCoord));
|
m_item_name->SetMinSize(wxSize(20*em, wxDefaultCoord));
|
||||||
msw_rescale_word_local_combo(m_word_local_combo);
|
msw_rescale_word_local_combo(m_word_local_combo);
|
||||||
m_word_local_combo_sizer->SetMinSize(wxSize(-1, m_word_local_combo->GetBestHeight(-1)));
|
m_word_local_combo_sizer->SetMinSize(wxSize(-1, m_word_local_combo->GetBestHeight(-1)));
|
||||||
m_manifold_warning_bmp.msw_rescale();
|
|
||||||
|
|
||||||
const wxString& tooltip = m_fix_throught_netfab_bitmap->GetToolTipText();
|
const wxString& tooltip = m_fix_throught_netfab_bitmap->GetToolTipText();
|
||||||
m_fix_throught_netfab_bitmap->SetBitmap(tooltip.IsEmpty() ? wxNullBitmap : m_manifold_warning_bmp.bmp());
|
m_fix_throught_netfab_bitmap->SetBitmap(tooltip.IsEmpty() ? wxNullBitmap : m_manifold_warning_bmp.bmp());
|
||||||
m_fix_throught_netfab_bitmap->SetMinSize(tooltip.IsEmpty() ? wxSize(0, 0) : m_manifold_warning_bmp.bmp().GetSize());
|
m_fix_throught_netfab_bitmap->SetMinSize(tooltip.IsEmpty() ? wxSize(0, 0) : m_manifold_warning_bmp.GetSize());
|
||||||
|
|
||||||
m_mirror_bitmap_on.msw_rescale();
|
|
||||||
m_mirror_bitmap_off.msw_rescale();
|
|
||||||
m_mirror_bitmap_hidden.msw_rescale();
|
|
||||||
m_reset_scale_button->msw_rescale();
|
|
||||||
m_reset_rotation_button->msw_rescale();
|
|
||||||
#if ENABLE_WORLD_COORDINATE
|
|
||||||
m_reset_skew_button->msw_rescale();
|
|
||||||
#endif /// ENABLE_WORLD_COORDINATE
|
|
||||||
m_drop_to_bed_button->msw_rescale();
|
|
||||||
m_lock_bnt->msw_rescale();
|
|
||||||
|
|
||||||
for (int id = 0; id < 3; ++id)
|
|
||||||
m_mirror_buttons[id].first->msw_rescale();
|
|
||||||
|
|
||||||
// rescale label-heights
|
// rescale label-heights
|
||||||
// Text trick to grid sizer layout:
|
// Text trick to grid sizer layout:
|
||||||
@ -1383,20 +1368,16 @@ void ObjectManipulation::sys_color_changed()
|
|||||||
for (ManipulationEditor* editor : m_editors)
|
for (ManipulationEditor* editor : m_editors)
|
||||||
editor->sys_color_changed(this);
|
editor->sys_color_changed(this);
|
||||||
|
|
||||||
// btn...->msw_rescale() updates icon on button, so use it
|
m_mirror_bitmap_on.sys_color_changed();
|
||||||
m_mirror_bitmap_on.msw_rescale();
|
m_mirror_bitmap_off.sys_color_changed();
|
||||||
m_mirror_bitmap_off.msw_rescale();
|
m_mirror_bitmap_hidden.sys_color_changed();
|
||||||
m_mirror_bitmap_hidden.msw_rescale();
|
m_reset_scale_button->sys_color_changed();
|
||||||
m_reset_scale_button->msw_rescale();
|
m_reset_rotation_button->sys_color_changed();
|
||||||
m_reset_rotation_button->msw_rescale();
|
m_drop_to_bed_button->sys_color_changed();
|
||||||
#if ENABLE_WORLD_COORDINATE
|
m_lock_bnt->sys_color_changed();
|
||||||
m_reset_skew_button->msw_rescale();
|
|
||||||
#endif // ENABLE_WORLD_COORDINATE
|
|
||||||
m_drop_to_bed_button->msw_rescale();
|
|
||||||
m_lock_bnt->msw_rescale();
|
|
||||||
|
|
||||||
for (int id = 0; id < 3; ++id)
|
for (int id = 0; id < 3; ++id)
|
||||||
m_mirror_buttons[id].first->msw_rescale();
|
m_mirror_buttons[id].first->sys_color_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_WORLD_COORDINATE
|
#if ENABLE_WORLD_COORDINATE
|
||||||
|
@ -99,7 +99,7 @@ bool ObjectSettings::update_settings_list()
|
|||||||
btn->SetToolTip(_(L("Remove parameter")));
|
btn->SetToolTip(_(L("Remove parameter")));
|
||||||
|
|
||||||
btn->SetBitmapFocus(m_bmp_delete_focus.bmp());
|
btn->SetBitmapFocus(m_bmp_delete_focus.bmp());
|
||||||
btn->SetBitmapHover(m_bmp_delete_focus.bmp());
|
btn->SetBitmapCurrent(m_bmp_delete_focus.bmp());
|
||||||
|
|
||||||
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
|
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
|
||||||
wxGetApp().plater()->take_snapshot(from_u8((boost::format(_utf8(L("Delete Option %s"))) % opt_key).str()));
|
wxGetApp().plater()->take_snapshot(from_u8((boost::format(_utf8(L("Delete Option %s"))) % opt_key).str()));
|
||||||
@ -133,7 +133,7 @@ bool ObjectSettings::update_settings_list()
|
|||||||
return;
|
return;
|
||||||
ctrl->SetBitmap_(m_bmp_delete);
|
ctrl->SetBitmap_(m_bmp_delete);
|
||||||
ctrl->SetBitmapFocus(m_bmp_delete_focus.bmp());
|
ctrl->SetBitmapFocus(m_bmp_delete_focus.bmp());
|
||||||
ctrl->SetBitmapHover(m_bmp_delete_focus.bmp());
|
ctrl->SetBitmapCurrent(m_bmp_delete_focus.bmp());
|
||||||
};
|
};
|
||||||
|
|
||||||
const bool is_extruders_cat = cat.first == "Extruders";
|
const bool is_extruders_cat = cat.first == "Extruders";
|
||||||
@ -268,15 +268,6 @@ void ObjectSettings::UpdateAndShow(const bool show)
|
|||||||
OG_Settings::UpdateAndShow(show ? update_settings_list() : false);
|
OG_Settings::UpdateAndShow(show ? update_settings_list() : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectSettings::msw_rescale()
|
|
||||||
{
|
|
||||||
m_bmp_delete.msw_rescale();
|
|
||||||
m_bmp_delete_focus.msw_rescale();
|
|
||||||
|
|
||||||
for (auto group : m_og_settings)
|
|
||||||
group->msw_rescale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectSettings::sys_color_changed()
|
void ObjectSettings::sys_color_changed()
|
||||||
{
|
{
|
||||||
m_og->sys_color_changed();
|
m_og->sys_color_changed();
|
||||||
|
@ -56,7 +56,6 @@ public:
|
|||||||
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from);
|
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from);
|
||||||
void update_config_values(ModelConfig *config);
|
void update_config_values(ModelConfig *config);
|
||||||
void UpdateAndShow(const bool show) override;
|
void UpdateAndShow(const bool show) override;
|
||||||
void msw_rescale();
|
|
||||||
void sys_color_changed();
|
void sys_color_changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -157,8 +157,9 @@ bool GalleryDialog::can_change_thumbnail()
|
|||||||
|
|
||||||
void GalleryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
void GalleryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||||
{
|
{
|
||||||
const int& em = em_unit();
|
update();
|
||||||
|
|
||||||
|
const int& em = em_unit();
|
||||||
msw_buttons_rescale(this, em, { ID_BTN_ADD_CUSTOM_SHAPE, ID_BTN_DEL_CUSTOM_SHAPE, ID_BTN_REPLACE_CUSTOM_PNG, wxID_OK, wxID_CLOSE });
|
msw_buttons_rescale(this, em, { ID_BTN_ADD_CUSTOM_SHAPE, ID_BTN_DEL_CUSTOM_SHAPE, ID_BTN_REPLACE_CUSTOM_PNG, wxID_OK, wxID_CLOSE });
|
||||||
|
|
||||||
wxSize size = wxSize(50 * em, 35 * em);
|
wxSize size = wxSize(50 * em, 35 * em);
|
||||||
@ -169,13 +170,14 @@ void GalleryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_lock(wxImage& image)
|
static void add_lock(wxImage& image, wxWindow* parent_win)
|
||||||
{
|
{
|
||||||
int lock_sz = 22;
|
wxBitmapBundle* bmp_bndl = get_bmp_bundle("lock", 22);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
lock_sz /= mac_max_scaling_factor();
|
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetDefaultSize() * mac_max_scaling_factor());
|
||||||
|
#else
|
||||||
|
wxBitmap bmp = bmp_bndl->GetBitmapFor(parent_win);
|
||||||
#endif
|
#endif
|
||||||
wxBitmap bmp = create_scaled_bitmap("lock", nullptr, lock_sz);
|
|
||||||
|
|
||||||
wxImage lock_image = bmp.ConvertToImage();
|
wxImage lock_image = bmp.ConvertToImage();
|
||||||
if (!lock_image.IsOk() || lock_image.GetWidth() == 0 || lock_image.GetHeight() == 0)
|
if (!lock_image.IsOk() || lock_image.GetWidth() == 0 || lock_image.GetHeight() == 0)
|
||||||
@ -213,21 +215,28 @@ static void add_lock(wxImage& image)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_default_image(wxImageList* img_list, bool is_system)
|
static void add_default_image(wxImageList* img_list, bool is_system, wxWindow* parent_win)
|
||||||
{
|
{
|
||||||
int sz = IMG_PX_CNT;
|
wxBitmapBundle* bmp_bndl = get_bmp_bundle("cog", IMG_PX_CNT);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
sz /= mac_max_scaling_factor();
|
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetDefaultSize() * mac_max_scaling_factor());
|
||||||
|
#else
|
||||||
|
wxBitmap bmp = bmp_bndl->GetBitmapFor(parent_win);
|
||||||
#endif
|
#endif
|
||||||
wxBitmap bmp = create_scaled_bitmap("cog", nullptr, sz, true);
|
|
||||||
|
|
||||||
|
bmp = bmp.ConvertToDisabled();
|
||||||
if (is_system) {
|
if (is_system) {
|
||||||
wxImage image = bmp.ConvertToImage();
|
wxImage image = bmp.ConvertToImage();
|
||||||
if (image.IsOk() && image.GetWidth() != 0 && image.GetHeight() != 0) {
|
if (image.IsOk() && image.GetWidth() != 0 && image.GetHeight() != 0) {
|
||||||
add_lock(image);
|
add_lock(image, parent_win);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
bmp = wxBitmap(std::move(image), -1, mac_max_scaling_factor());
|
||||||
|
#else
|
||||||
bmp = wxBitmap(std::move(image));
|
bmp = wxBitmap(std::move(image));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
img_list->Add(bmp);
|
img_list->Add(bmp);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -344,8 +353,13 @@ void GalleryDialog::load_label_icon_list()
|
|||||||
|
|
||||||
// Make an image list containing large icons
|
// Make an image list containing large icons
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
m_image_list = new wxImageList(IMG_PX_CNT, IMG_PX_CNT);
|
||||||
|
int px_cnt = IMG_PX_CNT * mac_max_scaling_factor();
|
||||||
|
#else
|
||||||
int px_cnt = (int)(em_unit() * IMG_PX_CNT * 0.1f + 0.5f);
|
int px_cnt = (int)(em_unit() * IMG_PX_CNT * 0.1f + 0.5f);
|
||||||
m_image_list = new wxImageList(px_cnt, px_cnt);
|
m_image_list = new wxImageList(px_cnt, px_cnt);
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string ext = ".png";
|
std::string ext = ".png";
|
||||||
|
|
||||||
@ -364,7 +378,7 @@ void GalleryDialog::load_label_icon_list()
|
|||||||
if (can_generate_thumbnail)
|
if (can_generate_thumbnail)
|
||||||
generate_thumbnail_from_model(model_name);
|
generate_thumbnail_from_model(model_name);
|
||||||
else {
|
else {
|
||||||
add_default_image(m_image_list, item.is_system);
|
add_default_image(m_image_list, item.is_system, this);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -373,14 +387,18 @@ void GalleryDialog::load_label_icon_list()
|
|||||||
if (!image.CanRead(from_u8(img_name)) ||
|
if (!image.CanRead(from_u8(img_name)) ||
|
||||||
!image.LoadFile(from_u8(img_name), wxBITMAP_TYPE_PNG) ||
|
!image.LoadFile(from_u8(img_name), wxBITMAP_TYPE_PNG) ||
|
||||||
image.GetWidth() == 0 || image.GetHeight() == 0) {
|
image.GetWidth() == 0 || image.GetHeight() == 0) {
|
||||||
add_default_image(m_image_list, item.is_system);
|
add_default_image(m_image_list, item.is_system, this);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
image.Rescale(px_cnt, px_cnt, wxIMAGE_QUALITY_BILINEAR);
|
image.Rescale(px_cnt, px_cnt, wxIMAGE_QUALITY_BILINEAR);
|
||||||
|
|
||||||
if (item.is_system)
|
if (item.is_system)
|
||||||
add_lock(image);
|
add_lock(image, this);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
wxBitmap bmp = wxBitmap(std::move(image), -1, mac_max_scaling_factor());
|
||||||
|
#else
|
||||||
wxBitmap bmp = wxBitmap(std::move(image));
|
wxBitmap bmp = wxBitmap(std::move(image));
|
||||||
|
#endif
|
||||||
m_image_list->Add(bmp);
|
m_image_list->Add(bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,9 +266,7 @@ wxPanel* KBShortcutsDialog::create_header(wxWindow* parent, const wxFont& bold_f
|
|||||||
sizer->AddStretchSpacer();
|
sizer->AddStretchSpacer();
|
||||||
|
|
||||||
// logo
|
// logo
|
||||||
//m_logo_bmp = ScalableBitmap(this, wxGetApp().logo_name(), 32);
|
m_header_bitmap = new wxStaticBitmap(panel, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 32));
|
||||||
//m_header_bitmap = new wxStaticBitmap(panel, wxID_ANY, m_logo_bmp.bmp());
|
|
||||||
m_header_bitmap = new wxStaticBitmap(panel, wxID_ANY, wxBitmapBundle::FromSVGFile(Slic3r::var(wxGetApp().logo_name() + ".svg"), wxSize(32, 32)));
|
|
||||||
|
|
||||||
sizer->Add(m_header_bitmap, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
sizer->Add(m_header_bitmap, 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
|
||||||
|
|
||||||
|
@ -1014,9 +1014,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
|
|||||||
for (auto tab : wxGetApp().tabs_list)
|
for (auto tab : wxGetApp().tabs_list)
|
||||||
tab->msw_rescale();
|
tab->msw_rescale();
|
||||||
|
|
||||||
for (size_t id = 0; id < m_menubar->GetMenuCount(); id++)
|
|
||||||
msw_rescale_menu(m_menubar->GetMenu(id));
|
|
||||||
|
|
||||||
// Workarounds for correct Window rendering after rescale
|
// Workarounds for correct Window rendering after rescale
|
||||||
|
|
||||||
/* Even if Window is maximized during moving,
|
/* Even if Window is maximized during moving,
|
||||||
@ -1051,7 +1048,7 @@ void MainFrame::on_sys_color_changed()
|
|||||||
#ifdef _MSW_DARK_MODE
|
#ifdef _MSW_DARK_MODE
|
||||||
// update common mode sizer
|
// update common mode sizer
|
||||||
if (!wxGetApp().tabs_as_menu())
|
if (!wxGetApp().tabs_as_menu())
|
||||||
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
|
dynamic_cast<Notebook*>(m_tabpanel)->OnColorsChanged();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1612,9 +1609,9 @@ void MainFrame::update_menubar()
|
|||||||
m_changeable_menu_items[miSend] ->SetItemLabel((is_fff ? _L("S&end G-code") : _L("S&end to print")) + dots + "\tCtrl+Shift+G");
|
m_changeable_menu_items[miSend] ->SetItemLabel((is_fff ? _L("S&end G-code") : _L("S&end to print")) + dots + "\tCtrl+Shift+G");
|
||||||
|
|
||||||
m_changeable_menu_items[miMaterialTab] ->SetItemLabel((is_fff ? _L("&Filament Settings Tab") : _L("Mate&rial Settings Tab")) + "\tCtrl+3");
|
m_changeable_menu_items[miMaterialTab] ->SetItemLabel((is_fff ? _L("&Filament Settings Tab") : _L("Mate&rial Settings Tab")) + "\tCtrl+3");
|
||||||
m_changeable_menu_items[miMaterialTab] ->SetBitmap(create_menu_bitmap(is_fff ? "spool" : "resin"));
|
m_changeable_menu_items[miMaterialTab] ->SetBitmap(*get_bmp_bundle(is_fff ? "spool" : "resin"));
|
||||||
|
|
||||||
m_changeable_menu_items[miPrinterTab] ->SetBitmap(create_menu_bitmap(is_fff ? "printer" : "sla_printer"));
|
m_changeable_menu_items[miPrinterTab] ->SetBitmap(*get_bmp_bundle(is_fff ? "printer" : "sla_printer"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -99,17 +99,10 @@ void MsgDialog::apply_style(long style)
|
|||||||
if (style & wxNO) add_button(wxID_NO, (style & wxNO_DEFAULT));
|
if (style & wxNO) add_button(wxID_NO, (style & wxNO_DEFAULT));
|
||||||
if (style & wxCANCEL) add_button(wxID_CANCEL, (style & wxCANCEL_DEFAULT));
|
if (style & wxCANCEL) add_button(wxID_CANCEL, (style & wxCANCEL_DEFAULT));
|
||||||
|
|
||||||
#if 0
|
|
||||||
logo->SetBitmap( create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" :
|
|
||||||
style & wxICON_INFORMATION ? "info" :
|
|
||||||
style & wxICON_QUESTION ? "question" : "PrusaSlicer", this, 64, style & wxICON_ERROR));
|
|
||||||
#else
|
|
||||||
std::string icon_name = style & wxICON_WARNING ? "exclamation" :
|
std::string icon_name = style & wxICON_WARNING ? "exclamation" :
|
||||||
style & wxICON_INFORMATION ? "info" :
|
style & wxICON_INFORMATION ? "info" :
|
||||||
style & wxICON_QUESTION ? "question" : "PrusaSlicer";
|
style & wxICON_QUESTION ? "question" : "PrusaSlicer";
|
||||||
icon_name += ".svg";
|
logo->SetBitmap(*get_bmp_bundle(icon_name, 64));
|
||||||
logo->SetBitmap(wxBitmapBundle::FromSVGFile(Slic3r::var(icon_name), wxSize(64, 64)));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MsgDialog::finalize()
|
void MsgDialog::finalize()
|
||||||
@ -238,7 +231,7 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_
|
|||||||
add_msg_content(this, content_sizer, msg, monospaced_font);
|
add_msg_content(this, content_sizer, msg, monospaced_font);
|
||||||
|
|
||||||
// Use a small bitmap with monospaced font, as the error text will not be wrapped.
|
// Use a small bitmap with monospaced font, as the error text will not be wrapped.
|
||||||
logo->SetBitmap(create_scaled_bitmap("PrusaSlicer_192px_grayscale.png", this, monospaced_font ? 48 : /*1*/84));
|
logo->SetBitmap(*get_bmp_bundle("PrusaSlicer_192px_grayscale.png", monospaced_font ? 48 : /*1*/84));
|
||||||
|
|
||||||
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));
|
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));
|
||||||
|
|
||||||
|
@ -95,10 +95,6 @@ void ButtonsListCtrl::UpdateMode()
|
|||||||
|
|
||||||
void ButtonsListCtrl::Rescale()
|
void ButtonsListCtrl::Rescale()
|
||||||
{
|
{
|
||||||
m_mode_sizer->msw_rescale();
|
|
||||||
for (ScalableButton* btn : m_pageButtons)
|
|
||||||
btn->msw_rescale();
|
|
||||||
|
|
||||||
int em = em_unit(this);
|
int em = em_unit(this);
|
||||||
m_btn_margin = std::lround(0.3 * em);
|
m_btn_margin = std::lround(0.3 * em);
|
||||||
m_line_margin = std::lround(0.1 * em);
|
m_line_margin = std::lround(0.1 * em);
|
||||||
@ -108,6 +104,14 @@ void ButtonsListCtrl::Rescale()
|
|||||||
m_sizer->Layout();
|
m_sizer->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ButtonsListCtrl::OnColorsChanged()
|
||||||
|
{
|
||||||
|
for (ScalableButton* btn : m_pageButtons)
|
||||||
|
btn->sys_color_changed();
|
||||||
|
|
||||||
|
m_sizer->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
void ButtonsListCtrl::SetSelection(int sel)
|
void ButtonsListCtrl::SetSelection(int sel)
|
||||||
{
|
{
|
||||||
if (m_selection == sel)
|
if (m_selection == sel)
|
||||||
|
@ -21,6 +21,7 @@ public:
|
|||||||
void SetSelection(int sel);
|
void SetSelection(int sel);
|
||||||
void UpdateMode();
|
void UpdateMode();
|
||||||
void Rescale();
|
void Rescale();
|
||||||
|
void OnColorsChanged();
|
||||||
bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = "");
|
bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = "");
|
||||||
void RemovePage(size_t n);
|
void RemovePage(size_t n);
|
||||||
bool SetPageImage(size_t n, const std::string& bmp_name) const;
|
bool SetPageImage(size_t n, const std::string& bmp_name) const;
|
||||||
@ -245,6 +246,11 @@ public:
|
|||||||
GetBtnsListCtrl()->Rescale();
|
GetBtnsListCtrl()->Rescale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnColorsChanged()
|
||||||
|
{
|
||||||
|
GetBtnsListCtrl()->OnColorsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void OnNavigationKey(wxNavigationKeyEvent& event)
|
void OnNavigationKey(wxNavigationKeyEvent& event)
|
||||||
{
|
{
|
||||||
if (event.IsWindowChange()) {
|
if (event.IsWindowChange()) {
|
||||||
|
@ -19,12 +19,12 @@ static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect)
|
|||||||
rect.GetTop() <= pt.y && pt.y <= rect.GetBottom();
|
rect.GetTop() <= pt.y && pt.y <= rect.GetBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
static wxSize get_bitmap_size(const wxBitmap& bmp)
|
static wxSize get_bitmap_size(const wxBitmapBundle* bmp, wxWindow* parent)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
return bmp.GetScaledSize();
|
return bmp->GetDefaultSize();
|
||||||
#else
|
#else
|
||||||
return bmp.GetSize();
|
return bmp->GetBitmapFor(parent).GetSize();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
|
|||||||
m_v_gap = lround(1.0 * m_em_unit);
|
m_v_gap = lround(1.0 * m_em_unit);
|
||||||
m_h_gap = lround(0.2 * m_em_unit);
|
m_h_gap = lround(0.2 * m_em_unit);
|
||||||
|
|
||||||
m_bmp_mode_sz = get_bitmap_size(create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12));
|
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
|
||||||
m_bmp_blinking_sz = get_bitmap_size(create_scaled_bitmap("search_blink", this));
|
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("search_blink"), this);
|
||||||
|
|
||||||
init_ctrl_lines();// from og.lines()
|
init_ctrl_lines();// from og.lines()
|
||||||
|
|
||||||
@ -416,8 +416,8 @@ void OG_CustomCtrl::msw_rescale()
|
|||||||
m_v_gap = lround(1.0 * m_em_unit);
|
m_v_gap = lround(1.0 * m_em_unit);
|
||||||
m_h_gap = lround(0.2 * m_em_unit);
|
m_h_gap = lround(0.2 * m_em_unit);
|
||||||
|
|
||||||
m_bmp_mode_sz = create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12).GetSize();
|
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
|
||||||
m_bmp_blinking_sz = create_scaled_bitmap("search_blink", this).GetSize();
|
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("search_blink"), this);
|
||||||
|
|
||||||
m_max_win_width = 0;
|
m_max_win_width = 0;
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ void OG_CustomCtrl::CtrlLine::msw_rescale()
|
|||||||
{
|
{
|
||||||
// if we have a single option with no label, no sidetext
|
// if we have a single option with no label, no sidetext
|
||||||
if (draw_just_act_buttons)
|
if (draw_just_act_buttons)
|
||||||
height = get_bitmap_size(create_scaled_bitmap("empty")).GetHeight();
|
height = get_bitmap_size(get_bmp_bundle("empty"), ctrl).GetHeight();
|
||||||
|
|
||||||
if (ctrl->opt_group->label_width != 0 && !og_line.label.IsEmpty()) {
|
if (ctrl->opt_group->label_width != 0 && !og_line.label.IsEmpty()) {
|
||||||
wxSize label_sz = ctrl->GetTextExtent(og_line.label);
|
wxSize label_sz = ctrl->GetTextExtent(og_line.label);
|
||||||
@ -666,13 +666,13 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_mode_bmp(wxDC& dc, wxCoord v_pos)
|
|||||||
ConfigOptionMode mode = og_line.get_options()[0].opt.mode;
|
ConfigOptionMode mode = og_line.get_options()[0].opt.mode;
|
||||||
const std::string& bmp_name = mode == ConfigOptionMode::comSimple ? "mode_simple" :
|
const std::string& bmp_name = mode == ConfigOptionMode::comSimple ? "mode_simple" :
|
||||||
mode == ConfigOptionMode::comAdvanced ? "mode_advanced" : "mode_expert";
|
mode == ConfigOptionMode::comAdvanced ? "mode_advanced" : "mode_expert";
|
||||||
wxBitmap bmp = create_scaled_bitmap(bmp_name, ctrl, wxOSX ? 10 : 12);
|
wxBitmapBundle* bmp = get_bmp_bundle(bmp_name, wxOSX ? 10 : 12);
|
||||||
wxCoord y_draw = v_pos + lround((height - get_bitmap_size(bmp).GetHeight()) / 2);
|
wxCoord y_draw = v_pos + lround((height - get_bitmap_size(bmp, ctrl).GetHeight()) / 2);
|
||||||
|
|
||||||
if (og_line.get_options().front().opt.gui_type != ConfigOptionDef::GUIType::legend)
|
if (og_line.get_options().front().opt.gui_type != ConfigOptionDef::GUIType::legend)
|
||||||
dc.DrawBitmap(bmp, 0, y_draw);
|
dc.DrawBitmap(bmp->GetBitmapFor(ctrl), 0, y_draw);
|
||||||
|
|
||||||
return get_bitmap_size(bmp).GetWidth() + ctrl->m_h_gap;
|
return get_bitmap_size(bmp, ctrl).GetWidth() + ctrl->m_h_gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url/* = false*/)
|
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url/* = false*/)
|
||||||
@ -734,33 +734,33 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxStr
|
|||||||
|
|
||||||
wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking)
|
wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking)
|
||||||
{
|
{
|
||||||
wxBitmap bmp_blinking = create_scaled_bitmap(is_blinking ? "search_blink" : "empty", ctrl);
|
wxBitmapBundle* bmp_blinking = get_bmp_bundle(is_blinking ? "search_blink" : "empty");
|
||||||
wxCoord h_pos = pos.x;
|
wxCoord h_pos = pos.x;
|
||||||
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking).GetHeight()) / 2);
|
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking, ctrl).GetHeight()) / 2);
|
||||||
|
|
||||||
dc.DrawBitmap(bmp_blinking, h_pos, v_pos);
|
dc.DrawBitmap(bmp_blinking->GetBitmapFor(ctrl), h_pos, v_pos);
|
||||||
|
|
||||||
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
|
int bmp_dim = get_bitmap_size(bmp_blinking, ctrl).GetWidth();
|
||||||
|
|
||||||
h_pos += bmp_dim + ctrl->m_h_gap;
|
h_pos += bmp_dim + ctrl->m_h_gap;
|
||||||
return wxPoint(h_pos, v_pos);
|
return wxPoint(h_pos, v_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id)
|
wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmapBundle& bmp_undo_to_sys, const wxBitmapBundle& bmp_undo, bool is_blinking, size_t rect_id)
|
||||||
{
|
{
|
||||||
pos = draw_blinking_bmp(dc, pos, is_blinking);
|
pos = draw_blinking_bmp(dc, pos, is_blinking);
|
||||||
wxCoord h_pos = pos.x;
|
wxCoord h_pos = pos.x;
|
||||||
wxCoord v_pos = pos.y;
|
wxCoord v_pos = pos.y;
|
||||||
|
|
||||||
dc.DrawBitmap(bmp_undo_to_sys, h_pos, v_pos);
|
dc.DrawBitmap(bmp_undo_to_sys.GetBitmapFor(ctrl), h_pos, v_pos);
|
||||||
|
|
||||||
int bmp_dim = get_bitmap_size(bmp_undo_to_sys).GetWidth();
|
int bmp_dim = get_bitmap_size(&bmp_undo_to_sys, ctrl).GetWidth();
|
||||||
rects_undo_to_sys_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
|
rects_undo_to_sys_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
|
||||||
|
|
||||||
h_pos += bmp_dim + ctrl->m_h_gap;
|
h_pos += bmp_dim + ctrl->m_h_gap;
|
||||||
dc.DrawBitmap(bmp_undo, h_pos, v_pos);
|
dc.DrawBitmap(bmp_undo.GetBitmapFor(ctrl), h_pos, v_pos);
|
||||||
|
|
||||||
bmp_dim = get_bitmap_size(bmp_undo).GetWidth();
|
bmp_dim = get_bitmap_size(&bmp_undo, ctrl).GetWidth();
|
||||||
rects_undo_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
|
rects_undo_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
|
||||||
|
|
||||||
h_pos += bmp_dim + ctrl->m_h_gap;
|
h_pos += bmp_dim + ctrl->m_h_gap;
|
||||||
|
@ -63,7 +63,7 @@ class OG_CustomCtrl :public wxPanel
|
|||||||
wxCoord draw_mode_bmp(wxDC& dc, wxCoord v_pos);
|
wxCoord draw_mode_bmp(wxDC& dc, wxCoord v_pos);
|
||||||
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false);
|
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false);
|
||||||
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking);
|
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking);
|
||||||
wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0);
|
wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmapBundle& bmp_undo_to_sys, const wxBitmapBundle& bmp_undo, bool is_blinking, size_t rect_id = 0);
|
||||||
bool launch_browser() const;
|
bool launch_browser() const;
|
||||||
bool is_separator() const { return og_line.is_separator(); }
|
bool is_separator() const { return og_line.is_separator(); }
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ const std::map<InfoItemType, InfoItemAtributes> INFO_ITEMS{
|
|||||||
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||||
const wxString& sub_obj_name,
|
const wxString& sub_obj_name,
|
||||||
Slic3r::ModelVolumeType type,
|
Slic3r::ModelVolumeType type,
|
||||||
const wxBitmap& bmp,
|
const wxBitmapBundle& bmp,
|
||||||
const wxString& extruder,
|
const wxString& extruder,
|
||||||
const int idx/* = -1*/,
|
const int idx/* = -1*/,
|
||||||
const std::string& warning_icon_name /*= std::string*/) :
|
const std::string& warning_icon_name /*= std::string*/) :
|
||||||
@ -101,7 +101,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
|||||||
}
|
}
|
||||||
else if (type == itLayerRoot)
|
else if (type == itLayerRoot)
|
||||||
{
|
{
|
||||||
m_bmp = create_scaled_bitmap(LayerRootIcon); // FIXME: pass window ptr
|
m_bmp = *get_bmp_bundle(LayerRootIcon);
|
||||||
m_name = _(L("Layers"));
|
m_name = _(L("Layers"));
|
||||||
}
|
}
|
||||||
else if (type == itInfo)
|
else if (type == itInfo)
|
||||||
@ -132,7 +132,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
|||||||
}
|
}
|
||||||
const std::string label_range = (boost::format(" %.2f-%.2f ") % layer_range.first % layer_range.second).str();
|
const std::string label_range = (boost::format(" %.2f-%.2f ") % layer_range.first % layer_range.second).str();
|
||||||
m_name = _(L("Range")) + label_range + "(" + _(L("mm")) + ")";
|
m_name = _(L("Range")) + label_range + "(" + _(L("mm")) + ")";
|
||||||
m_bmp = create_scaled_bitmap(LayerIcon); // FIXME: pass window ptr
|
m_bmp = *get_bmp_bundle(LayerIcon);
|
||||||
|
|
||||||
set_action_and_extruder_icons();
|
set_action_and_extruder_icons();
|
||||||
init_container();
|
init_container();
|
||||||
@ -151,7 +151,7 @@ void ObjectDataViewModelNode::set_action_and_extruder_icons()
|
|||||||
{
|
{
|
||||||
m_action_icon_name = m_type & itObject ? "advanced_plus" :
|
m_action_icon_name = m_type & itObject ? "advanced_plus" :
|
||||||
m_type & (itVolume | itLayer) ? "cog" : /*m_type & itInstance*/ "set_separate_obj";
|
m_type & (itVolume | itLayer) ? "cog" : /*m_type & itInstance*/ "set_separate_obj";
|
||||||
m_action_icon = create_scaled_bitmap(m_action_icon_name); // FIXME: pass window ptr
|
m_action_icon = *get_bmp_bundle(m_action_icon_name);
|
||||||
|
|
||||||
// set extruder bitmap
|
// set extruder bitmap
|
||||||
set_extruder_icon();
|
set_extruder_icon();
|
||||||
@ -170,7 +170,7 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
|
|||||||
{
|
{
|
||||||
m_printable = printable;
|
m_printable = printable;
|
||||||
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
|
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
|
||||||
create_scaled_bitmap(m_printable == piPrintable ? "eye_open.png" : "eye_closed.png");
|
*get_bmp_bundle(m_printable == piPrintable ? "eye_open" : "eye_closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
|
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
|
||||||
@ -185,14 +185,14 @@ void ObjectDataViewModelNode::update_settings_digest_bitmaps()
|
|||||||
m_bmp = m_empty_bmp;
|
m_bmp = m_empty_bmp;
|
||||||
|
|
||||||
std::string scaled_bitmap_name = m_name.ToUTF8().data();
|
std::string scaled_bitmap_name = m_name.ToUTF8().data();
|
||||||
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "");
|
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "");
|
||||||
|
|
||||||
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
|
wxBitmapBundle *bmp = m_bitmap_cache->find_bndl(scaled_bitmap_name);
|
||||||
if (bmp == nullptr) {
|
if (bmp == nullptr) {
|
||||||
std::vector<wxBitmap> bmps;
|
std::vector<wxBitmapBundle*> bmps;
|
||||||
for (auto& category : m_opt_categories)
|
for (auto& category : m_opt_categories)
|
||||||
bmps.emplace_back(SettingsFactory::get_category_bitmap_(category, false));
|
bmps.emplace_back(SettingsFactory::get_category_bitmap(category));
|
||||||
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
|
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bmp = *bmp;
|
m_bmp = *bmp;
|
||||||
@ -216,13 +216,13 @@ bool ObjectDataViewModelNode::update_settings_digest(const std::vector<std::stri
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDataViewModelNode::msw_rescale()
|
void ObjectDataViewModelNode::sys_color_changed()
|
||||||
{
|
{
|
||||||
if (!m_action_icon_name.empty())
|
if (!m_action_icon_name.empty())
|
||||||
m_action_icon = create_scaled_bitmap(m_action_icon_name);
|
m_action_icon = *get_bmp_bundle(m_action_icon_name);
|
||||||
|
|
||||||
if (m_printable != piUndef)
|
if (m_printable != piUndef)
|
||||||
m_printable_icon = create_scaled_bitmap(m_printable == piPrintable ? "eye_open.png" : "eye_closed.png");
|
m_printable_icon = *get_bmp_bundle(m_printable == piPrintable ? "eye_open" : "eye_closed");
|
||||||
|
|
||||||
if (!m_opt_categories.empty())
|
if (!m_opt_categories.empty())
|
||||||
update_settings_digest_bitmaps();
|
update_settings_digest_bitmaps();
|
||||||
@ -235,7 +235,7 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
|
|||||||
switch (col)
|
switch (col)
|
||||||
{
|
{
|
||||||
case colPrint:
|
case colPrint:
|
||||||
m_printable_icon << variant;
|
// m_printable_icon << variant;
|
||||||
return true;
|
return true;
|
||||||
case colName: {
|
case colName: {
|
||||||
DataViewBitmapText data;
|
DataViewBitmapText data;
|
||||||
@ -250,7 +250,7 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
|
|||||||
m_extruder = data.GetText() == "0" ? _(L("default")) : data.GetText();
|
m_extruder = data.GetText() == "0" ? _(L("default")) : data.GetText();
|
||||||
return true; }
|
return true; }
|
||||||
case colEditing:
|
case colEditing:
|
||||||
m_action_icon << variant;
|
// m_action_icon << variant;
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
printf("MyObjectTreeModel::SetValue: wrong column");
|
printf("MyObjectTreeModel::SetValue: wrong column");
|
||||||
@ -290,7 +290,7 @@ void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= "
|
|||||||
|
|
||||||
if (extruder_idx > 0) --extruder_idx;
|
if (extruder_idx > 0) --extruder_idx;
|
||||||
// Create the bitmap with color bars.
|
// Create the bitmap with color bars.
|
||||||
std::vector<wxBitmap*> bmps = get_extruder_color_icons(false);// use wide icons
|
std::vector<wxBitmapBundle*> bmps = get_extruder_color_icons();// use wide icons
|
||||||
if (bmps.empty()) {
|
if (bmps.empty()) {
|
||||||
m_extruder_bmp = wxNullBitmap;
|
m_extruder_bmp = wxNullBitmap;
|
||||||
return;
|
return;
|
||||||
@ -325,11 +325,11 @@ ObjectDataViewModel::ObjectDataViewModel()
|
|||||||
m_bitmap_cache = new Slic3r::GUI::BitmapCache;
|
m_bitmap_cache = new Slic3r::GUI::BitmapCache;
|
||||||
|
|
||||||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
m_warning_bmp = *get_bmp_bundle(WarningIcon);
|
||||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
|
||||||
|
|
||||||
for (auto item : INFO_ITEMS)
|
for (auto item : INFO_ITEMS)
|
||||||
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
|
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectDataViewModel::~ObjectDataViewModel()
|
ObjectDataViewModel::~ObjectDataViewModel()
|
||||||
@ -340,7 +340,7 @@ ObjectDataViewModel::~ObjectDataViewModel()
|
|||||||
m_bitmap_cache = nullptr;
|
m_bitmap_cache = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap& ObjectDataViewModel::GetWarningBitmap(const std::string& warning_icon_name)
|
wxBitmapBundle& ObjectDataViewModel::GetWarningBitmap(const std::string& warning_icon_name)
|
||||||
{
|
{
|
||||||
return warning_icon_name.empty() ? m_empty_bmp : warning_icon_name == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp;
|
return warning_icon_name.empty() ? m_empty_bmp : warning_icon_name == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp;
|
||||||
}
|
}
|
||||||
@ -429,7 +429,7 @@ wxDataViewItem ObjectDataViewModel::AddInfoChild(const wxDataViewItem &parent_it
|
|||||||
}
|
}
|
||||||
|
|
||||||
root->Insert(node, idx+1);
|
root->Insert(node, idx+1);
|
||||||
node->SetBitmap(m_info_bmps.at(info_type));
|
node->SetBitmap(*m_info_bmps.at(info_type));
|
||||||
// notify control
|
// notify control
|
||||||
const wxDataViewItem child((void*)node);
|
const wxDataViewItem child((void*)node);
|
||||||
ItemAdded(parent_item, child);
|
ItemAdded(parent_item, child);
|
||||||
@ -1237,7 +1237,7 @@ wxString ObjectDataViewModel::GetName(const wxDataViewItem &item) const
|
|||||||
return node->m_name;
|
return node->m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
|
wxBitmapBundle& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
|
||||||
{
|
{
|
||||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||||
return node->m_bmp;
|
return node->m_bmp;
|
||||||
@ -1278,16 +1278,16 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
|
|||||||
switch (col)
|
switch (col)
|
||||||
{
|
{
|
||||||
case colPrint:
|
case colPrint:
|
||||||
variant << node->m_printable_icon;
|
variant << node->m_printable_icon.GetBitmapFor(m_ctrl);
|
||||||
break;
|
break;
|
||||||
case colName:
|
case colName:
|
||||||
variant << DataViewBitmapText(node->m_name, node->m_bmp);
|
variant << DataViewBitmapText(node->m_name, node->m_bmp.GetBitmapFor(m_ctrl));
|
||||||
break;
|
break;
|
||||||
case colExtruder:
|
case colExtruder:
|
||||||
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp);
|
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp.GetBitmapFor(m_ctrl));
|
||||||
break;
|
break;
|
||||||
case colEditing:
|
case colEditing:
|
||||||
variant << node->m_action_icon;
|
variant << node->m_action_icon.GetBitmapFor(m_ctrl);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
@ -1618,7 +1618,7 @@ void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r
|
|||||||
|
|
||||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||||
node->SetVolumeType(volume_type);
|
node->SetVolumeType(volume_type);
|
||||||
node->SetBitmap(m_volume_bmps[int(volume_type)]);
|
node->SetBitmap(*m_volume_bmps[int(volume_type)]);
|
||||||
if (volume_type != Slic3r::ModelVolumeType::MODEL_PART && volume_type != Slic3r::ModelVolumeType::PARAMETER_MODIFIER)
|
if (volume_type != Slic3r::ModelVolumeType::MODEL_PART && volume_type != Slic3r::ModelVolumeType::PARAMETER_MODIFIER)
|
||||||
node->SetExtruder(""); // hide extruder
|
node->SetExtruder(""); // hide extruder
|
||||||
else if (node->GetExtruder().IsEmpty())
|
else if (node->GetExtruder().IsEmpty())
|
||||||
@ -1676,14 +1676,14 @@ wxDataViewItem ObjectDataViewModel::SetObjectPrintableState(
|
|||||||
return obj_item;
|
return obj_item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDataViewModel::Rescale()
|
void ObjectDataViewModel::UpdateBitmaps()
|
||||||
{
|
{
|
||||||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
m_warning_bmp = *get_bmp_bundle(WarningIcon);
|
||||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
|
||||||
|
|
||||||
for (auto item : INFO_ITEMS)
|
for (auto item : INFO_ITEMS)
|
||||||
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
|
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
|
||||||
|
|
||||||
wxDataViewItemArray all_items;
|
wxDataViewItemArray all_items;
|
||||||
GetAllChildren(wxDataViewItem(0), all_items);
|
GetAllChildren(wxDataViewItem(0), all_items);
|
||||||
@ -1694,7 +1694,7 @@ void ObjectDataViewModel::Rescale()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||||
node->msw_rescale();
|
node->sys_color_changed();
|
||||||
|
|
||||||
switch (node->m_type)
|
switch (node->m_type)
|
||||||
{
|
{
|
||||||
@ -1705,13 +1705,13 @@ void ObjectDataViewModel::Rescale()
|
|||||||
node->m_bmp = GetVolumeIcon(node->m_volume_type, node->m_warning_icon_name);
|
node->m_bmp = GetVolumeIcon(node->m_volume_type, node->m_warning_icon_name);
|
||||||
break;
|
break;
|
||||||
case itLayerRoot:
|
case itLayerRoot:
|
||||||
node->m_bmp = create_scaled_bitmap(LayerRootIcon);
|
node->m_bmp = *get_bmp_bundle(LayerRootIcon);
|
||||||
break;
|
break;
|
||||||
case itLayer:
|
case itLayer:
|
||||||
node->m_bmp = create_scaled_bitmap(LayerIcon);
|
node->m_bmp = *get_bmp_bundle(LayerIcon);
|
||||||
break;
|
break;
|
||||||
case itInfo:
|
case itInfo:
|
||||||
node->m_bmp = m_info_bmps.at(node->m_info_item_type);
|
node->m_bmp = *m_info_bmps.at(node->m_info_item_type);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@ -1720,22 +1720,22 @@ void ObjectDataViewModel::Rescale()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap ObjectDataViewModel::GetVolumeIcon(const Slic3r::ModelVolumeType vol_type, const std::string& warning_icon_name/* = std::string()*/)
|
wxBitmapBundle ObjectDataViewModel::GetVolumeIcon(const Slic3r::ModelVolumeType vol_type, const std::string& warning_icon_name/* = std::string()*/)
|
||||||
{
|
{
|
||||||
if (warning_icon_name.empty())
|
if (warning_icon_name.empty())
|
||||||
return m_volume_bmps[static_cast<int>(vol_type)];
|
return *m_volume_bmps[static_cast<int>(vol_type)];
|
||||||
|
|
||||||
std::string scaled_bitmap_name = warning_icon_name + std::to_string(static_cast<int>(vol_type));
|
std::string scaled_bitmap_name = warning_icon_name + std::to_string(static_cast<int>(vol_type));
|
||||||
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "-lm");
|
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "-lm");
|
||||||
|
|
||||||
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
|
wxBitmapBundle *bmp = m_bitmap_cache->find_bndl(scaled_bitmap_name);
|
||||||
if (bmp == nullptr) {
|
if (bmp == nullptr) {
|
||||||
std::vector<wxBitmap> bmps;
|
std::vector<wxBitmapBundle*> bmps;
|
||||||
|
|
||||||
bmps.emplace_back(GetWarningBitmap(warning_icon_name));
|
bmps.emplace_back(&GetWarningBitmap(warning_icon_name));
|
||||||
bmps.emplace_back(m_volume_bmps[static_cast<int>(vol_type)]);
|
bmps.emplace_back(m_volume_bmps[static_cast<int>(vol_type)]);
|
||||||
|
|
||||||
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
|
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *bmp;
|
return *bmp;
|
||||||
@ -1770,7 +1770,7 @@ void ObjectDataViewModel::DeleteWarningIcon(const wxDataViewItem& item, const bo
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (node->GetType() & itVolume) {
|
if (node->GetType() & itVolume) {
|
||||||
node->SetWarningBitmap(m_volume_bmps[static_cast<int>(node->volume_type())], "");
|
node->SetWarningBitmap(*m_volume_bmps[static_cast<int>(node->volume_type())], "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,21 +63,21 @@ class ObjectDataViewModelNode
|
|||||||
{
|
{
|
||||||
ObjectDataViewModelNode* m_parent;
|
ObjectDataViewModelNode* m_parent;
|
||||||
MyObjectTreeModelNodePtrArray m_children;
|
MyObjectTreeModelNodePtrArray m_children;
|
||||||
wxBitmap m_empty_bmp;
|
wxBitmapBundle m_empty_bmp;
|
||||||
size_t m_volumes_cnt = 0;
|
size_t m_volumes_cnt = 0;
|
||||||
std::vector< std::string > m_opt_categories;
|
std::vector< std::string > m_opt_categories;
|
||||||
t_layer_height_range m_layer_range = { 0.0f, 0.0f };
|
t_layer_height_range m_layer_range = { 0.0f, 0.0f };
|
||||||
|
|
||||||
wxString m_name;
|
wxString m_name;
|
||||||
wxBitmap& m_bmp = m_empty_bmp;
|
wxBitmapBundle& m_bmp = m_empty_bmp;
|
||||||
ItemType m_type;
|
ItemType m_type;
|
||||||
int m_idx = -1;
|
int m_idx = -1;
|
||||||
bool m_container = false;
|
bool m_container = false;
|
||||||
wxString m_extruder = "default";
|
wxString m_extruder = "default";
|
||||||
wxBitmap m_extruder_bmp;
|
wxBitmapBundle m_extruder_bmp;
|
||||||
wxBitmap m_action_icon;
|
wxBitmapBundle m_action_icon;
|
||||||
PrintIndicator m_printable {piUndef};
|
PrintIndicator m_printable {piUndef};
|
||||||
wxBitmap m_printable_icon;
|
wxBitmapBundle m_printable_icon;
|
||||||
std::string m_warning_icon_name{ "" };
|
std::string m_warning_icon_name{ "" };
|
||||||
|
|
||||||
std::string m_action_icon_name = "";
|
std::string m_action_icon_name = "";
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||||
const wxString& sub_obj_name,
|
const wxString& sub_obj_name,
|
||||||
Slic3r::ModelVolumeType type,
|
Slic3r::ModelVolumeType type,
|
||||||
const wxBitmap& bmp,
|
const wxBitmapBundle& bmp,
|
||||||
const wxString& extruder,
|
const wxString& extruder,
|
||||||
const int idx = -1,
|
const int idx = -1,
|
||||||
const std::string& warning_icon_name = std::string());
|
const std::string& warning_icon_name = std::string());
|
||||||
@ -179,10 +179,10 @@ public:
|
|||||||
|
|
||||||
bool SetValue(const wxVariant &variant, unsigned int col);
|
bool SetValue(const wxVariant &variant, unsigned int col);
|
||||||
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
|
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
|
||||||
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
|
void SetBitmap(const wxBitmapBundle &icon) { m_bmp = icon; }
|
||||||
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
|
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
|
||||||
void SetWarningBitmap(const wxBitmap& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
|
void SetWarningBitmap(const wxBitmapBundle& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
|
||||||
const wxBitmap& GetBitmap() const { return m_bmp; }
|
const wxBitmapBundle& GetBitmap() const { return m_bmp; }
|
||||||
const wxString& GetName() const { return m_name; }
|
const wxString& GetName() const { return m_name; }
|
||||||
ItemType GetType() const { return m_type; }
|
ItemType GetType() const { return m_type; }
|
||||||
InfoItemType GetInfoItemType() const { return m_info_item_type; }
|
InfoItemType GetInfoItemType() const { return m_info_item_type; }
|
||||||
@ -234,7 +234,7 @@ public:
|
|||||||
void update_settings_digest_bitmaps();
|
void update_settings_digest_bitmaps();
|
||||||
bool update_settings_digest(const std::vector<std::string>& categories);
|
bool update_settings_digest(const std::vector<std::string>& categories);
|
||||||
int volume_type() const { return int(m_volume_type); }
|
int volume_type() const { return int(m_volume_type); }
|
||||||
void msw_rescale();
|
void sys_color_changed();
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool valid();
|
bool valid();
|
||||||
@ -257,11 +257,11 @@ wxDECLARE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
|
|||||||
class ObjectDataViewModel :public wxDataViewModel
|
class ObjectDataViewModel :public wxDataViewModel
|
||||||
{
|
{
|
||||||
std::vector<ObjectDataViewModelNode*> m_objects;
|
std::vector<ObjectDataViewModelNode*> m_objects;
|
||||||
std::vector<wxBitmap> m_volume_bmps;
|
std::vector<wxBitmapBundle*> m_volume_bmps;
|
||||||
std::map<InfoItemType, wxBitmap> m_info_bmps;
|
std::map<InfoItemType, wxBitmapBundle*> m_info_bmps;
|
||||||
wxBitmap m_empty_bmp;
|
wxBitmapBundle m_empty_bmp;
|
||||||
wxBitmap m_warning_bmp;
|
wxBitmapBundle m_warning_bmp;
|
||||||
wxBitmap m_warning_manifold_bmp;
|
wxBitmapBundle m_warning_manifold_bmp;
|
||||||
|
|
||||||
wxDataViewCtrl* m_ctrl { nullptr };
|
wxDataViewCtrl* m_ctrl { nullptr };
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ public:
|
|||||||
// helper method for wxLog
|
// helper method for wxLog
|
||||||
|
|
||||||
wxString GetName(const wxDataViewItem &item) const;
|
wxString GetName(const wxDataViewItem &item) const;
|
||||||
wxBitmap& GetBitmap(const wxDataViewItem &item) const;
|
wxBitmapBundle& GetBitmap(const wxDataViewItem &item) const;
|
||||||
wxString GetExtruder(const wxDataViewItem &item) const;
|
wxString GetExtruder(const wxDataViewItem &item) const;
|
||||||
int GetExtruderNumber(const wxDataViewItem &item) const;
|
int GetExtruderNumber(const wxDataViewItem &item) const;
|
||||||
|
|
||||||
@ -383,9 +383,9 @@ public:
|
|||||||
|
|
||||||
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
|
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
|
||||||
// Rescale bitmaps for existing Items
|
// Rescale bitmaps for existing Items
|
||||||
void Rescale();
|
void UpdateBitmaps();
|
||||||
|
|
||||||
wxBitmap GetVolumeIcon(const Slic3r::ModelVolumeType vol_type,
|
wxBitmapBundle GetVolumeIcon(const Slic3r::ModelVolumeType vol_type,
|
||||||
const std::string& warning_icon_name = std::string());
|
const std::string& warning_icon_name = std::string());
|
||||||
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
|
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
|
||||||
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);
|
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);
|
||||||
@ -403,7 +403,7 @@ private:
|
|||||||
wxDataViewItem AddInstanceRoot(const wxDataViewItem& parent_item);
|
wxDataViewItem AddInstanceRoot(const wxDataViewItem& parent_item);
|
||||||
void AddAllChildren(const wxDataViewItem& parent);
|
void AddAllChildren(const wxDataViewItem& parent);
|
||||||
|
|
||||||
wxBitmap& GetWarningBitmap(const std::string& warning_icon_name);
|
wxBitmapBundle& GetWarningBitmap(const std::string& warning_icon_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -728,7 +728,6 @@ void ConfigOptionsGroup::msw_rescale()
|
|||||||
// check if window is ScalableButton
|
// check if window is ScalableButton
|
||||||
ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win);
|
ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win);
|
||||||
if (sc_btn) {
|
if (sc_btn) {
|
||||||
sc_btn->msw_rescale();
|
|
||||||
sc_btn->SetSize(sc_btn->GetBestSize());
|
sc_btn->SetSize(sc_btn->GetBestSize());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -773,7 +772,7 @@ void ConfigOptionsGroup::sys_color_changed()
|
|||||||
wxWindow* win = item->GetWindow();
|
wxWindow* win = item->GetWindow();
|
||||||
// check if window is ScalableButton
|
// check if window is ScalableButton
|
||||||
if (ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win)) {
|
if (ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win)) {
|
||||||
sc_btn->msw_rescale();
|
sc_btn->sys_color_changed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wxGetApp().UpdateDarkUI(win, dynamic_cast<wxButton*>(win) != nullptr);
|
wxGetApp().UpdateDarkUI(win, dynamic_cast<wxButton*>(win) != nullptr);
|
||||||
|
@ -142,10 +142,10 @@ void PresetForPrinter::AllowDelete()
|
|||||||
m_presets_list->update();
|
m_presets_list->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresetForPrinter::msw_rescale()
|
void PresetForPrinter::on_sys_color_changed()
|
||||||
{
|
{
|
||||||
m_presets_list->msw_rescale();
|
m_presets_list->sys_color_changed();
|
||||||
m_delete_preset_btn->msw_rescale();
|
m_delete_preset_btn->sys_color_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -603,19 +603,10 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||||||
{
|
{
|
||||||
const int& em = em_unit();
|
const int& em = em_unit();
|
||||||
|
|
||||||
m_add_preset_btn->msw_rescale();
|
|
||||||
m_printhost_browse_btn->msw_rescale();
|
|
||||||
m_printhost_test_btn->msw_rescale();
|
|
||||||
if (m_printhost_cafile_browse_btn)
|
|
||||||
m_printhost_cafile_browse_btn->msw_rescale();
|
|
||||||
|
|
||||||
m_optgroup->msw_rescale();
|
m_optgroup->msw_rescale();
|
||||||
|
|
||||||
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
|
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
|
||||||
|
|
||||||
for (PresetForPrinter* preset : m_presets)
|
|
||||||
preset->msw_rescale();
|
|
||||||
|
|
||||||
const wxSize& size = wxSize(45 * em, 35 * em);
|
const wxSize& size = wxSize(45 * em, 35 * em);
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
|
|
||||||
@ -623,6 +614,18 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhysicalPrinterDialog::on_sys_color_changed()
|
||||||
|
{
|
||||||
|
m_add_preset_btn->sys_color_changed();
|
||||||
|
m_printhost_browse_btn->sys_color_changed();
|
||||||
|
m_printhost_test_btn->sys_color_changed();
|
||||||
|
if (m_printhost_cafile_browse_btn)
|
||||||
|
m_printhost_cafile_browse_btn->sys_color_changed();
|
||||||
|
|
||||||
|
for (PresetForPrinter* preset : m_presets)
|
||||||
|
preset->on_sys_color_changed();
|
||||||
|
}
|
||||||
|
|
||||||
void PhysicalPrinterDialog::OnOK(wxEvent& event)
|
void PhysicalPrinterDialog::OnOK(wxEvent& event)
|
||||||
{
|
{
|
||||||
wxString printer_name = m_printer_name->GetValue();
|
wxString printer_name = m_printer_name->GetValue();
|
||||||
|
@ -48,8 +48,7 @@ public:
|
|||||||
void SuppressDelete();
|
void SuppressDelete();
|
||||||
void AllowDelete();
|
void AllowDelete();
|
||||||
|
|
||||||
void msw_rescale();
|
void on_sys_color_changed();
|
||||||
void on_sys_color_changed() {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +97,7 @@ public:
|
|||||||
void DeletePreset(PresetForPrinter* preset_for_printer);
|
void DeletePreset(PresetForPrinter* preset_for_printer);
|
||||||
protected:
|
protected:
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
void on_sys_color_changed() override {};
|
void on_sys_color_changed() override;
|
||||||
|
|
||||||
bool had_all_mk3;
|
bool had_all_mk3;
|
||||||
};
|
};
|
||||||
|
@ -180,7 +180,6 @@ public:
|
|||||||
|
|
||||||
bool showing_manifold_warning_icon;
|
bool showing_manifold_warning_icon;
|
||||||
void show_sizer(bool show);
|
void show_sizer(bool show);
|
||||||
void msw_rescale();
|
|
||||||
void update_warning_icon(const std::string& warning_icon_name);
|
void update_warning_icon(const std::string& warning_icon_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -210,7 +209,7 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
|||||||
|
|
||||||
init_info_label(&info_size, _L("Size"));
|
init_info_label(&info_size, _L("Size"));
|
||||||
|
|
||||||
info_icon = new wxStaticBitmap(parent, wxID_ANY, create_scaled_bitmap("info"));
|
info_icon = new wxStaticBitmap(parent, wxID_ANY, *get_bmp_bundle("info"));
|
||||||
info_icon->SetToolTip(_L("For a multipart object, this value isn't accurate.\n"
|
info_icon->SetToolTip(_L("For a multipart object, this value isn't accurate.\n"
|
||||||
"It doesn't take account of intersections and negative volumes."));
|
"It doesn't take account of intersections and negative volumes."));
|
||||||
auto* volume_info_sizer = new wxBoxSizer(wxHORIZONTAL);
|
auto* volume_info_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
@ -223,7 +222,7 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
|||||||
|
|
||||||
info_manifold = new wxStaticText(parent, wxID_ANY, "");
|
info_manifold = new wxStaticText(parent, wxID_ANY, "");
|
||||||
info_manifold->SetFont(wxGetApp().small_font());
|
info_manifold->SetFont(wxGetApp().small_font());
|
||||||
manifold_warning_icon = new wxStaticBitmap(parent, wxID_ANY, create_scaled_bitmap(m_warning_icon_name));
|
manifold_warning_icon = new wxStaticBitmap(parent, wxID_ANY, *get_bmp_bundle(m_warning_icon_name));
|
||||||
auto *sizer_manifold = new wxBoxSizer(wxHORIZONTAL);
|
auto *sizer_manifold = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer_manifold->Add(manifold_warning_icon, 0, wxLEFT, 2);
|
sizer_manifold->Add(manifold_warning_icon, 0, wxLEFT, 2);
|
||||||
sizer_manifold->Add(info_manifold, 0, wxLEFT, 2);
|
sizer_manifold->Add(info_manifold, 0, wxLEFT, 2);
|
||||||
@ -242,17 +241,11 @@ void ObjectInfo::show_sizer(bool show)
|
|||||||
manifold_warning_icon->Show(showing_manifold_warning_icon && show);
|
manifold_warning_icon->Show(showing_manifold_warning_icon && show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectInfo::msw_rescale()
|
|
||||||
{
|
|
||||||
manifold_warning_icon->SetBitmap(create_scaled_bitmap(m_warning_icon_name));
|
|
||||||
info_icon->SetBitmap(create_scaled_bitmap("info"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectInfo::update_warning_icon(const std::string& warning_icon_name)
|
void ObjectInfo::update_warning_icon(const std::string& warning_icon_name)
|
||||||
{
|
{
|
||||||
if ((showing_manifold_warning_icon = !warning_icon_name.empty())) {
|
if ((showing_manifold_warning_icon = !warning_icon_name.empty())) {
|
||||||
m_warning_icon_name = warning_icon_name;
|
m_warning_icon_name = warning_icon_name;
|
||||||
manifold_warning_icon->SetBitmap(create_scaled_bitmap(m_warning_icon_name));
|
manifold_warning_icon->SetBitmap(*get_bmp_bundle(m_warning_icon_name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,9 +343,6 @@ void FreqChangedParams::msw_rescale()
|
|||||||
{
|
{
|
||||||
m_og->msw_rescale();
|
m_og->msw_rescale();
|
||||||
m_og_sla->msw_rescale();
|
m_og_sla->msw_rescale();
|
||||||
|
|
||||||
for (auto btn: m_empty_buttons)
|
|
||||||
btn->msw_rescale();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreqChangedParams::sys_color_changed()
|
void FreqChangedParams::sys_color_changed()
|
||||||
@ -361,7 +351,7 @@ void FreqChangedParams::sys_color_changed()
|
|||||||
m_og_sla->sys_color_changed();
|
m_og_sla->sys_color_changed();
|
||||||
|
|
||||||
for (auto btn: m_empty_buttons)
|
for (auto btn: m_empty_buttons)
|
||||||
btn->msw_rescale();
|
btn->sys_color_changed();
|
||||||
|
|
||||||
wxGetApp().UpdateDarkUI(m_wiping_dialog_button, true);
|
wxGetApp().UpdateDarkUI(m_wiping_dialog_button, true);
|
||||||
}
|
}
|
||||||
@ -450,7 +440,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
|||||||
*/
|
*/
|
||||||
auto empty_widget = [this] (wxWindow* parent) {
|
auto empty_widget = [this] (wxWindow* parent) {
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
auto btn = new ScalableButton(parent, wxID_ANY, "mirroring_transparent.png", wxEmptyString,
|
auto btn = new ScalableButton(parent, wxID_ANY, "mirroring_transparent", wxEmptyString,
|
||||||
wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER | wxTRANSPARENT_WINDOW);
|
wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER | wxTRANSPARENT_WINDOW);
|
||||||
sizer->Add(btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, int(0.3 * wxGetApp().em_unit()));
|
sizer->Add(btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, int(0.3 * wxGetApp().em_unit()));
|
||||||
m_empty_buttons.push_back(btn);
|
m_empty_buttons.push_back(btn);
|
||||||
@ -508,7 +498,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
auto btn = new ScalableButton(parent, wxID_ANY, "mirroring_transparent.png", wxEmptyString,
|
auto btn = new ScalableButton(parent, wxID_ANY, "mirroring_transparent", wxEmptyString,
|
||||||
wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER | wxTRANSPARENT_WINDOW);
|
wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER | wxTRANSPARENT_WINDOW);
|
||||||
sizer->Add(btn , 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
|
sizer->Add(btn , 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
|
||||||
int(0.3 * wxGetApp().em_unit()));
|
int(0.3 * wxGetApp().em_unit()));
|
||||||
@ -1103,9 +1093,6 @@ void Sidebar::msw_rescale()
|
|||||||
{
|
{
|
||||||
SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
|
SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
|
||||||
|
|
||||||
if (p->mode_sizer)
|
|
||||||
p->mode_sizer->msw_rescale();
|
|
||||||
|
|
||||||
for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
|
for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
|
||||||
p->combo_sla_print,
|
p->combo_sla_print,
|
||||||
p->combo_sla_material,
|
p->combo_sla_material,
|
||||||
@ -1117,14 +1104,8 @@ void Sidebar::msw_rescale()
|
|||||||
p->frequently_changed_parameters->msw_rescale();
|
p->frequently_changed_parameters->msw_rescale();
|
||||||
p->object_list->msw_rescale();
|
p->object_list->msw_rescale();
|
||||||
p->object_manipulation->msw_rescale();
|
p->object_manipulation->msw_rescale();
|
||||||
p->object_settings->msw_rescale();
|
|
||||||
p->object_layers->msw_rescale();
|
p->object_layers->msw_rescale();
|
||||||
|
|
||||||
p->object_info->msw_rescale();
|
|
||||||
|
|
||||||
p->btn_send_gcode->msw_rescale();
|
|
||||||
// p->btn_eject_device->msw_rescale();
|
|
||||||
p->btn_export_gcode_removable->msw_rescale();
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const int scaled_height = p->btn_export_gcode_removable->GetBitmapHeight();
|
const int scaled_height = p->btn_export_gcode_removable->GetBitmapHeight();
|
||||||
#else
|
#else
|
||||||
@ -1145,14 +1126,13 @@ void Sidebar::sys_color_changed()
|
|||||||
|
|
||||||
for (wxWindow* win : std::vector<wxWindow*>{ this, p->sliced_info->GetStaticBox(), p->object_info->GetStaticBox(), p->btn_reslice, p->btn_export_gcode })
|
for (wxWindow* win : std::vector<wxWindow*>{ this, p->sliced_info->GetStaticBox(), p->object_info->GetStaticBox(), p->btn_reslice, p->btn_export_gcode })
|
||||||
wxGetApp().UpdateDarkUI(win);
|
wxGetApp().UpdateDarkUI(win);
|
||||||
p->object_info->msw_rescale();
|
|
||||||
for (wxWindow* win : std::vector<wxWindow*>{ p->scrolled, p->presets_panel })
|
for (wxWindow* win : std::vector<wxWindow*>{ p->scrolled, p->presets_panel })
|
||||||
wxGetApp().UpdateAllStaticTextDarkUI(win);
|
wxGetApp().UpdateAllStaticTextDarkUI(win);
|
||||||
for (wxWindow* btn : std::vector<wxWindow*>{ p->btn_reslice, p->btn_export_gcode })
|
for (wxWindow* btn : std::vector<wxWindow*>{ p->btn_reslice, p->btn_export_gcode })
|
||||||
wxGetApp().UpdateDarkUI(btn, true);
|
wxGetApp().UpdateDarkUI(btn, true);
|
||||||
|
|
||||||
if (p->mode_sizer)
|
if (p->mode_sizer)
|
||||||
p->mode_sizer->msw_rescale();
|
p->mode_sizer->sys_color_changed();
|
||||||
p->frequently_changed_parameters->sys_color_changed();
|
p->frequently_changed_parameters->sys_color_changed();
|
||||||
p->object_settings->sys_color_changed();
|
p->object_settings->sys_color_changed();
|
||||||
#endif
|
#endif
|
||||||
@ -1170,11 +1150,12 @@ void Sidebar::sys_color_changed()
|
|||||||
p->object_layers->sys_color_changed();
|
p->object_layers->sys_color_changed();
|
||||||
|
|
||||||
// btn...->msw_rescale() updates icon on button, so use it
|
// btn...->msw_rescale() updates icon on button, so use it
|
||||||
p->btn_send_gcode->msw_rescale();
|
p->btn_send_gcode->sys_color_changed();
|
||||||
// p->btn_eject_device->msw_rescale();
|
// p->btn_eject_device->msw_rescale();
|
||||||
p->btn_export_gcode_removable->msw_rescale();
|
p->btn_export_gcode_removable->sys_color_changed();
|
||||||
|
|
||||||
p->scrolled->Layout();
|
p->scrolled->Layout();
|
||||||
|
p->scrolled->Refresh();
|
||||||
|
|
||||||
p->searcher.dlg_sys_color_changed();
|
p->searcher.dlg_sys_color_changed();
|
||||||
}
|
}
|
||||||
@ -6974,8 +6955,6 @@ void Plater::msw_rescale()
|
|||||||
|
|
||||||
p->sidebar->msw_rescale();
|
p->sidebar->msw_rescale();
|
||||||
|
|
||||||
p->menus.msw_rescale();
|
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
GetParent()->Layout();
|
GetParent()->Layout();
|
||||||
}
|
}
|
||||||
|
@ -108,8 +108,8 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bitmapCompatible = ScalableBitmap(this, "flag_green");
|
m_bitmapCompatible = get_bmp_bundle("flag_green");
|
||||||
m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
|
m_bitmapIncompatible = get_bmp_bundle("flag_red");
|
||||||
|
|
||||||
// parameters for an icon's drawing
|
// parameters for an icon's drawing
|
||||||
fill_width_height();
|
fill_width_height();
|
||||||
@ -242,12 +242,12 @@ void PresetComboBox::update(std::string select_preset_name)
|
|||||||
|
|
||||||
const std::deque<Preset>& presets = m_collection->get_presets();
|
const std::deque<Preset>& presets = m_collection->get_presets();
|
||||||
|
|
||||||
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
|
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
|
||||||
std::map<wxString, wxBitmap*> incomp_presets;
|
std::map<wxString, wxBitmapBundle*> incomp_presets;
|
||||||
|
|
||||||
wxString selected = "";
|
wxString selected = "";
|
||||||
if (!presets.front().is_visible)
|
if (!presets.front().is_visible)
|
||||||
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
|
|
||||||
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
|
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -268,7 +268,7 @@ void PresetComboBox::update(std::string select_preset_name)
|
|||||||
}
|
}
|
||||||
std::string main_icon_name = m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
std::string main_icon_name = m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
||||||
|
|
||||||
wxBitmap* bmp = get_bmp(bitmap_key, main_icon_name, "lock_closed", is_enabled, preset.is_compatible, preset.is_system || preset.is_default);
|
auto bmp = get_bmp(bitmap_key, main_icon_name, "lock_closed", is_enabled, preset.is_compatible, preset.is_system || preset.is_default);
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
|
|
||||||
if (!is_enabled)
|
if (!is_enabled)
|
||||||
@ -280,17 +280,17 @@ void PresetComboBox::update(std::string select_preset_name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
|
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
|
||||||
if (preset.name == select_preset_name || (select_preset_name.empty() && is_enabled))
|
if (preset.name == select_preset_name || (select_preset_name.empty() && is_enabled))
|
||||||
selected = get_preset_name(preset);
|
selected = get_preset_name(preset);
|
||||||
}
|
}
|
||||||
if (i + 1 == m_collection->num_default_presets())
|
if (i + 1 == m_collection->num_default_presets())
|
||||||
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
}
|
}
|
||||||
if (!nonsys_presets.empty())
|
if (!nonsys_presets.empty())
|
||||||
{
|
{
|
||||||
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||||
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||||
int item_id = Append(it->first, *it->second.first);
|
int item_id = Append(it->first, *it->second.first);
|
||||||
bool is_enabled = it->second.second;
|
bool is_enabled = it->second.second;
|
||||||
if (!is_enabled)
|
if (!is_enabled)
|
||||||
@ -300,8 +300,8 @@ void PresetComboBox::update(std::string select_preset_name)
|
|||||||
}
|
}
|
||||||
if (!incomp_presets.empty())
|
if (!incomp_presets.empty())
|
||||||
{
|
{
|
||||||
set_label_marker(Append(separator(L("Incompatible presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("Incompatible presets")), NullBitmapBndl()));
|
||||||
for (std::map<wxString, wxBitmap*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
|
for (std::map<wxString, wxBitmapBundle*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
|
||||||
set_label_marker(Append(it->first, *it->second), LABEL_ITEM_DISABLED);
|
set_label_marker(Append(it->first, *it->second), LABEL_ITEM_DISABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,7 +337,6 @@ bool PresetComboBox::del_physical_printer(const wxString& note_string/* = wxEmpt
|
|||||||
msg += note_string + "\n";
|
msg += note_string + "\n";
|
||||||
msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), printer_name);
|
msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), printer_name);
|
||||||
|
|
||||||
//if (wxMessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
|
|
||||||
if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
|
if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -364,7 +363,8 @@ void PresetComboBox::show_all(bool show_all)
|
|||||||
|
|
||||||
void PresetComboBox::update()
|
void PresetComboBox::update()
|
||||||
{
|
{
|
||||||
this->update(into_u8(this->GetString(this->GetSelection())));
|
int n = this->GetSelection();
|
||||||
|
this->update(n < 0 ? "" : into_u8(this->GetString(n)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresetComboBox::update_from_bundle()
|
void PresetComboBox::update_from_bundle()
|
||||||
@ -375,43 +375,31 @@ void PresetComboBox::update_from_bundle()
|
|||||||
void PresetComboBox::msw_rescale()
|
void PresetComboBox::msw_rescale()
|
||||||
{
|
{
|
||||||
m_em_unit = em_unit(this);
|
m_em_unit = em_unit(this);
|
||||||
|
}
|
||||||
|
|
||||||
//m_bitmapIncompatible.msw_rescale();
|
void PresetComboBox::sys_color_changed()
|
||||||
//m_bitmapCompatible.msw_rescale();
|
{
|
||||||
|
m_bitmapCompatible = get_bmp_bundle("flag_green");
|
||||||
// parameters for an icon's drawing
|
m_bitmapIncompatible = get_bmp_bundle("flag_red");
|
||||||
fill_width_height();
|
wxGetApp().UpdateDarkUI(this);
|
||||||
|
|
||||||
// update the control to redraw the icons
|
// update the control to redraw the icons
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresetComboBox::sys_color_changed()
|
|
||||||
{
|
|
||||||
wxGetApp().UpdateDarkUI(this);
|
|
||||||
msw_rescale();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PresetComboBox::fill_width_height()
|
void PresetComboBox::fill_width_height()
|
||||||
{
|
{
|
||||||
// To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size, so
|
icon_height = m_bitmapCompatible->GetPreferredBitmapSizeAtScale(1.0).GetHeight();
|
||||||
// set a bitmap's height to m_bitmapCompatible->GetHeight() and norm_icon_width to m_bitmapCompatible->GetWidth()
|
norm_icon_width = m_bitmapCompatible->GetPreferredBitmapSizeAtScale(1.0).GetWidth();
|
||||||
icon_height = m_bitmapCompatible.GetBmpHeight();
|
|
||||||
norm_icon_width = m_bitmapCompatible.GetBmpWidth();
|
|
||||||
|
|
||||||
/* It's supposed that standard size of an icon is 16px*16px for 100% scaled display.
|
null_icon_width = 2 * norm_icon_width;
|
||||||
* So set sizes for solid_colored icons used for filament preset
|
|
||||||
* and scale them in respect to em_unit value
|
|
||||||
*/
|
|
||||||
// const float scale_f = (float)m_em_unit * 0.1f;
|
|
||||||
const float scale_f = 1.0f;
|
|
||||||
|
|
||||||
thin_icon_width = lroundf(8 * scale_f); // analogue to 8px;
|
thin_icon_width = 8;
|
||||||
wide_icon_width = norm_icon_width + thin_icon_width;
|
wide_icon_width = norm_icon_width + thin_icon_width;
|
||||||
|
|
||||||
space_icon_width = lroundf(2 * scale_f);
|
space_icon_width = 2;
|
||||||
thin_space_icon_width = lroundf(4 * scale_f);
|
thin_space_icon_width = 4;
|
||||||
wide_space_icon_width = lroundf(6 * scale_f);
|
wide_space_icon_width = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString PresetComboBox::separator(const std::string& label)
|
wxString PresetComboBox::separator(const std::string& label)
|
||||||
@ -419,7 +407,8 @@ wxString PresetComboBox::separator(const std::string& label)
|
|||||||
return wxString::FromUTF8(separator_head()) + _(label) + wxString::FromUTF8(separator_tail());
|
return wxString::FromUTF8(separator_head()) + _(label) + wxString::FromUTF8(separator_tail());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
|
|
||||||
|
wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
|
||||||
bool is_compatible/* = true*/, bool is_system/* = false*/, bool is_single_bar/* = false*/,
|
bool is_compatible/* = true*/, bool is_system/* = false*/, bool is_single_bar/* = false*/,
|
||||||
const std::string& filament_rgb/* = ""*/, const std::string& extruder_rgb/* = ""*/, const std::string& material_rgb/* = ""*/)
|
const std::string& filament_rgb/* = ""*/, const std::string& extruder_rgb/* = ""*/, const std::string& material_rgb/* = ""*/)
|
||||||
{
|
{
|
||||||
@ -435,45 +424,41 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con
|
|||||||
bitmap_key += ",dark";
|
bitmap_key += ",dark";
|
||||||
bitmap_key += material_rgb;
|
bitmap_key += material_rgb;
|
||||||
|
|
||||||
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
|
wxBitmapBundle* bmp_bndl = bitmap_cache().find_bndl(bitmap_key);
|
||||||
if (bmp == nullptr) {
|
if (bmp_bndl == nullptr) {
|
||||||
// Create the bitmap with color bars.
|
// Create the bitmap with color bars.
|
||||||
std::vector<wxBitmap> bmps;
|
std::vector<wxBitmapBundle*> bmps;
|
||||||
if (wide_icons)
|
if (wide_icons)
|
||||||
// Paint a red flag for incompatible presets.
|
// Paint a red flag for incompatible presets.
|
||||||
bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp());
|
bmps.emplace_back(is_compatible ? get_empty_bmp_bundle(norm_icon_width, icon_height) : m_bitmapIncompatible);
|
||||||
|
|
||||||
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty()) {
|
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty()) {
|
||||||
// Paint the color bars.
|
// Paint the color bars.
|
||||||
ColorRGB color;
|
bmps.emplace_back(get_solid_bmp_bundle(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, filament_rgb));
|
||||||
decode_color(filament_rgb, color);
|
if (!is_single_bar)
|
||||||
bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, color, false, 1, dark_mode));
|
bmps.emplace_back(get_solid_bmp_bundle(thin_icon_width, icon_height, extruder_rgb));
|
||||||
if (!is_single_bar) {
|
|
||||||
decode_color(extruder_rgb, color);
|
|
||||||
bmps.emplace_back(bitmap_cache().mksolid(thin_icon_width, icon_height, color, false, 1, dark_mode));
|
|
||||||
}
|
|
||||||
// Paint a lock at the system presets.
|
// Paint a lock at the system presets.
|
||||||
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
|
bmps.emplace_back(get_empty_bmp_bundle(space_icon_width, icon_height));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Paint the color bars.
|
// Paint the color bars.
|
||||||
bmps.emplace_back(bitmap_cache().mkclear(thin_space_icon_width, icon_height));
|
bmps.emplace_back(get_empty_bmp_bundle(thin_space_icon_width, icon_height));
|
||||||
if (m_type == Preset::TYPE_SLA_MATERIAL)
|
if (m_type == Preset::TYPE_SLA_MATERIAL)
|
||||||
bmps.emplace_back(create_scaled_bitmap(main_icon_name, this, 16, false, material_rgb));
|
bmps.emplace_back(bitmap_cache().from_svg(main_icon_name, 16, 16, dark_mode, material_rgb));
|
||||||
else
|
else
|
||||||
bmps.emplace_back(create_scaled_bitmap(main_icon_name));
|
bmps.emplace_back(get_bmp_bundle(main_icon_name));
|
||||||
// Paint a lock at the system presets.
|
// Paint a lock at the system presets.
|
||||||
bmps.emplace_back(bitmap_cache().mkclear(wide_space_icon_width, icon_height));
|
bmps.emplace_back(get_empty_bmp_bundle(wide_space_icon_width, icon_height));
|
||||||
}
|
}
|
||||||
bmps.emplace_back(is_system ? create_scaled_bitmap("lock_closed") : bitmap_cache().mkclear(norm_icon_width, icon_height));
|
bmps.emplace_back(is_system ? get_bmp_bundle("lock_closed") : get_empty_bmp_bundle(norm_icon_width, icon_height));
|
||||||
bmp = bitmap_cache().insert(bitmap_key, bmps);
|
bmp_bndl = bitmap_cache().insert_bndl(bitmap_key, bmps);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bmp;
|
return bmp_bndl;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
|
wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
|
||||||
bool is_enabled/* = true*/, bool is_compatible/* = true*/, bool is_system/* = false*/)
|
bool is_enabled/* = true*/, bool is_compatible/* = true*/, bool is_system/* = false*/)
|
||||||
{
|
{
|
||||||
bitmap_key += !is_enabled ? "_disabled" : "";
|
bitmap_key += !is_enabled ? "_disabled" : "";
|
||||||
@ -483,20 +468,25 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, const std::string& m
|
|||||||
if (wxGetApp().dark_mode())
|
if (wxGetApp().dark_mode())
|
||||||
bitmap_key += ",dark";
|
bitmap_key += ",dark";
|
||||||
|
|
||||||
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
|
wxBitmapBundle* bmp = bitmap_cache().find_bndl(bitmap_key);
|
||||||
if (bmp == nullptr) {
|
if (bmp == nullptr) {
|
||||||
// Create the bitmap with color bars.
|
// Create the bitmap with color bars.
|
||||||
std::vector<wxBitmap> bmps;
|
std::vector<wxBitmapBundle*> bmps;
|
||||||
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? create_scaled_bitmap(main_icon_name, this, 16, !is_enabled) :
|
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? get_bmp_bundle(main_icon_name) :
|
||||||
is_compatible ? m_bitmapCompatible.bmp() : m_bitmapIncompatible.bmp());
|
is_compatible ? m_bitmapCompatible : m_bitmapIncompatible);
|
||||||
// Paint a lock at the system presets.
|
// Paint a lock at the system presets.
|
||||||
bmps.emplace_back(is_system ? create_scaled_bitmap(next_icon_name, this, 16, !is_enabled) : bitmap_cache().mkclear(norm_icon_width, icon_height));
|
bmps.emplace_back(is_system ? get_bmp_bundle(next_icon_name) : get_empty_bmp_bundle(norm_icon_width, icon_height));
|
||||||
bmp = bitmap_cache().insert(bitmap_key, bmps);
|
bmp = bitmap_cache().insert_bndl(bitmap_key, bmps);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle PresetComboBox::NullBitmapBndl()
|
||||||
|
{
|
||||||
|
return *get_empty_bmp_bundle(null_icon_width, icon_height);
|
||||||
|
}
|
||||||
|
|
||||||
bool PresetComboBox::is_selected_physical_printer()
|
bool PresetComboBox::is_selected_physical_printer()
|
||||||
{
|
{
|
||||||
auto selected_item = this->GetSelection();
|
auto selected_item = this->GetSelection();
|
||||||
@ -783,14 +773,16 @@ void PlaterPresetComboBox::update()
|
|||||||
// and draw a red flag in front of the selected preset.
|
// and draw a red flag in front of the selected preset.
|
||||||
bool wide_icons = selected_preset && !selected_preset->is_compatible;
|
bool wide_icons = selected_preset && !selected_preset->is_compatible;
|
||||||
|
|
||||||
std::map<wxString, wxBitmap*> nonsys_presets;
|
null_icon_width = (wide_icons ? 3 : 2) * norm_icon_width + thin_space_icon_width + wide_space_icon_width;
|
||||||
|
|
||||||
|
std::map<wxString, wxBitmapBundle*> nonsys_presets;
|
||||||
|
|
||||||
wxString selected_user_preset;
|
wxString selected_user_preset;
|
||||||
wxString tooltip;
|
wxString tooltip;
|
||||||
const std::deque<Preset>& presets = m_collection->get_presets();
|
const std::deque<Preset>& presets = m_collection->get_presets();
|
||||||
|
|
||||||
if (!presets.front().is_visible)
|
if (!presets.front().is_visible)
|
||||||
this->set_label_marker(this->Append(separator(L("System presets")), wxNullBitmap));
|
this->set_label_marker(this->Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
|
|
||||||
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
|
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -824,7 +816,7 @@ void PlaterPresetComboBox::update()
|
|||||||
material_rgb = print_config_def.get("material_colour")->get_default_value<ConfigOptionString>()->value;
|
material_rgb = print_config_def.get("material_colour")->get_default_value<ConfigOptionString>()->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap* bmp = get_bmp(bitmap_key, wide_icons, bitmap_type_name,
|
auto bmp = get_bmp(bitmap_key, wide_icons, bitmap_type_name,
|
||||||
preset.is_compatible, preset.is_system || preset.is_default,
|
preset.is_compatible, preset.is_system || preset.is_default,
|
||||||
single_bar, filament_rgb, extruder_rgb, material_rgb);
|
single_bar, filament_rgb, extruder_rgb, material_rgb);
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
@ -845,12 +837,12 @@ void PlaterPresetComboBox::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i + 1 == m_collection->num_default_presets())
|
if (i + 1 == m_collection->num_default_presets())
|
||||||
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
}
|
}
|
||||||
if (!nonsys_presets.empty())
|
if (!nonsys_presets.empty())
|
||||||
{
|
{
|
||||||
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||||
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
for (std::map<wxString, wxBitmapBundle*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||||
Append(it->first, *it->second);
|
Append(it->first, *it->second);
|
||||||
validate_selection(it->first == selected_user_preset);
|
validate_selection(it->first == selected_user_preset);
|
||||||
}
|
}
|
||||||
@ -860,7 +852,7 @@ void PlaterPresetComboBox::update()
|
|||||||
{
|
{
|
||||||
// add Physical printers, if any exists
|
// add Physical printers, if any exists
|
||||||
if (!m_preset_bundle->physical_printers.empty()) {
|
if (!m_preset_bundle->physical_printers.empty()) {
|
||||||
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
|
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
|
||||||
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
|
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
|
||||||
|
|
||||||
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
||||||
@ -869,7 +861,7 @@ void PlaterPresetComboBox::update()
|
|||||||
if (!preset || !preset->is_visible)
|
if (!preset || !preset->is_visible)
|
||||||
continue;
|
continue;
|
||||||
std::string main_icon_name, bitmap_key = main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
std::string main_icon_name, bitmap_key = main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
||||||
wxBitmap* bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
|
auto bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
|
|
||||||
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
|
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
|
||||||
@ -880,7 +872,7 @@ void PlaterPresetComboBox::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) {
|
if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) {
|
||||||
wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
|
auto bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
|
|
||||||
if (m_type == Preset::TYPE_FILAMENT)
|
if (m_type == Preset::TYPE_FILAMENT)
|
||||||
@ -917,9 +909,20 @@ void PlaterPresetComboBox::update()
|
|||||||
void PlaterPresetComboBox::msw_rescale()
|
void PlaterPresetComboBox::msw_rescale()
|
||||||
{
|
{
|
||||||
PresetComboBox::msw_rescale();
|
PresetComboBox::msw_rescale();
|
||||||
edit_btn->msw_rescale();
|
#ifdef __WXMSW__
|
||||||
|
// Use this part of code just on Windows to avoid of some layout issues on Linux
|
||||||
|
// see https://github.com/prusa3d/PrusaSlicer/issues/5163 and https://github.com/prusa3d/PrusaSlicer/issues/5505
|
||||||
|
// Update control min size after rescale (changed Display DPI under MSW)
|
||||||
|
if (GetMinWidth() != 20 * m_em_unit)
|
||||||
|
SetMinSize(wxSize(20 * m_em_unit, GetSize().GetHeight()));
|
||||||
|
#endif //__WXMSW__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaterPresetComboBox::sys_color_changed()
|
||||||
|
{
|
||||||
|
PresetComboBox::sys_color_changed();
|
||||||
|
edit_btn->sys_color_changed();
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
// *** TabPresetComboBox ***
|
// *** TabPresetComboBox ***
|
||||||
@ -982,10 +985,10 @@ void TabPresetComboBox::update()
|
|||||||
|
|
||||||
const std::deque<Preset>& presets = m_collection->get_presets();
|
const std::deque<Preset>& presets = m_collection->get_presets();
|
||||||
|
|
||||||
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
|
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
|
||||||
wxString selected = "";
|
wxString selected = "";
|
||||||
if (!presets.front().is_visible)
|
if (!presets.front().is_visible)
|
||||||
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
size_t idx_selected = m_collection->get_selected_idx();
|
size_t idx_selected = m_collection->get_selected_idx();
|
||||||
|
|
||||||
if (m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection()) {
|
if (m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection()) {
|
||||||
@ -1012,7 +1015,7 @@ void TabPresetComboBox::update()
|
|||||||
}
|
}
|
||||||
std::string main_icon_name = m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
std::string main_icon_name = m_type == Preset::TYPE_PRINTER && preset.printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
||||||
|
|
||||||
wxBitmap* bmp = get_bmp(bitmap_key, main_icon_name, "lock_closed", is_enabled, preset.is_compatible, preset.is_system || preset.is_default);
|
auto bmp = get_bmp(bitmap_key, main_icon_name, "lock_closed", is_enabled, preset.is_compatible, preset.is_system || preset.is_default);
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
|
|
||||||
if (preset.is_default || preset.is_system) {
|
if (preset.is_default || preset.is_system) {
|
||||||
@ -1023,18 +1026,18 @@ void TabPresetComboBox::update()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
|
std::pair<wxBitmapBundle*, bool> pair(bmp, is_enabled);
|
||||||
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
|
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
|
||||||
if (i == idx_selected)
|
if (i == idx_selected)
|
||||||
selected = get_preset_name(preset);
|
selected = get_preset_name(preset);
|
||||||
}
|
}
|
||||||
if (i + 1 == m_collection->num_default_presets())
|
if (i + 1 == m_collection->num_default_presets())
|
||||||
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
|
||||||
}
|
}
|
||||||
if (!nonsys_presets.empty())
|
if (!nonsys_presets.empty())
|
||||||
{
|
{
|
||||||
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
|
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||||
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||||
int item_id = Append(it->first, *it->second.first);
|
int item_id = Append(it->first, *it->second.first);
|
||||||
bool is_enabled = it->second.second;
|
bool is_enabled = it->second.second;
|
||||||
if (!is_enabled)
|
if (!is_enabled)
|
||||||
@ -1047,7 +1050,7 @@ void TabPresetComboBox::update()
|
|||||||
{
|
{
|
||||||
// add Physical printers, if any exists
|
// add Physical printers, if any exists
|
||||||
if (!m_preset_bundle->physical_printers.empty()) {
|
if (!m_preset_bundle->physical_printers.empty()) {
|
||||||
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
|
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
|
||||||
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
|
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
|
||||||
|
|
||||||
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
||||||
@ -1057,7 +1060,7 @@ void TabPresetComboBox::update()
|
|||||||
continue;
|
continue;
|
||||||
std::string main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
std::string main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
|
||||||
|
|
||||||
wxBitmap* bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
|
auto bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
|
|
||||||
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
|
set_label_marker(Append(from_u8(it->get_full_name(preset_name) + suffix(preset)), *bmp), LABEL_ITEM_PHYSICAL_PRINTER);
|
||||||
@ -1068,7 +1071,7 @@ void TabPresetComboBox::update()
|
|||||||
|
|
||||||
// add "Add/Remove printers" item
|
// add "Add/Remove printers" item
|
||||||
std::string icon_name = "edit_uni";
|
std::string icon_name = "edit_uni";
|
||||||
wxBitmap* bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
|
auto bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
|
||||||
assert(bmp);
|
assert(bmp);
|
||||||
|
|
||||||
set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
|
set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef slic3r_PresetComboBoxes_hpp_
|
#ifndef slic3r_PresetComboBoxes_hpp_
|
||||||
#define slic3r_PresetComboBoxes_hpp_
|
#define slic3r_PresetComboBoxes_hpp_
|
||||||
|
|
||||||
//#include <wx/bmpcbox.h>
|
#include <wx/bmpbndl.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
|
||||||
#include "libslic3r/Preset.hpp"
|
#include "libslic3r/Preset.hpp"
|
||||||
@ -88,9 +88,9 @@ protected:
|
|||||||
static BitmapCache& bitmap_cache();
|
static BitmapCache& bitmap_cache();
|
||||||
|
|
||||||
// Indicator, that the preset is compatible with the selected printer.
|
// Indicator, that the preset is compatible with the selected printer.
|
||||||
ScalableBitmap m_bitmapCompatible;
|
wxBitmapBundle* m_bitmapCompatible;
|
||||||
// Indicator, that the preset is NOT compatible with the selected printer.
|
// Indicator, that the preset is NOT compatible with the selected printer.
|
||||||
ScalableBitmap m_bitmapIncompatible;
|
wxBitmapBundle* m_bitmapIncompatible;
|
||||||
|
|
||||||
int m_last_selected;
|
int m_last_selected;
|
||||||
int m_em_unit;
|
int m_em_unit;
|
||||||
@ -99,6 +99,7 @@ protected:
|
|||||||
// parameters for an icon's drawing
|
// parameters for an icon's drawing
|
||||||
int icon_height;
|
int icon_height;
|
||||||
int norm_icon_width;
|
int norm_icon_width;
|
||||||
|
int null_icon_width;
|
||||||
int thin_icon_width;
|
int thin_icon_width;
|
||||||
int wide_icon_width;
|
int wide_icon_width;
|
||||||
int space_icon_width;
|
int space_icon_width;
|
||||||
@ -120,13 +121,15 @@ protected:
|
|||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
static wxString separator(const std::string& label);
|
static wxString separator(const std::string& label);
|
||||||
|
|
||||||
wxBitmap* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
|
wxBitmapBundle* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
|
||||||
bool is_compatible = true, bool is_system = false, bool is_single_bar = false,
|
bool is_compatible = true, bool is_system = false, bool is_single_bar = false,
|
||||||
const std::string& filament_rgb = "", const std::string& extruder_rgb = "", const std::string& material_rgb = "");
|
const std::string& filament_rgb = "", const std::string& extruder_rgb = "", const std::string& material_rgb = "");
|
||||||
|
|
||||||
wxBitmap* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
|
wxBitmapBundle* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
|
||||||
bool is_enabled = true, bool is_compatible = true, bool is_system = false);
|
bool is_enabled = true, bool is_compatible = true, bool is_system = false);
|
||||||
|
|
||||||
|
wxBitmapBundle NullBitmapBndl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fill_width_height();
|
void fill_width_height();
|
||||||
};
|
};
|
||||||
@ -155,6 +158,7 @@ public:
|
|||||||
wxString get_preset_name(const Preset& preset) override;
|
wxString get_preset_name(const Preset& preset) override;
|
||||||
void update() override;
|
void update() override;
|
||||||
void msw_rescale() override;
|
void msw_rescale() override;
|
||||||
|
void sys_color_changed() override;
|
||||||
void OnSelect(wxCommandEvent& evt) override;
|
void OnSelect(wxCommandEvent& evt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -56,7 +56,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBox
|
|||||||
|
|
||||||
wxStaticText* label_top = new wxStaticText(m_parent, wxID_ANY, from_u8((boost::format(_utf8(L("Save %s as:"))) % into_u8(tab->title())).str()));
|
wxStaticText* label_top = new wxStaticText(m_parent, wxID_ANY, from_u8((boost::format(_utf8(L("Save %s as:"))) % into_u8(tab->title())).str()));
|
||||||
|
|
||||||
m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, create_scaled_bitmap("tick_mark", m_parent));
|
m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("tick_mark"));
|
||||||
|
|
||||||
m_combo = new wxComboBox(m_parent, wxID_ANY, from_u8(preset_name), wxDefaultPosition, wxSize(35 * wxGetApp().em_unit(), -1));
|
m_combo = new wxComboBox(m_parent, wxID_ANY, from_u8(preset_name), wxDefaultPosition, wxSize(35 * wxGetApp().em_unit(), -1));
|
||||||
for (const std::string& value : values)
|
for (const std::string& value : values)
|
||||||
@ -173,7 +173,7 @@ void SavePresetDialog::Item::update_valid_bmp()
|
|||||||
{
|
{
|
||||||
std::string bmp_name = m_valid_type == Warning ? "exclamation" :
|
std::string bmp_name = m_valid_type == Warning ? "exclamation" :
|
||||||
m_valid_type == NoValid ? "cross" : "tick_mark" ;
|
m_valid_type == NoValid ? "cross" : "tick_mark" ;
|
||||||
m_valid_bmp->SetBitmap(create_scaled_bitmap(bmp_name, m_parent));
|
m_valid_bmp->SetBitmap(*get_bmp_bundle(bmp_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavePresetDialog::Item::accept()
|
void SavePresetDialog::Item::accept()
|
||||||
|
@ -720,12 +720,9 @@ void SearchDialog::msw_rescale()
|
|||||||
{
|
{
|
||||||
const int& em = em_unit();
|
const int& em = em_unit();
|
||||||
|
|
||||||
search_list_model->msw_rescale();
|
|
||||||
search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em);
|
search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em);
|
||||||
search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(45 * em);
|
search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(45 * em);
|
||||||
|
|
||||||
msw_buttons_rescale(this, em, { wxID_CANCEL });
|
|
||||||
|
|
||||||
const wxSize& size = wxSize(40 * em, 30 * em);
|
const wxSize& size = wxSize(40 * em, 30 * em);
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
|
|
||||||
@ -743,7 +740,7 @@ void SearchDialog::on_sys_color_changed()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// msw_rescale updates just icons, so use it
|
// msw_rescale updates just icons, so use it
|
||||||
search_list_model->msw_rescale();
|
search_list_model->sys_color_changed();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
@ -776,10 +773,10 @@ void SearchListModel::Prepend(const std::string& label)
|
|||||||
RowPrepended();
|
RowPrepended();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchListModel::msw_rescale()
|
void SearchListModel::sys_color_changed()
|
||||||
{
|
{
|
||||||
for (ScalableBitmap& bmp : m_icon)
|
for (ScalableBitmap& bmp : m_icon)
|
||||||
bmp.msw_rescale();
|
bmp.sys_color_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString SearchListModel::GetColumnType(unsigned int col) const
|
wxString SearchListModel::GetColumnType(unsigned int col) const
|
||||||
@ -795,7 +792,7 @@ void SearchListModel::GetValueByRow(wxVariant& variant,
|
|||||||
switch (col)
|
switch (col)
|
||||||
{
|
{
|
||||||
case colIcon:
|
case colIcon:
|
||||||
variant << m_icon[m_values[row].second].bmp();
|
variant << m_icon[m_values[row].second].bmp().GetBitmapFor(m_icon[m_values[row].second].parent());
|
||||||
break;
|
break;
|
||||||
case colMarkedText:
|
case colMarkedText:
|
||||||
variant = m_values[row].first;
|
variant = m_values[row].first;
|
||||||
|
@ -213,7 +213,7 @@ public:
|
|||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void Prepend(const std::string& text);
|
void Prepend(const std::string& text);
|
||||||
void msw_rescale();
|
void sys_color_changed();
|
||||||
|
|
||||||
// implementation of base class virtuals to define model
|
// implementation of base class virtuals to define model
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ SysInfoDialog::SysInfoDialog()
|
|||||||
// logo
|
// logo
|
||||||
//m_logo_bmp = ScalableBitmap(this, wxGetApp().logo_name(), 192);
|
//m_logo_bmp = ScalableBitmap(this, wxGetApp().logo_name(), 192);
|
||||||
//m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
|
//m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
|
||||||
m_logo = new wxStaticBitmap(this, wxID_ANY, wxBitmapBundle::FromSVGFile(Slic3r::var(wxGetApp().logo_name() + ".svg"), wxSize(192, 192)));
|
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
|
||||||
|
|
||||||
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
|
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
|
@ -155,10 +155,8 @@ void Tab::create_preset_tab()
|
|||||||
add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
|
add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
|
||||||
|
|
||||||
m_show_incompatible_presets = false;
|
m_show_incompatible_presets = false;
|
||||||
add_scaled_bitmap(this, m_bmp_show_incompatible_presets, "flag_red");
|
|
||||||
add_scaled_bitmap(this, m_bmp_hide_incompatible_presets, "flag_green");
|
|
||||||
|
|
||||||
add_scaled_button(panel, &m_btn_hide_incompatible_presets, m_bmp_hide_incompatible_presets.name());
|
add_scaled_button(panel, &m_btn_hide_incompatible_presets, "flag_green");
|
||||||
|
|
||||||
m_btn_compare_preset->SetToolTip(_L("Compare this preset with some another"));
|
m_btn_compare_preset->SetToolTip(_L("Compare this preset with some another"));
|
||||||
// TRN "Save current Settings"
|
// TRN "Save current Settings"
|
||||||
@ -207,7 +205,7 @@ void Tab::create_preset_tab()
|
|||||||
#endif
|
#endif
|
||||||
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
|
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
|
||||||
|
|
||||||
const float scale_factor = /*wxGetApp().*/em_unit(this)*0.1;// GetContentScaleFactor();
|
const float scale_factor = em_unit(this)*0.1;// GetContentScaleFactor();
|
||||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 3);
|
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 3);
|
||||||
m_hsizer->Add(m_presets_choice, 0, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
m_hsizer->Add(m_presets_choice, 0, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
||||||
@ -254,11 +252,8 @@ void Tab::create_preset_tab()
|
|||||||
m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(20 * m_em_unit, -1),
|
m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(20 * m_em_unit, -1),
|
||||||
wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
||||||
m_left_sizer->Add(m_treectrl, 1, wxEXPAND);
|
m_left_sizer->Add(m_treectrl, 1, wxEXPAND);
|
||||||
const int img_sz = int(16 * scale_factor + 0.5f);
|
// Index of the last icon inserted into m_treectrl
|
||||||
m_icons = new wxImageList(img_sz, img_sz, true, 1);
|
|
||||||
// Index of the last icon inserted into $self->{icons}.
|
|
||||||
m_icon_count = -1;
|
m_icon_count = -1;
|
||||||
m_treectrl->AssignImageList(m_icons);
|
|
||||||
m_treectrl->AddRoot("root");
|
m_treectrl->AddRoot("root");
|
||||||
m_treectrl->SetIndent(0);
|
m_treectrl->SetIndent(0);
|
||||||
wxGetApp().UpdateDarkUI(m_treectrl);
|
wxGetApp().UpdateDarkUI(m_treectrl);
|
||||||
@ -321,6 +316,14 @@ void Tab::create_preset_tab()
|
|||||||
// Initialize the DynamicPrintConfig by default keys/values.
|
// Initialize the DynamicPrintConfig by default keys/values.
|
||||||
build();
|
build();
|
||||||
|
|
||||||
|
if (!m_scaled_icons_list.empty()) {
|
||||||
|
// update icons for tree_ctrl
|
||||||
|
wxVector<wxBitmapBundle> img_bundles;
|
||||||
|
for (const ScalableBitmap& bmp : m_scaled_icons_list)
|
||||||
|
img_bundles.push_back(bmp.bmp());
|
||||||
|
m_treectrl->SetImages(img_bundles);
|
||||||
|
}
|
||||||
|
|
||||||
// ys_FIXME: Following should not be needed, the function will be called later
|
// ys_FIXME: Following should not be needed, the function will be called later
|
||||||
// (update_mode->update_visibility->rebuild_page_tree). This does not work, during the
|
// (update_mode->update_visibility->rebuild_page_tree). This does not work, during the
|
||||||
// second call of rebuild_page_tree m_treectrl->GetFirstVisibleItem(); returns zero
|
// second call of rebuild_page_tree m_treectrl->GetFirstVisibleItem(); returns zero
|
||||||
@ -336,7 +339,7 @@ void Tab::add_scaled_button(wxWindow* parent,
|
|||||||
const wxString& label/* = wxEmptyString*/,
|
const wxString& label/* = wxEmptyString*/,
|
||||||
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/)
|
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/)
|
||||||
{
|
{
|
||||||
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style, true);
|
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style);
|
||||||
m_scaled_buttons.push_back(*btn);
|
m_scaled_buttons.push_back(*btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +369,6 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
|
|||||||
if (icon_idx == -1) {
|
if (icon_idx == -1) {
|
||||||
// Add a new icon to the icon list.
|
// Add a new icon to the icon list.
|
||||||
m_scaled_icons_list.push_back(ScalableBitmap(this, icon));
|
m_scaled_icons_list.push_back(ScalableBitmap(this, icon));
|
||||||
m_icons->Add(m_scaled_icons_list.back().bmp());
|
|
||||||
icon_idx = ++m_icon_count;
|
icon_idx = ++m_icon_count;
|
||||||
m_icon_index[icon] = icon_idx;
|
m_icon_index[icon] = icon_idx;
|
||||||
}
|
}
|
||||||
@ -656,16 +658,6 @@ void TabPrinter::init_options_list()
|
|||||||
m_options_list.emplace("extruders_count", m_opt_status_value);
|
m_options_list.emplace("extruders_count", m_opt_status_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabPrinter::msw_rescale()
|
|
||||||
{
|
|
||||||
Tab::msw_rescale();
|
|
||||||
|
|
||||||
if (m_reset_to_filament_color)
|
|
||||||
m_reset_to_filament_color->msw_rescale();
|
|
||||||
|
|
||||||
Layout();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabSLAMaterial::init_options_list()
|
void TabSLAMaterial::init_options_list()
|
||||||
{
|
{
|
||||||
if (!m_options_list.empty())
|
if (!m_options_list.empty())
|
||||||
@ -924,31 +916,9 @@ void Tab::msw_rescale()
|
|||||||
{
|
{
|
||||||
m_em_unit = em_unit(m_parent);
|
m_em_unit = em_unit(m_parent);
|
||||||
|
|
||||||
if (m_mode_sizer)
|
|
||||||
m_mode_sizer->msw_rescale();
|
|
||||||
m_presets_choice->msw_rescale();
|
m_presets_choice->msw_rescale();
|
||||||
|
|
||||||
m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1));
|
m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1));
|
||||||
|
|
||||||
// rescale buttons and cached bitmaps
|
|
||||||
for (const auto btn : m_scaled_buttons)
|
|
||||||
btn->msw_rescale();
|
|
||||||
for (const auto bmp : m_scaled_bitmaps)
|
|
||||||
bmp->msw_rescale();
|
|
||||||
|
|
||||||
if (m_detach_preset_btn)
|
|
||||||
m_detach_preset_btn->msw_rescale();
|
|
||||||
|
|
||||||
// rescale icons for tree_ctrl
|
|
||||||
for (ScalableBitmap& bmp : m_scaled_icons_list)
|
|
||||||
bmp.msw_rescale();
|
|
||||||
// recreate and set new ImageList for tree_ctrl
|
|
||||||
m_icons->RemoveAll();
|
|
||||||
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight());
|
|
||||||
for (ScalableBitmap& bmp : m_scaled_icons_list)
|
|
||||||
m_icons->Add(bmp.bmp());
|
|
||||||
m_treectrl->AssignImageList(m_icons);
|
|
||||||
|
|
||||||
// rescale options_groups
|
// rescale options_groups
|
||||||
if (m_active_page)
|
if (m_active_page)
|
||||||
m_active_page->msw_rescale();
|
m_active_page->msw_rescale();
|
||||||
@ -962,28 +932,28 @@ void Tab::sys_color_changed()
|
|||||||
|
|
||||||
// update buttons and cached bitmaps
|
// update buttons and cached bitmaps
|
||||||
for (const auto btn : m_scaled_buttons)
|
for (const auto btn : m_scaled_buttons)
|
||||||
btn->msw_rescale();
|
btn->sys_color_changed();
|
||||||
for (const auto bmp : m_scaled_bitmaps)
|
for (const auto bmp : m_scaled_bitmaps)
|
||||||
bmp->msw_rescale();
|
bmp->sys_color_changed();
|
||||||
if (m_detach_preset_btn)
|
if (m_detach_preset_btn)
|
||||||
m_detach_preset_btn->msw_rescale();
|
m_detach_preset_btn->sys_color_changed();
|
||||||
|
|
||||||
|
update_show_hide_incompatible_button();
|
||||||
|
|
||||||
// update icons for tree_ctrl
|
// update icons for tree_ctrl
|
||||||
for (ScalableBitmap& bmp : m_scaled_icons_list)
|
wxVector <wxBitmapBundle> img_bundles;
|
||||||
bmp.msw_rescale();
|
for (ScalableBitmap& bmp : m_scaled_icons_list) {
|
||||||
// recreate and set new ImageList for tree_ctrl
|
bmp.sys_color_changed();
|
||||||
m_icons->RemoveAll();
|
img_bundles.push_back(bmp.bmp());
|
||||||
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight());
|
}
|
||||||
for (ScalableBitmap& bmp : m_scaled_icons_list)
|
m_treectrl->SetImages(img_bundles);
|
||||||
m_icons->Add(bmp.bmp());
|
|
||||||
m_treectrl->AssignImageList(m_icons);
|
|
||||||
|
|
||||||
// Colors for ui "decoration"
|
// Colors for ui "decoration"
|
||||||
update_label_colours();
|
update_label_colours();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
wxWindowUpdateLocker noUpdates(this);
|
wxWindowUpdateLocker noUpdates(this);
|
||||||
if (m_mode_sizer)
|
if (m_mode_sizer)
|
||||||
m_mode_sizer->msw_rescale();
|
m_mode_sizer->sys_color_changed();
|
||||||
wxGetApp().UpdateDarkUI(this);
|
wxGetApp().UpdateDarkUI(this);
|
||||||
wxGetApp().UpdateDarkUI(m_treectrl);
|
wxGetApp().UpdateDarkUI(m_treectrl);
|
||||||
#endif
|
#endif
|
||||||
@ -994,6 +964,7 @@ void Tab::sys_color_changed()
|
|||||||
m_active_page->sys_color_changed();
|
m_active_page->sys_color_changed();
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
|
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
|
||||||
@ -1257,7 +1228,7 @@ void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup)
|
|||||||
|
|
||||||
auto detach_preset_btn = [this](wxWindow* parent) {
|
auto detach_preset_btn = [this](wxWindow* parent) {
|
||||||
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_open_sys", _L("Detach from system preset"),
|
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_open_sys", _L("Detach from system preset"),
|
||||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
|
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
ScalableButton* btn = m_detach_preset_btn;
|
ScalableButton* btn = m_detach_preset_btn;
|
||||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||||
|
|
||||||
@ -1681,14 +1652,14 @@ void TabPrint::build()
|
|||||||
option.opt.height = 5;//50;
|
option.opt.height = 5;//50;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Notes"), "note.png");
|
page = add_options_page(L("Notes"), "note");
|
||||||
optgroup = page->new_optgroup(L("Notes"), 0);
|
optgroup = page->new_optgroup(L("Notes"), 0);
|
||||||
option = optgroup->get_option("notes");
|
option = optgroup->get_option("notes");
|
||||||
option.opt.full_width = true;
|
option.opt.full_width = true;
|
||||||
option.opt.height = 25;//250;
|
option.opt.height = 25;//250;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Dependencies"), "wrench.png");
|
page = add_options_page(L("Dependencies"), "wrench");
|
||||||
optgroup = page->new_optgroup(L("Profile dependencies"));
|
optgroup = page->new_optgroup(L("Profile dependencies"));
|
||||||
|
|
||||||
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
||||||
@ -1928,7 +1899,7 @@ void TabFilament::build()
|
|||||||
m_presets = &m_preset_bundle->filaments;
|
m_presets = &m_preset_bundle->filaments;
|
||||||
load_initial_data();
|
load_initial_data();
|
||||||
|
|
||||||
auto page = add_options_page(L("Filament"), "spool.png");
|
auto page = add_options_page(L("Filament"), "spool");
|
||||||
auto optgroup = page->new_optgroup(L("Filament"));
|
auto optgroup = page->new_optgroup(L("Filament"));
|
||||||
optgroup->append_single_option_line("filament_colour");
|
optgroup->append_single_option_line("filament_colour");
|
||||||
optgroup->append_single_option_line("filament_diameter");
|
optgroup->append_single_option_line("filament_diameter");
|
||||||
@ -2068,7 +2039,7 @@ void TabFilament::build()
|
|||||||
option.opt.height = gcode_field_height;// 150;
|
option.opt.height = gcode_field_height;// 150;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Notes"), "note.png");
|
page = add_options_page(L("Notes"), "note");
|
||||||
optgroup = page->new_optgroup(L("Notes"), 0);
|
optgroup = page->new_optgroup(L("Notes"), 0);
|
||||||
optgroup->label_width = 0;
|
optgroup->label_width = 0;
|
||||||
option = optgroup->get_option("filament_notes");
|
option = optgroup->get_option("filament_notes");
|
||||||
@ -2076,7 +2047,7 @@ void TabFilament::build()
|
|||||||
option.opt.height = notes_field_height;// 250;
|
option.opt.height = notes_field_height;// 250;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Dependencies"), "wrench.png");
|
page = add_options_page(L("Dependencies"), "wrench");
|
||||||
optgroup = page->new_optgroup(L("Profile dependencies"));
|
optgroup = page->new_optgroup(L("Profile dependencies"));
|
||||||
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
||||||
return compatible_widget_create(parent, m_compatible_printers);
|
return compatible_widget_create(parent, m_compatible_printers);
|
||||||
@ -2460,14 +2431,14 @@ void TabPrinter::build_fff()
|
|||||||
option.opt.height = gcode_field_height;//150;
|
option.opt.height = gcode_field_height;//150;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Notes"), "note.png");
|
page = add_options_page(L("Notes"), "note");
|
||||||
optgroup = page->new_optgroup(L("Notes"), 0);
|
optgroup = page->new_optgroup(L("Notes"), 0);
|
||||||
option = optgroup->get_option("printer_notes");
|
option = optgroup->get_option("printer_notes");
|
||||||
option.opt.full_width = true;
|
option.opt.full_width = true;
|
||||||
option.opt.height = notes_field_height;//250;
|
option.opt.height = notes_field_height;//250;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Dependencies"), "wrench.png");
|
page = add_options_page(L("Dependencies"), "wrench");
|
||||||
optgroup = page->new_optgroup(L("Profile dependencies"));
|
optgroup = page->new_optgroup(L("Profile dependencies"));
|
||||||
|
|
||||||
build_preset_description_line(optgroup.get());
|
build_preset_description_line(optgroup.get());
|
||||||
@ -2538,14 +2509,14 @@ void TabPrinter::build_sla()
|
|||||||
|
|
||||||
const int notes_field_height = 25; // 250
|
const int notes_field_height = 25; // 250
|
||||||
|
|
||||||
page = add_options_page(L("Notes"), "note.png");
|
page = add_options_page(L("Notes"), "note");
|
||||||
optgroup = page->new_optgroup(L("Notes"), 0);
|
optgroup = page->new_optgroup(L("Notes"), 0);
|
||||||
option = optgroup->get_option("printer_notes");
|
option = optgroup->get_option("printer_notes");
|
||||||
option.opt.full_width = true;
|
option.opt.full_width = true;
|
||||||
option.opt.height = notes_field_height;//250;
|
option.opt.height = notes_field_height;//250;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Dependencies"), "wrench.png");
|
page = add_options_page(L("Dependencies"), "wrench");
|
||||||
optgroup = page->new_optgroup(L("Profile dependencies"));
|
optgroup = page->new_optgroup(L("Profile dependencies"));
|
||||||
|
|
||||||
build_preset_description_line(optgroup.get());
|
build_preset_description_line(optgroup.get());
|
||||||
@ -2803,7 +2774,7 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
|
|||||||
|
|
||||||
auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) {
|
auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) {
|
||||||
m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
|
m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
|
||||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
|
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
ScalableButton* btn = m_reset_to_filament_color;
|
ScalableButton* btn = m_reset_to_filament_color;
|
||||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||||
btn->SetSize(btn->GetBestSize());
|
btn->SetSize(btn->GetBestSize());
|
||||||
@ -3780,8 +3751,7 @@ void Tab::toggle_show_hide_incompatible()
|
|||||||
|
|
||||||
void Tab::update_show_hide_incompatible_button()
|
void Tab::update_show_hide_incompatible_button()
|
||||||
{
|
{
|
||||||
m_btn_hide_incompatible_presets->SetBitmap_(m_show_incompatible_presets ?
|
m_btn_hide_incompatible_presets->SetBitmap(*get_bmp_bundle(m_show_incompatible_presets ? "flag_red" : "flag_green"));
|
||||||
m_bmp_show_incompatible_presets : m_bmp_hide_incompatible_presets);
|
|
||||||
m_btn_hide_incompatible_presets->SetToolTip(m_show_incompatible_presets ?
|
m_btn_hide_incompatible_presets->SetToolTip(m_show_incompatible_presets ?
|
||||||
"Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." :
|
"Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." :
|
||||||
"Only compatible presets are shown. Click to show both the presets compatible and not compatible with the current printer.");
|
"Only compatible presets are shown. Click to show both the presets compatible and not compatible with the current printer.");
|
||||||
@ -3830,7 +3800,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
|
|||||||
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||||
wxGetApp().UpdateDarkUI(deps.checkbox, false, true);
|
wxGetApp().UpdateDarkUI(deps.checkbox, false, true);
|
||||||
deps.btn = new ScalableButton(parent, wxID_ANY, "printer", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
|
deps.btn = new ScalableButton(parent, wxID_ANY, "printer", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
|
||||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
|
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||||
deps.btn->SetSize(deps.btn->GetBestSize());
|
deps.btn->SetSize(deps.btn->GetBestSize());
|
||||||
|
|
||||||
@ -4139,7 +4109,7 @@ bool SubstitutionManager::is_empty_substitutions()
|
|||||||
wxSizer* TabPrint::create_manage_substitution_widget(wxWindow* parent)
|
wxSizer* TabPrint::create_manage_substitution_widget(wxWindow* parent)
|
||||||
{
|
{
|
||||||
auto create_btn = [parent](ScalableButton** btn, const wxString& label, const std::string& icon_name) {
|
auto create_btn = [parent](ScalableButton** btn, const wxString& label, const std::string& icon_name) {
|
||||||
*btn = new ScalableButton(parent, wxID_ANY, icon_name, " " + label + " ", wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
|
*btn = new ScalableButton(parent, wxID_ANY, icon_name, " " + label + " ", wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
(*btn)->SetFont(wxGetApp().normal_font());
|
(*btn)->SetFont(wxGetApp().normal_font());
|
||||||
(*btn)->SetSize((*btn)->GetBestSize());
|
(*btn)->SetSize((*btn)->GetBestSize());
|
||||||
};
|
};
|
||||||
@ -4192,7 +4162,7 @@ wxSizer* TabPrint::create_substitutions_widget(wxWindow* parent)
|
|||||||
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
|
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
|
||||||
{
|
{
|
||||||
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer", " " + _(L("Set")) + " " + dots,
|
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer", " " + _(L("Set")) + " " + dots,
|
||||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
|
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
btn->SetFont(wxGetApp().normal_font());
|
btn->SetFont(wxGetApp().normal_font());
|
||||||
btn->SetSize(btn->GetBestSize());
|
btn->SetSize(btn->GetBestSize());
|
||||||
|
|
||||||
@ -4586,7 +4556,7 @@ void TabSLAMaterial::build()
|
|||||||
|
|
||||||
optgroup->append_line(line);
|
optgroup->append_line(line);
|
||||||
|
|
||||||
page = add_options_page(L("Notes"), "note.png");
|
page = add_options_page(L("Notes"), "note");
|
||||||
optgroup = page->new_optgroup(L("Notes"), 0);
|
optgroup = page->new_optgroup(L("Notes"), 0);
|
||||||
optgroup->label_width = 0;
|
optgroup->label_width = 0;
|
||||||
Option option = optgroup->get_option("material_notes");
|
Option option = optgroup->get_option("material_notes");
|
||||||
@ -4594,7 +4564,7 @@ void TabSLAMaterial::build()
|
|||||||
option.opt.height = 25;//250;
|
option.opt.height = 25;//250;
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
|
||||||
page = add_options_page(L("Dependencies"), "wrench.png");
|
page = add_options_page(L("Dependencies"), "wrench");
|
||||||
optgroup = page->new_optgroup(L("Profile dependencies"));
|
optgroup = page->new_optgroup(L("Profile dependencies"));
|
||||||
|
|
||||||
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
||||||
@ -4615,7 +4585,7 @@ void TabSLAMaterial::build()
|
|||||||
|
|
||||||
build_preset_description_line(optgroup.get());
|
build_preset_description_line(optgroup.get());
|
||||||
|
|
||||||
page = add_options_page(L("Material printing profile"), "note.png");
|
page = add_options_page(L("Material printing profile"), "note");
|
||||||
optgroup = page->new_optgroup(L("Material printing profile"));
|
optgroup = page->new_optgroup(L("Material printing profile"));
|
||||||
option = optgroup->get_option("material_print_speed");
|
option = optgroup->get_option("material_print_speed");
|
||||||
optgroup->append_single_option_line(option);
|
optgroup->append_single_option_line(option);
|
||||||
|
@ -174,7 +174,6 @@ protected:
|
|||||||
wxBoxSizer* m_hsizer;
|
wxBoxSizer* m_hsizer;
|
||||||
wxBoxSizer* m_left_sizer;
|
wxBoxSizer* m_left_sizer;
|
||||||
wxTreeCtrl* m_treectrl;
|
wxTreeCtrl* m_treectrl;
|
||||||
wxImageList* m_icons;
|
|
||||||
|
|
||||||
wxScrolledWindow* m_page_view {nullptr};
|
wxScrolledWindow* m_page_view {nullptr};
|
||||||
wxBoxSizer* m_page_sizer {nullptr};
|
wxBoxSizer* m_page_sizer {nullptr};
|
||||||
@ -203,10 +202,6 @@ protected:
|
|||||||
ScalableButton* m_undo_to_sys_btn;
|
ScalableButton* m_undo_to_sys_btn;
|
||||||
ScalableButton* m_question_btn;
|
ScalableButton* m_question_btn;
|
||||||
|
|
||||||
// Cached bitmaps.
|
|
||||||
// A "flag" icon to be displayned next to the preset name in the Tab's combo box.
|
|
||||||
ScalableBitmap m_bmp_show_incompatible_presets;
|
|
||||||
ScalableBitmap m_bmp_hide_incompatible_presets;
|
|
||||||
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
|
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
|
||||||
ScalableBitmap m_bmp_value_lock;
|
ScalableBitmap m_bmp_value_lock;
|
||||||
ScalableBitmap m_bmp_value_unlock;
|
ScalableBitmap m_bmp_value_unlock;
|
||||||
@ -505,7 +500,6 @@ public:
|
|||||||
void build_unregular_pages(bool from_initial_build = false);
|
void build_unregular_pages(bool from_initial_build = false);
|
||||||
void on_preset_loaded() override;
|
void on_preset_loaded() override;
|
||||||
void init_options_list() override;
|
void init_options_list() override;
|
||||||
void msw_rescale() override;
|
|
||||||
bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; }
|
bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; }
|
||||||
|
|
||||||
wxSizer* create_bed_shape_widget(wxWindow* parent);
|
wxSizer* create_bed_shape_widget(wxWindow* parent);
|
||||||
|
@ -115,29 +115,21 @@ wxIcon ModelNode::get_bitmap(const wxString& color)
|
|||||||
wxBitmap ModelNode::get_bitmap(const wxString& color)
|
wxBitmap ModelNode::get_bitmap(const wxString& color)
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
{
|
{
|
||||||
/* It's supposed that standard size of an icon is 48px*16px for 100% scaled display.
|
wxBitmap bmp = get_solid_bmp_bundle(64, 16, into_u8(color))->GetBitmapFor(m_parent_win);
|
||||||
* So set sizes for solid_colored icons used for filament preset
|
if (!m_toggle)
|
||||||
* and scale them in respect to em_unit value
|
bmp = bmp.ConvertToDisabled();
|
||||||
*/
|
|
||||||
const double em = em_unit(m_parent_win);
|
|
||||||
const int icon_width = lround(6.4 * em);
|
|
||||||
const int icon_height = lround(1.6 * em);
|
|
||||||
|
|
||||||
BitmapCache bmp_cache;
|
|
||||||
ColorRGB rgb;
|
|
||||||
decode_color(into_u8(color), rgb);
|
|
||||||
// there is no need to scale created solid bitmap
|
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
|
return bmp;
|
||||||
#else
|
#else
|
||||||
wxIcon icon;
|
wxIcon icon;
|
||||||
icon.CopyFromBitmap(bmp_cache.mksolid(icon_width, icon_height, rgb, true));
|
icon.CopyFromBitmap(bmp);
|
||||||
return icon;
|
return icon;
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
}
|
}
|
||||||
|
|
||||||
// option node
|
// option node
|
||||||
ModelNode::ModelNode(ModelNode* parent, const wxString& text, const wxString& old_value, const wxString& new_value) :
|
ModelNode::ModelNode(ModelNode* parent, const wxString& text, const wxString& old_value, const wxString& new_value) :
|
||||||
|
m_parent_win(parent->m_parent_win),
|
||||||
m_parent(parent),
|
m_parent(parent),
|
||||||
m_old_color(old_value.StartsWith("#") ? old_value : ""),
|
m_old_color(old_value.StartsWith("#") ? old_value : ""),
|
||||||
m_new_color(new_value.StartsWith("#") ? new_value : ""),
|
m_new_color(new_value.StartsWith("#") ? new_value : ""),
|
||||||
@ -202,18 +194,22 @@ void ModelNode::UpdateIcons()
|
|||||||
{
|
{
|
||||||
// update icons for the colors, if any exists
|
// update icons for the colors, if any exists
|
||||||
if (!m_old_color.IsEmpty())
|
if (!m_old_color.IsEmpty())
|
||||||
m_old_color_bmp = get_bitmap(m_toggle ? m_old_color : wxString::FromUTF8(grey.c_str()));
|
m_old_color_bmp = get_bitmap(m_old_color);
|
||||||
if (!m_new_color.IsEmpty())
|
if (!m_new_color.IsEmpty())
|
||||||
m_new_color_bmp = get_bitmap(m_toggle ? m_new_color : wxString::FromUTF8(grey.c_str()));
|
m_new_color_bmp = get_bitmap(m_new_color);
|
||||||
|
|
||||||
// update main icon, if any exists
|
// update main icon, if any exists
|
||||||
if (m_icon_name.empty())
|
if (m_icon_name.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
wxBitmap bmp = get_bmp_bundle(m_icon_name)->GetBitmapFor(m_parent_win);
|
||||||
|
if (!m_toggle)
|
||||||
|
bmp = bmp.ConvertToDisabled();
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
m_icon.CopyFromBitmap(create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle));
|
m_icon.CopyFromBitmap(bmp);
|
||||||
#else
|
#else
|
||||||
m_icon = create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle);
|
m_icon = bmp;
|
||||||
#endif //__linux__
|
#endif //__linux__
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,7 +834,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
|
|||||||
|
|
||||||
auto add_btn = [this, buttons, btn_font, dependent_presets](ScalableButton** btn, int& btn_id, const std::string& icon_name, Action close_act, const wxString& label, bool process_enable = true)
|
auto add_btn = [this, buttons, btn_font, dependent_presets](ScalableButton** btn, int& btn_id, const std::string& icon_name, Action close_act, const wxString& label, bool process_enable = true)
|
||||||
{
|
{
|
||||||
*btn = new ScalableButton(this, btn_id = NewControlId(), icon_name, label, wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true, 24);
|
*btn = new ScalableButton(this, btn_id = NewControlId(), icon_name, label, wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, 24);
|
||||||
|
|
||||||
buttons->Add(*btn, 1, wxLEFT, 5);
|
buttons->Add(*btn, 1, wxLEFT, 5);
|
||||||
(*btn)->SetFont(btn_font);
|
(*btn)->SetFont(btn_font);
|
||||||
@ -876,7 +872,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
|
|||||||
if (ActionButtons::SAVE & m_buttons)
|
if (ActionButtons::SAVE & m_buttons)
|
||||||
add_btn(&m_save_btn, m_save_btn_id, "save", Action::Save, _L("Save"));
|
add_btn(&m_save_btn, m_save_btn_id, "save", Action::Save, _L("Save"));
|
||||||
|
|
||||||
ScalableButton* cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true, 24);
|
ScalableButton* cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, 24);
|
||||||
buttons->Add(cancel_btn, 1, wxLEFT|wxRIGHT, 5);
|
buttons->Add(cancel_btn, 1, wxLEFT|wxRIGHT, 5);
|
||||||
cancel_btn->SetFont(btn_font);
|
cancel_btn->SetFont(btn_font);
|
||||||
cancel_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) { this->EndModal(wxID_CANCEL); });
|
cancel_btn->Bind(wxEVT_BUTTON, [this](wxEvent&) { this->EndModal(wxID_CANCEL); });
|
||||||
@ -1310,8 +1306,6 @@ void UnsavedChangesDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||||||
int em = em_unit();
|
int em = em_unit();
|
||||||
|
|
||||||
msw_buttons_rescale(this, em, { wxID_CANCEL, m_save_btn_id, m_move_btn_id, m_continue_btn_id });
|
msw_buttons_rescale(this, em, { wxID_CANCEL, m_save_btn_id, m_move_btn_id, m_continue_btn_id });
|
||||||
for (auto btn : { m_save_btn, m_transfer_btn, m_discard_btn } )
|
|
||||||
if (btn) btn->msw_rescale();
|
|
||||||
|
|
||||||
const wxSize& size = wxSize(70 * em, 30 * em);
|
const wxSize& size = wxSize(70 * em, 30 * em);
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
@ -1325,7 +1319,7 @@ void UnsavedChangesDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||||||
void UnsavedChangesDialog::on_sys_color_changed()
|
void UnsavedChangesDialog::on_sys_color_changed()
|
||||||
{
|
{
|
||||||
for (auto btn : { m_save_btn, m_transfer_btn, m_discard_btn } )
|
for (auto btn : { m_save_btn, m_transfer_btn, m_discard_btn } )
|
||||||
btn->msw_rescale();
|
btn->sys_color_changed();
|
||||||
// msw_rescale updates just icons, so use it
|
// msw_rescale updates just icons, so use it
|
||||||
m_tree->Rescale();
|
m_tree->Rescale();
|
||||||
|
|
||||||
@ -1726,10 +1720,16 @@ void DiffPresetDialog::on_dpi_changed(const wxRect&)
|
|||||||
const wxSize& size = wxSize(80 * em, 30 * em);
|
const wxSize& size = wxSize(80 * em, 30 * em);
|
||||||
SetMinSize(size);
|
SetMinSize(size);
|
||||||
|
|
||||||
|
auto rescale = [em](PresetComboBox* pcb) {
|
||||||
|
pcb->msw_rescale();
|
||||||
|
wxSize sz = wxSize(35 * em, -1);
|
||||||
|
pcb->SetMinSize(sz);
|
||||||
|
pcb->SetSize(sz);
|
||||||
|
};
|
||||||
|
|
||||||
for (auto preset_combos : m_preset_combos) {
|
for (auto preset_combos : m_preset_combos) {
|
||||||
preset_combos.presets_left->msw_rescale();
|
rescale(preset_combos.presets_left);
|
||||||
preset_combos.equal_bmp->msw_rescale();
|
rescale(preset_combos.presets_right);
|
||||||
preset_combos.presets_right->msw_rescale();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tree->Rescale(em);
|
m_tree->Rescale(em);
|
||||||
@ -1747,9 +1747,9 @@ void DiffPresetDialog::on_sys_color_changed()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (auto preset_combos : m_preset_combos) {
|
for (auto preset_combos : m_preset_combos) {
|
||||||
preset_combos.presets_left->msw_rescale();
|
preset_combos.presets_left->sys_color_changed();
|
||||||
preset_combos.equal_bmp->msw_rescale();
|
preset_combos.equal_bmp->sys_color_changed();
|
||||||
preset_combos.presets_right->msw_rescale();
|
preset_combos.presets_right->sys_color_changed();
|
||||||
}
|
}
|
||||||
// msw_rescale updates just icons, so use it
|
// msw_rescale updates just icons, so use it
|
||||||
m_tree->Rescale();
|
m_tree->Rescale();
|
||||||
|
@ -24,18 +24,15 @@
|
|||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
// msw_menuitem_bitmaps is used for MSW and OSX
|
// msw_menuitem_bitmaps is used for MSW and OSX
|
||||||
static std::map<int, std::string> msw_menuitem_bitmaps;
|
static std::map<int, std::string> msw_menuitem_bitmaps;
|
||||||
#ifdef __WXMSW__
|
void sys_color_changed_menu(wxMenu* menu)
|
||||||
void msw_rescale_menu(wxMenu* menu)
|
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
struct update_icons {
|
struct update_icons {
|
||||||
static void run(wxMenuItem* item) {
|
static void run(wxMenuItem* item) {
|
||||||
const auto it = msw_menuitem_bitmaps.find(item->GetId());
|
const auto it = msw_menuitem_bitmaps.find(item->GetId());
|
||||||
if (it != msw_menuitem_bitmaps.end()) {
|
if (it != msw_menuitem_bitmaps.end()) {
|
||||||
// const wxBitmap& item_icon = create_menu_bitmap(it->second);
|
wxBitmapBundle* item_icon = get_bmp_bundle(it->second);
|
||||||
const wxBitmapBundle& item_icon = create_menu_bitmap(it->second);
|
if (item_icon->IsOk())
|
||||||
if (item_icon.IsOk())
|
item->SetBitmap(*item_icon);
|
||||||
item->SetBitmap(item_icon);
|
|
||||||
}
|
}
|
||||||
if (item->IsSubMenu())
|
if (item->IsSubMenu())
|
||||||
for (wxMenuItem *sub_item : item->GetSubMenu()->GetMenuItems())
|
for (wxMenuItem *sub_item : item->GetSubMenu()->GetMenuItems())
|
||||||
@ -46,36 +43,24 @@ void msw_rescale_menu(wxMenu* menu)
|
|||||||
for (wxMenuItem *item : menu->GetMenuItems())
|
for (wxMenuItem *item : menu->GetMenuItems())
|
||||||
update_icons::run(item);
|
update_icons::run(item);
|
||||||
}
|
}
|
||||||
#endif /* __WXMSW__ */
|
#endif /* no __linux__ */
|
||||||
#endif /* no __WXGTK__ */
|
|
||||||
|
|
||||||
void enable_menu_item(wxUpdateUIEvent& evt, std::function<bool()> const cb_condition, wxMenuItem* item, wxWindow* win)
|
void enable_menu_item(wxUpdateUIEvent& evt, std::function<bool()> const cb_condition, wxMenuItem* item, wxWindow* win)
|
||||||
{
|
{
|
||||||
const bool enable = cb_condition();
|
const bool enable = cb_condition();
|
||||||
evt.Enable(enable);
|
evt.Enable(enable);
|
||||||
|
|
||||||
#ifdef __WXOSX__
|
|
||||||
const auto it = msw_menuitem_bitmaps.find(item->GetId());
|
|
||||||
if (it != msw_menuitem_bitmaps.end())
|
|
||||||
{
|
|
||||||
const wxBitmap& item_icon = create_scaled_bitmap(it->second, win, 16, !enable);
|
|
||||||
if (item_icon.IsOk())
|
|
||||||
item->SetBitmap(item_icon);
|
|
||||||
}
|
|
||||||
#endif // __WXOSX__
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
||||||
// std::function<void(wxCommandEvent& event)> cb, const wxBitmap& icon, wxEvtHandler* event_handler,
|
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler,
|
||||||
std::function<void(wxCommandEvent& event)> cb, const wxBitmapBundle& icon, wxEvtHandler* event_handler,
|
|
||||||
std::function<bool()> const cb_condition, wxWindow* parent, int insert_pos/* = wxNOT_FOUND*/)
|
std::function<bool()> const cb_condition, wxWindow* parent, int insert_pos/* = wxNOT_FOUND*/)
|
||||||
{
|
{
|
||||||
if (id == wxID_ANY)
|
if (id == wxID_ANY)
|
||||||
id = wxNewId();
|
id = wxNewId();
|
||||||
|
|
||||||
auto *item = new wxMenuItem(menu, id, string, description);
|
auto *item = new wxMenuItem(menu, id, string, description);
|
||||||
if (icon.IsOk()) {
|
if (icon && icon->IsOk()) {
|
||||||
item->SetBitmap(icon);
|
item->SetBitmap(*icon);
|
||||||
}
|
}
|
||||||
if (insert_pos == wxNOT_FOUND)
|
if (insert_pos == wxNOT_FOUND)
|
||||||
menu->Append(item);
|
menu->Append(item);
|
||||||
@ -104,14 +89,12 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
|
|||||||
if (id == wxID_ANY)
|
if (id == wxID_ANY)
|
||||||
id = wxNewId();
|
id = wxNewId();
|
||||||
|
|
||||||
// const wxBitmap& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
|
wxBitmapBundle* bmp = icon.empty() ? nullptr : get_bmp_bundle(icon);
|
||||||
const wxBitmapBundle& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
|
|
||||||
|
|
||||||
//#ifdef __WXMSW__
|
#ifndef __linux__
|
||||||
#ifndef __WXGTK__
|
if (bmp && bmp->IsOk())
|
||||||
if (bmp.IsOk())
|
|
||||||
msw_menuitem_bitmaps[id] = icon;
|
msw_menuitem_bitmaps[id] = icon;
|
||||||
#endif /* __WXMSW__ */
|
#endif /* no __linux__ */
|
||||||
|
|
||||||
return append_menu_item(menu, id, string, description, cb, bmp, event_handler, cb_condition, parent, insert_pos);
|
return append_menu_item(menu, id, string, description, cb, bmp, event_handler, cb_condition, parent, insert_pos);
|
||||||
}
|
}
|
||||||
@ -124,7 +107,7 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
|
|||||||
|
|
||||||
wxMenuItem* item = new wxMenuItem(menu, id, string, description);
|
wxMenuItem* item = new wxMenuItem(menu, id, string, description);
|
||||||
if (!icon.empty()) {
|
if (!icon.empty()) {
|
||||||
item->SetBitmap(create_menu_bitmap(icon)); // FIXME: pass window ptr
|
item->SetBitmap(*get_bmp_bundle(icon));
|
||||||
//#ifdef __WXMSW__
|
//#ifdef __WXMSW__
|
||||||
#ifndef __WXGTK__
|
#ifndef __WXGTK__
|
||||||
msw_menuitem_bitmaps[id] = icon;
|
msw_menuitem_bitmaps[id] = icon;
|
||||||
@ -426,11 +409,34 @@ int mode_icon_px_size()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//wxBitmap create_menu_bitmap(const std::string& bmp_name)
|
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/)
|
||||||
wxBitmapBundle create_menu_bitmap(const std::string& bmp_name)
|
|
||||||
{
|
{
|
||||||
// return create_scaled_bitmap(bmp_name, nullptr, 16, false, "", true);
|
static Slic3r::GUI::BitmapCache cache;
|
||||||
return wxBitmapBundle::FromSVGFile(Slic3r::var(bmp_name + ".svg"), wxSize(16, 16));
|
|
||||||
|
std::string bmp_name = bmp_name_in;
|
||||||
|
boost::replace_last(bmp_name, ".png", "");
|
||||||
|
|
||||||
|
// Try loading an SVG first, then PNG if SVG is not found:
|
||||||
|
wxBitmapBundle* bmp = cache.from_svg(bmp_name, px_cnt, px_cnt, Slic3r::GUI::wxGetApp().dark_mode());
|
||||||
|
if (bmp == nullptr) {
|
||||||
|
bmp = cache.from_png(bmp_name, px_cnt, px_cnt);
|
||||||
|
if (!bmp)
|
||||||
|
// Neither SVG nor PNG has been found, raise error
|
||||||
|
throw Slic3r::RuntimeError("Could not load bitmap: " + bmp_name);
|
||||||
|
}
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* get_empty_bmp_bundle(int width, int height)
|
||||||
|
{
|
||||||
|
static Slic3r::GUI::BitmapCache cache;
|
||||||
|
return cache.mkclear_bndl(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color )
|
||||||
|
{
|
||||||
|
static Slic3r::GUI::BitmapCache cache;
|
||||||
|
return cache.mksolid_bndl(width, height, color, 1, Slic3r::GUI::wxGetApp().dark_mode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// win is used to get a correct em_unit value
|
// win is used to get a correct em_unit value
|
||||||
@ -471,41 +477,19 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
|
|||||||
return *bmp;
|
return *bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
|
std::vector<wxBitmapBundle*> get_extruder_color_icons(bool thin_icon/* = false*/)
|
||||||
{
|
{
|
||||||
static Slic3r::GUI::BitmapCache bmp_cache;
|
|
||||||
|
|
||||||
// Create the bitmap with color bars.
|
// Create the bitmap with color bars.
|
||||||
std::vector<wxBitmap*> bmps;
|
std::vector<wxBitmapBundle*> bmps;
|
||||||
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||||
|
|
||||||
if (colors.empty())
|
if (colors.empty())
|
||||||
return bmps;
|
return bmps;
|
||||||
|
|
||||||
/* It's supposed that standard size of an icon is 36px*16px for 100% scaled display.
|
|
||||||
* So set sizes for solid_colored icons used for filament preset
|
|
||||||
* and scale them in respect to em_unit value
|
|
||||||
*/
|
|
||||||
const double em = Slic3r::GUI::wxGetApp().em_unit();
|
|
||||||
const int icon_width = lround((thin_icon ? 1.6 : 3.2) * em);
|
|
||||||
const int icon_height = lround(1.6 * em);
|
|
||||||
|
|
||||||
bool dark_mode = Slic3r::GUI::wxGetApp().dark_mode();
|
bool dark_mode = Slic3r::GUI::wxGetApp().dark_mode();
|
||||||
|
|
||||||
for (const std::string& color : colors)
|
for (const std::string& color : colors)
|
||||||
{
|
bmps.emplace_back(get_solid_bmp_bundle(thin_icon ? 16 : 32, 16, color));
|
||||||
std::string bitmap_key = color + "-h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width);
|
|
||||||
|
|
||||||
wxBitmap* bitmap = bmp_cache.find(bitmap_key);
|
|
||||||
if (bitmap == nullptr) {
|
|
||||||
// Paint the color icon.
|
|
||||||
Slic3r::ColorRGB rgb;
|
|
||||||
Slic3r::decode_color(color, rgb);
|
|
||||||
// there is no neede to scale created solid bitmap
|
|
||||||
bitmap = bmp_cache.insert(bitmap_key, bmp_cache.mksolid(icon_width, icon_height, rgb, true, 1, dark_mode));
|
|
||||||
}
|
|
||||||
bmps.emplace_back(bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bmps;
|
return bmps;
|
||||||
}
|
}
|
||||||
@ -518,7 +502,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
|
|||||||
wxSize size/* = wxDefaultSize*/,
|
wxSize size/* = wxDefaultSize*/,
|
||||||
bool use_thin_icon/* = false*/)
|
bool use_thin_icon/* = false*/)
|
||||||
{
|
{
|
||||||
std::vector<wxBitmap*> icons = get_extruder_color_icons(use_thin_icon);
|
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(use_thin_icon);
|
||||||
|
|
||||||
if (!*ctrl) {
|
if (!*ctrl) {
|
||||||
*ctrl = new Slic3r::GUI::BitmapComboBox(parent, wxID_ANY, wxEmptyString, pos, size, 0, nullptr, wxCB_READONLY);
|
*ctrl = new Slic3r::GUI::BitmapComboBox(parent, wxID_ANY, wxEmptyString, pos, size, 0, nullptr, wxCB_READONLY);
|
||||||
@ -544,7 +528,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
wxString str = _(L("Extruder"));
|
wxString str = _(L("Extruder"));
|
||||||
for (wxBitmap* bmp : icons) {
|
for (wxBitmapBundle* bmp : icons) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (!first_item.empty())
|
if (!first_item.empty())
|
||||||
(*ctrl)->Append(_(first_item), *bmp);
|
(*ctrl)->Append(_(first_item), *bmp);
|
||||||
@ -578,7 +562,7 @@ LockButton::LockButton( wxWindow *parent,
|
|||||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||||
SetBitmap(m_bmp_lock_open.bmp());
|
SetBitmap(m_bmp_lock_open.bmp());
|
||||||
SetBitmapDisabled(m_bmp_lock_open.bmp());
|
SetBitmapDisabled(m_bmp_lock_open.bmp());
|
||||||
SetBitmapHover(m_bmp_lock_closed_f.bmp());
|
SetBitmapCurrent(m_bmp_lock_closed_f.bmp());
|
||||||
|
|
||||||
//button events
|
//button events
|
||||||
Bind(wxEVT_BUTTON, &LockButton::OnButton, this);
|
Bind(wxEVT_BUTTON, &LockButton::OnButton, this);
|
||||||
@ -607,13 +591,14 @@ void LockButton::SetLock(bool lock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LockButton::msw_rescale()
|
void LockButton::sys_color_changed()
|
||||||
{
|
{
|
||||||
return;
|
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||||
m_bmp_lock_closed.msw_rescale();
|
|
||||||
m_bmp_lock_closed_f.msw_rescale();
|
m_bmp_lock_closed.sys_color_changed();
|
||||||
m_bmp_lock_open.msw_rescale();
|
m_bmp_lock_closed_f.sys_color_changed();
|
||||||
m_bmp_lock_open_f.msw_rescale();
|
m_bmp_lock_open.sys_color_changed();
|
||||||
|
m_bmp_lock_open_f.sys_color_changed();
|
||||||
|
|
||||||
update_button_bitmaps();
|
update_button_bitmaps();
|
||||||
}
|
}
|
||||||
@ -621,7 +606,7 @@ void LockButton::msw_rescale()
|
|||||||
void LockButton::update_button_bitmaps()
|
void LockButton::update_button_bitmaps()
|
||||||
{
|
{
|
||||||
SetBitmap(m_is_pushed ? m_bmp_lock_closed.bmp() : m_bmp_lock_open.bmp());
|
SetBitmap(m_is_pushed ? m_bmp_lock_closed.bmp() : m_bmp_lock_open.bmp());
|
||||||
SetBitmapHover(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
|
SetBitmapCurrent(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
Update();
|
Update();
|
||||||
@ -648,8 +633,7 @@ ModeButton::ModeButton( wxWindow* parent,
|
|||||||
const wxString& mode/* = wxEmptyString*/,
|
const wxString& mode/* = wxEmptyString*/,
|
||||||
const std::string& icon_name/* = ""*/,
|
const std::string& icon_name/* = ""*/,
|
||||||
int px_cnt/* = 16*/) :
|
int px_cnt/* = 16*/) :
|
||||||
// ScalableButton(parent, wxID_ANY, ScalableBitmap(parent, icon_name, px_cnt), mode, wxBU_EXACTFIT)
|
ScalableButton(parent, wxID_ANY, icon_name, mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt)
|
||||||
ScalableButton(parent, wxID_ANY, icon_name, mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT)
|
|
||||||
{
|
{
|
||||||
Init(mode);
|
Init(mode);
|
||||||
}
|
}
|
||||||
@ -759,11 +743,10 @@ void ModeSizer::set_items_border(int border)
|
|||||||
item->SetBorder(border);
|
item->SetBorder(border);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeSizer::msw_rescale()
|
void ModeSizer::sys_color_changed()
|
||||||
{
|
{
|
||||||
this->SetHGap(std::lround(m_hgap_unscaled * em_unit(m_parent)));
|
|
||||||
for (size_t m = 0; m < m_mode_btns.size(); m++)
|
for (size_t m = 0; m < m_mode_btns.size(); m++)
|
||||||
m_mode_btns[m]->msw_rescale();
|
m_mode_btns[m]->sys_color_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -803,40 +786,13 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent,
|
|||||||
m_parent(parent), m_icon_name(icon_name),
|
m_parent(parent), m_icon_name(icon_name),
|
||||||
m_px_cnt(px_cnt)
|
m_px_cnt(px_cnt)
|
||||||
{
|
{
|
||||||
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, grayscale);
|
m_bmp = *get_bmp_bundle(icon_name, px_cnt);
|
||||||
|
m_bitmap = m_bmp.GetBitmapFor(m_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize ScalableBitmap::GetBmpSize() const
|
void ScalableBitmap::sys_color_changed()
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
m_bmp = *get_bmp_bundle(m_icon_name, m_px_cnt);
|
||||||
return m_bmp.GetScaledSize();
|
|
||||||
#else
|
|
||||||
return m_bmp.GetSize();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScalableBitmap::GetBmpWidth() const
|
|
||||||
{
|
|
||||||
#ifdef __APPLE__
|
|
||||||
return m_bmp.GetScaledWidth();
|
|
||||||
#else
|
|
||||||
return m_bmp.GetWidth();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScalableBitmap::GetBmpHeight() const
|
|
||||||
{
|
|
||||||
#ifdef __APPLE__
|
|
||||||
return m_bmp.GetScaledHeight();
|
|
||||||
#else
|
|
||||||
return m_bmp.GetHeight();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ScalableBitmap::msw_rescale()
|
|
||||||
{
|
|
||||||
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt, m_grayscale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -850,11 +806,9 @@ ScalableButton::ScalableButton( wxWindow * parent,
|
|||||||
const wxSize& size /* = wxDefaultSize*/,
|
const wxSize& size /* = wxDefaultSize*/,
|
||||||
const wxPoint& pos /* = wxDefaultPosition*/,
|
const wxPoint& pos /* = wxDefaultPosition*/,
|
||||||
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/,
|
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/,
|
||||||
bool use_default_disabled_bitmap/* = false*/,
|
|
||||||
int bmp_px_cnt/* = 16*/) :
|
int bmp_px_cnt/* = 16*/) :
|
||||||
m_parent(parent),
|
m_parent(parent),
|
||||||
m_current_icon_name(icon_name),
|
m_current_icon_name(icon_name),
|
||||||
m_use_default_disabled_bitmap (use_default_disabled_bitmap),
|
|
||||||
m_px_cnt(bmp_px_cnt),
|
m_px_cnt(bmp_px_cnt),
|
||||||
m_has_border(!(style & wxNO_BORDER))
|
m_has_border(!(style & wxNO_BORDER))
|
||||||
{
|
{
|
||||||
@ -862,10 +816,7 @@ ScalableButton::ScalableButton( wxWindow * parent,
|
|||||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||||
|
|
||||||
if (!icon_name.empty()) {
|
if (!icon_name.empty()) {
|
||||||
// SetBitmap(create_scaled_bitmap(icon_name, parent, m_px_cnt));
|
SetBitmap(*get_bmp_bundle(icon_name, m_px_cnt));
|
||||||
SetBitmap(wxBitmapBundle::FromSVGFile(Slic3r::var(icon_name + ".svg"), wxSize(m_px_cnt, m_px_cnt)));
|
|
||||||
//if (m_use_default_disabled_bitmap)
|
|
||||||
// SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
|
||||||
if (!label.empty())
|
if (!label.empty())
|
||||||
SetBitmapMargins(int(0.5* em_unit(parent)), 0);
|
SetBitmapMargins(int(0.5* em_unit(parent)), 0);
|
||||||
}
|
}
|
||||||
@ -907,14 +858,12 @@ bool ScalableButton::SetBitmap_(const std::string& bmp_name)
|
|||||||
if (m_current_icon_name.empty())
|
if (m_current_icon_name.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
|
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
|
||||||
wxBitmapBundle bmp = wxBitmapBundle::FromSVGFile(Slic3r::var(m_current_icon_name + ".svg"), wxSize(16, 16));
|
|
||||||
SetBitmap(bmp);
|
SetBitmap(bmp);
|
||||||
SetBitmapCurrent(bmp);
|
SetBitmapCurrent(bmp);
|
||||||
SetBitmapPressed(bmp);
|
SetBitmapPressed(bmp);
|
||||||
SetBitmapFocus(bmp);
|
SetBitmapFocus(bmp);
|
||||||
if (m_use_default_disabled_bitmap)
|
SetBitmapDisabled(bmp);
|
||||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,38 +882,21 @@ int ScalableButton::GetBitmapHeight()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScalableButton::UseDefaultBitmapDisabled()
|
void ScalableButton::sys_color_changed()
|
||||||
{
|
|
||||||
m_use_default_disabled_bitmap = true;
|
|
||||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScalableButton::msw_rescale()
|
|
||||||
{
|
{
|
||||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
|
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
|
||||||
|
|
||||||
// if (!m_current_icon_name.empty()) {
|
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
|
||||||
if (0) {
|
|
||||||
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
|
|
||||||
SetBitmap(bmp);
|
SetBitmap(bmp);
|
||||||
SetBitmapCurrent(bmp);
|
SetBitmapCurrent(bmp);
|
||||||
SetBitmapPressed(bmp);
|
SetBitmapPressed(bmp);
|
||||||
SetBitmapFocus(bmp);
|
SetBitmapFocus(bmp);
|
||||||
if (!m_disabled_icon_name.empty())
|
if (!m_disabled_icon_name.empty())
|
||||||
SetBitmapDisabled(create_scaled_bitmap(m_disabled_icon_name, m_parent, m_px_cnt));
|
SetBitmapDisabled(*get_bmp_bundle(m_disabled_icon_name, m_px_cnt));
|
||||||
else if (m_use_default_disabled_bitmap)
|
if (!GetLabelText().IsEmpty())
|
||||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
SetBitmapMargins(int(0.5 * em_unit(m_parent)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_width > 0 || m_height>0)
|
|
||||||
{
|
|
||||||
const int em = em_unit(m_parent);
|
|
||||||
wxSize size(m_width * em, m_height * em);
|
|
||||||
SetMinSize(size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// BlinkingBitmap
|
// BlinkingBitmap
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -975,13 +907,6 @@ BlinkingBitmap::BlinkingBitmap(wxWindow* parent, const std::string& icon_name) :
|
|||||||
bmp = ScalableBitmap(parent, icon_name);
|
bmp = ScalableBitmap(parent, icon_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlinkingBitmap::msw_rescale()
|
|
||||||
{
|
|
||||||
bmp.msw_rescale();
|
|
||||||
this->SetSize(bmp.GetBmpSize());
|
|
||||||
this->SetMinSize(bmp.GetBmpSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BlinkingBitmap::invalidate()
|
void BlinkingBitmap::invalidate()
|
||||||
{
|
{
|
||||||
this->SetBitmap(wxNullBitmap);
|
this->SetBitmap(wxNullBitmap);
|
||||||
|
@ -16,15 +16,14 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifndef __linux__
|
||||||
void msw_rescale_menu(wxMenu* menu);
|
void sys_color_changed_menu(wxMenu* menu);
|
||||||
#else /* __WXMSW__ */
|
#else
|
||||||
inline void msw_rescale_menu(wxMenu* /* menu */) {}
|
inline void sys_color_changed_menu(wxMenu* /* menu */) {}
|
||||||
#endif /* __WXMSW__ */
|
#endif // no __linux__
|
||||||
|
|
||||||
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
||||||
// std::function<void(wxCommandEvent& event)> cb, const wxBitmap& icon, wxEvtHandler* event_handler = nullptr,
|
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler = nullptr,
|
||||||
std::function<void(wxCommandEvent& event)> cb, const wxBitmapBundle& icon, wxEvtHandler* event_handler = nullptr,
|
|
||||||
std::function<bool()> const cb_condition = []() { return true;}, wxWindow* parent = nullptr, int insert_pos = wxNOT_FOUND);
|
std::function<bool()> const cb_condition = []() { return true;}, wxWindow* parent = nullptr, int insert_pos = wxNOT_FOUND);
|
||||||
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
||||||
std::function<void(wxCommandEvent& event)> cb, const std::string& icon = "", wxEvtHandler* event_handler = nullptr,
|
std::function<void(wxCommandEvent& event)> cb, const std::string& icon = "", wxEvtHandler* event_handler = nullptr,
|
||||||
@ -51,15 +50,16 @@ void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<
|
|||||||
int em_unit(wxWindow* win);
|
int em_unit(wxWindow* win);
|
||||||
int mode_icon_px_size();
|
int mode_icon_px_size();
|
||||||
|
|
||||||
//wxBitmap create_menu_bitmap(const std::string& bmp_name);
|
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int px_cnt = 16);
|
||||||
wxBitmapBundle create_menu_bitmap(const std::string& bmp_name);
|
wxBitmapBundle* get_empty_bmp_bundle(int width, int height);
|
||||||
|
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color);
|
||||||
|
|
||||||
wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullptr,
|
wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullptr,
|
||||||
const int px_cnt = 16, const bool grayscale = false,
|
const int px_cnt = 16, const bool grayscale = false,
|
||||||
const std::string& new_color = std::string(), // color witch will used instead of orange
|
const std::string& new_color = std::string(), // color witch will used instead of orange
|
||||||
const bool menu_bitmap = false);
|
const bool menu_bitmap = false);
|
||||||
|
|
||||||
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon = false);
|
std::vector<wxBitmapBundle*> get_extruder_color_icons(bool thin_icon = false);
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
@ -148,21 +148,28 @@ public:
|
|||||||
|
|
||||||
~ScalableBitmap() {}
|
~ScalableBitmap() {}
|
||||||
|
|
||||||
wxSize GetBmpSize() const;
|
void sys_color_changed();
|
||||||
int GetBmpWidth() const;
|
|
||||||
int GetBmpHeight() const;
|
|
||||||
|
|
||||||
void msw_rescale();
|
const wxBitmapBundle& bmp() const { return m_bmp; }
|
||||||
|
wxBitmap get_bitmap() { return m_bmp.GetBitmapFor(m_parent); }
|
||||||
const wxBitmap& bmp() const { return m_bmp; }
|
wxWindow* parent() const { return m_parent;}
|
||||||
wxBitmap& bmp() { return m_bmp; }
|
|
||||||
const std::string& name() const { return m_icon_name; }
|
const std::string& name() const { return m_icon_name; }
|
||||||
|
|
||||||
int px_cnt() const { return m_px_cnt;}
|
int px_cnt() const { return m_px_cnt;}
|
||||||
|
|
||||||
|
wxSize GetSize() const {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
return m_bmp.GetDefaultSize();
|
||||||
|
#else
|
||||||
|
return m_bmp.GetPreferredBitmapSizeFor(m_parent);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
int GetWidth() const { return GetSize().GetWidth(); }
|
||||||
|
int GetHeight() const { return GetSize().GetHeight(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxWindow* m_parent{ nullptr };
|
wxWindow* m_parent{ nullptr };
|
||||||
wxBitmap m_bmp = wxBitmap();
|
wxBitmapBundle m_bmp = wxBitmapBundle();
|
||||||
|
wxBitmap m_bitmap = wxBitmap();
|
||||||
std::string m_icon_name = "";
|
std::string m_icon_name = "";
|
||||||
int m_px_cnt {16};
|
int m_px_cnt {16};
|
||||||
bool m_grayscale {false};
|
bool m_grayscale {false};
|
||||||
@ -192,7 +199,7 @@ public:
|
|||||||
void enable() { m_disabled = false; }
|
void enable() { m_disabled = false; }
|
||||||
void disable() { m_disabled = true; }
|
void disable() { m_disabled = true; }
|
||||||
|
|
||||||
void msw_rescale();
|
void sys_color_changed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void update_button_bitmaps();
|
void update_button_bitmaps();
|
||||||
@ -224,7 +231,6 @@ public:
|
|||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
long style = wxBU_EXACTFIT | wxNO_BORDER,
|
long style = wxBU_EXACTFIT | wxNO_BORDER,
|
||||||
bool use_default_disabled_bitmap = false,
|
|
||||||
int bmp_px_cnt = 16);
|
int bmp_px_cnt = 16);
|
||||||
|
|
||||||
ScalableButton(
|
ScalableButton(
|
||||||
@ -240,9 +246,8 @@ public:
|
|||||||
bool SetBitmap_(const std::string& bmp_name);
|
bool SetBitmap_(const std::string& bmp_name);
|
||||||
void SetBitmapDisabled_(const ScalableBitmap &bmp);
|
void SetBitmapDisabled_(const ScalableBitmap &bmp);
|
||||||
int GetBitmapHeight();
|
int GetBitmapHeight();
|
||||||
void UseDefaultBitmapDisabled();
|
|
||||||
|
|
||||||
void msw_rescale();
|
void sys_color_changed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxWindow* m_parent { nullptr };
|
wxWindow* m_parent { nullptr };
|
||||||
@ -251,8 +256,6 @@ private:
|
|||||||
int m_width {-1}; // should be multiplied to em_unit
|
int m_width {-1}; // should be multiplied to em_unit
|
||||||
int m_height{-1}; // should be multiplied to em_unit
|
int m_height{-1}; // should be multiplied to em_unit
|
||||||
|
|
||||||
bool m_use_default_disabled_bitmap {false};
|
|
||||||
|
|
||||||
// bitmap dimensions
|
// bitmap dimensions
|
||||||
int m_px_cnt{ 16 };
|
int m_px_cnt{ 16 };
|
||||||
bool m_has_border {false};
|
bool m_has_border {false};
|
||||||
@ -318,7 +321,7 @@ public:
|
|||||||
void set_items_flag(int flag);
|
void set_items_flag(int flag);
|
||||||
void set_items_border(int border);
|
void set_items_border(int border);
|
||||||
|
|
||||||
void msw_rescale();
|
void sys_color_changed();
|
||||||
const std::vector<ModeButton*>& get_btns() { return m_mode_btns; }
|
const std::vector<ModeButton*>& get_btns() { return m_mode_btns; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -366,12 +369,11 @@ public:
|
|||||||
|
|
||||||
~BlinkingBitmap() {}
|
~BlinkingBitmap() {}
|
||||||
|
|
||||||
void msw_rescale();
|
|
||||||
void invalidate();
|
void invalidate();
|
||||||
void activate();
|
void activate();
|
||||||
void blink();
|
void blink();
|
||||||
|
|
||||||
const wxBitmap& get_bmp() const { return bmp.bmp(); }
|
const wxBitmapBundle& get_bmp() const { return bmp.bmp(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScalableBitmap bmp;
|
ScalableBitmap bmp;
|
||||||
|
Loading…
Reference in New Issue
Block a user