Using of wxWidgets 3.1.6 WIP: Linux/OSX specific fixes
OSX specific: Fixed get_mouse_position_in_control(). + Use GetItemRect() to calculation of the position and size for Extruder selector Linux specific: * Use just 1.0 scale for wxBitmapComboboxes under GTK3 and gtk3 * GTK2 specific: use GTK2 doesn't suppost get_scale, so scale bitmap size form em_unit()
This commit is contained in:
parent
dd6f7a71f1
commit
ae08819a24
@ -65,6 +65,8 @@ wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vec
|
|||||||
wxVector<wxBitmap> bitmaps;
|
wxVector<wxBitmap> bitmaps;
|
||||||
|
|
||||||
std::set<double> scales = {1.0};
|
std::set<double> scales = {1.0};
|
||||||
|
#ifndef __linux__
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
scales.emplace(m_scale);
|
scales.emplace(m_scale);
|
||||||
#else
|
#else
|
||||||
@ -73,12 +75,14 @@ wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vec
|
|||||||
scales.emplace(wxDisplay(disp).GetScaleFactor());
|
scales.emplace(wxDisplay(disp).GetScaleFactor());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // !__linux__
|
||||||
|
|
||||||
for (double scale : scales) {
|
for (double scale : scales) {
|
||||||
size_t width = 0;
|
size_t width = 0;
|
||||||
size_t height = 0;
|
size_t height = 0;
|
||||||
for (const wxBitmapBundle* bmp_bndl : bmps) {
|
for (const wxBitmapBundle* bmp_bndl : bmps) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
wxSize size = bmp_bndl->GetPreferredBitmapSizeAtScale(1.0);
|
wxSize size = bmp_bndl->GetDefaultSize();
|
||||||
#else
|
#else
|
||||||
wxSize size = bmp_bndl->GetPreferredBitmapSizeAtScale(scale);
|
wxSize size = bmp_bndl->GetPreferredBitmapSizeAtScale(scale);
|
||||||
#endif
|
#endif
|
||||||
@ -98,7 +102,7 @@ wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vec
|
|||||||
memset(image.GetAlpha(), 0, width * height);
|
memset(image.GetAlpha(), 0, width * height);
|
||||||
size_t x = 0;
|
size_t x = 0;
|
||||||
for (const wxBitmapBundle* bmp_bndl : bmps) {
|
for (const wxBitmapBundle* bmp_bndl : bmps) {
|
||||||
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetPreferredBitmapSizeAtScale(scale));
|
wxBitmap bmp = bmp_bndl->GetBitmap(bmp_bndl->GetDefaultSize());
|
||||||
if (bmp.GetWidth() > 0) {
|
if (bmp.GetWidth() > 0) {
|
||||||
if (bmp.GetDepth() == 32) {
|
if (bmp.GetDepth() == 32) {
|
||||||
wxAlphaPixelData data(bmp);
|
wxAlphaPixelData data(bmp);
|
||||||
@ -138,7 +142,7 @@ wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x += bmp.GetWidth();
|
x += bmp.GetScaledWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmaps.push_back(* this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image))));
|
bitmaps.push_back(* this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image))));
|
||||||
@ -156,8 +160,8 @@ wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vec
|
|||||||
|
|
||||||
if (bmp.GetWidth() > 0)
|
if (bmp.GetWidth() > 0)
|
||||||
memDC.DrawBitmap(bmp, x, 0, true);
|
memDC.DrawBitmap(bmp, x, 0, true);
|
||||||
#ifdef __APPLE__
|
|
||||||
// we should "move" with step equal to non-scaled width
|
// we should "move" with step equal to non-scaled width
|
||||||
|
#ifdef __APPLE__
|
||||||
x += bmp.GetScaledWidth();
|
x += bmp.GetScaledWidth();
|
||||||
#else
|
#else
|
||||||
x += bmp.GetWidth();
|
x += bmp.GetWidth();
|
||||||
@ -262,110 +266,6 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp
|
|||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2)
|
|
||||||
{
|
|
||||||
// Copying the wxBitmaps is cheap as the bitmap's content is reference counted.
|
|
||||||
const wxBitmap bmps[2] = { bmp, bmp2 };
|
|
||||||
return this->insert(bitmap_key, bmps, bmps + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3)
|
|
||||||
{
|
|
||||||
// Copying the wxBitmaps is cheap as the bitmap's content is reference counted.
|
|
||||||
const wxBitmap bmps[3] = { bmp, bmp2, bmp3 };
|
|
||||||
return this->insert(bitmap_key, bmps, bmps + 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap *begin, const wxBitmap *end)
|
|
||||||
{
|
|
||||||
size_t width = 0;
|
|
||||||
size_t height = 0;
|
|
||||||
for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) {
|
|
||||||
#ifdef __APPLE__
|
|
||||||
width += bmp->GetScaledWidth();
|
|
||||||
height = std::max<size_t>(height, bmp->GetScaledHeight());
|
|
||||||
#else
|
|
||||||
width += bmp->GetWidth();
|
|
||||||
height = std::max<size_t>(height, bmp->GetHeight());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#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 wxBitmap *bmp = begin; bmp != end; ++ bmp) {
|
|
||||||
if (bmp->GetWidth() > 0) {
|
|
||||||
if (bmp->GetDepth() == 32) {
|
|
||||||
wxAlphaPixelData data(*const_cast<wxBitmap*>(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(*const_cast<wxBitmap*>(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();
|
|
||||||
}
|
|
||||||
return this->insert(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
wxBitmap *bitmap = this->insert(bitmap_key, width, height);
|
|
||||||
wxMemoryDC memDC;
|
|
||||||
memDC.SelectObject(*bitmap);
|
|
||||||
memDC.SetBackground(*wxTRANSPARENT_BRUSH);
|
|
||||||
memDC.Clear();
|
|
||||||
size_t x = 0;
|
|
||||||
for (const wxBitmap *bmp = begin; bmp != end; ++ bmp) {
|
|
||||||
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);
|
|
||||||
return bitmap;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmap* BitmapCache::insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale/* = false*/)
|
wxBitmap* BitmapCache::insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale/* = false*/)
|
||||||
{
|
{
|
||||||
wxImage image(width, height);
|
wxImage image(width, height);
|
||||||
@ -492,7 +392,6 @@ wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned t
|
|||||||
std::string bitmap_key = bitmap_name + (target_height != 0 ?
|
std::string bitmap_key = bitmap_name + (target_height != 0 ?
|
||||||
"-h" + std::to_string(target_height) :
|
"-h" + std::to_string(target_height) :
|
||||||
"-w" + std::to_string(target_width))
|
"-w" + std::to_string(target_width))
|
||||||
// + (m_scale != 1.0f ? "-s" + float_to_string_decimal_point(m_scale) : "")
|
|
||||||
+ (dark_mode ? "-dm" : "")
|
+ (dark_mode ? "-dm" : "")
|
||||||
+ new_color;
|
+ new_color;
|
||||||
|
|
||||||
@ -594,7 +493,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
|
|||||||
|
|
||||||
return this->insert_raw_rgba(bitmap_key, width, height, data.data(), grayscale);
|
return this->insert_raw_rgba(bitmap_key, width, height, data.data(), grayscale);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
|
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
|
||||||
wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false* /, size_t border_width /*= 0* /, bool dark_mode/* = false* /)
|
wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling/* = false* /, size_t border_width /*= 0* /, bool dark_mode/* = false* /)
|
||||||
{
|
{
|
||||||
@ -638,13 +537,15 @@ wxBitmap BitmapCache::mksolid(size_t width, size_t height, unsigned char r, unsi
|
|||||||
|
|
||||||
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
|
return wxImage_to_wxBitmap_with_alpha(std::move(image), scale);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
//we make scaled solid bitmaps only for the cases, when its will be used with scaled SVG icon in one output bitmap
|
//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*/)
|
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;
|
wxVector<wxBitmap> bitmaps;
|
||||||
|
|
||||||
std::set<double> scales = { 1.0 };
|
std::set<double> scales = { 1.0 };
|
||||||
|
#ifndef __linux__
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
scales.emplace(m_scale);
|
scales.emplace(m_scale);
|
||||||
#else
|
#else
|
||||||
@ -653,6 +554,8 @@ wxBitmapBundle BitmapCache::mksolid(size_t width_in, size_t height_in, unsigned
|
|||||||
scales.emplace(wxDisplay(disp).GetScaleFactor());
|
scales.emplace(wxDisplay(disp).GetScaleFactor());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // !__linux__
|
||||||
|
|
||||||
for (double scale : scales) {
|
for (double scale : scales) {
|
||||||
size_t width = width_in * scale;
|
size_t width = width_in * scale;
|
||||||
size_t height = height_in * scale;
|
size_t height = height_in * scale;
|
||||||
@ -698,7 +601,7 @@ wxBitmapBundle BitmapCache::mksolid(size_t width_in, size_t height_in, unsigned
|
|||||||
|
|
||||||
wxBitmapBundle* BitmapCache::mksolid_bndl(size_t width, size_t height, const std::string& color, size_t border_width, bool dark_mode)
|
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" : "");
|
std::string bitmap_key = (color.empty() ? "empty" : color) + "-h" + std::to_string(height) + "-w" + std::to_string(width) + (dark_mode ? "-dm" : "");
|
||||||
|
|
||||||
wxBitmapBundle* bndl = nullptr;
|
wxBitmapBundle* bndl = nullptr;
|
||||||
auto it = m_bndl_map.find(bitmap_key);
|
auto it = m_bndl_map.find(bitmap_key);
|
||||||
|
@ -37,10 +37,6 @@ public:
|
|||||||
|
|
||||||
wxBitmap* insert(const std::string &name, size_t width, size_t height, double scale = -1.0);
|
wxBitmap* insert(const std::string &name, size_t width, size_t height, double scale = -1.0);
|
||||||
wxBitmap* insert(const std::string &name, const wxBitmap &bmp);
|
wxBitmap* insert(const std::string &name, const wxBitmap &bmp);
|
||||||
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2);
|
|
||||||
wxBitmap* insert(const std::string &name, const wxBitmap &bmp, const wxBitmap &bmp2, const wxBitmap &bmp3);
|
|
||||||
wxBitmap* insert(const std::string &name, const std::vector<wxBitmap> &bmps) { return this->insert(name, &bmps.front(), &bmps.front() + bmps.size()); }
|
|
||||||
wxBitmap* insert(const std::string &name, const wxBitmap *begin, const wxBitmap *end);
|
|
||||||
wxBitmap* insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
|
wxBitmap* insert_raw_rgba(const std::string &bitmap_key, unsigned width, unsigned height, const unsigned char *raw_data, const bool grayscale = false);
|
||||||
|
|
||||||
// Load png from resources/icons. bitmap_key is given without the .png suffix. Bitmap will be rescaled to provided height/width if nonzero.
|
// Load png from resources/icons. bitmap_key is given without the .png suffix. Bitmap will be rescaled to provided height/width if nonzero.
|
||||||
@ -58,9 +54,6 @@ public:
|
|||||||
// Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width.
|
// Load svg from resources/icons. bitmap_key is given without the .svg suffix. SVG will be rasterized to provided height/width.
|
||||||
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::string& new_color = "");
|
wxBitmap* load_svg(const std::string &bitmap_key, unsigned width = 0, unsigned height = 0, const bool grayscale = false, const bool dark_mode = false, const std::string& new_color = "");
|
||||||
|
|
||||||
wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
|
|
||||||
wxBitmap mksolid(size_t width, size_t height, 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, 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(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* 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); }
|
wxBitmapBundle* mkclear_bndl(size_t width, size_t height) { return mksolid_bndl(width, height); }
|
||||||
|
@ -33,6 +33,15 @@ wxIMPLEMENT_DYNAMIC_CLASS(DataViewBitmapText, wxObject)
|
|||||||
|
|
||||||
IMPLEMENT_VARIANT_OBJECT(DataViewBitmapText)
|
IMPLEMENT_VARIANT_OBJECT(DataViewBitmapText)
|
||||||
|
|
||||||
|
static wxSize get_size(const wxBitmap& icon)
|
||||||
|
{
|
||||||
|
#ifdef __WIN32__
|
||||||
|
return icon.GetSize();
|
||||||
|
#else
|
||||||
|
return icon.GetScaledSize();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// BitmapTextRenderer
|
// BitmapTextRenderer
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@ -124,11 +133,7 @@ bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
|
|||||||
const wxBitmap& icon = m_value.GetBitmap();
|
const wxBitmap& icon = m_value.GetBitmap();
|
||||||
if (icon.IsOk())
|
if (icon.IsOk())
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
wxSize icon_sz = get_size(icon);
|
||||||
wxSize icon_sz = icon.GetScaledSize();
|
|
||||||
#else
|
|
||||||
wxSize icon_sz = icon.GetSize();
|
|
||||||
#endif
|
|
||||||
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.y) / 2);
|
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.y) / 2);
|
||||||
xoffset = icon_sz.x + 4;
|
xoffset = icon_sz.x + 4;
|
||||||
}
|
}
|
||||||
@ -264,11 +269,13 @@ bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
|
|||||||
const wxBitmap& icon = m_value.GetBitmap();
|
const wxBitmap& icon = m_value.GetBitmap();
|
||||||
if (icon.IsOk())
|
if (icon.IsOk())
|
||||||
{
|
{
|
||||||
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
|
wxSize icon_sz = get_size(icon);
|
||||||
xoffset = icon.GetWidth() + 4;
|
|
||||||
|
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.GetHeight()) / 2);
|
||||||
|
xoffset = icon_sz.GetWidth() + 4;
|
||||||
|
|
||||||
if (rect.height==0)
|
if (rect.height==0)
|
||||||
rect.height= icon.GetHeight();
|
rect.height= icon_sz.GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -971,12 +971,11 @@ void ObjectList::extruder_editing()
|
|||||||
if (!item || !(m_objects_model->GetItemType(item) & (itVolume | itObject)))
|
if (!item || !(m_objects_model->GetItemType(item) & (itVolume | itObject)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int column_width = GetColumn(colExtruder)->GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 5;
|
wxRect rect = this->GetItemRect(item, GetColumn(colExtruder));
|
||||||
|
wxPoint pos = rect.GetPosition();
|
||||||
wxPoint pos = this->get_mouse_position_in_control();
|
pos.y -= 4;
|
||||||
wxSize size = wxSize(column_width, -1);
|
wxSize size = rect.GetSize();
|
||||||
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
|
size.SetWidth(size.GetWidth() + 8);
|
||||||
pos.y -= GetTextExtent("m").y;
|
|
||||||
|
|
||||||
apply_extruder_selector(&m_extruder_editor, this, L("default"), pos, size);
|
apply_extruder_selector(&m_extruder_editor, this, L("default"), pos, size);
|
||||||
|
|
||||||
@ -2433,6 +2432,21 @@ bool ObjectList::can_merge_to_single_object() const
|
|||||||
return (*m_objects)[obj_idx]->volumes.size() > 1;
|
return (*m_objects)[obj_idx]->volumes.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxPoint ObjectList::get_mouse_position_in_control() const
|
||||||
|
{
|
||||||
|
wxPoint pt = wxGetMousePosition() - this->GetScreenPosition();
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// Workaround for OSX. From wxWidgets 3.1.6 Hittest doesn't respect to the header of wxDataViewCtrl
|
||||||
|
if (wxDataViewItem top_item = this->GetTopItem(); top_item.IsOk()) {
|
||||||
|
auto rect = this->GetItemRect(top_item, this->GetColumn(0));
|
||||||
|
pt.y -= rect.y;
|
||||||
|
}
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
|
||||||
// NO_PARAMETERS function call means that changed object index will be determine from Selection()
|
// NO_PARAMETERS function call means that changed object index will be determine from Selection()
|
||||||
void ObjectList::changed_object(const int obj_idx/* = -1*/) const
|
void ObjectList::changed_object(const int obj_idx/* = -1*/) const
|
||||||
{
|
{
|
||||||
|
@ -280,7 +280,7 @@ public:
|
|||||||
bool can_merge_to_multipart_object() const;
|
bool can_merge_to_multipart_object() const;
|
||||||
bool can_merge_to_single_object() const;
|
bool can_merge_to_single_object() const;
|
||||||
|
|
||||||
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
|
wxPoint get_mouse_position_in_control() const;
|
||||||
wxBoxSizer* get_sizer() {return m_sizer;}
|
wxBoxSizer* get_sizer() {return m_sizer;}
|
||||||
int get_selected_obj_idx() const;
|
int get_selected_obj_idx() const;
|
||||||
ModelConfig& get_item_config(const wxDataViewItem& item) const;
|
ModelConfig& get_item_config(const wxDataViewItem& item) const;
|
||||||
|
@ -21,10 +21,10 @@ static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect)
|
|||||||
|
|
||||||
static wxSize get_bitmap_size(const wxBitmapBundle* bmp, wxWindow* parent)
|
static wxSize get_bitmap_size(const wxBitmapBundle* bmp, wxWindow* parent)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __WIN32__
|
||||||
return bmp->GetDefaultSize();
|
|
||||||
#else
|
|
||||||
return bmp->GetBitmapFor(parent).GetSize();
|
return bmp->GetBitmapFor(parent).GetSize();
|
||||||
|
#else
|
||||||
|
return bmp->GetDefaultSize();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,14 +389,14 @@ void PresetComboBox::sys_color_changed()
|
|||||||
|
|
||||||
void PresetComboBox::fill_width_height()
|
void PresetComboBox::fill_width_height()
|
||||||
{
|
{
|
||||||
icon_height = m_bitmapCompatible->GetPreferredBitmapSizeAtScale(1.0).GetHeight();
|
icon_height = 16;
|
||||||
norm_icon_width = m_bitmapCompatible->GetPreferredBitmapSizeAtScale(1.0).GetWidth();
|
norm_icon_width = 16;
|
||||||
|
|
||||||
null_icon_width = 2 * norm_icon_width;
|
|
||||||
|
|
||||||
thin_icon_width = 8;
|
thin_icon_width = 8;
|
||||||
wide_icon_width = norm_icon_width + thin_icon_width;
|
wide_icon_width = norm_icon_width + thin_icon_width;
|
||||||
|
|
||||||
|
null_icon_width = 2 * norm_icon_width;
|
||||||
|
|
||||||
space_icon_width = 2;
|
space_icon_width = 2;
|
||||||
thin_space_icon_width = 4;
|
thin_space_icon_width = 4;
|
||||||
wide_space_icon_width = 6;
|
wide_space_icon_width = 6;
|
||||||
@ -484,6 +484,7 @@ wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, const std::str
|
|||||||
|
|
||||||
wxBitmapBundle PresetComboBox::NullBitmapBndl()
|
wxBitmapBundle PresetComboBox::NullBitmapBndl()
|
||||||
{
|
{
|
||||||
|
assert(null_icon_width > 0);
|
||||||
return *get_empty_bmp_bundle(null_icon_width, icon_height);
|
return *get_empty_bmp_bundle(null_icon_width, icon_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,10 +108,10 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
|
|||||||
wxMenuItem* item = new wxMenuItem(menu, id, string, description);
|
wxMenuItem* item = new wxMenuItem(menu, id, string, description);
|
||||||
if (!icon.empty()) {
|
if (!icon.empty()) {
|
||||||
item->SetBitmap(*get_bmp_bundle(icon));
|
item->SetBitmap(*get_bmp_bundle(icon));
|
||||||
//#ifdef __WXMSW__
|
|
||||||
#ifndef __WXGTK__
|
#ifndef __linux__
|
||||||
msw_menuitem_bitmaps[id] = icon;
|
msw_menuitem_bitmaps[id] = icon;
|
||||||
#endif /* __WXMSW__ */
|
#endif // no __linux__
|
||||||
}
|
}
|
||||||
|
|
||||||
item->SetSubMenu(sub_menu);
|
item->SetSubMenu(sub_menu);
|
||||||
@ -409,8 +409,19 @@ int mode_icon_px_size()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WXGTK2__
|
||||||
|
static int scale()
|
||||||
|
{
|
||||||
|
return int(em_unit(nullptr) * 0.1f + 0.5f);
|
||||||
|
}
|
||||||
|
#endif // __WXGTK2__
|
||||||
|
|
||||||
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/)
|
wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16*/)
|
||||||
{
|
{
|
||||||
|
#ifdef __WXGTK2__
|
||||||
|
px_cnt *= scale();
|
||||||
|
#endif // __WXGTK2__
|
||||||
|
|
||||||
static Slic3r::GUI::BitmapCache cache;
|
static Slic3r::GUI::BitmapCache cache;
|
||||||
|
|
||||||
std::string bmp_name = bmp_name_in;
|
std::string bmp_name = bmp_name_in;
|
||||||
@ -430,13 +441,21 @@ wxBitmapBundle* get_bmp_bundle(const std::string& bmp_name_in, int px_cnt/* = 16
|
|||||||
wxBitmapBundle* get_empty_bmp_bundle(int width, int height)
|
wxBitmapBundle* get_empty_bmp_bundle(int width, int height)
|
||||||
{
|
{
|
||||||
static Slic3r::GUI::BitmapCache cache;
|
static Slic3r::GUI::BitmapCache cache;
|
||||||
|
#ifdef __WXGTK2__
|
||||||
|
return cache.mkclear_bndl(width * scale(), height * scale());
|
||||||
|
#else
|
||||||
return cache.mkclear_bndl(width, height);
|
return cache.mkclear_bndl(width, height);
|
||||||
|
#endif // __WXGTK2__
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color )
|
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color )
|
||||||
{
|
{
|
||||||
static Slic3r::GUI::BitmapCache cache;
|
static Slic3r::GUI::BitmapCache cache;
|
||||||
|
#ifdef __WXGTK2__
|
||||||
|
return cache.mksolid_bndl(width * scale(), height * scale(), color, 1, Slic3r::GUI::wxGetApp().dark_mode());
|
||||||
|
#else
|
||||||
return cache.mksolid_bndl(width, height, color, 1, Slic3r::GUI::wxGetApp().dark_mode());
|
return cache.mksolid_bndl(width, height, color, 1, Slic3r::GUI::wxGetApp().dark_mode());
|
||||||
|
#endif // __WXGTK2__
|
||||||
}
|
}
|
||||||
|
|
||||||
// win is used to get a correct em_unit value
|
// win is used to get a correct em_unit value
|
||||||
@ -486,8 +505,6 @@ std::vector<wxBitmapBundle*> get_extruder_color_icons(bool thin_icon/* = false*/
|
|||||||
if (colors.empty())
|
if (colors.empty())
|
||||||
return bmps;
|
return bmps;
|
||||||
|
|
||||||
bool dark_mode = Slic3r::GUI::wxGetApp().dark_mode();
|
|
||||||
|
|
||||||
for (const std::string& color : colors)
|
for (const std::string& color : colors)
|
||||||
bmps.emplace_back(get_solid_bmp_bundle(thin_icon ? 16 : 32, 16, color));
|
bmps.emplace_back(get_solid_bmp_bundle(thin_icon ? 16 : 32, 16, color));
|
||||||
|
|
||||||
|
@ -157,10 +157,10 @@ public:
|
|||||||
int px_cnt() const { return m_px_cnt;}
|
int px_cnt() const { return m_px_cnt;}
|
||||||
|
|
||||||
wxSize GetSize() const {
|
wxSize GetSize() const {
|
||||||
#ifdef __APPLE__
|
#ifdef __WIN32__
|
||||||
return m_bmp.GetDefaultSize();
|
|
||||||
#else
|
|
||||||
return m_bmp.GetPreferredBitmapSizeFor(m_parent);
|
return m_bmp.GetPreferredBitmapSizeFor(m_parent);
|
||||||
|
#else
|
||||||
|
return m_bmp.GetDefaultSize();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
int GetWidth() const { return GetSize().GetWidth(); }
|
int GetWidth() const { return GetSize().GetWidth(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user