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);
|
||||
|
||||
// logo
|
||||
// m_logo_bitmap = ScalableBitmap(this, 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)));
|
||||
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
|
||||
hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -60,7 +60,164 @@ static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.
|
||||
#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;
|
||||
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
|
||||
// know that the image may already be scaled appropriately for Retina,
|
||||
// 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
|
||||
m_map[bitmap_key] = bitmap;
|
||||
} else {
|
||||
@ -297,6 +454,93 @@ error:
|
||||
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,
|
||||
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);
|
||||
}
|
||||
|
||||
//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 Slic3r
|
||||
|
@ -24,10 +24,18 @@ public:
|
||||
void clear();
|
||||
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; }
|
||||
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, const wxBitmap &bmp2);
|
||||
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
|
||||
// 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);
|
||||
// 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.
|
||||
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, 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:
|
||||
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_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 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,
|
||||
wxWindowID id/* = wxID_ANY*/,
|
||||
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
|
||||
|
||||
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
|
||||
//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));
|
||||
wxBitmap bitmap(1, 16);
|
||||
{
|
||||
// bitmap.SetWidth(0); is depricated now
|
||||
// so, use next code
|
||||
bitmap.UnShare();// AllocExclusive();
|
||||
bitmap.GetGDIImageData()->m_width = 0;
|
||||
}
|
||||
|
||||
wxBitmapBundle bitmap = *get_empty_bmp_bundle(1, 16);
|
||||
OnAddBitmap(bitmap);
|
||||
|
||||
const int n = wxComboBox::Append(item);
|
||||
if (n != wxNOT_FOUND)
|
||||
DoSetItemBitmap(n, bitmap);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -269,7 +184,6 @@ void BitmapComboBox::DrawBackground_(wxDC& dc, const wxRect& rect, int WXUNUSED(
|
||||
|
||||
void BitmapComboBox::Rescale()
|
||||
{
|
||||
return;
|
||||
// Next workaround: To correct scaling of a BitmapCombobox
|
||||
// we need to refill control with new bitmaps
|
||||
const wxString selection = this->GetValue();
|
||||
|
@ -29,28 +29,13 @@ BitmapComboBox(wxWindow* parent,
|
||||
#ifdef _WIN32
|
||||
int Append(const wxString& item);
|
||||
#endif
|
||||
int Append(const wxString& item, const wxBitmap& bitmap)
|
||||
int Append(const wxString& item, const wxBitmapBundle& bitmap)
|
||||
{
|
||||
return wxBitmapComboBox::Append(item, bitmap);
|
||||
}
|
||||
|
||||
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
|
||||
bool MSWOnDraw(WXDRAWITEMSTRUCT* item) override;
|
||||
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);
|
||||
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) {
|
||||
// wrap the label_text to the max 80 characters
|
||||
if (label_text.Len() > 80) {
|
||||
|
@ -1609,7 +1609,7 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
|
||||
#ifndef __WXOSX__
|
||||
SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
|
||||
#endif //__WXOSX__
|
||||
SetMinSize(bg.bmp().GetSize());
|
||||
SetMinSize(bg.GetSize());
|
||||
|
||||
const wxSize size = GetTextExtent("m");
|
||||
em_w = size.x;
|
||||
@ -1734,8 +1734,8 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
||||
|
||||
wxPaintDC dc(this);
|
||||
|
||||
const auto bullet_w = bullet_black.bmp().GetSize().GetWidth();
|
||||
const auto bullet_h = bullet_black.bmp().GetSize().GetHeight();
|
||||
const auto bullet_w = bullet_black.GetWidth();
|
||||
const auto bullet_h = bullet_black.GetHeight();
|
||||
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 yinc = item_height();
|
||||
@ -1748,10 +1748,10 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
||||
unsigned x = em_w/2 + item.indent * em_w;
|
||||
|
||||
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_white.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.get_bitmap(), x, y + yoff_icon, false); }
|
||||
|
||||
x += + bullet_w + em_w/2;
|
||||
const auto text_size = dc.GetTextExtent(item.label);
|
||||
@ -1763,9 +1763,9 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
||||
}
|
||||
|
||||
//draw logo
|
||||
if (int y = size.y - bg.GetBmpHeight(); y>=0) {
|
||||
dc.DrawBitmap(bg.bmp(), 0, y, false);
|
||||
index_width = std::max(index_width, bg.GetBmpWidth() + em_w / 2);
|
||||
if (int y = size.y - bg.GetHeight(); y>=0) {
|
||||
dc.DrawBitmap(bg.get_bitmap(), 0, y, false);
|
||||
index_width = std::max(index_width, bg.GetWidth() + em_w / 2);
|
||||
}
|
||||
|
||||
if (GetMinSize().x < index_width) {
|
||||
@ -1797,12 +1797,8 @@ void ConfigWizardIndex::msw_rescale()
|
||||
em_w = size.x;
|
||||
em_h = size.y;
|
||||
|
||||
bg.msw_rescale();
|
||||
SetMinSize(bg.bmp().GetSize());
|
||||
SetMinSize(bg.GetSize());
|
||||
|
||||
bullet_black.msw_rescale();
|
||||
bullet_blue.msw_rescale();
|
||||
bullet_white.msw_rescale();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ private:
|
||||
ssize_t item_hover;
|
||||
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_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_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_off = ScalableBitmap(this, "colorchange_add_f");
|
||||
m_bmp_del_tick_on = ScalableBitmap(this, "colorchange_del");
|
||||
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_off = ScalableBitmap(this, "lock_closed_f");
|
||||
m_bmp_one_layer_unlock_on = ScalableBitmap(this, "lock_open");
|
||||
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_revert_icon_dim = m_bmp_revert.GetBmpWidth();
|
||||
m_revert_icon_dim = m_bmp_revert.GetWidth();
|
||||
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_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_bmp_thumb_higher.msw_rescale();
|
||||
m_bmp_thumb_lower .msw_rescale();
|
||||
m_thumb_size = m_bmp_thumb_lower.bmp().GetSize();
|
||||
|
||||
m_bmp_add_tick_on .msw_rescale();
|
||||
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;
|
||||
m_thumb_size = m_bmp_thumb_lower.GetSize();
|
||||
m_tick_icon_dim = m_bmp_add_tick_on.GetWidth();
|
||||
m_lock_icon_dim = m_bmp_one_layer_lock_on.GetWidth();
|
||||
m_revert_icon_dim = m_bmp_revert.GetWidth();
|
||||
m_cog_icon_dim = m_bmp_cog.GetWidth();
|
||||
|
||||
SLIDER_MARGIN = 4 + GUI::wxGetApp().em_unit();
|
||||
|
||||
@ -189,22 +174,18 @@ void Control::sys_color_changed()
|
||||
{
|
||||
GUI::wxGetApp().UpdateDarkUI(GetParent());
|
||||
|
||||
m_bmp_add_tick_on .msw_rescale();
|
||||
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.GetBmpWidth();
|
||||
m_bmp_add_tick_on .sys_color_changed();
|
||||
m_bmp_add_tick_off.sys_color_changed();
|
||||
m_bmp_del_tick_on .sys_color_changed();
|
||||
m_bmp_del_tick_off.sys_color_changed();
|
||||
|
||||
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.GetBmpWidth();
|
||||
m_bmp_one_layer_lock_on .sys_color_changed();
|
||||
m_bmp_one_layer_lock_off .sys_color_changed();
|
||||
m_bmp_one_layer_unlock_on .sys_color_changed();
|
||||
m_bmp_one_layer_unlock_off.sys_color_changed();
|
||||
|
||||
m_bmp_revert.msw_rescale();
|
||||
m_revert_icon_dim = m_bmp_revert.GetBmpWidth();
|
||||
m_bmp_cog.msw_rescale();
|
||||
m_cog_icon_dim = m_bmp_cog.GetBmpWidth();
|
||||
m_bmp_revert.sys_color_changed();
|
||||
m_bmp_cog .sys_color_changed();
|
||||
}
|
||||
|
||||
int Control::GetActiveValue() const
|
||||
@ -604,9 +585,12 @@ void Control::draw_action_icon(wxDC& dc, const wxPoint pt_beg, const wxPoint pt_
|
||||
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())
|
||||
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;
|
||||
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
|
||||
is_horizontal() ? y_draw = pt_beg.y - m_tick_icon_dim-2 : x_draw = pt_end.x + 3;
|
||||
|
||||
if (m_draw_mode == dmSequentialFffPrint)
|
||||
dc.DrawBitmap(create_scaled_bitmap("colorchange_add", nullptr, 16, true), x_draw, y_draw);
|
||||
if (m_draw_mode == dmSequentialFffPrint) {
|
||||
wxBitmap disabled_add = get_bmp_bundle("colorchange_add")->GetBitmapFor(this).ConvertToDisabled();
|
||||
dc.DrawBitmap(disabled_add, x_draw, y_draw);
|
||||
}
|
||||
else
|
||||
dc.DrawBitmap(*icon, x_draw, y_draw);
|
||||
dc.DrawBitmap((*icon).get_bitmap(), x_draw, y_draw);
|
||||
|
||||
//update rect of the tick action icon
|
||||
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 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(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
|
||||
if (!icon_name.empty()) {
|
||||
wxBitmap icon = create_scaled_bitmap(icon_name);
|
||||
wxBitmapBundle* icon = get_bmp_bundle(icon_name);
|
||||
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() ? 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)
|
||||
return;
|
||||
|
||||
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_unlock_off.bmp() : m_bmp_one_layer_unlock_on.bmp();
|
||||
//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_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;
|
||||
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() ? 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
|
||||
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() ? 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
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
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) {
|
||||
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();
|
||||
|
||||
@ -1684,7 +1673,7 @@ void Control::append_change_extruder_menu_item(wxMenu* menu, bool switch_current
|
||||
|
||||
if (m_mode == MultiAsSingle)
|
||||
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());
|
||||
}
|
||||
|
||||
@ -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("Add color change (%1%) for:"), gcode(ColorChange));
|
||||
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())
|
||||
return nullptr;
|
||||
|
||||
std::vector<wxBitmap*> icons = get_extruder_color_icons();
|
||||
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons();
|
||||
if (icons.empty())
|
||||
return nullptr;
|
||||
|
||||
|
@ -264,9 +264,6 @@ void ExtruderSequenceDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
SetFont(wxGetApp().normal_font());
|
||||
|
||||
m_bmp_add.msw_rescale();
|
||||
m_bmp_del.msw_rescale();
|
||||
|
||||
const int em = em_unit();
|
||||
|
||||
m_intervals_grid_sizer->SetHGap(em);
|
||||
|
@ -106,14 +106,14 @@ public:
|
||||
bool set_undo_to_sys_tooltip(const wxString* tip) { return m_undo_ui.set_undo_to_sys_tooltip(tip); }
|
||||
|
||||
// ui items used for revert line value
|
||||
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 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 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 bool blink() const { return m_undo_ui.blink; }
|
||||
bool* get_blink_ptr() { return &m_undo_ui.blink; }
|
||||
bool has_undo_ui() const { return m_undo_ui.undo_bitmap != nullptr; }
|
||||
const wxBitmapBundle& undo_bitmap() const { return m_undo_ui.undo_bitmap->bmp(); }
|
||||
const wxString* undo_tooltip() const { return m_undo_ui.undo_tooltip; }
|
||||
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 wxColour* label_color() const { return m_undo_ui.label_color; }
|
||||
const bool blink() const { return m_undo_ui.blink; }
|
||||
bool* get_blink_ptr() { return &m_undo_ui.blink; }
|
||||
};
|
||||
|
||||
|
||||
|
@ -331,7 +331,7 @@ private:
|
||||
// See https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/font.cpp
|
||||
// void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
|
||||
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.pointSize = pointSizeNew;
|
||||
font = wxFont(nfi);
|
||||
@ -1188,7 +1188,7 @@ bool GUI_App::on_init_inner()
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
if (!default_splashscreen_pos)
|
||||
|
@ -142,19 +142,11 @@ std::map<std::string, std::string> SettingsFactory::CATEGORY_ICON =
|
||||
{ L("Hollowing") , "hollowing" }
|
||||
};
|
||||
|
||||
//wxBitmap SettingsFactory::get_category_bitmap(const std::string& category_name, bool menu_bmp /*= true*/)
|
||||
wxBitmap SettingsFactory::get_category_bitmap_(const std::string& category_name, bool menu_bmp /*= true*/)
|
||||
wxBitmapBundle* SettingsFactory::get_category_bitmap(const std::string& category_name)
|
||||
{
|
||||
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
|
||||
return wxNullBitmap;
|
||||
return /*menu_bmp ? create_menu_bitmap(CATEGORY_ICON.at(category_name)) : */create_scaled_bitmap(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));
|
||||
return get_bmp_bundle("empty");
|
||||
return get_bmp_bundle(CATEGORY_ICON.at(category_name));
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
@ -437,13 +429,12 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se
|
||||
#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());
|
||||
for (auto item : ADD_VOLUME_MENU_ITEMS)
|
||||
// volume_bmps.push_back(create_menu_bitmap(item.second));
|
||||
volume_bmps.push_back(create_scaled_bitmap(item.second, nullptr, 16, false, "", true));
|
||||
volume_bmps.push_back(get_bmp_bundle(item.second));
|
||||
return volume_bmps;
|
||||
}
|
||||
|
||||
@ -623,7 +614,7 @@ wxMenuItem* MenuFactory::append_menu_item_settings(wxMenu* menu_)
|
||||
|
||||
// Add full settings list
|
||||
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));
|
||||
|
||||
return menu->Append(menu_item);
|
||||
@ -768,7 +759,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
|
||||
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();
|
||||
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") + ")" : "");
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
@ -1147,12 +1138,6 @@ void MenuFactory::update_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
|
||||
// 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
|
||||
@ -1182,7 +1167,7 @@ static void update_menu_item_def_colors(T* item)
|
||||
void MenuFactory::sys_color_changed()
|
||||
{
|
||||
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
|
||||
// but under MSW we have to update item's bachground color
|
||||
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++) {
|
||||
wxMenu* menu = menubar->GetMenu(id);
|
||||
msw_rescale_menu(menu);
|
||||
sys_color_changed_menu(menu);
|
||||
#ifndef __linux__
|
||||
menu->SetupBitmaps();
|
||||
#ifdef _WIN32
|
||||
// but under MSW we have to update item's bachground color
|
||||
for (wxMenuItem* item : menu->GetMenuItems())
|
||||
update_menu_item_def_colors(item);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
menubar->Refresh();
|
||||
// menubar->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,9 +25,7 @@ struct SettingsFactory
|
||||
typedef std::map<std::string, std::vector<std::string>> Bundle;
|
||||
static std::map<std::string, std::string> CATEGORY_ICON;
|
||||
|
||||
// static wxBitmap get_category_bitmap(const std::string& category_name, bool menu_bmp = true);
|
||||
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 wxBitmapBundle* get_category_bitmap(const std::string& category_name);
|
||||
static Bundle get_bundle(const DynamicPrintConfig* config, bool is_object_settings);
|
||||
static std::vector<std::string> get_options(bool is_part);
|
||||
};
|
||||
@ -36,7 +34,7 @@ class MenuFactory
|
||||
{
|
||||
public:
|
||||
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() = default;
|
||||
@ -45,7 +43,6 @@ public:
|
||||
void update();
|
||||
void update_object_menu();
|
||||
void update_default_menu();
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
||||
static void sys_color_changed(wxMenuBar* menu_bar);
|
||||
|
@ -234,47 +234,47 @@ void ObjectLayers::UpdateAndShow(const bool show)
|
||||
|
||||
void ObjectLayers::msw_rescale()
|
||||
{
|
||||
m_bmp_delete.msw_rescale();
|
||||
m_bmp_add.msw_rescale();
|
||||
//m_bmp_delete.msw_rescale();
|
||||
//m_bmp_add.msw_rescale();
|
||||
|
||||
m_grid_sizer->SetHGap(wxGetApp().em_unit());
|
||||
//m_grid_sizer->SetHGap(wxGetApp().em_unit());
|
||||
|
||||
// rescale edit-boxes
|
||||
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
|
||||
for (int i = 0; i < cells_cnt; ++i) {
|
||||
const wxSizerItem* item = m_grid_sizer->GetItem(i);
|
||||
if (item->IsWindow()) {
|
||||
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(item->GetWindow());
|
||||
if (editor != nullptr)
|
||||
editor->msw_rescale();
|
||||
}
|
||||
else if (item->IsSizer()) // case when we have editor with buttons
|
||||
{
|
||||
wxSizerItem* e_item = item->GetSizer()->GetItem(size_t(0)); // editor
|
||||
if (e_item->IsWindow()) {
|
||||
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(e_item->GetWindow());
|
||||
if (editor != nullptr)
|
||||
editor->msw_rescale();
|
||||
}
|
||||
//// rescale edit-boxes
|
||||
//const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
|
||||
//for (int i = 0; i < cells_cnt; ++i) {
|
||||
// const wxSizerItem* item = m_grid_sizer->GetItem(i);
|
||||
// if (item->IsWindow()) {
|
||||
// LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(item->GetWindow());
|
||||
// if (editor != nullptr)
|
||||
// editor->msw_rescale();
|
||||
// }
|
||||
// else if (item->IsSizer()) // case when we have editor with buttons
|
||||
// {
|
||||
// wxSizerItem* e_item = item->GetSizer()->GetItem(size_t(0)); // editor
|
||||
// if (e_item->IsWindow()) {
|
||||
// LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(e_item->GetWindow());
|
||||
// if (editor != nullptr)
|
||||
// editor->msw_rescale();
|
||||
// }
|
||||
|
||||
if (item->GetSizer()->GetItemCount() > 2) // if there are Add/Del buttons
|
||||
for (size_t btn : {2, 3}) { // del_btn, add_btn
|
||||
wxSizerItem* b_item = item->GetSizer()->GetItem(btn);
|
||||
if (b_item->IsWindow()) {
|
||||
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
|
||||
if (button != nullptr)
|
||||
button->msw_rescale();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (item->GetSizer()->GetItemCount() > 2) // if there are Add/Del buttons
|
||||
// for (size_t btn : {2, 3}) { // del_btn, add_btn
|
||||
// wxSizerItem* b_item = item->GetSizer()->GetItem(btn);
|
||||
// if (b_item->IsWindow()) {
|
||||
// auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
|
||||
// if (button != nullptr)
|
||||
// button->msw_rescale();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
m_grid_sizer->Layout();
|
||||
}
|
||||
|
||||
void ObjectLayers::sys_color_changed()
|
||||
{
|
||||
m_bmp_delete.msw_rescale();
|
||||
m_bmp_add.msw_rescale();
|
||||
m_bmp_delete.sys_color_changed();
|
||||
m_bmp_add.sys_color_changed();
|
||||
|
||||
// rescale edit-boxes
|
||||
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()) {
|
||||
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
|
||||
if (button != nullptr)
|
||||
button->msw_rescale();
|
||||
button->sys_color_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4239,9 +4239,6 @@ void ObjectList::msw_rescale()
|
||||
GetColumn(colExtruder)->SetWidth( 8 * em);
|
||||
GetColumn(colEditing )->SetWidth( 3 * em);
|
||||
|
||||
// rescale/update existing items with bitmaps
|
||||
m_objects_model->Rescale();
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
@ -4249,7 +4246,10 @@ void ObjectList::sys_color_changed()
|
||||
{
|
||||
wxGetApp().UpdateDVCDarkUI(this, true);
|
||||
|
||||
msw_rescale();
|
||||
// update existing items with bitmaps
|
||||
m_objects_model->UpdateBitmaps();
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
void ObjectList::ItemValueChanged(wxDataViewEvent &event)
|
||||
|
@ -126,7 +126,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||
// Load bitmaps to be used for the mirroring buttons:
|
||||
m_mirror_bitmap_on = ScalableBitmap(parent, "mirroring_on");
|
||||
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 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);
|
||||
const wxString& tooltip = warning.tooltip;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1336,25 +1336,10 @@ void ObjectManipulation::msw_rescale()
|
||||
m_item_name->SetMinSize(wxSize(20*em, wxDefaultCoord));
|
||||
msw_rescale_word_local_combo(m_word_local_combo);
|
||||
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();
|
||||
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_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();
|
||||
m_fix_throught_netfab_bitmap->SetMinSize(tooltip.IsEmpty() ? wxSize(0, 0) : m_manifold_warning_bmp.GetSize());
|
||||
|
||||
// rescale label-heights
|
||||
// Text trick to grid sizer layout:
|
||||
@ -1383,20 +1368,16 @@ void ObjectManipulation::sys_color_changed()
|
||||
for (ManipulationEditor* editor : m_editors)
|
||||
editor->sys_color_changed(this);
|
||||
|
||||
// btn...->msw_rescale() updates icon on button, so use it
|
||||
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();
|
||||
m_mirror_bitmap_on.sys_color_changed();
|
||||
m_mirror_bitmap_off.sys_color_changed();
|
||||
m_mirror_bitmap_hidden.sys_color_changed();
|
||||
m_reset_scale_button->sys_color_changed();
|
||||
m_reset_rotation_button->sys_color_changed();
|
||||
m_drop_to_bed_button->sys_color_changed();
|
||||
m_lock_bnt->sys_color_changed();
|
||||
|
||||
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
|
||||
|
@ -99,7 +99,7 @@ bool ObjectSettings::update_settings_list()
|
||||
btn->SetToolTip(_(L("Remove parameter")));
|
||||
|
||||
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) {
|
||||
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;
|
||||
ctrl->SetBitmap_(m_bmp_delete);
|
||||
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";
|
||||
@ -268,15 +268,6 @@ void ObjectSettings::UpdateAndShow(const bool show)
|
||||
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()
|
||||
{
|
||||
m_og->sys_color_changed();
|
||||
|
@ -56,7 +56,6 @@ public:
|
||||
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from);
|
||||
void update_config_values(ModelConfig *config);
|
||||
void UpdateAndShow(const bool show) override;
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
};
|
||||
|
||||
|
@ -157,8 +157,9 @@ bool GalleryDialog::can_change_thumbnail()
|
||||
|
||||
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 });
|
||||
|
||||
wxSize size = wxSize(50 * em, 35 * em);
|
||||
@ -169,13 +170,14 @@ void GalleryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
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__
|
||||
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
|
||||
wxBitmap bmp = create_scaled_bitmap("lock", nullptr, lock_sz);
|
||||
|
||||
wxImage lock_image = bmp.ConvertToImage();
|
||||
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__
|
||||
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
|
||||
wxBitmap bmp = create_scaled_bitmap("cog", nullptr, sz, true);
|
||||
|
||||
bmp = bmp.ConvertToDisabled();
|
||||
if (is_system) {
|
||||
wxImage image = bmp.ConvertToImage();
|
||||
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));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
img_list->Add(bmp);
|
||||
};
|
||||
|
||||
@ -344,8 +353,13 @@ void GalleryDialog::load_label_icon_list()
|
||||
|
||||
// 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);
|
||||
m_image_list = new wxImageList(px_cnt, px_cnt);
|
||||
#endif
|
||||
|
||||
std::string ext = ".png";
|
||||
|
||||
@ -364,7 +378,7 @@ void GalleryDialog::load_label_icon_list()
|
||||
if (can_generate_thumbnail)
|
||||
generate_thumbnail_from_model(model_name);
|
||||
else {
|
||||
add_default_image(m_image_list, item.is_system);
|
||||
add_default_image(m_image_list, item.is_system, this);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -373,14 +387,18 @@ void GalleryDialog::load_label_icon_list()
|
||||
if (!image.CanRead(from_u8(img_name)) ||
|
||||
!image.LoadFile(from_u8(img_name), wxBITMAP_TYPE_PNG) ||
|
||||
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;
|
||||
}
|
||||
image.Rescale(px_cnt, px_cnt, wxIMAGE_QUALITY_BILINEAR);
|
||||
|
||||
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));
|
||||
#endif
|
||||
m_image_list->Add(bmp);
|
||||
}
|
||||
|
||||
|
@ -266,9 +266,7 @@ wxPanel* KBShortcutsDialog::create_header(wxWindow* parent, const wxFont& bold_f
|
||||
sizer->AddStretchSpacer();
|
||||
|
||||
// logo
|
||||
//m_logo_bmp = ScalableBitmap(this, 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)));
|
||||
m_header_bitmap = new wxStaticBitmap(panel, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 32));
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
/* Even if Window is maximized during moving,
|
||||
@ -1051,7 +1048,7 @@ void MainFrame::on_sys_color_changed()
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// update common mode sizer
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->OnColorsChanged();
|
||||
#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[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
|
||||
|
@ -99,17 +99,10 @@ void MsgDialog::apply_style(long style)
|
||||
if (style & wxNO) add_button(wxID_NO, (style & wxNO_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" :
|
||||
style & wxICON_INFORMATION ? "info" :
|
||||
style & wxICON_QUESTION ? "question" : "PrusaSlicer";
|
||||
icon_name += ".svg";
|
||||
logo->SetBitmap(wxBitmapBundle::FromSVGFile(Slic3r::var(icon_name), wxSize(64, 64)));
|
||||
#endif
|
||||
logo->SetBitmap(*get_bmp_bundle(icon_name, 64));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// 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()));
|
||||
|
||||
|
@ -95,10 +95,6 @@ void ButtonsListCtrl::UpdateMode()
|
||||
|
||||
void ButtonsListCtrl::Rescale()
|
||||
{
|
||||
m_mode_sizer->msw_rescale();
|
||||
for (ScalableButton* btn : m_pageButtons)
|
||||
btn->msw_rescale();
|
||||
|
||||
int em = em_unit(this);
|
||||
m_btn_margin = std::lround(0.3 * em);
|
||||
m_line_margin = std::lround(0.1 * em);
|
||||
@ -108,6 +104,14 @@ void ButtonsListCtrl::Rescale()
|
||||
m_sizer->Layout();
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::OnColorsChanged()
|
||||
{
|
||||
for (ScalableButton* btn : m_pageButtons)
|
||||
btn->sys_color_changed();
|
||||
|
||||
m_sizer->Layout();
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::SetSelection(int sel)
|
||||
{
|
||||
if (m_selection == sel)
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
void SetSelection(int sel);
|
||||
void UpdateMode();
|
||||
void Rescale();
|
||||
void OnColorsChanged();
|
||||
bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = "");
|
||||
void RemovePage(size_t n);
|
||||
bool SetPageImage(size_t n, const std::string& bmp_name) const;
|
||||
@ -245,6 +246,11 @@ public:
|
||||
GetBtnsListCtrl()->Rescale();
|
||||
}
|
||||
|
||||
void OnColorsChanged()
|
||||
{
|
||||
GetBtnsListCtrl()->OnColorsChanged();
|
||||
}
|
||||
|
||||
void OnNavigationKey(wxNavigationKeyEvent& event)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
static wxSize get_bitmap_size(const wxBitmap& bmp)
|
||||
static wxSize get_bitmap_size(const wxBitmapBundle* bmp, wxWindow* parent)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
return bmp.GetScaledSize();
|
||||
return bmp->GetDefaultSize();
|
||||
#else
|
||||
return bmp.GetSize();
|
||||
return bmp->GetBitmapFor(parent).GetSize();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
|
||||
m_v_gap = lround(1.0 * 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_blinking_sz = get_bitmap_size(create_scaled_bitmap("search_blink", this));
|
||||
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
|
||||
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("search_blink"), this);
|
||||
|
||||
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_h_gap = lround(0.2 * m_em_unit);
|
||||
|
||||
m_bmp_mode_sz = create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12).GetSize();
|
||||
m_bmp_blinking_sz = create_scaled_bitmap("search_blink", this).GetSize();
|
||||
m_bmp_mode_sz = get_bitmap_size(get_bmp_bundle("mode_simple", wxOSX ? 10 : 12), this);
|
||||
m_bmp_blinking_sz = get_bitmap_size(get_bmp_bundle("search_blink"), this);
|
||||
|
||||
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 (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()) {
|
||||
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;
|
||||
const std::string& bmp_name = mode == ConfigOptionMode::comSimple ? "mode_simple" :
|
||||
mode == ConfigOptionMode::comAdvanced ? "mode_advanced" : "mode_expert";
|
||||
wxBitmap bmp = create_scaled_bitmap(bmp_name, ctrl, wxOSX ? 10 : 12);
|
||||
wxCoord y_draw = v_pos + lround((height - get_bitmap_size(bmp).GetHeight()) / 2);
|
||||
wxBitmapBundle* bmp = get_bmp_bundle(bmp_name, wxOSX ? 10 : 12);
|
||||
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)
|
||||
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*/)
|
||||
@ -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)
|
||||
{
|
||||
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 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;
|
||||
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);
|
||||
wxCoord h_pos = pos.x;
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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_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);
|
||||
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 is_separator() const { return og_line.is_separator(); }
|
||||
|
||||
|
@ -56,7 +56,7 @@ const std::map<InfoItemType, InfoItemAtributes> INFO_ITEMS{
|
||||
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||
const wxString& sub_obj_name,
|
||||
Slic3r::ModelVolumeType type,
|
||||
const wxBitmap& bmp,
|
||||
const wxBitmapBundle& bmp,
|
||||
const wxString& extruder,
|
||||
const int idx/* = -1*/,
|
||||
const std::string& warning_icon_name /*= std::string*/) :
|
||||
@ -101,7 +101,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
||||
}
|
||||
else if (type == itLayerRoot)
|
||||
{
|
||||
m_bmp = create_scaled_bitmap(LayerRootIcon); // FIXME: pass window ptr
|
||||
m_bmp = *get_bmp_bundle(LayerRootIcon);
|
||||
m_name = _(L("Layers"));
|
||||
}
|
||||
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();
|
||||
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();
|
||||
init_container();
|
||||
@ -151,7 +151,7 @@ void ObjectDataViewModelNode::set_action_and_extruder_icons()
|
||||
{
|
||||
m_action_icon_name = m_type & itObject ? "advanced_plus" :
|
||||
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_icon();
|
||||
@ -170,7 +170,7 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
|
||||
{
|
||||
m_printable = printable;
|
||||
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)
|
||||
@ -185,14 +185,14 @@ void ObjectDataViewModelNode::update_settings_digest_bitmaps()
|
||||
m_bmp = m_empty_bmp;
|
||||
|
||||
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) {
|
||||
std::vector<wxBitmap> bmps;
|
||||
std::vector<wxBitmapBundle*> bmps;
|
||||
for (auto& category : m_opt_categories)
|
||||
bmps.emplace_back(SettingsFactory::get_category_bitmap_(category, false));
|
||||
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
|
||||
bmps.emplace_back(SettingsFactory::get_category_bitmap(category));
|
||||
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
|
||||
}
|
||||
|
||||
m_bmp = *bmp;
|
||||
@ -216,13 +216,13 @@ bool ObjectDataViewModelNode::update_settings_digest(const std::vector<std::stri
|
||||
return true;
|
||||
}
|
||||
|
||||
void ObjectDataViewModelNode::msw_rescale()
|
||||
void ObjectDataViewModelNode::sys_color_changed()
|
||||
{
|
||||
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)
|
||||
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())
|
||||
update_settings_digest_bitmaps();
|
||||
@ -235,7 +235,7 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
|
||||
switch (col)
|
||||
{
|
||||
case colPrint:
|
||||
m_printable_icon << variant;
|
||||
// m_printable_icon << variant;
|
||||
return true;
|
||||
case colName: {
|
||||
DataViewBitmapText data;
|
||||
@ -250,7 +250,7 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
|
||||
m_extruder = data.GetText() == "0" ? _(L("default")) : data.GetText();
|
||||
return true; }
|
||||
case colEditing:
|
||||
m_action_icon << variant;
|
||||
// m_action_icon << variant;
|
||||
return true;
|
||||
default:
|
||||
printf("MyObjectTreeModel::SetValue: wrong column");
|
||||
@ -290,7 +290,7 @@ void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= "
|
||||
|
||||
if (extruder_idx > 0) --extruder_idx;
|
||||
// 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()) {
|
||||
m_extruder_bmp = wxNullBitmap;
|
||||
return;
|
||||
@ -325,11 +325,11 @@ ObjectDataViewModel::ObjectDataViewModel()
|
||||
m_bitmap_cache = new Slic3r::GUI::BitmapCache;
|
||||
|
||||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
||||
m_warning_bmp = *get_bmp_bundle(WarningIcon);
|
||||
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
|
||||
|
||||
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()
|
||||
@ -340,7 +340,7 @@ ObjectDataViewModel::~ObjectDataViewModel()
|
||||
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;
|
||||
}
|
||||
@ -429,7 +429,7 @@ wxDataViewItem ObjectDataViewModel::AddInfoChild(const wxDataViewItem &parent_it
|
||||
}
|
||||
|
||||
root->Insert(node, idx+1);
|
||||
node->SetBitmap(m_info_bmps.at(info_type));
|
||||
node->SetBitmap(*m_info_bmps.at(info_type));
|
||||
// notify control
|
||||
const wxDataViewItem child((void*)node);
|
||||
ItemAdded(parent_item, child);
|
||||
@ -1237,7 +1237,7 @@ wxString ObjectDataViewModel::GetName(const wxDataViewItem &item) const
|
||||
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());
|
||||
return node->m_bmp;
|
||||
@ -1278,16 +1278,16 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
|
||||
switch (col)
|
||||
{
|
||||
case colPrint:
|
||||
variant << node->m_printable_icon;
|
||||
variant << node->m_printable_icon.GetBitmapFor(m_ctrl);
|
||||
break;
|
||||
case colName:
|
||||
variant << DataViewBitmapText(node->m_name, node->m_bmp);
|
||||
variant << DataViewBitmapText(node->m_name, node->m_bmp.GetBitmapFor(m_ctrl));
|
||||
break;
|
||||
case colExtruder:
|
||||
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp);
|
||||
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp.GetBitmapFor(m_ctrl));
|
||||
break;
|
||||
case colEditing:
|
||||
variant << node->m_action_icon;
|
||||
variant << node->m_action_icon.GetBitmapFor(m_ctrl);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
@ -1618,7 +1618,7 @@ void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r
|
||||
|
||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
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)
|
||||
node->SetExtruder(""); // hide extruder
|
||||
else if (node->GetExtruder().IsEmpty())
|
||||
@ -1676,14 +1676,14 @@ wxDataViewItem ObjectDataViewModel::SetObjectPrintableState(
|
||||
return obj_item;
|
||||
}
|
||||
|
||||
void ObjectDataViewModel::Rescale()
|
||||
void ObjectDataViewModel::UpdateBitmaps()
|
||||
{
|
||||
m_volume_bmps = MenuFactory::get_volume_bitmaps();
|
||||
m_warning_bmp = create_scaled_bitmap(WarningIcon);
|
||||
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
|
||||
m_warning_bmp = *get_bmp_bundle(WarningIcon);
|
||||
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
|
||||
|
||||
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;
|
||||
GetAllChildren(wxDataViewItem(0), all_items);
|
||||
@ -1694,7 +1694,7 @@ void ObjectDataViewModel::Rescale()
|
||||
continue;
|
||||
|
||||
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
node->msw_rescale();
|
||||
node->sys_color_changed();
|
||||
|
||||
switch (node->m_type)
|
||||
{
|
||||
@ -1705,13 +1705,13 @@ void ObjectDataViewModel::Rescale()
|
||||
node->m_bmp = GetVolumeIcon(node->m_volume_type, node->m_warning_icon_name);
|
||||
break;
|
||||
case itLayerRoot:
|
||||
node->m_bmp = create_scaled_bitmap(LayerRootIcon);
|
||||
node->m_bmp = *get_bmp_bundle(LayerRootIcon);
|
||||
break;
|
||||
case itLayer:
|
||||
node->m_bmp = create_scaled_bitmap(LayerIcon);
|
||||
node->m_bmp = *get_bmp_bundle(LayerIcon);
|
||||
break;
|
||||
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;
|
||||
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())
|
||||
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));
|
||||
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) {
|
||||
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)]);
|
||||
|
||||
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
|
||||
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
|
||||
}
|
||||
|
||||
return *bmp;
|
||||
@ -1770,7 +1770,7 @@ void ObjectDataViewModel::DeleteWarningIcon(const wxDataViewItem& item, const bo
|
||||
return;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -63,21 +63,21 @@ class ObjectDataViewModelNode
|
||||
{
|
||||
ObjectDataViewModelNode* m_parent;
|
||||
MyObjectTreeModelNodePtrArray m_children;
|
||||
wxBitmap m_empty_bmp;
|
||||
wxBitmapBundle m_empty_bmp;
|
||||
size_t m_volumes_cnt = 0;
|
||||
std::vector< std::string > m_opt_categories;
|
||||
t_layer_height_range m_layer_range = { 0.0f, 0.0f };
|
||||
|
||||
wxString m_name;
|
||||
wxBitmap& m_bmp = m_empty_bmp;
|
||||
wxBitmapBundle& m_bmp = m_empty_bmp;
|
||||
ItemType m_type;
|
||||
int m_idx = -1;
|
||||
bool m_container = false;
|
||||
wxString m_extruder = "default";
|
||||
wxBitmap m_extruder_bmp;
|
||||
wxBitmap m_action_icon;
|
||||
wxBitmapBundle m_extruder_bmp;
|
||||
wxBitmapBundle m_action_icon;
|
||||
PrintIndicator m_printable {piUndef};
|
||||
wxBitmap m_printable_icon;
|
||||
wxBitmapBundle m_printable_icon;
|
||||
std::string m_warning_icon_name{ "" };
|
||||
|
||||
std::string m_action_icon_name = "";
|
||||
@ -99,7 +99,7 @@ public:
|
||||
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
|
||||
const wxString& sub_obj_name,
|
||||
Slic3r::ModelVolumeType type,
|
||||
const wxBitmap& bmp,
|
||||
const wxBitmapBundle& bmp,
|
||||
const wxString& extruder,
|
||||
const int idx = -1,
|
||||
const std::string& warning_icon_name = std::string());
|
||||
@ -179,10 +179,10 @@ public:
|
||||
|
||||
bool SetValue(const wxVariant &variant, unsigned int col);
|
||||
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 SetWarningBitmap(const wxBitmap& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
|
||||
const wxBitmap& GetBitmap() const { return m_bmp; }
|
||||
void SetWarningBitmap(const wxBitmapBundle& icon, const std::string& warning_icon_name) { m_bmp = icon; m_warning_icon_name = warning_icon_name; }
|
||||
const wxBitmapBundle& GetBitmap() const { return m_bmp; }
|
||||
const wxString& GetName() const { return m_name; }
|
||||
ItemType GetType() const { return m_type; }
|
||||
InfoItemType GetInfoItemType() const { return m_info_item_type; }
|
||||
@ -234,7 +234,7 @@ public:
|
||||
void update_settings_digest_bitmaps();
|
||||
bool update_settings_digest(const std::vector<std::string>& categories);
|
||||
int volume_type() const { return int(m_volume_type); }
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool valid();
|
||||
@ -257,11 +257,11 @@ wxDECLARE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
|
||||
class ObjectDataViewModel :public wxDataViewModel
|
||||
{
|
||||
std::vector<ObjectDataViewModelNode*> m_objects;
|
||||
std::vector<wxBitmap> m_volume_bmps;
|
||||
std::map<InfoItemType, wxBitmap> m_info_bmps;
|
||||
wxBitmap m_empty_bmp;
|
||||
wxBitmap m_warning_bmp;
|
||||
wxBitmap m_warning_manifold_bmp;
|
||||
std::vector<wxBitmapBundle*> m_volume_bmps;
|
||||
std::map<InfoItemType, wxBitmapBundle*> m_info_bmps;
|
||||
wxBitmapBundle m_empty_bmp;
|
||||
wxBitmapBundle m_warning_bmp;
|
||||
wxBitmapBundle m_warning_manifold_bmp;
|
||||
|
||||
wxDataViewCtrl* m_ctrl { nullptr };
|
||||
|
||||
@ -315,7 +315,7 @@ public:
|
||||
// helper method for wxLog
|
||||
|
||||
wxString GetName(const wxDataViewItem &item) const;
|
||||
wxBitmap& GetBitmap(const wxDataViewItem &item) const;
|
||||
wxBitmapBundle& GetBitmap(const wxDataViewItem &item) const;
|
||||
wxString GetExtruder(const wxDataViewItem &item) const;
|
||||
int GetExtruderNumber(const wxDataViewItem &item) const;
|
||||
|
||||
@ -383,9 +383,9 @@ public:
|
||||
|
||||
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
|
||||
// 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());
|
||||
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
|
||||
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);
|
||||
@ -403,7 +403,7 @@ private:
|
||||
wxDataViewItem AddInstanceRoot(const wxDataViewItem& parent_item);
|
||||
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
|
||||
ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win);
|
||||
if (sc_btn) {
|
||||
sc_btn->msw_rescale();
|
||||
sc_btn->SetSize(sc_btn->GetBestSize());
|
||||
return;
|
||||
}
|
||||
@ -773,7 +772,7 @@ void ConfigOptionsGroup::sys_color_changed()
|
||||
wxWindow* win = item->GetWindow();
|
||||
// check if window is ScalableButton
|
||||
if (ScalableButton* sc_btn = dynamic_cast<ScalableButton*>(win)) {
|
||||
sc_btn->msw_rescale();
|
||||
sc_btn->sys_color_changed();
|
||||
return;
|
||||
}
|
||||
wxGetApp().UpdateDarkUI(win, dynamic_cast<wxButton*>(win) != nullptr);
|
||||
|
@ -142,10 +142,10 @@ void PresetForPrinter::AllowDelete()
|
||||
m_presets_list->update();
|
||||
}
|
||||
|
||||
void PresetForPrinter::msw_rescale()
|
||||
void PresetForPrinter::on_sys_color_changed()
|
||||
{
|
||||
m_presets_list->msw_rescale();
|
||||
m_delete_preset_btn->msw_rescale();
|
||||
m_presets_list->sys_color_changed();
|
||||
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();
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
SetMinSize(size);
|
||||
|
||||
@ -623,6 +614,18 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
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)
|
||||
{
|
||||
wxString printer_name = m_printer_name->GetValue();
|
||||
|
@ -48,8 +48,7 @@ public:
|
||||
void SuppressDelete();
|
||||
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);
|
||||
protected:
|
||||
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;
|
||||
};
|
||||
|
@ -180,7 +180,6 @@ public:
|
||||
|
||||
bool showing_manifold_warning_icon;
|
||||
void show_sizer(bool show);
|
||||
void msw_rescale();
|
||||
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"));
|
||||
|
||||
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"
|
||||
"It doesn't take account of intersections and negative volumes."));
|
||||
auto* volume_info_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
@ -223,7 +222,7 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
||||
|
||||
info_manifold = new wxStaticText(parent, wxID_ANY, "");
|
||||
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);
|
||||
sizer_manifold->Add(manifold_warning_icon, 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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if ((showing_manifold_warning_icon = !warning_icon_name.empty())) {
|
||||
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_sla->msw_rescale();
|
||||
|
||||
for (auto btn: m_empty_buttons)
|
||||
btn->msw_rescale();
|
||||
}
|
||||
|
||||
void FreqChangedParams::sys_color_changed()
|
||||
@ -361,7 +351,7 @@ void FreqChangedParams::sys_color_changed()
|
||||
m_og_sla->sys_color_changed();
|
||||
|
||||
for (auto btn: m_empty_buttons)
|
||||
btn->msw_rescale();
|
||||
btn->sys_color_changed();
|
||||
|
||||
wxGetApp().UpdateDarkUI(m_wiping_dialog_button, true);
|
||||
}
|
||||
@ -450,7 +440,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) :
|
||||
*/
|
||||
auto empty_widget = [this] (wxWindow* parent) {
|
||||
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);
|
||||
sizer->Add(btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, int(0.3 * wxGetApp().em_unit()));
|
||||
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);
|
||||
sizer->Add(btn , 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT,
|
||||
int(0.3 * wxGetApp().em_unit()));
|
||||
@ -1103,9 +1093,6 @@ void Sidebar::msw_rescale()
|
||||
{
|
||||
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,
|
||||
p->combo_sla_print,
|
||||
p->combo_sla_material,
|
||||
@ -1117,14 +1104,8 @@ void Sidebar::msw_rescale()
|
||||
p->frequently_changed_parameters->msw_rescale();
|
||||
p->object_list->msw_rescale();
|
||||
p->object_manipulation->msw_rescale();
|
||||
p->object_settings->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
|
||||
const int scaled_height = p->btn_export_gcode_removable->GetBitmapHeight();
|
||||
#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 })
|
||||
wxGetApp().UpdateDarkUI(win);
|
||||
p->object_info->msw_rescale();
|
||||
for (wxWindow* win : std::vector<wxWindow*>{ p->scrolled, p->presets_panel })
|
||||
wxGetApp().UpdateAllStaticTextDarkUI(win);
|
||||
for (wxWindow* btn : std::vector<wxWindow*>{ p->btn_reslice, p->btn_export_gcode })
|
||||
wxGetApp().UpdateDarkUI(btn, true);
|
||||
|
||||
if (p->mode_sizer)
|
||||
p->mode_sizer->msw_rescale();
|
||||
p->mode_sizer->sys_color_changed();
|
||||
p->frequently_changed_parameters->sys_color_changed();
|
||||
p->object_settings->sys_color_changed();
|
||||
#endif
|
||||
@ -1170,11 +1150,12 @@ void Sidebar::sys_color_changed()
|
||||
p->object_layers->sys_color_changed();
|
||||
|
||||
// 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_export_gcode_removable->msw_rescale();
|
||||
p->btn_export_gcode_removable->sys_color_changed();
|
||||
|
||||
p->scrolled->Layout();
|
||||
p->scrolled->Refresh();
|
||||
|
||||
p->searcher.dlg_sys_color_changed();
|
||||
}
|
||||
@ -6974,8 +6955,6 @@ void Plater::msw_rescale()
|
||||
|
||||
p->sidebar->msw_rescale();
|
||||
|
||||
p->menus.msw_rescale();
|
||||
|
||||
Layout();
|
||||
GetParent()->Layout();
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
|
||||
default: break;
|
||||
}
|
||||
|
||||
m_bitmapCompatible = ScalableBitmap(this, "flag_green");
|
||||
m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
|
||||
m_bitmapCompatible = get_bmp_bundle("flag_green");
|
||||
m_bitmapIncompatible = get_bmp_bundle("flag_red");
|
||||
|
||||
// parameters for an icon's drawing
|
||||
fill_width_height();
|
||||
@ -242,12 +242,12 @@ void PresetComboBox::update(std::string select_preset_name)
|
||||
|
||||
const std::deque<Preset>& presets = m_collection->get_presets();
|
||||
|
||||
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
|
||||
std::map<wxString, wxBitmap*> incomp_presets;
|
||||
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
|
||||
std::map<wxString, wxBitmapBundle*> incomp_presets;
|
||||
|
||||
wxString selected = "";
|
||||
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)
|
||||
{
|
||||
@ -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;
|
||||
|
||||
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);
|
||||
|
||||
if (!is_enabled)
|
||||
@ -280,17 +280,17 @@ void PresetComboBox::update(std::string select_preset_name)
|
||||
}
|
||||
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))
|
||||
selected = get_preset_name(preset);
|
||||
}
|
||||
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())
|
||||
{
|
||||
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
|
||||
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||
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);
|
||||
bool is_enabled = it->second.second;
|
||||
if (!is_enabled)
|
||||
@ -300,8 +300,8 @@ void PresetComboBox::update(std::string select_preset_name)
|
||||
}
|
||||
if (!incomp_presets.empty())
|
||||
{
|
||||
set_label_marker(Append(separator(L("Incompatible presets")), wxNullBitmap));
|
||||
for (std::map<wxString, wxBitmap*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
|
||||
set_label_marker(Append(separator(L("Incompatible presets")), NullBitmapBndl()));
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -337,7 +337,6 @@ bool PresetComboBox::del_physical_printer(const wxString& note_string/* = wxEmpt
|
||||
msg += note_string + "\n";
|
||||
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)
|
||||
return false;
|
||||
|
||||
@ -364,7 +363,8 @@ void PresetComboBox::show_all(bool show_all)
|
||||
|
||||
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()
|
||||
@ -375,43 +375,31 @@ void PresetComboBox::update_from_bundle()
|
||||
void PresetComboBox::msw_rescale()
|
||||
{
|
||||
m_em_unit = em_unit(this);
|
||||
}
|
||||
|
||||
//m_bitmapIncompatible.msw_rescale();
|
||||
//m_bitmapCompatible.msw_rescale();
|
||||
|
||||
// parameters for an icon's drawing
|
||||
fill_width_height();
|
||||
void PresetComboBox::sys_color_changed()
|
||||
{
|
||||
m_bitmapCompatible = get_bmp_bundle("flag_green");
|
||||
m_bitmapIncompatible = get_bmp_bundle("flag_red");
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
|
||||
// update the control to redraw the icons
|
||||
update();
|
||||
}
|
||||
|
||||
void PresetComboBox::sys_color_changed()
|
||||
{
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
msw_rescale();
|
||||
}
|
||||
|
||||
void PresetComboBox::fill_width_height()
|
||||
{
|
||||
// To avoid asserts, each added bitmap to wxBitmapCombobox should be the same size, so
|
||||
// set a bitmap's height to m_bitmapCompatible->GetHeight() and norm_icon_width to m_bitmapCompatible->GetWidth()
|
||||
icon_height = m_bitmapCompatible.GetBmpHeight();
|
||||
norm_icon_width = m_bitmapCompatible.GetBmpWidth();
|
||||
icon_height = m_bitmapCompatible->GetPreferredBitmapSizeAtScale(1.0).GetHeight();
|
||||
norm_icon_width = m_bitmapCompatible->GetPreferredBitmapSizeAtScale(1.0).GetWidth();
|
||||
|
||||
/* It's supposed that standard size of an icon is 16px*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 float scale_f = (float)m_em_unit * 0.1f;
|
||||
const float scale_f = 1.0f;
|
||||
null_icon_width = 2 * norm_icon_width;
|
||||
|
||||
thin_icon_width = lroundf(8 * scale_f); // analogue to 8px;
|
||||
thin_icon_width = 8;
|
||||
wide_icon_width = norm_icon_width + thin_icon_width;
|
||||
|
||||
space_icon_width = lroundf(2 * scale_f);
|
||||
thin_space_icon_width = lroundf(4 * scale_f);
|
||||
wide_space_icon_width = lroundf(6 * scale_f);
|
||||
space_icon_width = 2;
|
||||
thin_space_icon_width = 4;
|
||||
wide_space_icon_width = 6;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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*/,
|
||||
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 += material_rgb;
|
||||
|
||||
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
|
||||
if (bmp == nullptr) {
|
||||
wxBitmapBundle* bmp_bndl = bitmap_cache().find_bndl(bitmap_key);
|
||||
if (bmp_bndl == nullptr) {
|
||||
// Create the bitmap with color bars.
|
||||
std::vector<wxBitmap> bmps;
|
||||
std::vector<wxBitmapBundle*> bmps;
|
||||
if (wide_icons)
|
||||
// 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()) {
|
||||
// Paint the color bars.
|
||||
ColorRGB color;
|
||||
decode_color(filament_rgb, color);
|
||||
bmps.emplace_back(bitmap_cache().mksolid(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, color, false, 1, dark_mode));
|
||||
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));
|
||||
}
|
||||
bmps.emplace_back(get_solid_bmp_bundle(is_single_bar ? wide_icon_width : norm_icon_width, icon_height, filament_rgb));
|
||||
if (!is_single_bar)
|
||||
bmps.emplace_back(get_solid_bmp_bundle(thin_icon_width, icon_height, extruder_rgb));
|
||||
// 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
|
||||
{
|
||||
// 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)
|
||||
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
|
||||
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.
|
||||
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));
|
||||
bmp = bitmap_cache().insert(bitmap_key, bmps);
|
||||
bmps.emplace_back(is_system ? get_bmp_bundle("lock_closed") : get_empty_bmp_bundle(norm_icon_width, icon_height));
|
||||
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*/)
|
||||
{
|
||||
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())
|
||||
bitmap_key += ",dark";
|
||||
|
||||
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
|
||||
wxBitmapBundle* bmp = bitmap_cache().find_bndl(bitmap_key);
|
||||
if (bmp == nullptr) {
|
||||
// Create the bitmap with color bars.
|
||||
std::vector<wxBitmap> bmps;
|
||||
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? create_scaled_bitmap(main_icon_name, this, 16, !is_enabled) :
|
||||
is_compatible ? m_bitmapCompatible.bmp() : m_bitmapIncompatible.bmp());
|
||||
std::vector<wxBitmapBundle*> bmps;
|
||||
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? get_bmp_bundle(main_icon_name) :
|
||||
is_compatible ? m_bitmapCompatible : m_bitmapIncompatible);
|
||||
// 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));
|
||||
bmp = bitmap_cache().insert(bitmap_key, bmps);
|
||||
bmps.emplace_back(is_system ? get_bmp_bundle(next_icon_name) : get_empty_bmp_bundle(norm_icon_width, icon_height));
|
||||
bmp = bitmap_cache().insert_bndl(bitmap_key, bmps);
|
||||
}
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
||||
wxBitmapBundle PresetComboBox::NullBitmapBndl()
|
||||
{
|
||||
return *get_empty_bmp_bundle(null_icon_width, icon_height);
|
||||
}
|
||||
|
||||
bool PresetComboBox::is_selected_physical_printer()
|
||||
{
|
||||
auto selected_item = this->GetSelection();
|
||||
@ -783,14 +773,16 @@ void PlaterPresetComboBox::update()
|
||||
// and draw a red flag in front of the selected preset.
|
||||
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 tooltip;
|
||||
const std::deque<Preset>& presets = m_collection->get_presets();
|
||||
|
||||
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)
|
||||
{
|
||||
@ -824,7 +816,7 @@ void PlaterPresetComboBox::update()
|
||||
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,
|
||||
single_bar, filament_rgb, extruder_rgb, material_rgb);
|
||||
assert(bmp);
|
||||
@ -845,12 +837,12 @@ void PlaterPresetComboBox::update()
|
||||
}
|
||||
}
|
||||
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())
|
||||
{
|
||||
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
|
||||
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||
for (std::map<wxString, wxBitmapBundle*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||
Append(it->first, *it->second);
|
||||
validate_selection(it->first == selected_user_preset);
|
||||
}
|
||||
@ -860,7 +852,7 @@ void PlaterPresetComboBox::update()
|
||||
{
|
||||
// add Physical printers, if any exists
|
||||
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;
|
||||
|
||||
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
||||
@ -869,7 +861,7 @@ void PlaterPresetComboBox::update()
|
||||
if (!preset || !preset->is_visible)
|
||||
continue;
|
||||
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);
|
||||
|
||||
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) {
|
||||
wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
|
||||
auto bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
|
||||
assert(bmp);
|
||||
|
||||
if (m_type == Preset::TYPE_FILAMENT)
|
||||
@ -917,9 +909,20 @@ void PlaterPresetComboBox::update()
|
||||
void PlaterPresetComboBox::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 ***
|
||||
@ -982,10 +985,10 @@ void TabPresetComboBox::update()
|
||||
|
||||
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 = "";
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
if (preset.is_default || preset.is_system) {
|
||||
@ -1023,18 +1026,18 @@ void TabPresetComboBox::update()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
|
||||
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
|
||||
std::pair<wxBitmapBundle*, bool> pair(bmp, is_enabled);
|
||||
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
|
||||
if (i == idx_selected)
|
||||
selected = get_preset_name(preset);
|
||||
}
|
||||
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())
|
||||
{
|
||||
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
|
||||
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
|
||||
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
|
||||
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);
|
||||
bool is_enabled = it->second.second;
|
||||
if (!is_enabled)
|
||||
@ -1047,7 +1050,7 @@ void TabPresetComboBox::update()
|
||||
{
|
||||
// add Physical printers, if any exists
|
||||
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;
|
||||
|
||||
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
||||
@ -1057,7 +1060,7 @@ void TabPresetComboBox::update()
|
||||
continue;
|
||||
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);
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
set_label_marker(Append(separator(L("Add/Remove printers")), *bmp), LABEL_ITEM_WIZARD_PRINTERS);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef slic3r_PresetComboBoxes_hpp_
|
||||
#define slic3r_PresetComboBoxes_hpp_
|
||||
|
||||
//#include <wx/bmpcbox.h>
|
||||
#include <wx/bmpbndl.h>
|
||||
#include <wx/gdicmn.h>
|
||||
|
||||
#include "libslic3r/Preset.hpp"
|
||||
@ -88,9 +88,9 @@ protected:
|
||||
static BitmapCache& bitmap_cache();
|
||||
|
||||
// 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.
|
||||
ScalableBitmap m_bitmapIncompatible;
|
||||
wxBitmapBundle* m_bitmapIncompatible;
|
||||
|
||||
int m_last_selected;
|
||||
int m_em_unit;
|
||||
@ -99,6 +99,7 @@ protected:
|
||||
// parameters for an icon's drawing
|
||||
int icon_height;
|
||||
int norm_icon_width;
|
||||
int null_icon_width;
|
||||
int thin_icon_width;
|
||||
int wide_icon_width;
|
||||
int space_icon_width;
|
||||
@ -120,13 +121,15 @@ protected:
|
||||
#endif // __linux__
|
||||
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,
|
||||
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);
|
||||
|
||||
wxBitmapBundle NullBitmapBndl();
|
||||
|
||||
private:
|
||||
void fill_width_height();
|
||||
};
|
||||
@ -155,6 +158,7 @@ public:
|
||||
wxString get_preset_name(const Preset& preset) override;
|
||||
void update() override;
|
||||
void msw_rescale() override;
|
||||
void sys_color_changed() override;
|
||||
void OnSelect(wxCommandEvent& evt) override;
|
||||
|
||||
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()));
|
||||
|
||||
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));
|
||||
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" :
|
||||
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()
|
||||
|
@ -720,12 +720,9 @@ void SearchDialog::msw_rescale()
|
||||
{
|
||||
const int& em = em_unit();
|
||||
|
||||
search_list_model->msw_rescale();
|
||||
search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em);
|
||||
search_list->GetColumn(SearchListModel::colMarkedText)->SetWidth(45 * em);
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_CANCEL });
|
||||
|
||||
const wxSize& size = wxSize(40 * em, 30 * em);
|
||||
SetMinSize(size);
|
||||
|
||||
@ -743,7 +740,7 @@ void SearchDialog::on_sys_color_changed()
|
||||
#endif
|
||||
|
||||
// msw_rescale updates just icons, so use it
|
||||
search_list_model->msw_rescale();
|
||||
search_list_model->sys_color_changed();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
@ -776,10 +773,10 @@ void SearchListModel::Prepend(const std::string& label)
|
||||
RowPrepended();
|
||||
}
|
||||
|
||||
void SearchListModel::msw_rescale()
|
||||
void SearchListModel::sys_color_changed()
|
||||
{
|
||||
for (ScalableBitmap& bmp : m_icon)
|
||||
bmp.msw_rescale();
|
||||
bmp.sys_color_changed();
|
||||
}
|
||||
|
||||
wxString SearchListModel::GetColumnType(unsigned int col) const
|
||||
@ -795,7 +792,7 @@ void SearchListModel::GetValueByRow(wxVariant& variant,
|
||||
switch (col)
|
||||
{
|
||||
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;
|
||||
case colMarkedText:
|
||||
variant = m_values[row].first;
|
||||
|
@ -213,7 +213,7 @@ public:
|
||||
|
||||
void Clear();
|
||||
void Prepend(const std::string& text);
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
||||
// implementation of base class virtuals to define model
|
||||
|
||||
|
@ -104,7 +104,7 @@ SysInfoDialog::SysInfoDialog()
|
||||
// logo
|
||||
//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, 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);
|
||||
|
||||
|
@ -155,10 +155,8 @@ void Tab::create_preset_tab()
|
||||
add_scaled_button(panel, &m_btn_edit_ph_printer, "cog");
|
||||
|
||||
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"));
|
||||
// TRN "Save current Settings"
|
||||
@ -207,7 +205,7 @@ void Tab::create_preset_tab()
|
||||
#endif
|
||||
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);
|
||||
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 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),
|
||||
wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
||||
m_left_sizer->Add(m_treectrl, 1, wxEXPAND);
|
||||
const int img_sz = int(16 * scale_factor + 0.5f);
|
||||
m_icons = new wxImageList(img_sz, img_sz, true, 1);
|
||||
// Index of the last icon inserted into $self->{icons}.
|
||||
// Index of the last icon inserted into m_treectrl
|
||||
m_icon_count = -1;
|
||||
m_treectrl->AssignImageList(m_icons);
|
||||
m_treectrl->AddRoot("root");
|
||||
m_treectrl->SetIndent(0);
|
||||
wxGetApp().UpdateDarkUI(m_treectrl);
|
||||
@ -321,6 +316,14 @@ void Tab::create_preset_tab()
|
||||
// Initialize the DynamicPrintConfig by default keys/values.
|
||||
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
|
||||
// (update_mode->update_visibility->rebuild_page_tree). This does not work, during the
|
||||
// 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*/,
|
||||
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);
|
||||
}
|
||||
|
||||
@ -366,7 +369,6 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
|
||||
if (icon_idx == -1) {
|
||||
// Add a new icon to the icon list.
|
||||
m_scaled_icons_list.push_back(ScalableBitmap(this, icon));
|
||||
m_icons->Add(m_scaled_icons_list.back().bmp());
|
||||
icon_idx = ++m_icon_count;
|
||||
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);
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if (!m_options_list.empty())
|
||||
@ -924,31 +916,9 @@ void Tab::msw_rescale()
|
||||
{
|
||||
m_em_unit = em_unit(m_parent);
|
||||
|
||||
if (m_mode_sizer)
|
||||
m_mode_sizer->msw_rescale();
|
||||
m_presets_choice->msw_rescale();
|
||||
|
||||
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
|
||||
if (m_active_page)
|
||||
m_active_page->msw_rescale();
|
||||
@ -962,28 +932,28 @@ void Tab::sys_color_changed()
|
||||
|
||||
// update buttons and cached bitmaps
|
||||
for (const auto btn : m_scaled_buttons)
|
||||
btn->msw_rescale();
|
||||
btn->sys_color_changed();
|
||||
for (const auto bmp : m_scaled_bitmaps)
|
||||
bmp->msw_rescale();
|
||||
bmp->sys_color_changed();
|
||||
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
|
||||
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);
|
||||
wxVector <wxBitmapBundle> img_bundles;
|
||||
for (ScalableBitmap& bmp : m_scaled_icons_list) {
|
||||
bmp.sys_color_changed();
|
||||
img_bundles.push_back(bmp.bmp());
|
||||
}
|
||||
m_treectrl->SetImages(img_bundles);
|
||||
|
||||
// Colors for ui "decoration"
|
||||
update_label_colours();
|
||||
#ifdef _WIN32
|
||||
wxWindowUpdateLocker noUpdates(this);
|
||||
if (m_mode_sizer)
|
||||
m_mode_sizer->msw_rescale();
|
||||
m_mode_sizer->sys_color_changed();
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
wxGetApp().UpdateDarkUI(m_treectrl);
|
||||
#endif
|
||||
@ -994,6 +964,7 @@ void Tab::sys_color_changed()
|
||||
m_active_page->sys_color_changed();
|
||||
|
||||
Layout();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
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) {
|
||||
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;
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
|
||||
@ -1681,14 +1652,14 @@ void TabPrint::build()
|
||||
option.opt.height = 5;//50;
|
||||
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);
|
||||
option = optgroup->get_option("notes");
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = 25;//250;
|
||||
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"));
|
||||
|
||||
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
||||
@ -1928,7 +1899,7 @@ void TabFilament::build()
|
||||
m_presets = &m_preset_bundle->filaments;
|
||||
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"));
|
||||
optgroup->append_single_option_line("filament_colour");
|
||||
optgroup->append_single_option_line("filament_diameter");
|
||||
@ -2068,7 +2039,7 @@ void TabFilament::build()
|
||||
option.opt.height = gcode_field_height;// 150;
|
||||
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->label_width = 0;
|
||||
option = optgroup->get_option("filament_notes");
|
||||
@ -2076,7 +2047,7 @@ void TabFilament::build()
|
||||
option.opt.height = notes_field_height;// 250;
|
||||
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"));
|
||||
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
||||
return compatible_widget_create(parent, m_compatible_printers);
|
||||
@ -2460,14 +2431,14 @@ void TabPrinter::build_fff()
|
||||
option.opt.height = gcode_field_height;//150;
|
||||
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);
|
||||
option = optgroup->get_option("printer_notes");
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = notes_field_height;//250;
|
||||
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"));
|
||||
|
||||
build_preset_description_line(optgroup.get());
|
||||
@ -2538,14 +2509,14 @@ void TabPrinter::build_sla()
|
||||
|
||||
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);
|
||||
option = optgroup->get_option("printer_notes");
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = notes_field_height;//250;
|
||||
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"));
|
||||
|
||||
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) {
|
||||
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;
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
btn->SetSize(btn->GetBestSize());
|
||||
@ -3780,8 +3751,7 @@ void Tab::toggle_show_hide_incompatible()
|
||||
|
||||
void Tab::update_show_hide_incompatible_button()
|
||||
{
|
||||
m_btn_hide_incompatible_presets->SetBitmap_(m_show_incompatible_presets ?
|
||||
m_bmp_show_incompatible_presets : m_bmp_hide_incompatible_presets);
|
||||
m_btn_hide_incompatible_presets->SetBitmap(*get_bmp_bundle(m_show_incompatible_presets ? "flag_red" : "flag_green"));
|
||||
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." :
|
||||
"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());
|
||||
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()),
|
||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
|
||||
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
deps.btn->SetSize(deps.btn->GetBestSize());
|
||||
|
||||
@ -4139,7 +4109,7 @@ bool SubstitutionManager::is_empty_substitutions()
|
||||
wxSizer* TabPrint::create_manage_substitution_widget(wxWindow* parent)
|
||||
{
|
||||
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)->SetSize((*btn)->GetBestSize());
|
||||
};
|
||||
@ -4192,7 +4162,7 @@ wxSizer* TabPrint::create_substitutions_widget(wxWindow* parent)
|
||||
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
|
||||
{
|
||||
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->SetSize(btn->GetBestSize());
|
||||
|
||||
@ -4586,7 +4556,7 @@ void TabSLAMaterial::build()
|
||||
|
||||
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->label_width = 0;
|
||||
Option option = optgroup->get_option("material_notes");
|
||||
@ -4594,7 +4564,7 @@ void TabSLAMaterial::build()
|
||||
option.opt.height = 25;//250;
|
||||
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"));
|
||||
|
||||
create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
|
||||
@ -4615,7 +4585,7 @@ void TabSLAMaterial::build()
|
||||
|
||||
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"));
|
||||
option = optgroup->get_option("material_print_speed");
|
||||
optgroup->append_single_option_line(option);
|
||||
|
@ -174,7 +174,6 @@ protected:
|
||||
wxBoxSizer* m_hsizer;
|
||||
wxBoxSizer* m_left_sizer;
|
||||
wxTreeCtrl* m_treectrl;
|
||||
wxImageList* m_icons;
|
||||
|
||||
wxScrolledWindow* m_page_view {nullptr};
|
||||
wxBoxSizer* m_page_sizer {nullptr};
|
||||
@ -203,10 +202,6 @@ protected:
|
||||
ScalableButton* m_undo_to_sys_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.
|
||||
ScalableBitmap m_bmp_value_lock;
|
||||
ScalableBitmap m_bmp_value_unlock;
|
||||
@ -505,7 +500,6 @@ public:
|
||||
void build_unregular_pages(bool from_initial_build = false);
|
||||
void on_preset_loaded() override;
|
||||
void init_options_list() override;
|
||||
void msw_rescale() override;
|
||||
bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; }
|
||||
|
||||
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)
|
||||
#endif // __linux__
|
||||
{
|
||||
/* It's supposed that standard size of an icon is 48px*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 = 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
|
||||
wxBitmap bmp = get_solid_bmp_bundle(64, 16, into_u8(color))->GetBitmapFor(m_parent_win);
|
||||
if (!m_toggle)
|
||||
bmp = bmp.ConvertToDisabled();
|
||||
#ifndef __linux__
|
||||
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
|
||||
return bmp;
|
||||
#else
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap(bmp_cache.mksolid(icon_width, icon_height, rgb, true));
|
||||
icon.CopyFromBitmap(bmp);
|
||||
return icon;
|
||||
#endif // __linux__
|
||||
}
|
||||
|
||||
// option node
|
||||
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_old_color(old_value.StartsWith("#") ? old_value : ""),
|
||||
m_new_color(new_value.StartsWith("#") ? new_value : ""),
|
||||
@ -202,18 +194,22 @@ void ModelNode::UpdateIcons()
|
||||
{
|
||||
// update icons for the colors, if any exists
|
||||
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())
|
||||
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
|
||||
if (m_icon_name.empty())
|
||||
return;
|
||||
|
||||
wxBitmap bmp = get_bmp_bundle(m_icon_name)->GetBitmapFor(m_parent_win);
|
||||
if (!m_toggle)
|
||||
bmp = bmp.ConvertToDisabled();
|
||||
|
||||
#ifdef __linux__
|
||||
m_icon.CopyFromBitmap(create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle));
|
||||
m_icon.CopyFromBitmap(bmp);
|
||||
#else
|
||||
m_icon = create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle);
|
||||
m_icon = bmp;
|
||||
#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)
|
||||
{
|
||||
*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);
|
||||
(*btn)->SetFont(btn_font);
|
||||
@ -876,7 +872,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
|
||||
if (ActionButtons::SAVE & m_buttons)
|
||||
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);
|
||||
cancel_btn->SetFont(btn_font);
|
||||
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();
|
||||
|
||||
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);
|
||||
SetMinSize(size);
|
||||
@ -1325,7 +1319,7 @@ void UnsavedChangesDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
void UnsavedChangesDialog::on_sys_color_changed()
|
||||
{
|
||||
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
|
||||
m_tree->Rescale();
|
||||
|
||||
@ -1726,10 +1720,16 @@ void DiffPresetDialog::on_dpi_changed(const wxRect&)
|
||||
const wxSize& size = wxSize(80 * em, 30 * em);
|
||||
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) {
|
||||
preset_combos.presets_left->msw_rescale();
|
||||
preset_combos.equal_bmp->msw_rescale();
|
||||
preset_combos.presets_right->msw_rescale();
|
||||
rescale(preset_combos.presets_left);
|
||||
rescale(preset_combos.presets_right);
|
||||
}
|
||||
|
||||
m_tree->Rescale(em);
|
||||
@ -1747,9 +1747,9 @@ void DiffPresetDialog::on_sys_color_changed()
|
||||
#endif
|
||||
|
||||
for (auto preset_combos : m_preset_combos) {
|
||||
preset_combos.presets_left->msw_rescale();
|
||||
preset_combos.equal_bmp->msw_rescale();
|
||||
preset_combos.presets_right->msw_rescale();
|
||||
preset_combos.presets_left->sys_color_changed();
|
||||
preset_combos.equal_bmp->sys_color_changed();
|
||||
preset_combos.presets_right->sys_color_changed();
|
||||
}
|
||||
// msw_rescale updates just icons, so use it
|
||||
m_tree->Rescale();
|
||||
|
@ -24,18 +24,15 @@
|
||||
#ifndef __linux__
|
||||
// msw_menuitem_bitmaps is used for MSW and OSX
|
||||
static std::map<int, std::string> msw_menuitem_bitmaps;
|
||||
#ifdef __WXMSW__
|
||||
void msw_rescale_menu(wxMenu* menu)
|
||||
void sys_color_changed_menu(wxMenu* menu)
|
||||
{
|
||||
return;
|
||||
struct update_icons {
|
||||
static void run(wxMenuItem* item) {
|
||||
const auto it = msw_menuitem_bitmaps.find(item->GetId());
|
||||
if (it != msw_menuitem_bitmaps.end()) {
|
||||
// const wxBitmap& item_icon = create_menu_bitmap(it->second);
|
||||
const wxBitmapBundle& item_icon = create_menu_bitmap(it->second);
|
||||
if (item_icon.IsOk())
|
||||
item->SetBitmap(item_icon);
|
||||
wxBitmapBundle* item_icon = get_bmp_bundle(it->second);
|
||||
if (item_icon->IsOk())
|
||||
item->SetBitmap(*item_icon);
|
||||
}
|
||||
if (item->IsSubMenu())
|
||||
for (wxMenuItem *sub_item : item->GetSubMenu()->GetMenuItems())
|
||||
@ -46,36 +43,24 @@ void msw_rescale_menu(wxMenu* menu)
|
||||
for (wxMenuItem *item : menu->GetMenuItems())
|
||||
update_icons::run(item);
|
||||
}
|
||||
#endif /* __WXMSW__ */
|
||||
#endif /* no __WXGTK__ */
|
||||
#endif /* no __linux__ */
|
||||
|
||||
void enable_menu_item(wxUpdateUIEvent& evt, std::function<bool()> const cb_condition, wxMenuItem* item, wxWindow* win)
|
||||
{
|
||||
const bool enable = cb_condition();
|
||||
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,
|
||||
// std::function<void(wxCommandEvent& event)> cb, const wxBitmap& icon, wxEvtHandler* event_handler,
|
||||
std::function<void(wxCommandEvent& event)> cb, const wxBitmapBundle& icon, wxEvtHandler* event_handler,
|
||||
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler,
|
||||
std::function<bool()> const cb_condition, wxWindow* parent, int insert_pos/* = wxNOT_FOUND*/)
|
||||
{
|
||||
if (id == wxID_ANY)
|
||||
id = wxNewId();
|
||||
|
||||
auto *item = new wxMenuItem(menu, id, string, description);
|
||||
if (icon.IsOk()) {
|
||||
item->SetBitmap(icon);
|
||||
if (icon && icon->IsOk()) {
|
||||
item->SetBitmap(*icon);
|
||||
}
|
||||
if (insert_pos == wxNOT_FOUND)
|
||||
menu->Append(item);
|
||||
@ -104,14 +89,12 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
|
||||
if (id == wxID_ANY)
|
||||
id = wxNewId();
|
||||
|
||||
// const wxBitmap& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
|
||||
const wxBitmapBundle& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
|
||||
wxBitmapBundle* bmp = icon.empty() ? nullptr : get_bmp_bundle(icon);
|
||||
|
||||
//#ifdef __WXMSW__
|
||||
#ifndef __WXGTK__
|
||||
if (bmp.IsOk())
|
||||
#ifndef __linux__
|
||||
if (bmp && bmp->IsOk())
|
||||
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);
|
||||
}
|
||||
@ -124,7 +107,7 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
|
||||
|
||||
wxMenuItem* item = new wxMenuItem(menu, id, string, description);
|
||||
if (!icon.empty()) {
|
||||
item->SetBitmap(create_menu_bitmap(icon)); // FIXME: pass window ptr
|
||||
item->SetBitmap(*get_bmp_bundle(icon));
|
||||
//#ifdef __WXMSW__
|
||||
#ifndef __WXGTK__
|
||||
msw_menuitem_bitmaps[id] = icon;
|
||||
@ -426,11 +409,34 @@ int mode_icon_px_size()
|
||||
#endif
|
||||
}
|
||||
|
||||
//wxBitmap create_menu_bitmap(const std::string& bmp_name)
|
||||
wxBitmapBundle create_menu_bitmap(const std::string& bmp_name)
|
||||
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/)
|
||||
{
|
||||
// return create_scaled_bitmap(bmp_name, nullptr, 16, false, "", true);
|
||||
return wxBitmapBundle::FromSVGFile(Slic3r::var(bmp_name + ".svg"), wxSize(16, 16));
|
||||
static Slic3r::GUI::BitmapCache cache;
|
||||
|
||||
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
|
||||
@ -471,41 +477,19 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
|
||||
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.
|
||||
std::vector<wxBitmap*> bmps;
|
||||
std::vector<wxBitmapBundle*> bmps;
|
||||
std::vector<std::string> colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config();
|
||||
|
||||
if (colors.empty())
|
||||
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();
|
||||
|
||||
for (const std::string& color : colors)
|
||||
{
|
||||
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);
|
||||
}
|
||||
bmps.emplace_back(get_solid_bmp_bundle(thin_icon ? 16 : 32, 16, color));
|
||||
|
||||
return bmps;
|
||||
}
|
||||
@ -518,7 +502,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
|
||||
wxSize size/* = wxDefaultSize*/,
|
||||
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) {
|
||||
*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;
|
||||
wxString str = _(L("Extruder"));
|
||||
for (wxBitmap* bmp : icons) {
|
||||
for (wxBitmapBundle* bmp : icons) {
|
||||
if (i == 0) {
|
||||
if (!first_item.empty())
|
||||
(*ctrl)->Append(_(first_item), *bmp);
|
||||
@ -578,7 +562,7 @@ LockButton::LockButton( wxWindow *parent,
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||
SetBitmap(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
|
||||
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;
|
||||
m_bmp_lock_closed.msw_rescale();
|
||||
m_bmp_lock_closed_f.msw_rescale();
|
||||
m_bmp_lock_open.msw_rescale();
|
||||
m_bmp_lock_open_f.msw_rescale();
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||
|
||||
m_bmp_lock_closed.sys_color_changed();
|
||||
m_bmp_lock_closed_f.sys_color_changed();
|
||||
m_bmp_lock_open.sys_color_changed();
|
||||
m_bmp_lock_open_f.sys_color_changed();
|
||||
|
||||
update_button_bitmaps();
|
||||
}
|
||||
@ -621,7 +606,7 @@ void LockButton::msw_rescale()
|
||||
void LockButton::update_button_bitmaps()
|
||||
{
|
||||
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();
|
||||
Update();
|
||||
@ -648,8 +633,7 @@ ModeButton::ModeButton( wxWindow* parent,
|
||||
const wxString& mode/* = wxEmptyString*/,
|
||||
const std::string& icon_name/* = ""*/,
|
||||
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)
|
||||
ScalableButton(parent, wxID_ANY, icon_name, mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt)
|
||||
{
|
||||
Init(mode);
|
||||
}
|
||||
@ -759,11 +743,10 @@ void ModeSizer::set_items_border(int 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++)
|
||||
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_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__
|
||||
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);
|
||||
m_bmp = *get_bmp_bundle(m_icon_name, m_px_cnt);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -850,11 +806,9 @@ ScalableButton::ScalableButton( wxWindow * parent,
|
||||
const wxSize& size /* = wxDefaultSize*/,
|
||||
const wxPoint& pos /* = wxDefaultPosition*/,
|
||||
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/,
|
||||
bool use_default_disabled_bitmap/* = false*/,
|
||||
int bmp_px_cnt/* = 16*/) :
|
||||
m_parent(parent),
|
||||
m_current_icon_name(icon_name),
|
||||
m_use_default_disabled_bitmap (use_default_disabled_bitmap),
|
||||
m_px_cnt(bmp_px_cnt),
|
||||
m_has_border(!(style & wxNO_BORDER))
|
||||
{
|
||||
@ -862,10 +816,7 @@ ScalableButton::ScalableButton( wxWindow * parent,
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||
|
||||
if (!icon_name.empty()) {
|
||||
// SetBitmap(create_scaled_bitmap(icon_name, parent, 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));
|
||||
SetBitmap(*get_bmp_bundle(icon_name, m_px_cnt));
|
||||
if (!label.empty())
|
||||
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())
|
||||
return false;
|
||||
|
||||
// wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
|
||||
wxBitmapBundle bmp = wxBitmapBundle::FromSVGFile(Slic3r::var(m_current_icon_name + ".svg"), wxSize(16, 16));
|
||||
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
|
||||
SetBitmap(bmp);
|
||||
SetBitmapCurrent(bmp);
|
||||
SetBitmapPressed(bmp);
|
||||
SetBitmapFocus(bmp);
|
||||
if (m_use_default_disabled_bitmap)
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
SetBitmapDisabled(bmp);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -933,38 +882,21 @@ int ScalableButton::GetBitmapHeight()
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScalableButton::UseDefaultBitmapDisabled()
|
||||
{
|
||||
m_use_default_disabled_bitmap = true;
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
}
|
||||
|
||||
void ScalableButton::msw_rescale()
|
||||
void ScalableButton::sys_color_changed()
|
||||
{
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
|
||||
|
||||
// if (!m_current_icon_name.empty()) {
|
||||
if (0) {
|
||||
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
|
||||
SetBitmap(bmp);
|
||||
SetBitmapCurrent(bmp);
|
||||
SetBitmapPressed(bmp);
|
||||
SetBitmapFocus(bmp);
|
||||
if (!m_disabled_icon_name.empty())
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_disabled_icon_name, m_parent, m_px_cnt));
|
||||
else if (m_use_default_disabled_bitmap)
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
}
|
||||
|
||||
if (m_width > 0 || m_height>0)
|
||||
{
|
||||
const int em = em_unit(m_parent);
|
||||
wxSize size(m_width * em, m_height * em);
|
||||
SetMinSize(size);
|
||||
}
|
||||
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
|
||||
SetBitmap(bmp);
|
||||
SetBitmapCurrent(bmp);
|
||||
SetBitmapPressed(bmp);
|
||||
SetBitmapFocus(bmp);
|
||||
if (!m_disabled_icon_name.empty())
|
||||
SetBitmapDisabled(*get_bmp_bundle(m_disabled_icon_name, m_px_cnt));
|
||||
if (!GetLabelText().IsEmpty())
|
||||
SetBitmapMargins(int(0.5 * em_unit(m_parent)), 0);
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// BlinkingBitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -975,13 +907,6 @@ BlinkingBitmap::BlinkingBitmap(wxWindow* parent, const std::string& 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()
|
||||
{
|
||||
this->SetBitmap(wxNullBitmap);
|
||||
|
@ -16,15 +16,14 @@
|
||||
#include <functional>
|
||||
|
||||
|
||||
#ifdef __WXMSW__
|
||||
void msw_rescale_menu(wxMenu* menu);
|
||||
#else /* __WXMSW__ */
|
||||
inline void msw_rescale_menu(wxMenu* /* menu */) {}
|
||||
#endif /* __WXMSW__ */
|
||||
#ifndef __linux__
|
||||
void sys_color_changed_menu(wxMenu* menu);
|
||||
#else
|
||||
inline void sys_color_changed_menu(wxMenu* /* menu */) {}
|
||||
#endif // no __linux__
|
||||
|
||||
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, const wxBitmapBundle& icon, wxEvtHandler* event_handler = nullptr,
|
||||
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler = nullptr,
|
||||
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,
|
||||
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 mode_icon_px_size();
|
||||
|
||||
//wxBitmap create_menu_bitmap(const std::string& bmp_name);
|
||||
wxBitmapBundle create_menu_bitmap(const std::string& bmp_name);
|
||||
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name, int px_cnt = 16);
|
||||
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,
|
||||
const int px_cnt = 16, const bool grayscale = false,
|
||||
const std::string& new_color = std::string(), // color witch will used instead of orange
|
||||
const bool menu_bitmap = false);
|
||||
|
||||
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 GUI {
|
||||
@ -148,21 +148,28 @@ public:
|
||||
|
||||
~ScalableBitmap() {}
|
||||
|
||||
wxSize GetBmpSize() const;
|
||||
int GetBmpWidth() const;
|
||||
int GetBmpHeight() const;
|
||||
void sys_color_changed();
|
||||
|
||||
void msw_rescale();
|
||||
const wxBitmapBundle& bmp() const { return m_bmp; }
|
||||
wxBitmap get_bitmap() { return m_bmp.GetBitmapFor(m_parent); }
|
||||
wxWindow* parent() const { return m_parent;}
|
||||
const std::string& name() const { return m_icon_name; }
|
||||
int px_cnt() const { return m_px_cnt;}
|
||||
|
||||
const wxBitmap& bmp() const { return m_bmp; }
|
||||
wxBitmap& bmp() { return m_bmp; }
|
||||
const std::string& name() const{ return m_icon_name; }
|
||||
|
||||
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:
|
||||
wxWindow* m_parent{ nullptr };
|
||||
wxBitmap m_bmp = wxBitmap();
|
||||
wxBitmapBundle m_bmp = wxBitmapBundle();
|
||||
wxBitmap m_bitmap = wxBitmap();
|
||||
std::string m_icon_name = "";
|
||||
int m_px_cnt {16};
|
||||
bool m_grayscale {false};
|
||||
@ -192,7 +199,7 @@ public:
|
||||
void enable() { m_disabled = false; }
|
||||
void disable() { m_disabled = true; }
|
||||
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
||||
protected:
|
||||
void update_button_bitmaps();
|
||||
@ -224,7 +231,6 @@ public:
|
||||
const wxSize& size = wxDefaultSize,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
long style = wxBU_EXACTFIT | wxNO_BORDER,
|
||||
bool use_default_disabled_bitmap = false,
|
||||
int bmp_px_cnt = 16);
|
||||
|
||||
ScalableButton(
|
||||
@ -240,9 +246,8 @@ public:
|
||||
bool SetBitmap_(const std::string& bmp_name);
|
||||
void SetBitmapDisabled_(const ScalableBitmap &bmp);
|
||||
int GetBitmapHeight();
|
||||
void UseDefaultBitmapDisabled();
|
||||
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
||||
private:
|
||||
wxWindow* m_parent { nullptr };
|
||||
@ -251,8 +256,6 @@ private:
|
||||
int m_width {-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
|
||||
int m_px_cnt{ 16 };
|
||||
bool m_has_border {false};
|
||||
@ -318,7 +321,7 @@ public:
|
||||
void set_items_flag(int flag);
|
||||
void set_items_border(int border);
|
||||
|
||||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
const std::vector<ModeButton*>& get_btns() { return m_mode_btns; }
|
||||
|
||||
private:
|
||||
@ -366,12 +369,11 @@ public:
|
||||
|
||||
~BlinkingBitmap() {}
|
||||
|
||||
void msw_rescale();
|
||||
void invalidate();
|
||||
void activate();
|
||||
void blink();
|
||||
|
||||
const wxBitmap& get_bmp() const { return bmp.bmp(); }
|
||||
const wxBitmapBundle& get_bmp() const { return bmp.bmp(); }
|
||||
|
||||
private:
|
||||
ScalableBitmap bmp;
|
||||
|
Loading…
Reference in New Issue
Block a user