Merge branch 'main' into enh-port-edit-gcode-dlg

# Conflicts:
#	src/slic3r/GUI/OG_CustomCtrl.cpp
#	src/slic3r/GUI/OG_CustomCtrl.hpp
This commit is contained in:
Ocraftyone 2024-01-01 10:58:04 -05:00
commit f78d55eac5
No known key found for this signature in database
GPG key ID: 85836ED21AD4D125
265 changed files with 29219 additions and 7128 deletions

View file

@ -1084,7 +1084,7 @@ void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
m_input_nozzle_min->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
//m_clr_picker->msw_rescale();
degree->sys_color_changed();
degree->msw_rescale();
bitmap_max_degree->SetBitmap(degree->bmp());
bitmap_min_degree->SetBitmap(degree->bmp());
m_button_reset->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);

View file

@ -19,7 +19,7 @@ AboutDialogLogo::AboutDialogLogo(wxWindow* parent)
{
this->SetBackgroundColour(*wxWHITE);
this->logo = ScalableBitmap(this, Slic3r::var("OrcaSlicer_192px.png"), wxBITMAP_TYPE_PNG);
this->SetMinSize(this->logo.GetSize());
this->SetMinSize(this->logo.GetBmpSize());
this->Bind(wxEVT_PAINT, &AboutDialogLogo::onRepaint, this);
}
@ -30,9 +30,9 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
dc.SetBackgroundMode(wxTRANSPARENT);
wxSize size = this->GetSize();
int logo_w = this->logo.GetWidth();
int logo_h = this->logo.GetHeight();
dc.DrawBitmap(this->logo.get_bitmap(), (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true);
int logo_w = this->logo.GetBmpWidth();
int logo_h = this->logo.GetBmpHeight();
dc.DrawBitmap(this->logo.bmp(), (size.GetWidth() - logo_w)/2, (size.GetHeight() - logo_h)/2, true);
event.Skip();
}
@ -380,7 +380,7 @@ AboutDialog::AboutDialog()
void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bitmap.sys_color_changed();
m_logo_bitmap.msw_rescale();
m_logo->SetBitmap(m_logo_bitmap.bmp());
const wxFont& font = GetFont();

View file

@ -187,7 +187,7 @@ void MaterialItem::doRender(wxDC &dc)
auto acolor = m_ams_coloul;
if (mcolor.Alpha() == 0 || acolor.Alpha() == 0) {
dc.DrawBitmap(m_transparent_mitem.get_bitmap(), FromDIP(1), FromDIP(1));
dc.DrawBitmap(m_transparent_mitem.bmp(), FromDIP(1), FromDIP(1));
}
if (!IsEnabled()) {
@ -247,10 +247,10 @@ void MaterialItem::doRender(wxDC &dc)
//arrow
if ( (acolor.Red() > 160 && acolor.Green() > 160 && acolor.Blue() > 160) &&
(acolor.Red() < 180 && acolor.Green() < 180 && acolor.Blue() < 180)) {
dc.DrawBitmap(m_arraw_bitmap_white.get_bitmap(), GetSize().x - m_arraw_bitmap_white.GetSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetSize().y);
dc.DrawBitmap(m_arraw_bitmap_white.bmp(), GetSize().x - m_arraw_bitmap_white.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_white.GetBmpSize().y);
}
else {
dc.DrawBitmap(m_arraw_bitmap_gray.get_bitmap(), GetSize().x - m_arraw_bitmap_gray.GetSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_gray.GetSize().y);
dc.DrawBitmap(m_arraw_bitmap_gray.bmp(), GetSize().x - m_arraw_bitmap_gray.GetBmpSize().x - FromDIP(7), GetSize().y - m_arraw_bitmap_gray.GetBmpSize().y);
}
@ -677,7 +677,7 @@ void MappingItem::doRender(wxDC &dc)
dc.SetBrush(wxBrush(m_coloul));
if (m_coloul.Alpha() == 0) {
dc.DrawBitmap( m_transparent_mapping_item.get_bitmap(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
dc.DrawBitmap( m_transparent_mapping_item.bmp(), 0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2);
}
else {
dc.DrawRectangle(0, (GetSize().y - MAPPING_ITEM_REAL_SIZE.y) / 2, MAPPING_ITEM_REAL_SIZE.x, MAPPING_ITEM_REAL_SIZE.y);
@ -1340,7 +1340,7 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
}
else {
label_txt->SetLabelText(_L("If there are two identical filaments in AMS, AMS filament backup will be enabled. \n(Currently supporting automatic supply of consumables with the same brand, material type, and color)"));
}
}
label_txt->SetMinSize(wxSize(FromDIP(380), -1));
label_txt->SetMaxSize(wxSize(FromDIP(380), -1));
@ -1494,7 +1494,7 @@ void AmsRMGroup::doRender(wxDC& dc)
float startAngle = 0.0;
float endAngle = 0.0;
dc.DrawBitmap(bitmap_bg.get_bitmap(), wxPoint((size.x - bitmap_bg.GetSize().x) / 2, (size.y - bitmap_bg.GetSize().y) / 2));
dc.DrawBitmap(bitmap_bg.bmp(), wxPoint((size.x - bitmap_bg.GetBmpSize().x) / 2, (size.y - bitmap_bg.GetBmpSize().y) / 2));
for (auto iter = m_group_info.rbegin(); iter != m_group_info.rend(); ++iter) {
std::string tray_name = iter->first;
@ -1575,7 +1575,7 @@ void AmsRMGroup::doRender(wxDC& dc)
dc.DrawEllipticArc(x - center_mask_radius, y - center_mask_radius, center_mask_radius * 2, center_mask_radius * 2, 0, 360);
//draw center icon
dc.DrawBitmap(bitmap_backup_tips_0.get_bitmap(), wxPoint((size.x - bitmap_backup_tips_0.GetSize().x) / 2, (size.y - bitmap_backup_tips_0.GetSize().y) / 2));
dc.DrawBitmap(bitmap_backup_tips_0.bmp(), wxPoint((size.x - bitmap_backup_tips_0.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_0.GetBmpSize().y) / 2));
//dc.DrawBitmap(bitmap_backup_tips_1.bmp(), wxPoint((size.x - bitmap_backup_tips_1.GetBmpSize().x) / 2, (size.y - bitmap_backup_tips_1.GetBmpSize().y) / 2));
//draw material

View file

@ -226,7 +226,7 @@ void AuFile::PaintBackground(wxDC &dc)
dc.SetPen(AUFILE_GREY200);
dc.SetBrush(AUFILE_GREY200);
dc.DrawRoundedRectangle(0, 0, size.x, size.y, AUFILE_ROUNDING);
dc.DrawBitmap(m_file_bitmap.get_bitmap(), (size.x - m_file_bitmap.GetWidth()) / 2, (size.y - m_file_bitmap.GetHeight()) / 2);
dc.DrawBitmap(m_file_bitmap.bmp(), (size.x - m_file_bitmap.GetBmpWidth()) / 2, (size.y - m_file_bitmap.GetBmpHeight()) / 2);
}
}
@ -257,7 +257,7 @@ void AuFile::PaintForeground(wxDC &dc)
}
if (m_type == MODEL_PICTURE) {
dc.DrawBitmap(m_file_edit_mask.get_bitmap(), 0, size.y - m_file_edit_mask.GetSize().y);
dc.DrawBitmap(m_file_edit_mask.bmp(), 0, size.y - m_file_edit_mask.GetBmpSize().y);
}
@ -268,14 +268,14 @@ void AuFile::PaintForeground(wxDC &dc)
auto sizet = dc.GetTextExtent(cover_text_left);
auto pos = wxPoint(0, 0);
pos.x = (size.x / 2 - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_left, pos);
// right text
sizet = dc.GetTextExtent(cover_text_right);
pos = wxPoint(0, 0);
pos.x = size.x / 2 + (size.x / 2 - sizet.x) / 2;
pos.y = (size.y - (m_file_edit_mask.GetSize().y + sizet.y) / 2);
pos.y = (size.y - (m_file_edit_mask.GetBmpSize().y + sizet.y) / 2);
dc.DrawText(cover_text_right, pos);
// Split
@ -283,7 +283,7 @@ void AuFile::PaintForeground(wxDC &dc)
dc.SetBrush(*wxWHITE);
pos = wxPoint(0, 0);
pos.x = size.x / 2 - 1;
pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetSize().y - FromDIP(24)) / 2;
pos.y = size.y - FromDIP(24) - (m_file_edit_mask.GetBmpSize().y - FromDIP(24)) / 2;
dc.DrawRectangle(pos.x, pos.y, 2, FromDIP(24));
} else {
// right text
@ -297,7 +297,7 @@ void AuFile::PaintForeground(wxDC &dc)
if (m_cover) {
dc.SetTextForeground(*wxWHITE);
dc.DrawBitmap(m_file_cover.get_bitmap(), size.x - m_file_cover.GetSize().x, 0);
dc.DrawBitmap(m_file_cover.bmp(), size.x - m_file_cover.GetBmpSize().x, 0);
dc.SetFont(Label::Body_12);
auto sizet = dc.GetTextExtent(cover_text_cover);
auto pos = wxPoint(0, 0);
@ -306,7 +306,7 @@ void AuFile::PaintForeground(wxDC &dc)
dc.DrawText(cover_text_cover, pos);
}
if (m_hover) { dc.DrawBitmap(m_file_delete.get_bitmap(), size.x - m_file_delete.GetSize().x - FromDIP(10), FromDIP(10)); }
if (m_hover) { dc.DrawBitmap(m_file_delete.bmp(), size.x - m_file_delete.GetBmpSize().x - FromDIP(10), FromDIP(10)); }
}
void AuFile::on_mouse_enter(wxMouseEvent &evt)
@ -421,7 +421,7 @@ void AuFile::on_mouse_left_up(wxMouseEvent &evt)
auto pos = evt.GetPosition();
// set cover
auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetSize().y);
auto mask_size = wxSize(GetSize().x, m_file_edit_mask.GetBmpSize().y);
auto cover_left = 0;
auto cover_top = size.y - mask_size.y;
auto cover_right = mask_size.x / 2;
@ -443,10 +443,10 @@ void AuFile::on_mouse_left_up(wxMouseEvent &evt)
if (pos.x > rename_left && pos.x < rename_right && pos.y > rename_top && pos.y < rename_bottom) { on_set_rename(); return; }
// close
auto close_left = size.x - m_file_delete.GetSize().x - FromDIP(10);
auto close_left = size.x - m_file_delete.GetBmpSize().x - FromDIP(10);
auto close_top = FromDIP(10);
auto close_right = size.x - FromDIP(10);
auto close_bottom = m_file_delete.GetSize().y + FromDIP(10);
auto close_bottom = m_file_delete.GetBmpSize().y + FromDIP(10);
if (pos.x > close_left && pos.x < close_right && pos.y > close_top && pos.y < close_bottom) { on_set_delete(); return; }
exit_rename_mode();

View file

@ -93,7 +93,9 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
int bmpX = 0, bmpY = 0;
int textX = 0, textY = 0;
const wxBitmap &bmp = item.GetCurrentBitmapFor(wnd);
const wxBitmap& bmp = item.GetState() & wxAUI_BUTTON_STATE_DISABLED
? item.GetDisabledBitmap()
: item.GetBitmap();
const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
@ -531,15 +533,6 @@ void BBLTopbar::OnFullScreen(wxAuiToolBarEvent& event)
m_frame->Restore();
}
else {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
#ifdef __WXMSW__
HWND hWnd = m_frame->GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
m_frame->SetMaxSize(size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom});
#endif // __WXMSW__
m_normalRect = m_frame->GetRect();
m_frame->Maximize();
}

View file

@ -13,8 +13,10 @@
#include <wx/rawbmp.h>
#endif /* __WXGTK2__ */
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
#define NANOSVG_IMPLEMENTATION
#include "nanosvg/nanosvg.h"
#define NANOSVGRAST_IMPLEMENTATION
#include "nanosvg/nanosvgrast.h"
namespace Slic3r { namespace GUI {
@ -58,168 +60,7 @@ static wxBitmap wxImage_to_wxBitmap_with_alpha(wxImage &&image, float scale = 1.
#endif
}
wxBitmapBundle* BitmapCache::insert_bndl(const std::string& name, const std::vector<wxBitmapBundle*>& bmps)
{
wxVector<wxBitmap> bitmaps;
std::set<double> scales = {1.0};
#ifndef __linux__
#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
#endif // !__linux__
for (double scale : scales) {
size_t width = 0;
size_t height = 0;
for (const wxBitmapBundle* bmp_bndl : bmps) {
#ifdef __APPLE__
wxSize size = bmp_bndl->GetDefaultSize();
#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->GetDefaultSize());
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.GetScaledWidth();
}
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);
// we should "move" with step equal to non-scaled width
#ifdef __APPLE__
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* BitmapCache::insert(const std::string &bitmap_key, size_t width, size_t height)
{
wxBitmap *bitmap = nullptr;
auto it = m_map.find(bitmap_key);
@ -235,7 +76,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, scale < 0.0 ? m_scale : scale);
bitmap->CreateScaled(width, height, -1, m_scale);
#endif
m_map[bitmap_key] = bitmap;
} else {
@ -264,6 +105,110 @@ wxBitmap* BitmapCache::insert(const std::string &bitmap_key, const wxBitmap &bmp
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*/)
{
wxImage image(width, height);
@ -360,102 +305,7 @@ 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))
+ (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
//Orca: use replaces from load_svg function
std::map<std::string, std::string> replaces;
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#00FF00\""] = "\"#52c7b8\"";
if (dark_mode) {
replaces["\"#262E30\""] = "\"#EFEFF0\"";
replaces["\"#323A3D\""] = "\"#B3B3B5\"";
replaces["\"#808080\""] = "\"#818183\"";
replaces["\"#CECECE\""] = "\"#54545B\"";
replaces["\"#6B6B6B\""] = "\"#818182\"";
replaces["\"#909090\""] = "\"#FFFFFF\"";
replaces["\"#00FF00\""] = "\"#FF0000\"";
replaces["\"#009688\""] = "\"#00675b\"";
}
std::string str;
nsvgGetDataFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), str, replaces);
if (str.empty())
return nullptr;
return insert_bndl(bitmap_key, str.data(), target_width, target_height);
}
wxBitmapBundle* BitmapCache::from_png(const std::string& bitmap_name, unsigned width, unsigned height)
{
std::string bitmap_key = bitmap_name + (height != 0 ?
"-h" + std::to_string(height) :
"-w" + std::to_string(width));
auto it = m_bndl_map.find(bitmap_key);
if (it != m_bndl_map.end())
return it->second;
wxImage image;
if (!image.LoadFile(Slic3r::GUI::from_u8(Slic3r::var(bitmap_name + ".png")), wxBITMAP_TYPE_PNG) ||
image.GetWidth() == 0 || image.GetHeight() == 0)
return nullptr;
if (height != 0 && unsigned(image.GetHeight()) != height)
width = unsigned(0.5f + float(image.GetWidth()) * height / image.GetHeight());
else if (width != 0 && unsigned(image.GetWidth()) != width)
height = unsigned(0.5f + float(image.GetHeight()) * width / image.GetWidth());
if (height != 0 && width != 0)
image.Rescale(width, height, wxIMAGE_QUALITY_BILINEAR);
return this->insert_bndl(bitmap_key, wxImage_to_wxBitmap_with_alpha(std::move(image)));
}
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_width, unsigned target_height,
const bool grayscale/* = false*/, const bool dark_mode/* = false*/, const std::string& new_color /*= ""*/, const float scale_in_center/* = 0*/)
{
std::string bitmap_key = bitmap_name + ( target_height !=0 ?
@ -472,7 +322,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
// map of color replaces
std::map<std::string, std::string> replaces;
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#0x00AE42\""] = "\"#009688\"";
replaces["\"#00FF00\""] = "\"#52c7b8\"";
if (dark_mode) {
replaces["\"#262E30\""] = "\"#EFEFF0\"";
@ -483,7 +333,7 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
replaces["\"#6B6B6B\""] = "\"#818182\"";
replaces["\"#909090\""] = "\"#FFFFFF\"";
replaces["\"#00FF00\""] = "\"#FF0000\"";
replaces["\"#009688\""] = "\"#00675b\"";
replaces["\"#009688\""] = "\"#00675b\"";
}
//if (!new_color.empty())
// replaces["\"#ED6B21\""] = "\"" + new_color + "\"";
@ -536,9 +386,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
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
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*/)
{
double scale = suppress_scaling ? 1.0f : m_scale;
width *= scale;
@ -580,89 +430,6 @@ 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 };
#ifndef __linux__
#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
#endif // !__linux__
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" : 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;
}
bool BitmapCache::parse_color(const std::string& scolor, unsigned char* rgb_out)
{

View file

@ -12,8 +12,7 @@
#include "libslic3r/Color.hpp"
struct NSVGimage;
namespace Slic3r {
namespace GUI {
namespace Slic3r { namespace GUI {
class BitmapCache
{
@ -23,23 +22,15 @@ 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); }
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, size_t width, size_t height);
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(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);
// BBS: support resize by fill border (scale_in_center)
@ -50,28 +41,19 @@ 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 = "", const float scale_in_center = 0.f);
// wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
// wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
// 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_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); }
wxBitmap mksolid(size_t width, size_t height, unsigned char r, unsigned char g, unsigned char b, unsigned char transparency, bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false);
wxBitmap mksolid(size_t width, size_t height, const unsigned char rgb[3], bool suppress_scaling = false, size_t border_width = 0, bool dark_mode = false) { return mksolid(width, height, rgb[0], rgb[1], rgb[2], wxALPHA_OPAQUE, suppress_scaling, border_width, dark_mode); }
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); }
static bool parse_color(const std::string& scolor, unsigned char* rgb_out);
static bool parse_color4(const std::string& scolor, unsigned char* rgba_out);
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
};

View file

@ -54,6 +54,17 @@ 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*/,
@ -79,6 +90,72 @@ 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)
@ -89,11 +166,18 @@ 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
wxBitmapBundle bitmap = *get_empty_bmp_bundle(1, 16);
wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1));
{
// bitmap.SetWidth(0); is depricated now
// so, use next code
bitmap.UnShare();// AllocExclusive();
bitmap.GetGDIImageData()->m_width = 0;
}
OnAddBitmap(bitmap);
const int n = wxComboBox::Append(item);
if (n != wxNOT_FOUND)
DoSetItemBitmap(n, bitmap);
return n;
}

View file

@ -29,13 +29,28 @@ BitmapComboBox(wxWindow* parent,
#ifdef _WIN32
int Append(const wxString& item);
#endif
int Append(const wxString& item, const wxBitmapBundle& bitmap)
int Append(const wxString& item, const wxBitmap& 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;

View file

@ -102,9 +102,9 @@ void MObjectPanel::doRender(wxDC& dc)
if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; }
// dc.DrawCircle(left, size.y / 2, 3);
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
left += dwbitmap.GetSize().x + 8;
left += dwbitmap.GetBmpSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
@ -242,7 +242,7 @@ void SelectMObjectPopup::Popup(wxWindow* WXUNUSED(focus))
if (wxGetApp().is_user_login()) {
if (!get_print_info_thread) {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -716,4 +716,4 @@ CalibrationPanel::~CalibrationPanel() {
delete m_refresh_timer;
}
}}
}}

View file

@ -371,7 +371,7 @@ CaliPageCaption::CaliPageCaption(wxWindow* parent, CalibMode cali_mode,
auto top_sizer = new wxBoxSizer(wxVERTICAL);
auto caption_sizer = new wxBoxSizer(wxHORIZONTAL);
m_prev_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_prev",
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 30);
m_prev_btn->SetBackgroundColour(*wxWHITE);
caption_sizer->Add(m_prev_btn, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(10));
@ -382,7 +382,7 @@ CaliPageCaption::CaliPageCaption(wxWindow* parent, CalibMode cali_mode,
caption_sizer->Add(title_text, 0, wxALIGN_CENTER | wxRIGHT, FromDIP(10));
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help",
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 30);
wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true, 30);
m_help_btn->Hide();
m_help_btn->SetBackgroundColour(*wxWHITE);
caption_sizer->Add(m_help_btn, 0, wxALIGN_CENTER);
@ -472,12 +472,12 @@ void CaliPageCaption::show_help_icon(bool show)
void CaliPageCaption::on_sys_color_changed()
{
m_prev_btn->sys_color_changed();
m_prev_btn->msw_rescale();
}
void CaliPageCaption::msw_rescale()
{
m_prev_btn->sys_color_changed();
m_prev_btn->msw_rescale();
}
CaliPageStepGuide::CaliPageStepGuide(wxWindow* parent, wxArrayString steps,
@ -593,7 +593,7 @@ PAPageHelpPanel::PAPageHelpPanel(wxWindow* parent, bool ground_panel, wxWindowID
wxBoxSizer* help_text_sizer = new wxBoxSizer(wxHORIZONTAL);
auto help_text = new Label(this, _L("You could change the Flow Dynamics Calibration Factor in material editing"));
help_text->SetFont(Label::Body_14);
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 24);
m_help_btn = new ScalableButton(this, wxID_ANY, "cali_page_caption_help", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 24);
m_help_btn->SetBackgroundColour(m_help_btn->GetParent()->GetBackgroundColour());
help_text_sizer->Add(help_text, 0, wxALIGN_CENTER | wxLEFT, left_align_padding);
help_text_sizer->Add(m_help_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(8));
@ -611,8 +611,8 @@ PAPageHelpPanel::PAPageHelpPanel(wxWindow* parent, bool ground_panel, wxWindowID
void PAPageHelpPanel::msw_rescale()
{
m_help_btn->sys_color_changed();
m_bmp.sys_color_changed();
m_help_btn->msw_rescale();
m_bmp.msw_rescale();
m_img->SetBitmap(m_bmp.bmp());
}

View file

@ -448,7 +448,7 @@ CalibrationPresetPage::CalibrationPresetPage(
void CalibrationPresetPage::msw_rescale()
{
CalibrationWizardPage::msw_rescale();
m_ams_sync_button->sys_color_changed();
m_ams_sync_button->msw_rescale();
m_virtual_tray_comboBox->msw_rescale();
for (auto& comboBox : m_filament_comboBox_list) {
comboBox->msw_rescale();
@ -458,7 +458,7 @@ void CalibrationPresetPage::msw_rescale()
void CalibrationPresetPage::on_sys_color_changed()
{
CalibrationWizardPage::on_sys_color_changed();
m_ams_sync_button->sys_color_changed();
m_ams_sync_button->msw_rescale();
}
void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
@ -507,7 +507,7 @@ void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
filament_for_text->SetFont(Label::Head_14);
filament_for_title_sizer->Add(filament_for_text, 0, wxALIGN_CENTER);
filament_for_title_sizer->AddSpacer(FromDIP(25));
m_ams_sync_button = new ScalableButton(parent, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, 18);
m_ams_sync_button = new ScalableButton(parent, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 18);
m_ams_sync_button->SetBackgroundColour(*wxWHITE);
m_ams_sync_button->SetToolTip(_L("Synchronize filament list from AMS"));
filament_for_title_sizer->Add(m_ams_sync_button, 0, wxALIGN_CENTER);

View file

@ -470,8 +470,8 @@ CameraItem::CameraItem(wxWindow *parent, std::string normal, std::string hover)
CameraItem::~CameraItem() {}
void CameraItem::msw_rescale() {
m_bitmap_normal.sys_color_changed();
m_bitmap_hover.sys_color_changed();
m_bitmap_normal.msw_rescale();
m_bitmap_hover.msw_rescale();
}
void CameraItem::on_enter_win(wxMouseEvent &evt)
@ -519,9 +519,9 @@ void CameraItem::render(wxDC &dc)
void CameraItem::doRender(wxDC &dc)
{
if (m_hover) {
dc.DrawBitmap(m_bitmap_hover.get_bitmap(), wxPoint((GetSize().x - m_bitmap_hover.GetSize().x) / 2, (GetSize().y - m_bitmap_hover.GetSize().y) / 2));
dc.DrawBitmap(m_bitmap_hover.bmp(), wxPoint((GetSize().x - m_bitmap_hover.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_hover.GetBmpSize().y) / 2));
} else {
dc.DrawBitmap(m_bitmap_normal.get_bitmap(), wxPoint((GetSize().x - m_bitmap_normal.GetSize().x) / 2, (GetSize().y - m_bitmap_normal.GetSize().y) / 2));
dc.DrawBitmap(m_bitmap_normal.bmp(), wxPoint((GetSize().x - m_bitmap_normal.GetBmpSize().x) / 2, (GetSize().y - m_bitmap_normal.GetBmpSize().y) / 2));
}
}

View file

@ -277,7 +277,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
sparse_infill_density == 0 &&
! config->opt_bool("enable_support") &&
config->opt_int("enforce_support_layers") == 0 &&
config->opt_bool("ensure_vertical_shell_thickness") &&
! config->opt_bool("detect_thin_wall") &&
! config->opt_bool("overhang_reverse") &&
config->opt_enum<TimelapseType>("timelapse_type") == TimelapseType::tlTraditional))
@ -305,7 +304,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
new_conf.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
new_conf.set_key_value("enable_support", new ConfigOptionBool(false));
new_conf.set_key_value("enforce_support_layers", new ConfigOptionInt(0));
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(true));
new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false));
new_conf.set_key_value("overhang_reverse", new ConfigOptionBool(false));
new_conf.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
@ -326,6 +324,30 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
}
is_msg_dlg_already_exist = false;
}
if (config->opt_bool("alternate_extra_wall") && config->opt_bool("ensure_vertical_shell_thickness"))
{
wxString msg_text = _(L("Alternate extra wall only works with ensure vertical shell thickness disabled. "));
if (is_global_config)
msg_text += "\n\n" + _(L("Change these settings automatically? \n"
"Yes - Disable ensure vertical shell thickness and enable alternate extra wall\n"
"No - Dont use alternate extra wall"));
MessageDialog dialog(m_msg_dlg_parent, msg_text, "",
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
if (!is_global_config || answer == wxID_YES) {
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(false));
new_conf.set_key_value("alternate_extra_wall", new ConfigOptionBool(true));
}
else {
new_conf.set_key_value("ensure_vertical_shell_thickness", new ConfigOptionBool(true));
new_conf.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
}
apply(config, &new_conf);
}
// BBS
int filament_cnt = wxGetApp().preset_bundle->filament_presets.size();
@ -506,7 +528,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
bool has_spiral_vase = config->opt_bool("spiral_mode");
toggle_line("spiral_mode_smooth", has_spiral_vase);
toggle_line("spiral_mode_max_xy_smoothing", config->opt_bool("spiral_mode_smooth"));
toggle_line("spiral_mode_max_xy_smoothing", has_spiral_vase && config->opt_bool("spiral_mode_smooth"));
bool has_top_solid_infill = config->opt_int("top_shell_layers") > 0;
bool has_bottom_solid_infill = config->opt_int("bottom_shell_layers") > 0;
bool has_solid_infill = has_top_solid_infill || has_bottom_solid_infill;
@ -690,8 +712,6 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
toggle_line("make_overhang_printable_angle", have_make_overhang_printable);
toggle_line("make_overhang_printable_hole_size", have_make_overhang_printable);
toggle_line("exclude_object", gcflavor == gcfKlipper);
toggle_line("min_width_top_surface",config->opt_bool("only_one_wall_top"));
for (auto el : { "hole_to_polyhole_threshold", "hole_to_polyhole_twisted" })

View file

@ -1499,7 +1499,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.GetSize());
SetMinSize(bg.bmp().GetSize());
const wxSize size = GetTextExtent("m");
em_w = size.x;
@ -1626,8 +1626,8 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
wxPaintDC dc(this);
const auto bullet_w = bullet_black.GetWidth();
const auto bullet_h = bullet_black.GetHeight();
const auto bullet_w = bullet_black.bmp().GetSize().GetWidth();
const auto bullet_h = bullet_black.bmp().GetSize().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();
@ -1640,10 +1640,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.get_bitmap(), x, y + yoff_icon, false);
dc.DrawBitmap(bullet_blue.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); }
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); }
x += + bullet_w + em_w/2;
const auto text_size = dc.GetTextExtent(item.label);
@ -1655,9 +1655,9 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
}
//draw logo
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 (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 (GetMinSize().x < index_width) {
@ -1689,12 +1689,12 @@ void ConfigWizardIndex::msw_rescale()
em_w = size.x;
em_h = size.y;
bg.sys_color_changed();
SetMinSize(bg.GetSize());
bg.msw_rescale();
SetMinSize(bg.bmp().GetSize());
bullet_black.sys_color_changed();
bullet_blue.sys_color_changed();
bullet_white.sys_color_changed();
bullet_black.msw_rescale();
bullet_blue.msw_rescale();
bullet_white.msw_rescale();
Refresh();
}

View file

@ -510,7 +510,7 @@ private:
ssize_t item_hover;
size_t last_page;
int item_height() const { return std::max(bullet_black.GetHeight(), em_w) + em_w; }
int item_height() const { return std::max(bullet_black.bmp().GetSize().GetHeight(), em_w) + em_w; }
void on_paint(wxPaintEvent &evt);
void on_mouse_move(wxMouseEvent &evt);

View file

@ -13,6 +13,7 @@
#include "FileHelp.hpp"
#include "Tab.hpp"
#include "MainFrame.hpp"
#include "libslic3r_version.h"
#define NAME_OPTION_COMBOBOX_SIZE wxSize(FromDIP(200), FromDIP(24))
#define FILAMENT_PRESET_COMBOBOX_SIZE wxSize(FromDIP(300), FromDIP(24))
@ -179,7 +180,7 @@ static bool delete_filament_preset_by_name(std::string delete_preset_name, std::
return true;
}
static std::string get_curr_time()
static std::string get_curr_time(const char* format = "%Y_%m_%d_%H_%M_%S")
{
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
@ -187,7 +188,7 @@ static std::string get_curr_time()
std::tm local_time = *std::localtime(&time);
std::ostringstream time_stream;
time_stream << std::put_time(&local_time, "%Y_%m_%d_%H_%M_%S");
time_stream << std::put_time(&local_time, format);
std::string current_time = time_stream.str();
return current_time;
@ -195,11 +196,12 @@ static std::string get_curr_time()
static std::string get_curr_timestmp()
{
std::time_t currentTime = std::time(nullptr);
std::ostringstream oss;
oss << currentTime;
std::string timestampString = oss.str();
return timestampString;
return get_curr_time("%Y%m%d%H%M%S");
// std::time_t currentTime = std::time(nullptr);
// std::ostringstream oss;
// oss << currentTime;
// std::string timestampString = oss.str();
// return timestampString;
}
static void get_filament_compatible_printer(Preset* preset, vector<std::string>& printers)
@ -1474,9 +1476,9 @@ wxBoxSizer *CreatePrinterPresetDialog::create_step_switch_item()
{
wxBoxSizer *step_switch_sizer = new wxBoxSizer(wxVERTICAL);
std::string wiki_url = "https://wiki.bambulab.com/en/software/bambu-studio/3rd-party-printer-profile";
wxHyperlinkCtrl *m_download_hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("wiki"), wiki_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
step_switch_sizer->Add(m_download_hyperlink, 0, wxRIGHT | wxALIGN_RIGHT, FromDIP(5));
// std::string wiki_url = "https://wiki.bambulab.com/en/software/bambu-studio/3rd-party-printer-profile";
// wxHyperlinkCtrl *m_download_hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("wiki"), wiki_url, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
// step_switch_sizer->Add(m_download_hyperlink, 0, wxRIGHT | wxALIGN_RIGHT, FromDIP(5));
wxBoxSizer *horizontal_sizer = new wxBoxSizer(wxHORIZONTAL);
wxPanel * step_switch_panel = new wxPanel(this);
@ -3266,8 +3268,8 @@ void CreatePresetSuccessfulDialog::on_dpi_changed(const wxRect &suggested_rect)
ExportConfigsDialog::ExportConfigsDialog(wxWindow *parent)
: DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Export Configs"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
m_exprot_type.preset_bundle = _L("Printer config bundle(.bbscfg)");
m_exprot_type.filament_bundle = _L("Filament bundle(.bbsflmt)");
m_exprot_type.preset_bundle = _L("Printer config bundle(.orca_printer)");
m_exprot_type.filament_bundle = _L("Filament bundle(.orca_filament)");
m_exprot_type.printer_preset = _L("Printer presets(.zip)");
m_exprot_type.filament_preset = _L("Filament presets(.zip)");
m_exprot_type.process_preset = _L("Process presets(.zip)");
@ -3407,49 +3409,7 @@ std::string ExportConfigsDialog::initial_file_path(const wxString &path, const s
std::string export_path = into_u8(path);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "initial file path and path is:" << export_path << " and sub path is: " << sub_file_path;
boost::filesystem::path printer_export_path = (boost::filesystem::path(export_path) / sub_file_path).make_preferred();
if (boost::filesystem::exists(printer_export_path)) {
MessageDialog dlg(this, wxString::Format(_L("The '%s' folder already exists in the current directory. Do you want to clear it and rebuild it.\nIf not, a time suffix will be "
"added, and you can modify the name after creation."), sub_file_path), wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"), wxYES_NO | wxYES_DEFAULT | wxCENTRE);
int res = dlg.ShowModal();
if (wxID_YES == res) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Same path exists, delete and need to rebuild, and path is: " << printer_export_path.string();
try {
boost::filesystem::remove_all(printer_export_path);
} catch (...) {
MessageDialog dlg(this, _L(wxString::Format("The file: %s \nin the directory may have been opened by another program. \nPlease close it and try again.",
encode_path(printer_export_path.string().c_str()))),
wxString(SLIC3R_APP_FULL_NAME) + " - " + _L("Info"),
wxYES | wxYES_DEFAULT | wxCENTRE);
dlg.ShowModal();
return "initial_failed";
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "delete path";
boost::filesystem::create_directories(printer_export_path);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "create path";
export_path = printer_export_path.string();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Same path exists, delete and rebuild, and path is: " << export_path;
} else if (wxID_NO == res) {
export_path = printer_export_path.string();
std::string export_path_with_time;
boost::filesystem::path *printer_export_path_with_time = nullptr;
do {
if (printer_export_path_with_time) {
delete printer_export_path_with_time;
printer_export_path_with_time = nullptr;
}
export_path_with_time = export_path + " " + get_curr_time();
printer_export_path_with_time = new boost::filesystem::path(export_path_with_time);
} while (boost::filesystem::exists(*printer_export_path_with_time));
export_path = export_path_with_time;
boost::filesystem::create_directories(*printer_export_path_with_time);
if (printer_export_path_with_time) {
delete printer_export_path_with_time;
printer_export_path_with_time = nullptr;
}
} else {
return "";
}
} else {
if (!boost::filesystem::exists(printer_export_path)) {
boost::filesystem::create_directories(printer_export_path);
export_path = printer_export_path.string();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "Same path exists, delete and rebuild, and path is: " << export_path;
@ -3519,7 +3479,7 @@ wxBoxSizer *ExportConfigsDialog::create_export_config_item(wxWindow *parent)
radioBoxSizer->Add(create_radio_item(m_exprot_type.preset_bundle, parent, wxEmptyString, m_export_type_btns), 0, wxEXPAND | wxALL, 0);
radioBoxSizer->Add(0, 0, 0, wxTOP, FromDIP(6));
wxStaticText *static_export_printer_preset_bundle_text = new wxStaticText(parent, wxID_ANY, _L("Printer and all the filament&process presets that belongs to the printer. \nCan be shared with others."), wxDefaultPosition, wxDefaultSize);
wxStaticText *static_export_printer_preset_bundle_text = new wxStaticText(parent, wxID_ANY, _L("Printer and all the filament&&process presets that belongs to the printer. \nCan be shared with others."), wxDefaultPosition, wxDefaultSize);
static_export_printer_preset_bundle_text->SetFont(Label::Body_12);
static_export_printer_preset_bundle_text->SetForegroundColour(wxColour("#6B6B6B"));
radioBoxSizer->Add(static_export_printer_preset_bundle_text, 0, wxEXPAND | wxLEFT, FromDIP(22));
@ -3707,7 +3667,7 @@ void ExportConfigsDialog::select_curr_radiobox(std::vector<std::pair<RadioBox *,
ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_file(const wxString &path)
{
std::string export_path = initial_file_path(path, "Printer config bundle");
std::string export_path = initial_file_path(path, "");
if (export_path.empty() || "initial_failed" == export_path) return ExportCase::EXPORT_CANCEL;
BOOST_LOG_TRIVIAL(info) << "Export printer preset bundle";
@ -3717,19 +3677,11 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
std::string printer_preset_name_ = printer_preset->name;
json bundle_structure;
NetworkAgent *agent = wxGetApp().getAgent();
std::string clock = get_curr_timestmp();
if (agent) {
bundle_structure["user_name"] = agent->get_user_name();
bundle_structure["user_id"] = agent->get_user_id();
bundle_structure["version"] = agent->get_version();
bundle_structure["bundle_id"] = agent->get_user_id() + "_" + printer_preset_name_ + "_" + clock;
} else {
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = "";
bundle_structure["bundle_id"] = "offline_" + printer_preset_name_ + "_" + clock;
}
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = SoftFever_VERSION;
bundle_structure["bundle_id"] = printer_preset_name_ + "_" + clock;
bundle_structure["bundle_type"] = "printer config bundle";
bundle_structure["printer_preset_name"] = printer_preset_name_;
json printer_config = json::array();
@ -3737,21 +3689,21 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
json process_configs = json::array();
mz_zip_archive zip_archive;
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + printer_preset->name + ".bbscfg");
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + printer_preset->name + ".orca_printer");
if (MZ_FALSE == status) {
BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
return ExportCase::INITIALIZE_FAIL;
}
boost::filesystem::path pronter_file_path = boost::filesystem::path(printer_preset->file);
std::string preset_path = pronter_file_path.make_preferred().string();
boost::filesystem::path printer_file_path = boost::filesystem::path(printer_preset->file);
std::string preset_path = printer_file_path.make_preferred().string();
if (preset_path.empty()) {
BOOST_LOG_TRIVIAL(info) << "Export printer preset: " << printer_preset->name << " skip because of the preset file path is empty.";
continue;
}
// Add a file to the ZIP file
std::string printer_config_file_name = "printer/" + pronter_file_path.filename().string();
std::string printer_config_file_name = "printer/" + printer_file_path.filename().string();
status = mz_zip_writer_add_file(&zip_archive, printer_config_file_name.c_str(), encode_path(preset_path.c_str()).c_str(), NULL, 0, MZ_DEFAULT_COMPRESSION);
//status = mz_zip_writer_add_mem(&zip_archive, ("printer/" + printer_preset->name + ".json").c_str(), json_contents, strlen(json_contents), MZ_DEFAULT_COMPRESSION);
if (MZ_FALSE == status) {
@ -3831,7 +3783,7 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_preset_bundle_to_fi
ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_file(const wxString &path)
{
std::string export_path = initial_file_path(path, "Filament bundle");
std::string export_path = initial_file_path(path, "");
if (export_path.empty() || "initial_failed" == export_path) return ExportCase::EXPORT_CANCEL;
BOOST_LOG_TRIVIAL(info) << "Export filament preset bundle";
@ -3840,25 +3792,17 @@ ExportConfigsDialog::ExportCase ExportConfigsDialog::archive_filament_bundle_to_
std::string filament_name = checkbox_filament_name.second;
json bundle_structure;
NetworkAgent *agent = wxGetApp().getAgent();
std::string clock = get_curr_timestmp();
if (agent) {
bundle_structure["user_name"] = agent->get_user_name();
bundle_structure["user_id"] = agent->get_user_id();
bundle_structure["version"] = agent->get_version();
bundle_structure["bundle_id"] = agent->get_user_id() + "_" + filament_name + "_" + clock;
} else {
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = "";
bundle_structure["bundle_id"] = "offline_" + filament_name + "_" + clock;
}
bundle_structure["user_name"] = "";
bundle_structure["user_id"] = "";
bundle_structure["version"] = SoftFever_VERSION;
bundle_structure["bundle_id"] = filament_name + "_" + clock;
bundle_structure["bundle_type"] = "filament config bundle";
bundle_structure["filament_name"] = filament_name;
std::unordered_map<std::string, json> vendor_structure;
mz_zip_archive zip_archive;
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + filament_name + ".bbsflmt");
mz_bool status = initial_zip_archive(zip_archive, export_path + "/" + filament_name + ".orca_filament");
if (MZ_FALSE == status) {
BOOST_LOG_TRIVIAL(info) << "Failed to initialize ZIP archive";
return ExportCase::INITIALIZE_FAIL;
@ -4070,7 +4014,7 @@ wxBoxSizer *ExportConfigsDialog::create_button_item(wxWindow* parent)
return;
}
wxDirDialog dlg(this, _L("Choose a directory"), from_u8(wxGetApp().app_config->get_last_dir()), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
wxDirDialog dlg(this, _L("Choose a directory"), "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
wxString path;
if (dlg.ShowModal() == wxID_OK) path = dlg.GetPath();
ExportCase export_case = ExportCase::EXPORT_CANCEL;

View file

@ -1378,9 +1378,13 @@ void MachineObject::parse_status(int flag)
}
if (!is_support_p1s_plus) {
is_support_p1s_plus = ((flag >> 27) & 0x1) != 0;
}
auto supported_plus = ((flag >> 27) & 0x1) != 0;
auto installed_plus = ((flag >> 26) & 0x1) != 0;
if (installed_plus && supported_plus) {
is_support_p1s_plus = true;
}
}
sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11);
@ -4064,12 +4068,6 @@ int MachineObject::parse_json(std::string payload)
} else if (jj["command"].get<std::string>() == "gcode_line") {
//ack of gcode_line
BOOST_LOG_TRIVIAL(debug) << "parse_json, ack of gcode_line = " << j.dump(4);
if (m_agent && is_studio_cmd(sequence_id)) {
json t;
t["dev_id"] = this->dev_id;
t["signal"] = this->wifi_signal;
m_agent->track_event("ack_cmd_gcode_line", t.dump());
}
} else if (jj["command"].get<std::string>() == "project_prepare") {
//ack of project file
BOOST_LOG_TRIVIAL(info) << "parse_json, ack of project_prepare = " << j.dump(4);
@ -4082,13 +4080,6 @@ int MachineObject::parse_json(std::string payload)
} else if (jj["command"].get<std::string>() == "project_file") {
//ack of project file
BOOST_LOG_TRIVIAL(debug) << "parse_json, ack of project_file = " << j.dump(4);
if (m_agent && is_studio_cmd(sequence_id)) {
json t;
t["dev_id"] = this->dev_id;
t["signal"] = this->wifi_signal;
m_agent->track_event("ack_cmd_project_file", t.dump());
}
std::string result;
if (jj.contains("result")) {
result = jj["result"].get<std::string>();

View file

@ -46,8 +46,8 @@ void DragCanvas::set_shape_list(const std::vector<std::string>& colors, const st
m_dragshape_list.clear();
for (int i = 0; i < order.size(); i++) {
wxBitmap bmp = get_extruder_color_icon(colors[order[i] - 1], std::to_string(order[i]), SHAPE_SIZE, SHAPE_SIZE)->GetBitmapFor(m_parent);
DragShape* shape = new DragShape(bmp, order[i]);
wxBitmap* bmp = get_extruder_color_icon(colors[order[i] - 1], std::to_string(order[i]), SHAPE_SIZE, SHAPE_SIZE);
DragShape* shape = new DragShape(*bmp, order[i]);
m_dragshape_list.push_back(shape);
}

View file

@ -33,15 +33,6 @@ wxIMPLEMENT_DYNAMIC_CLASS(DataViewBitmapText, wxObject)
IMPLEMENT_VARIANT_OBJECT(DataViewBitmapText)
static wxSize get_size(const wxBitmap& icon)
{
#ifdef __WIN32__
return icon.GetSize();
#else
return icon.GetScaledSize();
#endif
}
// ---------------------------------------------------------
// BitmapTextRenderer
// ---------------------------------------------------------
@ -133,7 +124,11 @@ bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
const wxBitmap& icon = m_value.GetBitmap();
if (icon.IsOk())
{
wxSize icon_sz = get_size(icon);
#ifdef __APPLE__
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);
xoffset = icon_sz.x + 4;
}
@ -275,12 +270,11 @@ bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
const wxBitmap& icon = m_value.GetBitmap();
if (icon.IsOk())
{
wxSize icon_sz = get_size(icon);
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.GetHeight()) / 2);
// xoffset = icon_sz.GetWidth() + 4;
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
// xoffset = icon.GetWidth() + 4;
if (rect.height == 0)
rect.height = icon_sz.GetHeight();
rect.height = icon.GetHeight();
}
#ifdef _WIN32
@ -311,7 +305,7 @@ wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelR
if (can_create_editor_ctrl && !can_create_editor_ctrl())
return nullptr;
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons();
std::vector<wxBitmap*> icons = get_extruder_color_icons();
if (icons.empty())
return nullptr;

View file

@ -1132,7 +1132,7 @@ void Choice::BUILD()
auto icon_name = "param_" + m_opt.enum_values[i];
if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
ScalableBitmap bm(temp, icon_name, 24);
temp->Append(_(el), bm.get_bitmap());
temp->Append(_(el), bm.bmp());
} else {
temp->Append(_(el));
}
@ -1534,7 +1534,7 @@ void Choice::msw_rescale()
auto icon_name = "param_" + m_opt.enum_values[i];
if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) {
ScalableBitmap bm(window, icon_name, 24);
temp->SetItemBitmap(i, bm.get_bitmap());
temp->SetItemBitmap(i, bm.bmp());
}
++i;
}

View file

@ -4485,11 +4485,14 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
}
};
auto append_headers = [&imgui](const std::vector<std::pair<std::string, float>>& title_offsets) {
auto append_headers = [&imgui, window_padding](const std::vector<std::pair<std::string, float>>& title_offsets) {
for (size_t i = 0; i < title_offsets.size(); i++) {
ImGui::SameLine(title_offsets[i].second);
imgui.bold_text(title_offsets[i].first);
}
// Ensure right padding
ImGui::SameLine();
ImGui::Dummy({window_padding, 1});
ImGui::Separator();
};
@ -4507,8 +4510,12 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
offsets.push_back(max_width(title_columns[0].second, title_columns[0].first, extra_size) + 3.0f * style.ItemSpacing.x);
for (size_t i = 1; i < title_columns.size() - 1; i++)
offsets.push_back(offsets.back() + max_width(title_columns[i].second, title_columns[i].first) + style.ItemSpacing.x);
if (title_columns.back().first == _u8L("Display"))
offsets.back() = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding;
if (title_columns.back().first == _u8L("Display")) {
const auto preferred_offset = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding;
if (preferred_offset > offsets.back()) {
offsets.back() = preferred_offset;
}
}
float average_col_width = ImGui::GetWindowWidth() / static_cast<float>(title_columns.size());
std::vector<float> ret;
@ -4586,8 +4593,9 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
if (it == m_print_statistics.used_filaments_per_role.end())
return std::make_pair(0.0, 0.0);
double koef = imperial_units ? 1000.0 / GizmoObjectManipulation::in_to_mm : 1.0;
return std::make_pair(it->second.first * koef, it->second.second);
double koef = imperial_units ? GizmoObjectManipulation::in_to_mm / 1000.0 : 1.0;
double unit_conver = imperial_units ? GizmoObjectManipulation::oz_to_g : 1;
return std::make_pair(it->second.first / koef, it->second.second / unit_conver);
};
// get used filament (meters and grams) from used volume in respect to the active extruder
@ -4664,6 +4672,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
std::vector<std::string> times;
std::string travel_time;
std::vector<std::string> percents;
std::vector<std::string> used_filaments_length;
std::vector<std::string> used_filaments_weight;
std::string travel_percent;
std::vector<double> model_used_filaments_m;
std::vector<double> model_used_filaments_g;
@ -4707,9 +4717,12 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
else
percent > 0.001 ? ::sprintf(buffer, "%.1f%%", percent * 100) : ::sprintf(buffer, "<0.1%%");
percents.push_back(buffer);
//auto [model_used_filament_m, model_used_filament_g] = used_filament_per_role(role);
//model_used_filaments_m.push_back(model_used_filament_m);
//model_used_filaments_g.push_back(model_used_filament_g);
auto [model_used_filament_m, model_used_filament_g] = used_filament_per_role(role);
::sprintf(buffer, imperial_units ? "%.2f in" : "%.2f m", model_used_filament_m);
used_filaments_length.push_back(buffer);
::sprintf(buffer, imperial_units ? "%.2f oz" : "%.2f g", model_used_filament_g);
used_filaments_weight.push_back(buffer);
}
}
@ -4724,8 +4737,8 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
travel_percent = buffer;
}
offsets = calculate_offsets({ {_u8L("Line Type"), labels}, {_u8L("Time"), times}, {_u8L("Percent"), percents}, {_u8L("Display"), {""}}}, icon_size);
append_headers({{_u8L("Line Type"), offsets[0]}, {_u8L("Time"), offsets[1]}, {_u8L("Percent"), offsets[2]}, {_u8L("Display"), offsets[3]}});
offsets = calculate_offsets({ {_u8L("Line Type"), labels}, {_u8L("Time"), times}, {_u8L("Percent"), percents}, {"", used_filaments_length}, {"", used_filaments_weight}, {_u8L("Display"), {""}}}, icon_size);
append_headers({{_u8L("Line Type"), offsets[0]}, {_u8L("Time"), offsets[1]}, {_u8L("Percent"), offsets[2]}, {_u8L("Used filament"), offsets[3]}, {_u8L("Display"), offsets[5]}});
break;
}
case EViewType::Height: { imgui.title(_u8L("Layer Height (mm)")); break; }
@ -4877,7 +4890,9 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
std::vector<std::pair<std::string, float>> columns_offsets;
columns_offsets.push_back({ labels[i], offsets[0] });
columns_offsets.push_back({ times[i], offsets[1] });
columns_offsets.push_back({ percents[i], offsets[2] });
columns_offsets.push_back({percents[i], offsets[2]});
columns_offsets.push_back({used_filaments_length[i], offsets[3]});
columns_offsets.push_back({used_filaments_weight[i], offsets[4]});
append_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], columns_offsets,
true, visible, [this, role, visible]() {
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role);

View file

@ -28,8 +28,8 @@
#define STB_DXT_IMPLEMENTATION
#include "stb_dxt/stb_dxt.h"
#include <nanosvg/nanosvg.h>
#include <nanosvg/nanosvgrast.h>
#include "nanosvg/nanosvg.h"
#include "nanosvg/nanosvgrast.h"
#include "libslic3r/Utils.hpp"
#include "GUI_App.hpp"

View file

@ -4,6 +4,7 @@
#include "GUI_ObjectList.hpp"
#include "GUI_Factories.hpp"
#include "format.hpp"
#include "libslic3r_version.h"
// Localization headers: include libslic3r version first so everything in this file
// uses the slic3r/GUI version (the macros will take precedence over the functions).
@ -369,7 +370,7 @@ public:
// See https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/font.cpp
// void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
wxNativeFontInfo nfi= *font.GetNativeFontInfo();
float pointSizeNew = wxDisplay(this).GetScaleFactor() * scale * font.GetPointSize();
float pointSizeNew = scale * font.GetPointSize();
nfi.lf.lfHeight = nfi.GetLogFontHeightAtPPI(pointSizeNew, get_dpi_for_window(this));
nfi.pointSize = pointSizeNew;
font = wxFont(nfi);
@ -2107,6 +2108,9 @@ void GUI_App::init_app_config()
if (!boost::filesystem::exists(data_dir_path)){
boost::filesystem::create_directory(data_dir_path);
}
// Change current dirtory of application
chdir(encode_path((Slic3r::data_dir() + "/log").c_str()).c_str());
} else {
m_datadir_redefined = true;
}
@ -4290,7 +4294,8 @@ Semver get_version(const std::string& str, const std::regex& regexp) {
void GUI_App::check_new_version_sf(bool show_tips, int by_user)
{
AppConfig* app_config = wxGetApp().app_config;
auto version_check_url = app_config->version_check_url();
bool check_stable_only = app_config->get_bool("check_stable_update_only");
auto version_check_url = app_config->version_check_url(check_stable_only);
Http::get(version_check_url)
.on_error([&](std::string body, std::string error, unsigned http_status) {
(void)body;
@ -4298,25 +4303,22 @@ void GUI_App::check_new_version_sf(bool show_tips, int by_user)
error);
})
.timeout_connect(1)
.on_complete([this,by_user](std::string body, unsigned http_status) {
.on_complete([this,by_user, check_stable_only](std::string body, unsigned http_status) {
// Http response OK
if (http_status != 200)
return;
try {
boost::trim(body);
// SoftFever: parse github release, ported from SS
// Orca: parse github release, inspired by SS
boost::property_tree::ptree root;
std::stringstream json_stream(body);
boost::property_tree::read_json(json_stream, root);
bool i_am_pre = false;
// at least two number, use '.' as separator. can be followed by -Az23 for prereleased and +Az42 for
// metadata
std::regex matcher("[0-9]+\\.[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9]+)?(\\+[A-Za-z0-9]+)?");
Semver current_version = get_version(SoftFever_VERSION, matcher);
Semver current_version = get_version(SoftFever_VERSION, matcher);
Semver best_pre(1, 0, 0);
Semver best_release(1, 0, 0);
std::string best_pre_url;
@ -4324,56 +4326,73 @@ void GUI_App::check_new_version_sf(bool show_tips, int by_user)
std::string best_release_content;
std::string best_pre_content;
const std::regex reg_num("([0-9]+)");
std::string tag = root.get<std::string>("tag_name");
if (tag[0] == 'v')
tag.erase(0, 1);
for (std::regex_iterator it = std::sregex_iterator(tag.begin(), tag.end(), reg_num);
it != std::sregex_iterator(); ++it) {
}
Semver tag_version = get_version(tag, matcher);
if (current_version == tag_version)
i_am_pre = root.get<bool>("prerelease");
if (root.get<bool>("prerelease")) {
if (best_pre < tag_version) {
best_pre = tag_version;
best_pre_url = root.get<std::string>("html_url");
best_pre_content = root.get<std::string>("body");
best_pre.set_prerelease("Preview");
}
if (check_stable_only) {
std::string tag = root.get<std::string>("tag_name");
if (tag[0] == 'v')
tag.erase(0, 1);
for (std::regex_iterator it = std::sregex_iterator(tag.begin(), tag.end(), reg_num); it != std::sregex_iterator(); ++it) {}
Semver tag_version = get_version(tag, matcher);
if (root.get<bool>("prerelease")) {
if (best_pre < tag_version) {
best_pre = tag_version;
best_pre_url = root.get<std::string>("html_url");
best_pre_content = root.get<std::string>("body");
best_pre.set_prerelease("Preview");
}
} else {
if (best_release < tag_version) {
best_release = tag_version;
best_release_url = root.get<std::string>("html_url");
best_release_content = root.get<std::string>("body");
}
}
} else {
if (best_release < tag_version) {
best_release = tag_version;
best_release_url = root.get<std::string>("html_url");
best_release_content = root.get<std::string>("body");
}
for (auto json_version : root) {
std::string tag = json_version.second.get<std::string>("tag_name");
if (tag[0] == 'v')
tag.erase(0, 1);
for (std::regex_iterator it = std::sregex_iterator(tag.begin(), tag.end(), reg_num); it != std::sregex_iterator();
++it) {}
Semver tag_version = get_version(tag, matcher);
if (json_version.second.get<bool>("prerelease")) {
if (best_pre < tag_version) {
best_pre = tag_version;
best_pre_url = json_version.second.get<std::string>("html_url");
best_pre_content = json_version.second.get<std::string>("body");
best_pre.set_prerelease("Preview");
}
} else {
if (best_release < tag_version) {
best_release = tag_version;
best_release_url = json_version.second.get<std::string>("html_url");
best_release_content = json_version.second.get<std::string>("body");
}
}
}
}
// if release is more recent than beta, use release anyway
if (best_pre < best_release) {
best_pre = best_release;
best_pre_url = best_release_url;
best_pre_content = best_release_content;
best_pre = best_release;
best_pre_url = best_release_url;
best_pre_content = best_release_content;
}
// if we're the most recent, don't do anything
if ((i_am_pre ? best_pre : best_release) <= current_version) {
if (by_user != 0)
this->no_new_version();
return;
if ((check_stable_only ? best_release : best_pre) <= current_version) {
if (by_user != 0)
this->no_new_version();
return;
}
// BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...",
// SLIC3R_APP_NAME, i_am_pre ? best_pre.to_string(): best_release.to_string());
version_info.url = i_am_pre ? best_pre_url : best_release_url;
version_info.version_str = i_am_pre ? best_pre.to_string() : best_release.to_string_sf();
version_info.description = i_am_pre ? best_pre_content : best_release_content;
version_info.url = check_stable_only ? best_release_url : best_pre_url;
version_info.version_str = check_stable_only ? best_release.to_string_sf() : best_pre.to_string();
version_info.description = check_stable_only ? best_release_content : best_pre_content;
version_info.force_upgrade = false;
wxCommandEvent *evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
evt->SetString((i_am_pre ? best_pre : best_release).to_string());
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
evt->SetString((check_stable_only ? best_release : best_pre).to_string());
GUI::wxGetApp().QueueEvent(evt);
} catch (...) {
}
} catch (...) {}
})
.perform();
}
@ -4591,8 +4610,7 @@ void GUI_App::sync_preset(Preset* preset)
if (http_code >= 400) {
result = 0;
updated_info = "hold";
}
else
} else
result = -1;
}
}
@ -4614,8 +4632,7 @@ void GUI_App::sync_preset(Preset* preset)
auto update_time_str = values_map[BBL_JSON_KEY_UPDATE_TIME];
if (!update_time_str.empty())
update_time = std::atoll(update_time_str.c_str());
}
else {
} else {
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]create: request_setting_id failed, http code "<<http_code;
// do not post new preset this time if http code >= 400
if (http_code >= 400) {
@ -4625,12 +4642,10 @@ void GUI_App::sync_preset(Preset* preset)
else
result = -1;
}
}
else {
} else {
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]create: can not generate differed preset";
}
}
else if (preset->sync_info.compare("update") == 0) {
} else if (preset->sync_info.compare("update") == 0) {
if (!setting_id.empty()) {
int ret = preset_bundle->get_differed_values_to_update(*preset, values_map);
if (!ret) {
@ -4724,7 +4739,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
cancelFn = [this, dlg]() {
return m_is_closing || dlg->WasCanceled();
};
finishFn = [this, userid = m_agent->get_user_id(), dlg, t = std::weak_ptr(m_user_sync_token)](bool ok) {
finishFn = [this, userid = m_agent->get_user_id(), dlg, t = std::weak_ptr<int>(m_user_sync_token)](bool ok) {
CallAfter([=]{
dlg->Destroy();
if (ok && m_agent && t.lock() == m_user_sync_token && userid == m_agent->get_user_id()) reload_settings();
@ -4732,7 +4747,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
};
}
else {
finishFn = [this, userid = m_agent->get_user_id(), t = std::weak_ptr(m_user_sync_token)](bool ok) {
finishFn = [this, userid = m_agent->get_user_id(), t = std::weak_ptr<int>(m_user_sync_token)](bool ok) {
CallAfter([=] {
if (ok && m_agent && t.lock() == m_user_sync_token && userid == m_agent->get_user_id()) reload_settings();
});
@ -4740,7 +4755,7 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
}
m_sync_update_thread = Slic3r::create_thread(
[this, progressFn, cancelFn, finishFn, t = std::weak_ptr(m_user_sync_token)] {
[this, progressFn, cancelFn, finishFn, t = std::weak_ptr<int>(m_user_sync_token)] {
// get setting list, update setting list
std::string version = preset_bundle->get_vendor_profile_version(PresetBundle::BBL_BUNDLE).to_string();
int ret = m_agent->get_setting_list2(version, [this](auto info) {
@ -5028,7 +5043,7 @@ bool GUI_App::select_language()
// 3) new_language_info->CanonicalName is a safe bet. It points to a valid dictionary name.
app_config->set("language", new_language_info->CanonicalName.ToUTF8().data());
return true;
}
}
}
return false;
@ -5936,18 +5951,15 @@ void GUI_App::MacOpenFiles(const wxArrayString &fileNames)
input_files.push_back(non_gcode_files[i]);
}
this->plater()->load_files(input_files);
}
else {
} else {
for (size_t i = 0; i < files.size(); ++i) {
this->init_params->input_files.emplace_back(files[i]);
}
}
}
else {
} else {
if (m_post_initialized) {
this->plater()->load_gcode(gcode_files.front());
}
else {
} else {
this->init_params->input_gcode = true;
this->init_params->input_files = { into_u8(gcode_files.front()) };
}
@ -6296,8 +6308,7 @@ void GUI_App::gcode_thumbnails_debug()
width = 0;
height = 0;
rows.clear();
}
else if (reading_image)
} else if (reading_image)
row += gcode_line.substr(2);
}
}

View file

@ -267,13 +267,14 @@ std::map<std::string, std::string> SettingsFactory::CATEGORY_ICON =
// BBS: remove SLA categories
};
wxBitmapBundle* SettingsFactory::get_category_bitmap(const std::string& category_name)
wxBitmap SettingsFactory::get_category_bitmap(const std::string& category_name, bool menu_bmp)
{
if (CATEGORY_ICON.find(category_name) == CATEGORY_ICON.end())
return get_bmp_bundle("empty");
return get_bmp_bundle(CATEGORY_ICON.at(category_name));
return wxNullBitmap;
return create_scaled_bitmap(CATEGORY_ICON.at(category_name));
}
//-------------------------------------
// MenuFactory
//-------------------------------------
@ -434,30 +435,31 @@ static void create_freq_settings_popupmenu(wxMenu* menu, const bool is_object_se
}
}
std::vector<wxBitmapBundle*> MenuFactory::get_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(ADD_VOLUME_MENU_ITEMS.size());
for (const auto& item : ADD_VOLUME_MENU_ITEMS)
volume_bmps.push_back(get_bmp_bundle(item.second));
for (const auto& item : ADD_VOLUME_MENU_ITEMS) {
volume_bmps.push_back(create_scaled_bitmap(item.second));
}
return volume_bmps;
}
std::vector<wxBitmapBundle*> MenuFactory::get_text_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_text_volume_bitmaps()
{
std::vector<wxBitmapBundle*> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(TEXT_VOLUME_ICONS.size());
for (const auto& item : TEXT_VOLUME_ICONS)
volume_bmps.push_back(get_bmp_bundle(item.second));
volume_bmps.push_back(create_scaled_bitmap(item.second));
return volume_bmps;
}
std::vector<wxBitmapBundle*> MenuFactory::get_svg_volume_bitmaps()
std::vector<wxBitmap> MenuFactory::get_svg_volume_bitmaps()
{
std::vector<wxBitmapBundle *> volume_bmps;
std::vector<wxBitmap> volume_bmps;
volume_bmps.reserve(SVG_VOLUME_ICONS.size());
for (const auto &item : SVG_VOLUME_ICONS)
volume_bmps.push_back(get_bmp_bundle(item.second));
volume_bmps.push_back(create_scaled_bitmap(item.second));
return volume_bmps;
}
@ -496,8 +498,27 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
sub_menu->AppendSeparator();
}
for (auto &item : {L("Cube"), L("Cylinder"), L("Sphere"), L("Cone"), L("Disc"), L("Torus")}) {
append_menu_item(
sub_menu, wxID_ANY, _(item), "",
[type, item](wxCommandEvent &) {
obj_list()->load_generic_subobject(item, type);
},
"", menu);
}
append_menu_item_add_text(sub_menu, type);
append_menu_item_add_svg(sub_menu, type);
return sub_menu;
}
// Orca: add submenu for adding handy models
wxMenu* MenuFactory::append_submenu_add_handy_model(wxMenu* menu, ModelVolumeType type) {
auto sub_menu = new wxMenu;
for (auto &item : {L("Orca Cube"), L("3DBenchy"), L("Autodesk FDM Test"),
L("Voron Cube")}) {
L("Voron Cube"), L("Stanford Bunny")}) {
append_menu_item(
sub_menu, wxID_ANY, _(item), "",
[type, item](wxCommandEvent &) {
@ -511,6 +532,8 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
file_name = "ksr_fdmtest_v4.stl";
else if (file_name == L("Voron Cube"))
file_name = "Voron_Design_Cube_v7.stl";
else if (file_name == L("Stanford Bunny"))
file_name = "Stanford_Bunny.stl";
else
return;
input_files.push_back(
@ -521,22 +544,9 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
"", menu);
}
append_menu_item_add_text(sub_menu, type);
append_menu_item_add_svg(sub_menu, type);
sub_menu->AppendSeparator();
for (auto &item : {L("Cube"), L("Cylinder"), L("Sphere"), L("Cone")}) {
append_menu_item(
sub_menu, wxID_ANY, _(item), "",
[type, item](wxCommandEvent &) {
obj_list()->load_generic_subobject(item, type);
},
"", menu);
}
return sub_menu;
}
static void append_menu_itemm_add_(const wxString& name, GLGizmosManager::EType gizmo_type, wxMenu *menu, ModelVolumeType type, bool is_submenu_item) {
auto add_ = [type, gizmo_type](const wxCommandEvent & /*unnamed*/) {
const GLCanvas3D *canvas = plater()->canvas3D();
@ -690,7 +700,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(*get_bmp_bundle("cog"));
menu_item->SetBitmap(create_scaled_bitmap("cog"));
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_object_settings, item));
return menu->Append(menu_item);
@ -839,7 +849,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
if (sels.IsEmpty())
return;
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
wxMenu* extruder_selection_menu = new wxMenu();
const wxString& name = sels.Count() == 1 ? names[0] : names[1];
@ -860,7 +870,7 @@ void MenuFactory::append_menu_item_change_extruder(wxMenu* menu)
if (icon_idx >= 0 && icon_idx < icons.size()) {
append_menu_item(
extruder_selection_menu, wxID_ANY, item_name, "", [i](wxCommandEvent &) { obj_list()->set_extruder_for_selected_items(i); }, icons[icon_idx], menu,
extruder_selection_menu, wxID_ANY, item_name, "", [i](wxCommandEvent &) { obj_list()->set_extruder_for_selected_items(i); }, *icons[icon_idx], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
} else {
append_menu_item(
@ -1163,12 +1173,17 @@ MenuFactory::MenuFactory()
void MenuFactory::create_default_menu()
{
wxMenu* sub_menu = append_submenu_add_generic(&m_default_menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_primitives = append_submenu_add_generic(&m_default_menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_handy = append_submenu_add_handy_model(&m_default_menu, ModelVolumeType::INVALID);
#ifdef __WINDOWS__
append_submenu(&m_default_menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
append_submenu(&m_default_menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
[]() {return true; }, m_parent);
append_submenu(&m_default_menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "menu_add_part",
[]() {return true; }, m_parent);
#else
append_submenu(&m_default_menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "",
append_submenu(&m_default_menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "",
[]() {return true; }, m_parent);
append_submenu(&m_default_menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "",
[]() {return true; }, m_parent);
#endif
@ -1452,13 +1467,18 @@ void MenuFactory::create_plate_menu()
// add shapes
menu->AppendSeparator();
wxMenu* sub_menu = append_submenu_add_generic(menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_primitives = append_submenu_add_generic(menu, ModelVolumeType::INVALID);
wxMenu* sub_menu_handy = append_submenu_add_handy_model(menu, ModelVolumeType::INVALID);
#ifdef __WINDOWS__
append_submenu(menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
append_submenu(menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "menu_add_part",
[]() {return true; }, m_parent);
append_submenu(menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "menu_add_part",
[]() {return true; }, m_parent);
#else
append_submenu(menu, sub_menu, wxID_ANY, _L("Add Primitive"), "", "",
append_submenu(menu, sub_menu_primitives, wxID_ANY, _L("Add Primitive"), "", "",
[]() {return true; }, m_parent);
append_submenu(menu, sub_menu_handy, wxID_ANY, _L("Add Handy models"), "", "",
[]() {return true; }, m_parent);
#endif
@ -1788,7 +1808,7 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
return;
}
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(true);
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
if (icons.size() < filaments_cnt) {
BOOST_LOG_TRIVIAL(warning) << boost::format("Warning: icons size %1%, filaments_cnt=%2%")%icons.size()%filaments_cnt;
if (icons.size() <= 1)
@ -1828,9 +1848,8 @@ void MenuFactory::append_menu_item_change_filament(wxMenu* menu)
const wxString& item_name = (i == 0 ? _L("Default") : wxString::Format(_L("Filament %d"), i)) +
(is_active_extruder ? " (" + _L("current") + ")" : "");
//OcraftyoneTODO: determine if nullptr in place of icon causes issues
append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? nullptr : icons[i - 1], menu,
[i](wxCommandEvent&) { obj_list()->set_extruder_for_selected_items(i); }, i == 0 ? wxNullBitmap : *icons[i - 1], menu,
[is_active_extruder]() { return !is_active_extruder; }, m_parent);
}
menu->Append(wxID_ANY, name, extruder_selection_menu, _L("Change Filament"));
@ -1940,7 +1959,7 @@ void MenuFactory::update_object_menu()
void MenuFactory::update_default_menu()
{
for (auto& name : { _L("Add Primitive") , _L("Show Labels") }) {
for (auto& name : { _L("Add Primitive") , _L("Add Handy models"), _L("Show Labels") }) {
const auto menu_item_id = m_default_menu.FindItem(name);
if (menu_item_id != wxNOT_FOUND)
m_default_menu.Destroy(menu_item_id);
@ -1948,6 +1967,12 @@ 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
@ -1977,7 +2002,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 }) {
sys_color_changed_menu(dynamic_cast<wxMenu *>(menu));// msw_rescale_menu updates just icons, so use it
msw_rescale_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())
@ -1992,17 +2017,14 @@ void MenuFactory::sys_color_changed(wxMenuBar* menubar)
#if 0
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
wxMenu* menu = menubar->GetMenu(id);
sys_color_changed_menu(menu);
#ifndef __linux__
menu->SetupBitmaps();
msw_rescale_menu(menu);
#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
}
// menubar->Refresh();
#endif
menubar->Refresh();
#endif
}

View file

@ -40,7 +40,7 @@ struct SettingsFactory
static std::map<std::string, std::vector<SimpleSettingData>> OBJECT_CATEGORY_SETTINGS;
static std::map<std::string, std::vector<SimpleSettingData>> PART_CATEGORY_SETTINGS;
static wxBitmapBundle* get_category_bitmap(const std::string& category_name);
static wxBitmap get_category_bitmap(const std::string& category_name, bool menu_bmp = true);
static Bundle get_bundle(const DynamicPrintConfig* config, bool is_object_settings, bool is_layer_settings = false);
static std::vector<std::string> get_options(bool is_part);
//BBS: add api to get options for catogary
@ -51,9 +51,9 @@ struct SettingsFactory
class MenuFactory
{
public:
static std::vector<wxBitmapBundle*> get_volume_bitmaps();
static std::vector<wxBitmapBundle*> get_text_volume_bitmaps();
static std::vector<wxBitmapBundle*> get_svg_volume_bitmaps();
static std::vector<wxBitmap> get_volume_bitmaps();
static std::vector<wxBitmap> get_text_volume_bitmaps();
static std::vector<wxBitmap> get_svg_volume_bitmaps();
MenuFactory();
~MenuFactory() = default;
@ -62,6 +62,7 @@ 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);
@ -124,6 +125,8 @@ private:
void create_bbl_assemble_part_menu();
wxMenu* append_submenu_add_generic(wxMenu* menu, ModelVolumeType type);
// Orca: add submenu for adding handy models
wxMenu* append_submenu_add_handy_model(wxMenu* menu, ModelVolumeType type);
void append_menu_item_add_text(wxMenu* menu, ModelVolumeType type, bool is_submenu_item = true);
void append_menu_item_add_svg(wxMenu *menu, ModelVolumeType type, bool is_submenu_item = true);
void append_menu_items_add_volume(wxMenu* menu);

View file

@ -248,14 +248,47 @@ void ObjectLayers::UpdateAndShow(const bool show)
void ObjectLayers::msw_rescale()
{
//Orca: deleted what PS commented out
m_bmp_delete.msw_rescale();
m_bmp_add.msw_rescale();
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();
}
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.sys_color_changed();
m_bmp_add.sys_color_changed();
m_bmp_delete.msw_rescale();
m_bmp_add.msw_rescale();
// rescale edit-boxes
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
@ -267,7 +300,7 @@ void ObjectLayers::sys_color_changed()
if (b_item && b_item->IsWindow()) {
auto button = dynamic_cast<PlusMinusButton*>(b_item->GetWindow());
if (button != nullptr)
button->sys_color_changed();
button->msw_rescale();
}
}
}

View file

@ -1368,11 +1368,12 @@ void ObjectList::extruder_editing()
if (!item || !(m_objects_model->GetItemType(item) & (itVolume | itObject)))
return;
wxRect rect = this->GetItemRect(item, GetColumn(colFilament));
wxPoint pos = rect.GetPosition();
pos.y -= 4;
wxSize size = rect.GetSize();
size.SetWidth(size.GetWidth() + 8);
const int column_width = GetColumn(colFilament)->GetWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 5;
wxPoint pos = this->get_mouse_position_in_control();
wxSize size = wxSize(column_width, -1);
pos.x = GetColumn(colName)->GetWidth() + GetColumn(colPrint)->GetWidth() + 5;
pos.y -= GetTextExtent("m").y;
apply_extruder_selector(&m_extruder_editor, this, "1", pos, size);
@ -2084,23 +2085,27 @@ static TriangleMesh create_mesh(const std::string& type_name, const BoundingBoxf
{
const double side = wxGetApp().plater()->canvas3D()->get_size_proportional_to_max_bed_size(0.1);
indexed_triangle_set mesh;
TriangleMesh mesh;
if (type_name == "Cube")
// Sitting on the print bed, left front front corner at (0, 0).
mesh = its_make_cube(side, side, side);
mesh = TriangleMesh(its_make_cube(side, side, side));
else if (type_name == "Cylinder")
// Centered around 0, sitting on the print bed.
// The cylinder has the same volume as the box above.
mesh = its_make_cylinder(0.5 * side, side);
mesh = TriangleMesh(its_make_cylinder(0.5 * side, side));
else if (type_name == "Sphere")
// Centered around 0, half the sphere below the print bed, half above.
// The sphere has the same volume as the box above.
mesh = its_make_sphere(0.5 * side, PI / 18);
mesh = TriangleMesh(its_make_sphere(0.5 * side, PI / 18));
else if (type_name == "Slab")
// Sitting on the print bed, left front front corner at (0, 0).
mesh = its_make_cube(bb.size().x() * 1.5, bb.size().y() * 1.5, bb.size().z() * 0.5);
mesh = TriangleMesh(its_make_cube(bb.size().x() * 1.5, bb.size().y() * 1.5, bb.size().z() * 0.5));
else if (type_name == "Cone")
mesh = its_make_cone(0.5 * side, side);
mesh = TriangleMesh(its_make_cone(0.5 * side, side));
else if (type_name == "Disc")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/handy_models/helper_disk.stl").c_str(), true, nullptr);
else if (type_name == "Torus")
mesh.ReadSTLFile((Slic3r::resources_dir() + "/handy_models/torus.stl").c_str(), true, nullptr);
return TriangleMesh(mesh);
}
@ -3156,21 +3161,6 @@ bool ObjectList::can_merge_to_single_object() const
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;
}
bool ObjectList::can_mesh_boolean() const
{
int obj_idx = get_selected_obj_idx();
@ -5482,17 +5472,17 @@ void ObjectList::msw_rescale()
GetColumn(colSinking)->SetWidth(3 * em);
GetColumn(colEditing )->SetWidth( 3 * em);
// rescale/update existing items with bitmaps
m_objects_model->Rescale();
Layout();
}
void ObjectList::sys_color_changed()
{
wxGetApp().UpdateDVCDarkUI(this, true);
// rescale/update existing items with bitmaps
m_objects_model->UpdateBitmaps();
Layout();
msw_rescale();
if (m_objects_model) { m_objects_model->sys_color_changed(); }
}
@ -5529,12 +5519,6 @@ void GUI::ObjectList::OnStartEditing(wxDataViewEvent &event)
// Here the last active column is forgotten, so when leaving the editing mode, the next mouse click will not enter the editing mode of the newly selected column.
void ObjectList::OnEditingStarted(wxDataViewEvent &event)
{
// Orca: Automatically show drop down on editing start and finish editing when the combobox is closed
if (event.GetColumn() == colFilament) {
::ComboBox*c = static_cast<::ComboBox *>(event.GetDataViewColumn()->GetRenderer()->GetEditorCtrl());
c->ToggleDropDown();
c->Bind(wxEVT_COMBOBOX_CLOSEUP, [event](wxCommandEvent& evt){ event.GetDataViewColumn()->GetRenderer()->FinishEditing(); });
}
#ifdef __WXMSW__
m_last_selected_column = -1;
#else

View file

@ -319,7 +319,7 @@ public:
void delete_all_connectors_for_selection();
void delete_all_connectors_for_object(int obj_idx);
wxPoint get_mouse_position_in_control() const;
wxPoint get_mouse_position_in_control() const { return wxGetMousePosition() - this->GetScreenPosition(); }
int get_selected_obj_idx() const;
ModelConfig& get_item_config(const wxDataViewItem& item) const;

View file

@ -112,7 +112,7 @@ bool ObjectSettings::update_settings_list()
btn->SetToolTip(_(L("Remove parameter")));
btn->SetBitmapFocus(m_bmp_delete_focus.bmp());
btn->SetBitmapCurrent(m_bmp_delete_focus.bmp());
btn->SetBitmapHover(m_bmp_delete_focus.bmp());
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
wxGetApp().plater()->take_snapshot(from_u8((boost::format("Delete Option %s") % opt_key).str()).ToStdString());
@ -146,7 +146,7 @@ bool ObjectSettings::update_settings_list()
return;
ctrl->SetBitmap_(m_bmp_delete);
ctrl->SetBitmapFocus(m_bmp_delete_focus.bmp());
ctrl->SetBitmapCurrent(m_bmp_delete_focus.bmp());
ctrl->SetBitmapHover(m_bmp_delete_focus.bmp());
};
const bool is_extruders_cat = cat.first == "Extruders";
@ -415,13 +415,21 @@ void ObjectSettings::UpdateAndShow(const bool show)
#endif
}
void ObjectSettings::msw_rescale()
{
#if !NEW_OBJECT_SETTING
m_bmp_delete.msw_rescale();
m_bmp_delete_focus.msw_rescale();
for (auto group : m_og_settings)
group->msw_rescale();
#endif
}
void ObjectSettings::sys_color_changed()
{
#if !NEW_OBJECT_SETTING
m_og->sys_color_changed(); // not in old msw_rescale. is it needed?
// moved from old msw_rescale
m_bmp_delete.sys_color_changed();
m_bmp_delete_focus.sys_color_changed();
m_og->sys_color_changed();
for (auto group : m_og_settings)
group->sys_color_changed();

View file

@ -68,6 +68,7 @@ public:
bool add_missed_options(ModelConfig *config_to, const DynamicPrintConfig &config_from);
void update_config_values(ModelConfig *config);
void UpdateAndShow(const bool show);
void msw_rescale();
void sys_color_changed();
};

View file

@ -77,7 +77,7 @@ void GridCellIconRenderer::Draw(wxGrid& grid,
table->m_icon_row_height = grid.GetRowSize(row);
table->m_icon_col_width = grid.GetColSize(col);
//}
wxBitmap bitmap = table->get_undo_bitmap().GetBitmapFor(dc.GetWindow());
wxBitmap& bitmap = table->get_undo_bitmap();
int bitmap_width = bitmap.GetWidth();
int bitmap_height = bitmap.GetHeight();
int offset_x = (table->m_icon_col_width - bitmap_width)/2;
@ -125,7 +125,7 @@ GridCellIconRenderer *GridCellIconRenderer::Clone() const
GridCellFilamentsEditor::GridCellFilamentsEditor(const wxArrayString& choices,
bool allowOthers,
std::vector<wxBitmapBundle*>* bitmaps)
std::vector<wxBitmap*>* bitmaps)
: wxGridCellChoiceEditor(choices, allowOthers), m_icons(bitmaps)
{
}
@ -133,7 +133,7 @@ GridCellFilamentsEditor::GridCellFilamentsEditor(const wxArrayString& choices,
GridCellFilamentsEditor::GridCellFilamentsEditor(size_t count,
const wxString choices[],
bool allowOthers,
std::vector<wxBitmapBundle*>* bitmaps)
std::vector<wxBitmap*>* bitmaps)
: wxGridCellChoiceEditor(count, choices, allowOthers), m_icons(bitmaps)
{
}
@ -159,14 +159,13 @@ void GridCellFilamentsEditor::Create(wxWindow* parent,
if ( !m_allowOthers )
style |= wxCB_READONLY;
::ComboBox *bitmap_combo = new ComboBox(parent, id, wxEmptyString,
wxDefaultPosition, wxSize(get_preferred_size(*((*m_icons)[0]), wxGetApp().mainframe).GetWidth() + 10, -1),
0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY); //Unsure
wxDefaultPosition, wxSize(((*m_icons)[0])->GetWidth() + 10, -1), 0, nullptr, CB_NO_DROP_ICON | CB_NO_TEXT | wxCB_READONLY);
if (m_icons) {
int array_count = m_choices.GetCount();
int icon_count = m_icons->size();
for (int i = 0; i < array_count; i++)
{
wxBitmapBundle* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
wxBitmap* bitmap = (i < icon_count) ? (*m_icons)[i] : (*m_icons)[0];
bitmap_combo->Append(m_choices[i], *bitmap);
}
}
@ -240,9 +239,6 @@ void GridCellFilamentsEditor::BeginEdit(int row, int col, wxGrid* grid)
Combo()->SetFocus();
// Orca: Show dropdown on editing start
Combo()->ToggleDropDown();
#ifdef __WXOSX_COCOA__
// This is a work around for the combobox being simply dismissed when a
// choice is made in it under OS X. The bug is almost certainly due to a
@ -339,9 +335,9 @@ void GridCellFilamentsRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &d
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmapBundle *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetBitmapFor(dc.GetWindow()).GetWidth();
int bitmap_height = bitmap->GetBitmapFor(dc.GetWindow()).GetHeight();
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
@ -349,7 +345,7 @@ void GridCellFilamentsRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &d
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
if ( grid_row->model_volume_type != ModelVolumeType::NEGATIVE_VOLUME) {
dc.DrawBitmap(bitmap->GetBitmapFor(dc.GetWindow()), wxPoint(rect.x + offset_x, rect.y + offset_y));//TODO: determine if this way of getting bitmap works well
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
}
text_rect.x += bitmap_width + grid_cell_border_width * 2;
@ -435,9 +431,6 @@ void GridCellChoiceEditor::BeginEdit(int row, int col, wxGrid *grid)
Combo()->SetFocus();
// Orca: Show dropdown on editing start
Combo()->ToggleDropDown();
#ifdef __WXOSX_COCOA__
// This is a work around for the combobox being simply dismissed when a
// choice is made in it under OS X. The bug is almost certainly due to a
@ -525,16 +518,16 @@ void GridCellComboBoxRenderer::Draw(wxGrid &grid, wxGridCellAttr &attr, wxDC &dc
ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
ConfigOptionInt & cur_option = dynamic_cast<ConfigOptionInt &>((*grid_row)[(ObjectGridTable::GridColType) col]);
wxBitmapBundle *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetBitmapFor(dc.GetWindow()).GetWidth();
int bitmap_height = bitmap->GetBitmapFor(dc.GetWindow()).GetHeight();
wxBitmap *bitmap = table->get_color_bitmap((cur_option.value >= 1) ? cur_option.value - 1 : cur_option.value);
int bitmap_width = bitmap->GetWidth();
int bitmap_height = bitmap->GetHeight();
int offset_x = grid_cell_border_width;
int offset_y = (rect.height > bitmap_height) ? (rect.height - bitmap_height) / 2 : grid_cell_border_height;
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
dc.DrawRectangle(rect);
dc.DrawBitmap(bitmap->GetBitmapFor(dc.GetWindow()), wxPoint(rect.x + offset_x, rect.y + offset_y));
dc.DrawBitmap(*bitmap, wxPoint(rect.x + offset_x, rect.y + offset_y));
text_rect.x += bitmap_width + grid_cell_border_width * 2;
text_rect.width -= (bitmap_width + grid_cell_border_width * 2);
}
@ -2648,12 +2641,12 @@ void ObjectGridTable::OnCellValueChanged(int row, int col)
}
}
wxBitmapBundle& ObjectGridTable::get_undo_bitmap(bool selected)
wxBitmap& ObjectGridTable::get_undo_bitmap(bool selected)
{
return m_panel->m_undo_bitmap;
}
wxBitmapBundle* ObjectGridTable::get_color_bitmap(int color_index)
wxBitmap* ObjectGridTable::get_color_bitmap(int color_index)
{
if (color_index < m_panel->m_color_bitmaps.size())
return m_panel->m_color_bitmaps[color_index];

View file

@ -82,10 +82,10 @@ public:
GridCellFilamentsEditor(size_t count = 0,
const wxString choices[] = NULL,
bool allowOthers = false,
std::vector<wxBitmapBundle*>* bitmaps = NULL);
std::vector<wxBitmap*>* bitmaps = NULL);
GridCellFilamentsEditor(const wxArrayString& choices,
bool allowOthers = false,
std::vector<wxBitmapBundle*>* bitmaps = NULL);
std::vector<wxBitmap*>* bitmaps = NULL);
virtual void Create(wxWindow* parent,
wxWindowID id,
@ -105,7 +105,7 @@ protected:
::ComboBox *Combo() const { return (::ComboBox *)m_control; }
void OnComboCloseUp(wxCommandEvent& evt);
std::vector<wxBitmapBundle*>* m_icons;
std::vector<wxBitmap*>* m_icons;
wxDECLARE_NO_COPY_CLASS(GridCellFilamentsEditor);
private:
@ -498,8 +498,8 @@ public:
void update_filament_to_config(ModelConfig* config, std::string& key, ConfigOption& new_value, ConfigOption& ori_value, bool is_object);
void update_volume_values_from_object(int row, int col);
void update_value_to_object(Model* model, ObjectGridRow* grid_row, int col);
wxBitmapBundle& get_undo_bitmap(bool selected = false);
wxBitmapBundle* get_color_bitmap(int color_index);
wxBitmap& get_undo_bitmap(bool selected = false);
wxBitmap* get_color_bitmap(int color_index);
bool OnCellLeftClick(int row, int col, ConfigOptionType &type);
void OnSelectCell(int row, int col);
void OnRangeSelected(int row, int col, int row_count, int col_count);
@ -610,10 +610,10 @@ private:
int init_filaments_and_colors();
wxFloatingPointValidator<float> m_float_validator;
wxBitmapBundle m_undo_bitmap;
std::vector<wxBitmapBundle*> m_color_bitmaps;
wxBitmapBundle m_bmp_reset;
wxBitmapBundle m_bmp_reset_disable;
wxBitmap m_undo_bitmap;
std::vector<wxBitmap*> m_color_bitmaps;
ScalableBitmap m_bmp_reset;
ScalableBitmap m_bmp_reset_disable;
private:
wxDECLARE_ABSTRACT_CLASS(ObjectGrid);
wxDECLARE_EVENT_TABLE();

View file

@ -173,7 +173,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
btn->SetBitmapFocus(m_bmp_reset_focus.bmp());
btn->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
btn->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
btn->SetBitmapDisabled(m_bmp_reset_disable.bmp());
@ -220,7 +220,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
optgroup->sidetext_width = 5;
optgroup->set_config_category_and_type(GUI::from_u8(group_category), Preset::TYPE_PRINT);
std::weak_ptr weak_optgroup(optgroup);
std::weak_ptr<ConfigOptionsGroup> weak_optgroup(optgroup);
optgroup->m_on_change = [this, is_object, object, config, group_category](const t_config_option_key &opt_id, const boost::any &value) {
this->m_parent->Freeze();
this->update_config_values(is_object, object, config, group_category);
@ -236,7 +236,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_
return;
ctrl->SetBitmap_(m_bmp_reset);
ctrl->SetBitmapFocus(m_bmp_reset_focus.bmp());
ctrl->SetBitmapHover(m_bmp_reset_focus.get_bitmap());
ctrl->SetBitmapHover(m_bmp_reset_focus.bmp());
#ifdef __WINDOWS__
ctrl->SetBitmapDisabled(m_bmp_reset_disable.bmp());
#endif

View file

@ -668,7 +668,7 @@ void GLGizmoAdvancedCut::perform_cut(const Selection& selection)
if (its_num_open_edges(new_objects[i]->volumes[j]->mesh().its) > 0) {
if (!is_showed_dialog) {
is_showed_dialog = true;
MessageDialog dlg(nullptr, _L("non-mainifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
MessageDialog dlg(nullptr, _L("non-manifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
int ret = dlg.ShowModal();
if (ret == wxID_YES) {
user_fix_model = true;

View file

@ -3392,7 +3392,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
if (its_num_open_edges(new_objects[i]->volumes[j]->mesh().its) > 0) {
if (!is_showed_dialog) {
is_showed_dialog = true;
MessageDialog dlg(nullptr, _L("non-mainifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
MessageDialog dlg(nullptr, _L("non-manifold edges be caused by cut tool, do you want to fix it now?"), "", wxYES | wxCANCEL);
int ret = dlg.ShowModal();
if (ret == wxID_YES) {
user_fix_model = true;

View file

@ -508,10 +508,10 @@ void ImageGrid::render(wxDC& dc)
if (!m_file_sys || m_file_sys->GetCount() == 0) {
dc.DrawRectangle({ 0, 0, size.x, size.y });
if (!m_status_msg.IsEmpty()) {
auto si = m_status_icon.GetSize();
auto si = m_status_icon.GetBmpSize();
auto st = dc.GetTextExtent(m_status_msg);
auto rect = wxRect{0, 0, max(st.x, si.x), si.y + 26 + st.y}.CenterIn(wxRect({0, 0}, size));
dc.DrawBitmap(m_status_icon.get_bitmap(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.DrawBitmap(m_status_icon.bmp(), rect.x + (rect.width - si.x) / 2, rect.y);
dc.SetTextForeground(wxColor(0x909090));
dc.DrawText(m_status_msg, rect.x + (rect.width - st.x) / 2, rect.GetBottom() - st.y);
}
@ -602,7 +602,7 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind
bool show_download_state_always = true;
// Draw checked icon
if (m_selecting && !show_download_state_always)
dc.DrawBitmap(selected ? m_checked_icon.get_bitmap() : m_unchecked_icon.get_bitmap(), pt + wxPoint{10, m_content_rect.GetHeight() - m_checked_icon.GetHeight() - 10});
dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
// can't handle alpha
// dc.GradientFillLinear({pt.x, pt.y, m_border_size.GetWidth(), 60}, wxColour(0x6F, 0x6F, 0x6F, 0x99), wxColour(0x6F, 0x6F, 0x6F, 0), wxBOTTOM);
else if (m_file_sys->GetGroupMode() == PrinterFileSystem::G_NONE) {
@ -653,7 +653,7 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind
dc.DrawText(date, pt + wxPoint{24, 16});
}
if (m_selecting && show_download_state_always)
dc.DrawBitmap(selected ? m_checked_icon.get_bitmap() : m_unchecked_icon.get_bitmap(), pt + wxPoint{10, m_content_rect.GetHeight() - m_checked_icon.GetHeight() - 10});
dc.DrawBitmap(selected ? m_checked_icon.bmp() : m_unchecked_icon.bmp(), pt + wxPoint{10, 10});
}
void Slic3r::GUI::ImageGrid::renderContent2(wxDC &dc, wxPoint const &pt, int index, bool hit)
@ -745,8 +745,8 @@ void Slic3r::GUI::ImageGrid::renderText2(wxDC &dc, wxString text, wxRect const &
void Slic3r::GUI::ImageGrid::renderIconText(wxDC & dc, ScalableBitmap const & icon, wxString text, wxRect const & rect)
{
dc.DrawBitmap(icon.get_bitmap(), rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
renderText2(dc, text, {rect.x + icon.GetWidth() + 4, rect.y, rect.width - icon.GetWidth() - 4, rect.height});
dc.DrawBitmap(icon.bmp(), rect.x, rect.y + (rect.height - icon.GetBmpHeight()) / 2);
renderText2(dc, text, {rect.x + icon.GetBmpWidth() + 4, rect.y, rect.width - icon.GetBmpWidth() - 4, rect.height});
}
}}

View file

@ -118,26 +118,20 @@ class PlaterWorker: public Worker {
}
};
void on_idle(wxIdleEvent &evt)
{
process_events();
evt.Skip();
}
EventGuard on_idle_evt;
EventGuard on_paint_evt;
public:
template<class... WorkerArgs>
PlaterWorker(wxWindow *plater, WorkerArgs &&...args)
: m_w{std::forward<WorkerArgs>(args)...}, m_plater{plater}
{
: m_w{std::forward<WorkerArgs>(args)...}
, m_plater{plater}
// Ensure that messages from the worker thread to the UI thread are
// processed continuously.
plater->Bind(wxEVT_IDLE, &PlaterWorker::on_idle, this);
}
~PlaterWorker()
, on_idle_evt(plater, wxEVT_IDLE, [this](wxIdleEvent&) { process_events(); })
, on_paint_evt(plater, wxEVT_PAINT, [this](wxPaintEvent&) { process_events(); })
{
m_plater->Unbind(wxEVT_IDLE, &PlaterWorker::on_idle, this);
}
// Always package the job argument into a PlaterJob

View file

@ -155,7 +155,7 @@ wxWindow *KBShortcutsDialog::create_button(int id, wxString text)
void KBShortcutsDialog::on_dpi_changed(const wxRect& suggested_rect)
{
m_logo_bmp.sys_color_changed();
m_logo_bmp.msw_rescale();
m_header_bitmap->SetBitmap(m_logo_bmp.bmp());
msw_buttons_rescale(this, em_unit(), { wxID_OK });
@ -258,7 +258,7 @@ void KBShortcutsDialog::fill_shortcuts()
{ "F", L("Gizmo Place face on bed") },
{ "L", L("Gizmo SLA support points") },
{ "P", L("Gizmo FDM paint-on seam") },
{ "Tab", L("Swtich between Prepare/Prewview") },
{ "Tab", L("Switch between Prepare/Preview") },
};
m_full_shortcuts.push_back({ { _L("Plater"), "" }, plater_shortcuts });
@ -300,7 +300,7 @@ void KBShortcutsDialog::fill_shortcuts()
{ L("Arrow Right"), L("Horizontal slider - Move active thumb Right")},
{ "L", L("On/Off one layer mode of the vertical slider")},
{ "C", L("On/Off g-code window")},
{ "Tab", L("Swtich between Prepare/Prewview") },
{ "Tab", L("Switch between Prepare/Preview") },
{L("Shift+Any arrow"), L("Move slider 5x faster")},
{L("Shift+Mouse wheel"), L("Move slider 5x faster")},
#ifdef __APPLE__

View file

@ -396,29 +396,20 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
sizer->SetSizeHints(this);
#ifdef WIN32
auto setMaxSize = [this]() {
wxDisplay display(this);
auto size = display.GetClientArea().GetSize();
HWND hWnd = GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
SetMaxSize(size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom});
};
this->Bind(wxEVT_DPI_CHANGED, [setMaxSize](auto & e) {
setMaxSize();
e.Skip();
});
setMaxSize();
// SetMaximize already position window at left/top corner, even if Windows Task Bar is at left side.
// Not known why, but fix it here
// SetMaximize causes the window to overlap the taskbar, due to the fact this window has wxMAXIMIZE_BOX off
// https://forums.wxwidgets.org/viewtopic.php?t=50634
// Fix it here
this->Bind(wxEVT_MAXIMIZE, [this](auto &e) {
wxDisplay display(this);
auto pos = display.GetClientArea().GetPosition();
auto size = display.GetClientArea().GetSize();
auto pos = display.GetClientArea().GetPosition();
HWND hWnd = GetHandle();
RECT borderThickness;
SetRectEmpty(&borderThickness);
AdjustWindowRectEx(&borderThickness, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, 0);
const auto max_size = size + wxSize{-borderThickness.left + borderThickness.right, -borderThickness.top + borderThickness.bottom};
const auto current_size = GetSize();
SetSize({std::min(max_size.x, current_size.x), std::min(max_size.y, current_size.y)});
Move(pos + wxPoint{borderThickness.left, borderThickness.top});
e.Skip();
});
@ -1979,6 +1970,11 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
m_monitor->msw_rescale();
m_calibration->msw_rescale();
// BBS
#if 0
for (size_t id = 0; id < m_menubar->GetMenuCount(); id++)
msw_rescale_menu(m_menubar->GetMenu(id));
#endif
// Workarounds for correct Window rendering after rescale
@ -2020,7 +2016,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)->OnColorsChanged();
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
#endif
#endif
@ -3088,7 +3084,7 @@ void MainFrame::load_config_file()
// return;
wxFileDialog dlg(this, _L("Select profile to load:"),
!m_last_config.IsEmpty() ? get_dir_name(m_last_config) : wxGetApp().app_config->get_last_dir(),
"config.json", "Config files (*.json;*.zip;*.bbscfg;*.bbsflmt)|*.json;*.zip;*.bbscfg;*.bbsflmt", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
"config.json", "Config files (*.json;*.zip;*.orca_printer;*.orca_filament)|*.json;*.zip;*.orca_printer;*.orca_filament", wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST);
wxArrayString files;
if (dlg.ShowModal() != wxID_OK)
return;
@ -3117,8 +3113,11 @@ void MainFrame::load_config_file()
}
wxGetApp().preset_bundle->update_compatible(PresetSelectCompatibleType::Always);
update_side_preset_ui();
MessageDialog dlg2(this, wxString::Format(_L_PLURAL("There is %d config imported. (Only non-system and compatible configs)",
"There are %d configs imported. (Only non-system and compatible configs)", cfiles.size()), cfiles.size()),
auto msg = wxString::Format(_L_PLURAL("There is %d config imported. (Only non-system and compatible configs)",
"There are %d configs imported. (Only non-system and compatible configs)", cfiles.size()), cfiles.size());
if(cfiles.empty())
msg += _L("\nHint: Make sure you have added the corresponding printer before importing the configs.");
MessageDialog dlg2(this,msg ,
_L("Import result"), wxOK);
dlg2.ShowModal();
}

View file

@ -354,9 +354,9 @@ void MediaFilePanel::SwitchStorage(bool external)
void MediaFilePanel::Rescale()
{
m_bmp_loading.sys_color_changed();
m_bmp_failed.sys_color_changed();
m_bmp_empty.sys_color_changed();
m_bmp_loading.msw_rescale();
m_bmp_failed.msw_rescale();
m_bmp_empty.msw_rescale();
auto top_sizer = GetSizer()->GetItem((size_t) 0)->GetSizer();
top_sizer->SetMinSize({-1, 75 * em_unit(this) / 10});

View file

@ -37,10 +37,10 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
m_button_play->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &e) { TogglePlay(); });
m_button_play->Bind(wxEVT_RIGHT_UP, [this](auto & e) { m_media_ctrl->Play(); });
m_label_status->Bind(wxEVT_LEFT_UP, [this](auto &e) {
auto url = wxString::Format(L"https://wiki.bambulab.com/%s/software/bambu-studio/faq/live-view", L"en");
wxLaunchDefaultBrowser(url);
});
// m_label_status->Bind(wxEVT_LEFT_UP, [this](auto &e) {
// auto url = wxString::Format(L"https://wiki.bambulab.com/%s/software/bambu-studio/faq/live-view", L"en");
// wxLaunchDefaultBrowser(url);
// });
Bind(wxEVT_RIGHT_UP, [this](auto & e) {
wxClipboard & c = *wxTheClipboard;

View file

@ -36,7 +36,7 @@ namespace GUI {
wxBoxSizer* m_sizer_web_control = new wxBoxSizer(wxHORIZONTAL);
auto m_control_back = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_back", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_back = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_back", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_back->SetBackgroundColour(*wxWHITE);
m_control_back->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_back->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));
@ -47,7 +47,7 @@ namespace GUI {
m_control_back->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_ARROW));});
auto m_control_forward = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_forward", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_forward = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_forward", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_forward->SetBackgroundColour(*wxWHITE);
m_control_forward->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_forward->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));
@ -57,7 +57,7 @@ namespace GUI {
m_control_forward->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_HAND)); });
m_control_forward->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCursor(wxCURSOR_ARROW)); });
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
auto m_control_refresh = new ScalableButton(m_web_control_panel, wxID_ANY, "mall_control_refresh", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_control_refresh->SetBackgroundColour(*wxWHITE);
m_control_refresh->SetSize(wxSize(FromDIP(25), FromDIP(30)));
m_control_refresh->SetMinSize(wxSize(FromDIP(25), FromDIP(30)));

View file

@ -227,10 +227,10 @@ void MsgDialog::apply_style(long style)
if (style & wxNO) add_button(wxID_NO, false,_L("No"));
if (style & wxCANCEL) add_button(wxID_CANCEL, false, _L("Cancel"));
logo->SetBitmap( *get_bmp_bundle(style & wxAPPLY ? "completed" :
logo->SetBitmap( create_scaled_bitmap(style & wxAPPLY ? "completed" :
style & wxICON_WARNING ? "obj_warning" :
style & wxICON_INFORMATION ? "info" :
style & wxICON_QUESTION ? "question" : "OrcaSlicer", 64));
style & wxICON_QUESTION ? "question" : "OrcaSlicer", this, 64, style & wxICON_ERROR));
}
void MsgDialog::finalize()
@ -339,7 +339,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(*get_bmp_bundle("OrcaSlicer_192px_grayscale.png", monospaced_font ? 48 : /*1*/84));
logo->SetBitmap(create_scaled_bitmap("OrcaSlicer_192px_grayscale.png", this, monospaced_font ? 48 : /*1*/84));
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));

View file

@ -122,8 +122,6 @@ void ButtonsListCtrl::Rescale()
{
//m_mode_sizer->msw_rescale();
int em = em_unit(this);
// Orca: following is removed by PS in wx 3.16 refactor.
// doesn't seem to be doing anything rn so leaving it alone
for (Button* btn : m_pageButtons) {
//BBS
btn->SetMinSize({(btn->GetLabel().empty() ? 40 : 132) * em / 10, 36 * em / 10});
@ -139,14 +137,6 @@ void ButtonsListCtrl::Rescale()
m_sizer->Layout();
}
void ButtonsListCtrl::OnColorsChanged()
{
for (Button* btn : m_pageButtons)
btn->Rescale();
m_sizer->Layout();
}
void ButtonsListCtrl::SetSelection(int sel)
{
if (m_selection == sel)

View file

@ -23,7 +23,6 @@ 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 = "", const std::string &inactive_bmp_name = "");
void RemovePage(size_t n);
bool SetPageImage(size_t n, const std::string& bmp_name) const;
@ -262,11 +261,6 @@ public:
GetBtnsListCtrl()->Rescale();
}
void OnColorsChanged()
{
GetBtnsListCtrl()->OnColorsChanged();
}
void OnNavigationKey(wxNavigationKeyEvent& event)
{
if (event.IsWindowChange()) {

View file

@ -28,12 +28,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 wxBitmapBundle* bmp, wxWindow* parent)
static wxSize get_bitmap_size(const wxBitmap& bmp)
{
#ifndef __WIN32__
return bmp->GetBitmapFor(parent).GetSize();
#ifdef __APPLE__
return bmp.GetScaledSize();
#else
return bmp->GetDefaultSize();
return bmp.GetSize();
#endif
}
@ -58,8 +58,8 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
m_v_gap2 = lround(0.8 * m_em_unit);
m_h_gap = lround(0.2 * m_em_unit);
//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("blank_16"), this);
//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("blank_16", this));
init_ctrl_lines();// from og.lines()
@ -597,8 +597,8 @@ void OG_CustomCtrl::msw_rescale()
m_v_gap2 = lround(0.8 * m_em_unit);
m_h_gap = lround(0.2 * m_em_unit);
//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("blank_16"), this);
//m_bmp_mode_sz = create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12).GetSize();
m_bmp_blinking_sz = create_scaled_bitmap("blank_16", this).GetSize();
m_max_win_width = 0;
@ -691,7 +691,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(get_bmp_bundle("empty"), ctrl).GetHeight();
height = get_bitmap_size(create_scaled_bitmap("empty")).GetHeight();
if (ctrl->opt_group->label_width != 0 && !og_line.label.IsEmpty()) {
wxSize label_sz = ctrl->GetTextExtent(og_line.label);
@ -773,8 +773,8 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
if (field && field->undo_bitmap()) {
// if (field)
// BBS: new layout
const wxPoint pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->get_bitmap(),
field->undo_bitmap()->get_bitmap(), field->blink());
const wxPoint pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(),
field->undo_bitmap()->bmp(), field->blink());
if (field->has_edit_ui())
draw_edit_bmp(dc, pos, field->edit_bitmap());
}
@ -831,7 +831,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord h_pos, wxCoord v_pos)
auto draw_buttons = [&h_pos, &dc, &v_pos, this](Field* field, size_t bmp_rect_id = 0) {
if (field && field->undo_to_sys_bitmap()) {
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->get_bitmap(), field->undo_bitmap()->get_bitmap(), field->blink(), bmp_rect_id).x;
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink(), bmp_rect_id).x;
}
#ifndef DISABLE_BLINKING
else if (field && !field->undo_to_sys_bitmap() && field->blink())
@ -962,19 +962,19 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC &dc, wxPoint pos, const wxString
wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking)
{
wxBitmapBundle* bmp_blinking = get_bmp_bundle(is_blinking ? "blank_16" : "empty");
wxBitmap bmp_blinking = create_scaled_bitmap(is_blinking ? "blank_16" : "empty", ctrl);
wxCoord h_pos = pos.x;
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking, ctrl).GetHeight()) / 2);
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking).GetHeight()) / 2);
dc.DrawBitmap(bmp_blinking->GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(bmp_blinking, h_pos, v_pos);
int bmp_dim = get_bitmap_size(bmp_blinking, ctrl).GetWidth();
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
h_pos += bmp_dim + ctrl->m_h_gap;
return wxPoint(h_pos, v_pos);
}
wxPoint 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)
wxPoint 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)
{
#ifndef DISABLE_BLINKING
pos = draw_blinking_bmp(dc, pos, is_blinking);
@ -982,11 +982,11 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
if (ctrl->opt_group->split_multi_line) { // BBS
const std::vector<Option> &option_set = og_line.get_options();
if (option_set.size() > 1)
pos.y += lround(((height - ctrl->m_v_gap + ctrl->m_v_gap2) / option_set.size() - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround(((height - ctrl->m_v_gap + ctrl->m_v_gap2) / option_set.size() - get_bitmap_size(bmp_undo).GetHeight()) / 2);
else
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
} else {
pos.y += lround((height - get_bitmap_size(&bmp_undo, ctrl).GetHeight()) / 2);
pos.y += lround((height - get_bitmap_size(bmp_undo).GetHeight()) / 2);
}
#endif
wxCoord h_pos = pos.x;
@ -994,16 +994,16 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
#ifndef DISABLE_UNDO_SYS
//BBS: GUI refactor
dc.DrawBitmap(bmp_undo_to_sys.GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(bmp_undo_to_sys, h_pos, v_pos);
int bmp_dim = get_bitmap_size(&bmp_undo_to_sys, ctrl).GetWidth();
int bmp_dim = get_bitmap_size(bmp_undo_to_sys).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;
#endif
dc.DrawBitmap(og_line.undo_to_sys ? bmp_undo_to_sys.GetBitmapFor(ctrl) : bmp_undo.GetBitmapFor(ctrl), h_pos, v_pos);
dc.DrawBitmap(og_line.undo_to_sys ? bmp_undo_to_sys : bmp_undo, h_pos, v_pos);
int bmp_dim2 = get_bitmap_size(&bmp_undo, ctrl).GetWidth();
int bmp_dim2 = get_bitmap_size(bmp_undo).GetWidth();
(og_line.undo_to_sys ? rects_undo_to_sys_icon[rect_id] : rects_undo_icon[rect_id]) = wxRect(h_pos, v_pos, bmp_dim2, bmp_dim2);
h_pos += bmp_dim2 + ctrl->m_h_gap;

View file

@ -64,7 +64,7 @@ class OG_CustomCtrl :public wxPanel
void render(wxDC& dc, wxCoord h_pos, wxCoord v_pos);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false, bool is_main = false);
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking);
wxPoint 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);
wxPoint 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_edit_bmp(wxDC& dc, wxPoint pos, const wxBitmapBundle* bmp_edit);
bool launch_browser() const;
bool is_separator() const { return og_line.is_separator(); }

View file

@ -4,6 +4,7 @@
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
///|/
#include "ObjectDataViewModel.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
#include "wxExtensions.hpp"
#include "BitmapCache.hpp"
#include "GUI_App.hpp"
@ -26,13 +27,6 @@ wxDEFINE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
BitmapCache* m_bitmap_cache = nullptr;
wxBitmapBundle* find_bndl(const std::string& bmp_name)
{
if (!m_bitmap_cache)
m_bitmap_cache = new BitmapCache;
return m_bitmap_cache->find_bndl(bmp_name);
}
// *****************************************************************************
// ----------------------------------------------------------------------------
@ -138,7 +132,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
else if (type == itLayerRoot)
{
//BBS do not support layer range edit
m_bmp = *get_bmp_bundle(LayerRootIcon);
m_bmp = create_scaled_bitmap(LayerRootIcon);
m_name = _(L("Layers"));
}
else if (type == itInfo)
@ -169,7 +163,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 = *get_bmp_bundle(LayerIcon);
m_bmp = create_scaled_bitmap(LayerIcon);
set_icons();
init_container();
@ -187,15 +181,7 @@ bool ObjectDataViewModelNode::valid()
void ObjectDataViewModelNode::sys_color_changed()
{
m_printable_icon = m_printable == piUndef ? m_empty_bmp : *get_bmp_bundle(m_printable == piPrintable ? "check_on" : "check_off_focused");
if (!m_action_icon_name.empty())
m_action_icon = *get_bmp_bundle(m_action_icon_name);
if (!m_opt_categories.empty())
update_settings_digest_bitmaps();
set_extruder_icon();
m_printable_icon = m_printable == piUndef ? m_empty_bmp : create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
}
void ObjectDataViewModelNode::set_icons()
@ -224,7 +210,7 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
return;
m_printable = printable;
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
*get_bmp_bundle(m_printable == piPrintable ? "check_on" : "check_off_focused");
create_scaled_bitmap(m_printable == piPrintable ? "check_on" : "check_off_focused");
}
void ObjectDataViewModelNode::set_action_icon(bool enable)
@ -236,7 +222,7 @@ void ObjectDataViewModelNode::set_action_icon(bool enable)
m_action_icon_name = m_type & itPlate ? undo :
m_type & itObject ? undo :
m_type & (itVolume | itLayer) ? undo : /*m_type & itInstance*/ "set_separate_obj";
m_action_icon = *get_bmp_bundle(m_action_icon_name); // FIXME: pass window ptr
m_action_icon = create_scaled_bitmap(m_action_icon_name); // FIXME: pass window ptr
}
// BBS
@ -246,9 +232,9 @@ void ObjectDataViewModelNode::set_color_icon(bool enable)
return;
m_color_enable = enable;
if ((m_type & itObject) && enable)
m_color_icon = *get_bmp_bundle("mmu_segmentation");
m_color_icon = create_scaled_bitmap("mmu_segmentation");
else
m_color_icon = *get_bmp_bundle("dot");
m_color_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_support_icon(bool enable)
@ -257,9 +243,9 @@ void ObjectDataViewModelNode::set_support_icon(bool enable)
return;
m_support_enable = enable;
if ((m_type & itObject) && enable)
m_support_icon = *get_bmp_bundle("toolbar_support");
m_support_icon = create_scaled_bitmap("toolbar_support");
else
m_support_icon = *get_bmp_bundle("dot");
m_support_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_sinking_icon(bool enable)
@ -268,9 +254,9 @@ void ObjectDataViewModelNode::set_sinking_icon(bool enable)
return;
m_sink_enable = enable;
if ((m_type & itObject) && enable)
m_sinking_icon = *get_bmp_bundle("objlist_sinking");
m_sinking_icon = create_scaled_bitmap("objlist_sinking");
else
m_sinking_icon = *get_bmp_bundle("dot");
m_sinking_icon = create_scaled_bitmap("dot");
}
void ObjectDataViewModelNode::set_warning_icon(const std::string& warning_icon_name)
@ -285,14 +271,14 @@ void ObjectDataViewModelNode::update_settings_digest_bitmaps()
m_bmp = m_empty_bmp;
std::string scaled_bitmap_name = m_name.ToUTF8().data();
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "");
scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : "");
wxBitmapBundle *bmp = find_bndl(scaled_bitmap_name);
wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap> bmps;
for (auto& category : m_opt_categories)
bmps.emplace_back(SettingsFactory::get_category_bitmap(category));
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
bmps.emplace_back(SettingsFactory::get_category_bitmap(category, false));
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
}
m_bmp = *bmp;
@ -316,12 +302,26 @@ bool ObjectDataViewModelNode::update_settings_digest(const std::vector<std::stri
return true;
}
void ObjectDataViewModelNode::msw_rescale()
{
if (!m_action_icon_name.empty())
m_action_icon = create_scaled_bitmap(m_action_icon_name);
if (m_printable != piUndef)
m_printable_icon = create_scaled_bitmap(m_printable == piPrintable ? "obj_printable" : "obj_unprintable");
if (!m_opt_categories.empty())
update_settings_digest_bitmaps();
set_extruder_icon();
}
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;
@ -346,7 +346,7 @@ bool ObjectDataViewModelNode::SetValue(const wxVariant& variant, unsigned col)
m_color_icon << variant;
break;
case colEditing:
// m_action_icon << variant;
m_action_icon << variant;
return true;
default:
printf("MyObjectTreeModel::SetValue: wrong column");
@ -413,7 +413,7 @@ void ObjectDataViewModelNode::UpdateExtruderAndColorIcon(wxString extruder /*= "
if (extruder_idx > 0) --extruder_idx;
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps = get_extruder_color_icons();// use wide icons
std::vector<wxBitmap*> bmps = get_extruder_color_icons(false);// use wide icons
if (bmps.empty()) {
m_extruder_bmp = wxNullBitmap;
return;
@ -450,12 +450,12 @@ ObjectDataViewModel::ObjectDataViewModel()
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_text_volume_bmps = MenuFactory::get_text_volume_bitmaps();
m_svg_volume_bmps = MenuFactory::get_svg_volume_bitmaps();
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
m_plate_outside = nullptr;
@ -538,9 +538,9 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
if (!node->has_warning_icon() && !node->has_lock()) {
node->SetBitmap(is_volume_node ? (
node->is_text_volume() ? *m_text_volume_bmps.at(vol_type) :
node->is_svg_volume() ? *m_svg_volume_bmps.at(vol_type) :
*m_volume_bmps.at(vol_type)) : m_empty_bmp);
node->is_text_volume() ? m_text_volume_bmps.at(vol_type) :
node->is_svg_volume() ? m_svg_volume_bmps.at(vol_type) :
m_volume_bmps.at(vol_type)) : m_empty_bmp);
return;
}
@ -553,19 +553,19 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node)
scaled_bitmap_name += std::to_string(vol_type);
scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "-lm");
wxBitmapBundle* bmp = find_bndl(scaled_bitmap_name);
if (!bmp) {
std::vector<wxBitmapBundle*> bmps;
wxBitmap* bmp = m_bitmap_cache->find(scaled_bitmap_name);
if (bmp == nullptr) {
std::vector<wxBitmap> bmps;
if (node->has_warning_icon())
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? &m_warning_bmp : &m_warning_manifold_bmp);
bmps.emplace_back(node->warning_icon_name() == WarningIcon ? m_warning_bmp : m_warning_manifold_bmp);
if (node->has_lock())
bmps.emplace_back(&m_lock_bmp);
bmps.emplace_back(m_lock_bmp);
if (is_volume_node)
bmps.emplace_back(
node->is_text_volume() ? m_text_volume_bmps[vol_type] :
node->is_svg_volume() ? m_svg_volume_bmps[vol_type] :
m_volume_bmps[vol_type]);
bmp = m_bitmap_cache->insert_bndl(scaled_bitmap_name, bmps);
bmp = m_bitmap_cache->insert(scaled_bitmap_name, bmps);
}
node->SetBitmap(*bmp);
@ -705,7 +705,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);
@ -1693,7 +1693,7 @@ wxString ObjectDataViewModel::GetName(const wxDataViewItem &item) const
return node->m_name;
}
wxBitmapBundle& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
wxBitmap& ObjectDataViewModel::GetBitmap(const wxDataViewItem &item) const
{
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
return node->m_bmp;
@ -1735,13 +1735,13 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
switch (col)
{
case colPrint:
variant << node->m_printable_icon.GetBitmapFor(m_ctrl);
variant << node->m_printable_icon;
break;
case colName:
variant << DataViewBitmapText(node->m_name, node->m_bmp.GetBitmapFor(m_ctrl));
variant << DataViewBitmapText(node->m_name, node->m_bmp);
break;
case colFilament:
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp.GetBitmapFor(m_ctrl));
variant << DataViewBitmapText(node->m_extruder, node->m_extruder_bmp);
break;
// BBS
case colSupportPaint:
@ -1754,7 +1754,7 @@ void ObjectDataViewModel::GetValue(wxVariant &variant, const wxDataViewItem &ite
variant << node->m_color_icon;
break;
case colEditing:
variant << node->m_action_icon.GetBitmapFor(m_ctrl);
variant << node->m_action_icon;
break;
default:
;
@ -2207,7 +2207,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())
@ -2320,17 +2320,17 @@ void ObjectDataViewModel::SetSinkState(const bool painted, wxDataViewItem obj_it
ItemChanged(obj_item);
}
void ObjectDataViewModel::UpdateBitmaps()
void ObjectDataViewModel::Rescale()
{
m_volume_bmps = MenuFactory::get_volume_bitmaps();
m_text_volume_bmps = MenuFactory::get_text_volume_bitmaps();
m_svg_volume_bmps = MenuFactory::get_svg_volume_bitmaps();
m_warning_bmp = *get_bmp_bundle(WarningIcon);
m_warning_manifold_bmp = *get_bmp_bundle(WarningManifoldIcon);
m_lock_bmp = *get_bmp_bundle(LockIcon);
m_warning_bmp = create_scaled_bitmap(WarningIcon);
m_warning_manifold_bmp = create_scaled_bitmap(WarningManifoldIcon);
m_lock_bmp = create_scaled_bitmap(LockIcon);
for (auto item : INFO_ITEMS)
m_info_bmps[item.first] = get_bmp_bundle(item.second.bmp_name);
m_info_bmps[item.first] = create_scaled_bitmap(item.second.bmp_name);
wxDataViewItemArray all_items;
GetAllChildren(wxDataViewItem(0), all_items);
@ -2341,7 +2341,7 @@ void ObjectDataViewModel::UpdateBitmaps()
continue;
ObjectDataViewModelNode *node = static_cast<ObjectDataViewModelNode*>(item.GetID());
node->sys_color_changed();
node->msw_rescale();
switch (node->m_type)
{
@ -2350,13 +2350,13 @@ void ObjectDataViewModel::UpdateBitmaps()
UpdateBitmapForNode(node);
break;
case itLayerRoot:
node->m_bmp = *get_bmp_bundle(LayerRootIcon);
node->m_bmp = create_scaled_bitmap(LayerRootIcon);
break;
case itLayer:
node->m_bmp = *get_bmp_bundle(LayerIcon);
node->m_bmp = create_scaled_bitmap(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;
}

View file

@ -75,27 +75,27 @@ class ObjectDataViewModelNode
{
ObjectDataViewModelNode* m_parent;
MyObjectTreeModelNodePtrArray m_children;
wxBitmapBundle m_empty_bmp;
wxBitmap 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;
wxBitmapBundle& m_bmp = m_empty_bmp;
wxBitmap& m_bmp = m_empty_bmp;
ItemType m_type;
int m_idx = -1;
int m_plate_idx = -1;
bool m_container = false;
// BBS
wxString m_extruder = wxEmptyString;
wxBitmapBundle m_extruder_bmp;
wxBitmapBundle m_action_icon;
wxBitmap m_extruder_bmp;
wxBitmap m_action_icon;
// BBS
wxBitmapBundle m_support_icon;
wxBitmapBundle m_color_icon;
wxBitmapBundle m_sinking_icon;
wxBitmap m_support_icon;
wxBitmap m_color_icon;
wxBitmap m_sinking_icon;
PrintIndicator m_printable {piUndef};
wxBitmapBundle m_printable_icon;
wxBitmap m_printable_icon;
std::string m_warning_icon_name{ "" };
bool m_has_lock{false}; // for cut object icon
@ -229,11 +229,11 @@ public:
void SetName(const wxString &);
bool SetValue(const wxVariant &variant, unsigned int col);
void SetVolumeType(ModelVolumeType type) { m_volume_type = type; }
void SetBitmap(const wxBitmapBundle &icon) { m_bmp = icon; }
void SetBitmap(const wxBitmap &icon) { m_bmp = icon; }
void SetExtruder(const wxString &extruder) { m_extruder = extruder; }
void SetWarningIconName(const std::string& warning_icon_name) { m_warning_icon_name = warning_icon_name; }
void SetLock(bool has_lock) { m_has_lock = has_lock; }
const wxBitmapBundle& GetBitmap() const { return m_bmp; }
const wxBitmap& 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; }
@ -302,6 +302,7 @@ public:
bool is_text_volume() const { return m_is_text_volume; }
bool is_svg_volume() const { return m_is_svg_volume; }
void sys_color_changed();
void msw_rescale();
#ifndef NDEBUG
bool valid();
@ -327,14 +328,14 @@ class ObjectDataViewModel :public wxDataViewModel
{
std::vector<ObjectDataViewModelNode*> m_plates;
std::vector<ObjectDataViewModelNode*> m_objects;
std::vector<wxBitmapBundle*> m_volume_bmps;
std::vector<wxBitmapBundle*> m_text_volume_bmps;
std::vector<wxBitmapBundle*> m_svg_volume_bmps;
std::map<InfoItemType, wxBitmapBundle*> m_info_bmps;
wxBitmapBundle m_empty_bmp;
wxBitmapBundle m_warning_bmp;
wxBitmapBundle m_warning_manifold_bmp;
wxBitmapBundle m_lock_bmp;
std::vector<wxBitmap> m_volume_bmps;
std::vector<wxBitmap> m_text_volume_bmps;
std::vector<wxBitmap> m_svg_volume_bmps;
std::map<InfoItemType, wxBitmap> m_info_bmps;
wxBitmap m_empty_bmp;
wxBitmap m_warning_bmp;
wxBitmap m_warning_manifold_bmp;
wxBitmap m_lock_bmp;
ObjectDataViewModelNode* m_plate_outside;
@ -399,7 +400,7 @@ public:
// helper method for wxLog
wxString GetName(const wxDataViewItem &item) const;
wxBitmapBundle& GetBitmap(const wxDataViewItem &item) const;
wxBitmap& GetBitmap(const wxDataViewItem &item) const;
wxString GetExtruder(const wxDataViewItem &item) const;
int GetExtruderNumber(const wxDataViewItem &item) const;
@ -479,7 +480,7 @@ public:
void SetAssociatedControl(wxDataViewCtrl* ctrl) { m_ctrl = ctrl; }
// Rescale bitmaps for existing Items
void UpdateBitmaps();
void Rescale();
void AddWarningIcon(const wxDataViewItem& item, const std::string& warning_name);
void DeleteWarningIcon(const wxDataViewItem& item, const bool unmark_object = false);

View file

@ -845,6 +845,7 @@ 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;
}
@ -892,7 +893,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->sys_color_changed();
sc_btn->msw_rescale();
return;
}
wxGetApp().UpdateDarkUI(win, dynamic_cast<wxButton*>(win) != nullptr);

View file

@ -233,11 +233,11 @@ ParamsPanel::ParamsPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
//m_search_btn->SetToolTip(format_wxstr(_L("Search in settings [%1%]"), "Ctrl+F"));
//m_search_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { wxGetApp().plater()->search(false); });
m_compare_btn = new ScalableButton(m_top_panel, wxID_ANY, "compare", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_compare_btn = new ScalableButton(m_top_panel, wxID_ANY, "compare", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_compare_btn->SetToolTip(_L("Compare presets"));
m_compare_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { wxGetApp().mainframe->diff_dialog.show(); }));
m_setting_btn = new ScalableButton(m_top_panel, wxID_ANY, "table", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_setting_btn = new ScalableButton(m_top_panel, wxID_ANY, "table", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_setting_btn->SetToolTip(_L("View all object's settings"));
m_setting_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { wxGetApp().plater()->PopupObjectTable(-1, -1, {0, 0}); });
@ -646,11 +646,11 @@ void ParamsPanel::update_mode()
void ParamsPanel::msw_rescale()
{
if (m_process_icon) m_process_icon->sys_color_changed();
if (m_setting_btn) m_setting_btn->sys_color_changed();
if (m_search_btn) m_search_btn->sys_color_changed();
if (m_compare_btn) m_compare_btn->sys_color_changed();
if (m_tips_arrow) m_tips_arrow->sys_color_changed();
if (m_process_icon) m_process_icon->msw_rescale();
if (m_setting_btn) m_setting_btn->msw_rescale();
if (m_search_btn) m_search_btn->msw_rescale();
if (m_compare_btn) m_compare_btn->msw_rescale();
if (m_tips_arrow) m_tips_arrow->msw_rescale();
m_left_sizer->SetMinSize(wxSize(40 * em_unit(this), -1));
if (m_mode_sizer)
m_mode_sizer->SetMinSize(-1, 3 * em_unit(this));

View file

@ -4604,6 +4604,7 @@ void PartPlateList::update_logo_texture_filename(const std::string &texture_file
return !texture.empty() && (boost::algorithm::iends_with(texture, ".png") || boost::algorithm::iends_with(texture, ".svg")) && boost::filesystem::exists(texture, ec);
};
if (!texture_filename.empty() && !check_texture(texture_filename)) {
m_logo_texture_filename = "";
BOOST_LOG_TRIVIAL(error) << "Unable to load bed texture: " << texture_filename;
} else
m_logo_texture_filename = texture_filename;

View file

@ -515,6 +515,11 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
{
const int& em = em_unit();
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 });
@ -526,15 +531,6 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
Refresh();
}
void PhysicalPrinterDialog::on_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();
}
void PhysicalPrinterDialog::OnOK(wxEvent& event)
{
wxGetApp().get_tab(Preset::TYPE_PRINTER)->save_preset("", false, false, true, m_preset_name );

View file

@ -64,7 +64,7 @@ public:
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
void on_sys_color_changed() override;
void on_sys_color_changed() override {};
};

View file

@ -494,7 +494,7 @@ void Sidebar::priv::hide_rich_tip(wxButton* btn)
static struct DynamicFilamentList : DynamicList
{
std::vector<std::pair<wxString, wxBitmapBundle *>> items;
std::vector<std::pair<wxString, wxBitmap *>> items;
void apply_on(Choice *c) override
{
@ -533,8 +533,7 @@ static struct DynamicFilamentList : DynamicList
std::string type;
wxGetApp().preset_bundle->filaments.find_preset(presets[i])->get_filament_type(type);
str << type;
wxBitmapBundle* bmp = icons[i];
items.push_back({str, bmp});
items.push_back({str, icons[i]});
}
DynamicList::update();
}
@ -702,9 +701,6 @@ Sidebar::Sidebar(Plater *parent)
bed_type_title->SetFont(font);
SetCursor(wxCURSOR_ARROW);
});
bed_type_title->Bind(wxEVT_LEFT_UP, [bed_type_title, this](wxMouseEvent &e) {
wxLaunchDefaultBrowser("https://wiki.bambulab.com/en/x1/manual/compatibility-and-parameter-settings-of-filaments");
});
AppConfig *app_config = wxGetApp().app_config;
std::string str_bed_type = app_config->get("curr_bed_type");
@ -818,7 +814,9 @@ Sidebar::Sidebar(Plater *parent)
if (dlg.ShowModal() == wxID_OK) {
std::vector<float> matrix = dlg.get_matrix();
std::vector<float> extruders = dlg.get_extruders();
(project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values = std::vector<double>(matrix.begin(), matrix.end());
(project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values = std::vector<double>(extruders.begin(), extruders.end());
(project_config.option<ConfigOptionFloat>("flush_multiplier"))->set(new ConfigOptionFloat(dlg.get_flush_multiplier()));
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
@ -879,7 +877,7 @@ Sidebar::Sidebar(Plater *parent)
bSizer39->Add(FromDIP(20), 0, 0, 0, 0);
ams_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 18);
wxBU_EXACTFIT | wxNO_BORDER, false, 18);
ams_btn->SetToolTip(_L("Synchronize filament list from AMS"));
ams_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
sync_ams_list();
@ -1341,20 +1339,20 @@ void Sidebar::msw_rescale()
p->m_panel_printer_title->GetSizer()->SetMinSize(-1, 3 * wxGetApp().em_unit());
p->m_panel_filament_title->GetSizer()
->SetMinSize(-1, 3 * wxGetApp().em_unit());
p->m_printer_icon->sys_color_changed();
p->m_printer_setting->sys_color_changed();
p->m_filament_icon->sys_color_changed();
p->m_bpButton_add_filament->sys_color_changed();
p->m_bpButton_del_filament->sys_color_changed();
p->m_bpButton_ams_filament->sys_color_changed();
p->m_bpButton_set_filament->sys_color_changed();
p->m_printer_icon->msw_rescale();
p->m_printer_setting->msw_rescale();
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();
//BBS
m_bed_type_list->Rescale();
m_bed_type_list->SetMinSize({-1, 3 * wxGetApp().em_unit()});
#if 0
if (p->mode_sizer)
p->mode_sizer->sys_color_changed();
p->mode_sizer->msw_rescale();
#endif
//for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
@ -1373,14 +1371,15 @@ void Sidebar::msw_rescale()
// BBS TODO: add msw_rescale for newly added windows
// BBS
//p->object_manipulation->msw_rescale();
p->object_settings->msw_rescale();
// BBS
#if 0
p->object_info->msw_rescale();
p->btn_send_gcode->sys_color_changed();
p->btn_send_gcode->msw_rescale();
// p->btn_eject_device->msw_rescale();
p->btn_export_gcode_removable->sys_color_changed();
p->btn_export_gcode_removable->msw_rescale();
#ifdef _WIN32
const int scaled_height = p->btn_export_gcode_removable->GetBitmapHeight();
#else
@ -1401,26 +1400,26 @@ void Sidebar::sys_color_changed()
#if 0
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->sys_color_changed();
p->object_info->msw_rescale();
for (wxWindow* win : std::vector<wxWindow*>{ p->scrolled, p->presets_panel })
wxGetApp().UpdateAllStaticTextDarkUI(win);
#endif
//for (wxWindow* btn : std::vector<wxWindow*>{ p->btn_reslice, p->btn_export_gcode })
// wxGetApp().UpdateDarkUI(btn, true);
p->m_printer_icon->sys_color_changed();
p->m_printer_setting->sys_color_changed();
p->m_filament_icon->sys_color_changed();
p->m_bpButton_add_filament->sys_color_changed();
p->m_bpButton_del_filament->sys_color_changed();
p->m_bpButton_ams_filament->sys_color_changed();
p->m_bpButton_set_filament->sys_color_changed();
p->m_printer_icon->msw_rescale();
p->m_printer_setting->msw_rescale();
p->m_filament_icon->msw_rescale();
p->m_bpButton_add_filament->msw_rescale();
p->m_bpButton_del_filament->msw_rescale();
p->m_bpButton_ams_filament->msw_rescale();
p->m_bpButton_set_filament->msw_rescale();
p->m_flushing_volume_btn->Rescale();
// BBS
#if 0
if (p->mode_sizer)
p->mode_sizer->sys_color_changed();
p->mode_sizer->msw_rescale();
p->frequently_changed_parameters->sys_color_changed();
#endif
p->object_settings->sys_color_changed();
@ -1448,7 +1447,6 @@ void Sidebar::sys_color_changed()
//p->btn_export_gcode_removable->msw_rescale();
p->scrolled->Layout();
p->scrolled->Refresh();
p->searcher.dlg_sys_color_changed();
}
@ -8968,6 +8966,7 @@ void Plater::_calib_pa_tower(const Calib_Params& params) {
const double nozzle_diameter = printer_config->option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
filament_config->set_key_value("slow_down_layer_time", new ConfigOptionFloats{ 1.0f });
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("default_jerk", new ConfigOptionFloat(1.0f));
print_config->set_key_value("outer_wall_jerk", new ConfigOptionFloat(1.0f));
print_config->set_key_value("inner_wall_jerk", new ConfigOptionFloat(1.0f));
@ -9096,6 +9095,7 @@ void Plater::calib_flowrate(int pass) {
}
print_config->set_key_value("layer_height", new ConfigOptionFloat(layer_height));
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("initial_layer_print_height", new ConfigOptionFloat(first_layer_height));
print_config->set_key_value("reduce_crossing_wall", new ConfigOptionBool(true));
//filament_config->set_key_value("filament_max_volumetric_speed", new ConfigOptionFloats{ 9. });
@ -9123,6 +9123,7 @@ void Plater::calib_temp(const Calib_Params& params) {
model().objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly));
model().objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(5.0));
model().objects[0]->config.set_key_value("brim_object_gap", new ConfigOptionFloat(0.0));
model().objects[0]->config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
changed_objects({ 0 });
wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty();
@ -9191,6 +9192,7 @@ void Plater::calib_max_vol_speed(const Calib_Params& params)
print_config->set_key_value("enable_overhang_speed", new ConfigOptionBool { false });
print_config->set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
print_config->set_key_value("wall_loops", new ConfigOptionInt(1));
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("top_shell_layers", new ConfigOptionInt(0));
print_config->set_key_value("bottom_shell_layers", new ConfigOptionInt(0));
print_config->set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
@ -9256,6 +9258,7 @@ void Plater::calib_retraction(const Calib_Params& params)
obj->config.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
obj->config.set_key_value("initial_layer_print_height", new ConfigOptionFloat(layer_height));
obj->config.set_key_value("layer_height", new ConfigOptionFloat(layer_height));
obj->config.set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
changed_objects({ 0 });
@ -9285,10 +9288,12 @@ void Plater::calib_VFA(const Calib_Params& params)
print_config->set_key_value("enable_overhang_speed", new ConfigOptionBool { false });
print_config->set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
print_config->set_key_value("wall_loops", new ConfigOptionInt(1));
print_config->set_key_value("alternate_extra_wall", new ConfigOptionBool(false));
print_config->set_key_value("top_shell_layers", new ConfigOptionInt(0));
print_config->set_key_value("bottom_shell_layers", new ConfigOptionInt(1));
print_config->set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
print_config->set_key_value("overhang_reverse", new ConfigOptionBool(false));
print_config->set_key_value("detect_thin_wall", new ConfigOptionBool(false));
print_config->set_key_value("spiral_mode", new ConfigOptionBool(true));
model().objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly));
model().objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(3.0));
@ -12452,6 +12457,8 @@ void Plater::msw_rescale()
p->sidebar->msw_rescale();
p->menus.msw_rescale();
Layout();
GetParent()->Layout();
}

View file

@ -159,19 +159,16 @@ wxBoxSizer *PreferencesDialog::create_item_language_combobox(
language_name = wxString::FromUTF8("\xED\x95\x9C\xEA\xB5\xAD\xEC\x96\xB4");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_RUSSIAN)) {
language_name = wxString::FromUTF8("\xD0\xA0\xD1\x83\xD1\x81\xD1\x81\xD0\xBA\xD0\xB8\xD0\xB9");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_CZECH)) {
language_name = wxString::FromUTF8("\xC4\x8D\x65\xC5\xA1\x74\x69\x6E\x61");
language_name = wxString::FromUTF8("\xd0\xa0\xd1\x83\xd1\x81\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_UKRAINIAN)) {
language_name = wxString::FromUTF8("\xC4\x8D\x65\xC5\xA1\x74\x69\x6E\x61");
language_name = wxString::FromUTF8("Ukrainian");
}
else if (vlist[i] == wxLocale::GetLanguageInfo(wxLANGUAGE_TURKISH)) {
language_name = wxString::FromUTF8("\xD1\x83\xD0\xBA\xD1\x80\xD0\xB0\xD1\x97\xD1\x9D\xD1\x81\xD1\x8C\xD0\xBA\xD0\xB0");
language_name = wxString::FromUTF8("Turkish");
}
if (language == vlist[i]->CanonicalName) {
if (app_config->get(param) == vlist[i]->CanonicalName) {
m_current_language_selected = i;
}
combobox->Append(language_name);
@ -999,6 +996,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_region= create_item_region_combobox(_L("Login Region"), page, _L("Login Region"), Regions);
auto item_stealth_mode = create_item_checkbox(_L("Stealth Mode"), page, _L("Stealth Mode"), 50, "stealth_mode");
auto item_check_stable_version_only = create_item_checkbox(_L("Check for stable updates only"), page, _L("Check for stable updates only"), 50, "check_stable_update_only");
std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"};
auto item_currency = create_item_combobox(_L("Units"), page, _L("Units"), "use_inches", Units);
@ -1075,6 +1073,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_stealth_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_check_stable_version_only, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_calc_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3));

View file

@ -112,8 +112,8 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
default: break;
}
m_bitmapCompatible = get_bmp_bundle("flag_green");
m_bitmapIncompatible = get_bmp_bundle("flag_red");
m_bitmapCompatible = ScalableBitmap(this, "flag_green");
m_bitmapIncompatible = ScalableBitmap(this, "flag_red");
// parameters for an icon's drawing
fill_width_height();
@ -295,12 +295,12 @@ void PresetComboBox::update(std::string select_preset_name)
const std::deque<Preset>& presets = m_collection->get_presets();
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
std::map<wxString, wxBitmapBundle*> incomp_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
std::map<wxString, wxBitmap*> incomp_presets;
wxString selected = "";
if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
@ -313,7 +313,7 @@ void PresetComboBox::update(std::string select_preset_name)
if (select_preset_name.empty() && is_enabled)
select_preset_name = preset.name;
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (!is_enabled)
@ -325,17 +325,17 @@ void PresetComboBox::update(std::string select_preset_name)
}
else
{
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, 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")), NullBitmapBndl()));
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
}
if (!nonsys_presets.empty())
{
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) {
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) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -345,8 +345,8 @@ void PresetComboBox::update(std::string select_preset_name)
}
if (!incomp_presets.empty())
{
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(separator(L("Incompatible presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = incomp_presets.begin(); it != incomp_presets.end(); ++it) {
set_label_marker(Append(it->first, *it->second), LABEL_ITEM_DISABLED);
}
}
@ -363,8 +363,7 @@ void PresetComboBox::show_all(bool show_all)
void PresetComboBox::update()
{
int n = this->GetSelection();
this->update(n < 0 ? "" : into_u8(this->GetString(n)));
this->update(into_u8(this->GetString(this->GetSelection())));
}
void PresetComboBox::update_from_bundle()
@ -400,7 +399,9 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
const_cast<Preset&>(*iter).is_visible = true;
auto color = tray.opt_string("filament_colour", 0u);
auto name = tray.opt_string("tray_name", 0u);
int item_id = Append(get_preset_name(*iter), *get_extruder_color_icon(color, name, 24, 16), &m_first_ams_filament + entry.first);
wxBitmap bmp(*get_extruder_color_icon(color, name, 24, 16));
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
//validate_selection(id->value == selected); // can not select
}
m_last_ams_filament = GetCount();
}
@ -418,24 +419,29 @@ void PresetComboBox::msw_rescale()
{
m_em_unit = em_unit(this);
Rescale();
m_bitmapIncompatible.msw_rescale();
m_bitmapCompatible.msw_rescale();
// parameters for an icon's drawing
fill_width_height();
// update the control to redraw the icons
update();
}
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();
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 = 16;
norm_icon_width = 16;
icon_height = m_bitmapCompatible.GetBmpHeight();
norm_icon_width = m_bitmapCompatible.GetBmpWidth();
/* It's supposed that standard size of an icon is 16px*16px for 100% scaled display.
* So set sizes for solid_colored icons used for filament preset
@ -446,11 +452,9 @@ void PresetComboBox::fill_width_height()
thin_icon_width = lroundf(8 * scale_f); // analogue to 8px;
wide_icon_width = norm_icon_width + thin_icon_width;
null_icon_width = 2 * norm_icon_width;
space_icon_width = 2;
thin_space_icon_width = 4;
wide_space_icon_width = 6;
space_icon_width = lroundf(2 * scale_f);
thin_space_icon_width = lroundf(4 * scale_f);
wide_space_icon_width = lroundf(6 * scale_f);
}
wxString PresetComboBox::separator(const std::string& label)
@ -458,15 +462,15 @@ wxString PresetComboBox::separator(const std::string& label)
return wxString::FromUTF8(separator_head()) + _(label) + wxString::FromUTF8(separator_tail());
}
wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmap* 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/* = ""*/)
{
// BBS: no icon
#if 1
static wxBitmapBundle bmp;
static wxBitmap bmp;
return &bmp;
#else // if this is updated, refer to PrusaSlicer for updates
#else
// If the filament preset is not compatible and there is a "red flag" icon loaded, show it left
// to the filament color image.
if (wide_icons)
@ -479,52 +483,52 @@ wxBitmapBundle* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icon
bitmap_key += ",dark";
bitmap_key += material_rgb;
wxBitmapBundle* bmp_bndl = bitmap_cache().find_bndl(bitmap_key);
if (bmp_bndl == nullptr) {
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap> bmps;
if (wide_icons)
// Paint a red flag for incompatible presets.
bmps.emplace_back(is_compatible ? get_empty_bmp_bundle(norm_icon_width, icon_height) : m_bitmapIncompatible);
bmps.emplace_back(is_compatible ? bitmap_cache().mkclear(norm_icon_width, icon_height) : m_bitmapIncompatible.bmp());
if (m_type == Preset::TYPE_FILAMENT && !filament_rgb.empty())
{
// BBS
// Paint a lock at the system presets.
bmps.emplace_back(get_empty_bmp_bundle(space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(space_icon_width, icon_height));
}
else
{
// BBS
#if 0
// Paint the color bars.
bmps.emplace_back(get_empty_bmp_bundle(thin_space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(thin_space_icon_width, icon_height));
if (m_type == Preset::TYPE_SLA_MATERIAL)
bmps.emplace_back(bitmap_cache().from_svg(main_icon_name, 16, 16, dark_mode, material_rgb));
bmps.emplace_back(create_scaled_bitmap(main_icon_name, this, 16, false, material_rgb));
else
bmps.emplace_back(get_bmp_bundle(main_icon_name));
bmps.emplace_back(create_scaled_bitmap(main_icon_name));
#endif
// Paint a lock at the system presets.
bmps.emplace_back(get_empty_bmp_bundle(wide_space_icon_width, icon_height));
bmps.emplace_back(bitmap_cache().mkclear(wide_space_icon_width, icon_height));
}
bmps.emplace_back(is_system ? get_bmp_bundle("unlock_normal") : get_empty_bmp_bundle(norm_icon_width, icon_height));
bmp_bndl = bitmap_cache().insert_bndl(bitmap_key, bmps);
bmps.emplace_back(is_system ? create_scaled_bitmap("unlock_normal") : bitmap_cache().mkclear(norm_icon_width, icon_height));
bmp = bitmap_cache().insert(bitmap_key, bmps);
}
return bmp_bndl;
return bmp;
#endif
}
wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
wxBitmap *PresetComboBox::get_bmp(Preset const &preset)
{
static wxBitmapBundle sbmp;
static wxBitmap sbmp;
if (m_type == Preset::TYPE_FILAMENT) {
Preset const & preset2 = &m_collection->get_selected_preset() == &preset ? m_collection->get_edited_preset() : preset;
wxString color = preset2.config.opt_string("default_filament_colour", 0);
wxColour clr(color);
if (clr.IsOk()) {
std::string bitmap_key = "default_filament_colour_" + color.ToStdString();
wxBitmapBundle *bmp = bitmap_cache().find_bndl(bitmap_key);
wxBitmap *bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
wxImage img(16, 16);
if (clr.Red() > 224 && clr.Blue() > 224 && clr.Green() > 224) {
@ -533,8 +537,8 @@ wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
} else {
img.SetRGB(wxRect({0, 0}, img.GetSize()), clr.Red(), clr.Green(), clr.Blue());
}
bmp = new wxBitmapBundle(img);
bmp = bitmap_cache().insert_bndl(bitmap_key, *bmp);
bmp = new wxBitmap(img);
bmp = bitmap_cache().insert(bitmap_key, *bmp);
}
return bmp;
}
@ -542,14 +546,14 @@ wxBitmapBundle* PresetComboBox::get_bmp(Preset const &preset)
return &sbmp;
}
wxBitmapBundle *PresetComboBox::get_bmp(std::string bitmap_key,
wxBitmap *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*/)
{
// BBS: no icon
#if 1
static wxBitmapBundle bmp;
static wxBitmap bmp;
return &bmp;
#else
bitmap_key += !is_enabled ? "_disabled" : "";
@ -559,27 +563,21 @@ wxBitmapBundle *PresetComboBox::get_bmp(std::string bitmap_key,
if (wxGetApp().dark_mode())
bitmap_key += ",dark";
wxBitmapBundle* bmp = bitmap_cache().find_bndl(bitmap_key);
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
bmps.emplace_back(m_type == Preset::TYPE_PRINTER ? get_bmp_bundle(main_icon_name, this, 16, !is_enabled) :
is_compatible ? m_bitmapCompatible : m_bitmapIncompatible);
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());
// Paint a lock at the system presets.
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);
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);
}
return bmp;
#endif
}
wxBitmapBundle PresetComboBox::NullBitmapBndl()
{
assert(null_icon_width > 0);
return *get_empty_bmp_bundle(null_icon_width, icon_height);
}
bool PresetComboBox::is_selected_physical_printer()
{
auto selected_item = this->GetSelection();
@ -946,12 +944,10 @@ void PlaterPresetComboBox::update()
// and draw a red flag in front of the selected preset.
bool wide_icons = selected_preset && !selected_preset->is_compatible;
null_icon_width = (wide_icons ? 3 : 2) * norm_icon_width + thin_space_icon_width + wide_space_icon_width;
std::map<wxString, wxBitmapBundle*> nonsys_presets;
std::map<wxString, wxBitmap*> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, wxBitmapBundle*> project_embedded_presets;
std::map<wxString, wxBitmapBundle*> system_presets;
std::map<wxString, wxBitmap*> project_embedded_presets;
std::map<wxString, wxBitmap*> system_presets;
//BBS: move system to the end
wxString selected_system_preset;
@ -961,7 +957,7 @@ void PlaterPresetComboBox::update()
//BBS: move system to the end
/*if (!presets.front().is_visible)
this->set_label_marker(this->Append(separator(L("System presets")), NullBitmapBndl()));*/
this->set_label_marker(this->Append(separator(L("System presets")), wxNullBitmap));*/
for (size_t i = presets.front().is_visible ? 0 : m_collection->num_default_presets(); i < presets.size(); ++i)
{
@ -989,7 +985,7 @@ void PlaterPresetComboBox::update()
#endif
}
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
const std::string name = preset.alias.empty() ? preset.name : preset.alias;
@ -1034,16 +1030,16 @@ void PlaterPresetComboBox::update()
//BBS: add project embedded preset logic
if (!project_embedded_presets.empty())
{
set_label_marker(Append(separator(L("Project-inside presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
set_label_marker(Append(separator(L("Project-inside presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
}
if (!nonsys_presets.empty())
{
set_label_marker(Append(separator(L("User presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
set_label_marker(Append(separator(L("User presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = nonsys_presets.begin(); it != nonsys_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_user_preset);
}
@ -1051,8 +1047,8 @@ void PlaterPresetComboBox::update()
//BBS: move system to the end
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
for (std::map<wxString, wxBitmapBundle*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, wxBitmap*>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
Append(it->first, *it->second);
validate_selection(it->first == selected_system_preset);
}
@ -1063,7 +1059,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")), NullBitmapBndl()));
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1072,7 +1068,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;
auto bmp = get_bmp(main_icon_name, wide_icons, main_icon_name);
wxBitmap* 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);
@ -1083,7 +1079,7 @@ void PlaterPresetComboBox::update()
}*/
if (m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_FILAMENT || m_type == Preset::TYPE_SLA_MATERIAL) {
wxBitmapBundle* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
wxBitmap* bmp = get_bmp("edit_preset_list", wide_icons, "edit_uni");
assert(bmp);
if (m_type == Preset::TYPE_FILAMENT)
@ -1125,23 +1121,12 @@ void PlaterPresetComboBox::msw_rescale()
if (clr_picker)
clr_picker->SetSize(20 * m_em_unit / 10, 20 * m_em_unit / 10);
#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();
// BBS
if (edit_btn != nullptr)
edit_btn->sys_color_changed();
edit_btn->msw_rescale();
}
// ---------------------------------
// *** TabPresetComboBox ***
// ---------------------------------
@ -1208,16 +1193,16 @@ void TabPresetComboBox::update()
const std::deque<Preset>& presets = m_collection->get_presets();
std::map<wxString, std::pair<wxBitmapBundle*, bool>> nonsys_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> nonsys_presets;
//BBS: add project embedded presets logic
std::map<wxString, std::pair<wxBitmapBundle*, bool>> project_embedded_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> project_embedded_presets;
//BBS: move system to the end
std::map<wxString, std::pair<wxBitmapBundle*, bool>> system_presets;
std::map<wxString, std::pair<wxBitmap*, bool>> system_presets;
wxString selected = "";
//BBS: move system to the end
/*if (!presets.front().is_visible)
set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));*/
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));*/
size_t idx_selected = m_collection->get_selected_idx();
if (m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection()) {
@ -1236,12 +1221,12 @@ void TabPresetComboBox::update()
// marker used for disable incompatible printer models for the selected physical printer
bool is_enabled = true;
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (preset.is_default || preset.is_system) {
//BBS: move system to the end
system_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
system_presets.emplace(get_preset_name(preset), std::pair<wxBitmap *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
//int item_id = Append(get_preset_name(preset), *bmp);
@ -1253,20 +1238,20 @@ void TabPresetComboBox::update()
else if (preset.is_project_embedded)
{
//std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
project_embedded_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle *, bool>(bmp, is_enabled));
project_embedded_presets.emplace(get_preset_name(preset), std::pair<wxBitmap *, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
}
else
{
std::pair<wxBitmapBundle*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmapBundle*, bool>(bmp, is_enabled));
std::pair<wxBitmap*, bool> pair(bmp, is_enabled);
nonsys_presets.emplace(get_preset_name(preset), std::pair<wxBitmap*, bool>(bmp, is_enabled));
if (i == idx_selected)
selected = get_preset_name(preset);
}
//BBS: move system to the end
//if (i + 1 == m_collection->num_default_presets())
// set_label_marker(Append(separator(L("System presets")), NullBitmapBndl()));
// set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
}
if (m_type == Preset::TYPE_FILAMENT && m_preset_bundle->is_bbl_vendor())
@ -1276,7 +1261,7 @@ void TabPresetComboBox::update()
if (!project_embedded_presets.empty())
{
set_label_marker(Append(separator(L("Project-inside presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = project_embedded_presets.begin(); it != project_embedded_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1286,8 +1271,8 @@ void TabPresetComboBox::update()
}
if (!nonsys_presets.empty())
{
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) {
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) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1299,7 +1284,7 @@ void TabPresetComboBox::update()
if (!system_presets.empty())
{
set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
for (std::map<wxString, std::pair<wxBitmapBundle*, bool>>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
for (std::map<wxString, std::pair<wxBitmap*, bool>>::iterator it = system_presets.begin(); it != system_presets.end(); ++it) {
int item_id = Append(it->first, *it->second.first);
bool is_enabled = it->second.second;
if (!is_enabled)
@ -1313,7 +1298,7 @@ void TabPresetComboBox::update()
//BBS: remove unused pysical printer logic
/*// add Physical printers, if any exists
if (!m_preset_bundle->physical_printers.empty()) {
set_label_marker(Append(separator(L("Physical printers")), NullBitmapBndl()));
set_label_marker(Append(separator(L("Physical printers")), wxNullBitmap));
const PhysicalPrinterCollection& ph_printers = m_preset_bundle->physical_printers;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
@ -1323,7 +1308,7 @@ void TabPresetComboBox::update()
continue;
std::string main_icon_name = preset->printer_technology() == ptSLA ? "sla_printer" : m_main_bitmap_name;
auto bmp = get_bmp(main_icon_name, main_icon_name, "", true, true, false);
wxBitmap* 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);
@ -1334,14 +1319,14 @@ void TabPresetComboBox::update()
// add "Add/Remove printers" item
//std::string icon_name = "edit_uni";
//auto bmp = get_bmp("edit_preset_list, tab,", icon_name, "");
//wxBitmap* 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);
}
// BBS Add/Remove filaments select
//wxBitmapBundle* bmp = get_bmp("edit_preset_list", false, "edit_uni");
//wxBitmap* bmp = get_bmp("edit_preset_list", false, "edit_uni");
//assert(bmp);
//if (m_type == Preset::TYPE_FILAMENT)
// set_label_marker(Append(separator(L("Add/Remove filaments")), *bmp), LABEL_ITEM_WIZARD_FILAMENTS);
@ -1501,7 +1486,7 @@ void GUI::CalibrateFilamentComboBox::update()
tooltip = get_tooltip(preset);
}
wxBitmapBundle* bmp = get_bmp(preset);
wxBitmap* bmp = get_bmp(preset);
assert(bmp);
if (preset.is_default || preset.is_system) {
@ -1544,7 +1529,7 @@ void GUI::CalibrateFilamentComboBox::msw_rescale()
}
// BBS
if (edit_btn != nullptr)
edit_btn->sys_color_changed();
edit_btn->msw_rescale();
}
void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt)

View file

@ -1,7 +1,7 @@
#ifndef slic3r_PresetComboBoxes_hpp_
#define slic3r_PresetComboBoxes_hpp_
#include <wx/bmpbndl.h>
//#include <wx/bmpcbox.h>
#include <wx/gdicmn.h>
#include <wx/clrpicker.h>
@ -37,7 +37,7 @@ public:
PresetComboBox(wxWindow* parent, Preset::Type preset_type, const wxSize& size = wxDefaultSize, PresetBundle* preset_bundle = nullptr);
~PresetComboBox();
enum LabelItemType : size_t {
enum LabelItemType {
LABEL_ITEM_PHYSICAL_PRINTER = 0xffffff01,
LABEL_ITEM_DISABLED,
LABEL_ITEM_MARKER,
@ -99,9 +99,9 @@ protected:
static BitmapCache& bitmap_cache();
// Indicator, that the preset is compatible with the selected printer.
wxBitmapBundle* m_bitmapCompatible;
ScalableBitmap m_bitmapCompatible;
// Indicator, that the preset is NOT compatible with the selected printer.
wxBitmapBundle* m_bitmapIncompatible;
ScalableBitmap m_bitmapIncompatible;
int m_last_selected;
int m_em_unit;
@ -115,7 +115,6 @@ 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;
@ -140,16 +139,14 @@ protected:
#endif // __linux__
static wxString separator(const std::string& label);
wxBitmapBundle* get_bmp( std::string bitmap_key, bool wide_icons, const std::string& main_icon_name,
wxBitmap* 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 = "");
wxBitmapBundle* get_bmp( std::string bitmap_key, const std::string& main_icon_name, const std::string& next_icon_name,
wxBitmap* 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* get_bmp(Preset const &preset);
wxBitmapBundle NullBitmapBndl();
wxBitmap *get_bmp(Preset const &preset);
private:
void fill_width_height();
@ -182,7 +179,6 @@ 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:
@ -249,8 +245,8 @@ private:
bool m_filament_exist{false};
bool m_is_compatible{true};
const Preset* m_selected_preset = nullptr;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmapBundle*>> m_system_presets;
std::map<wxString, std::pair<std::string, wxBitmap*>> m_nonsys_presets;
std::map<wxString, std::pair<std::string, wxBitmap*>> m_system_presets;
};
} // namespace GUI

View file

@ -94,16 +94,16 @@ void RecenterDialog::render(wxDC& dc) {
wxSize hint1_size = dc.GetTextExtent(hint1);
wxPoint pos_hint1 = pos_start;
pos_hint1.y += (m_home_bmp.GetWidth() - hint1_size.y) / 2;
pos_hint1.y += (m_home_bmp.GetBmpWidth() - hint1_size.y) / 2;
dc.DrawText(hint1, pos_hint1);
wxPoint pos_bmp = pos_start;
pos_bmp.x += hint1_size.x;
dc.DrawBitmap(m_home_bmp.get_bitmap(), pos_bmp);
dc.DrawBitmap(m_home_bmp.bmp(), pos_bmp);
wxSize hint2_size = dc.GetTextExtent(hint2);
wxPoint pos_hint2 = pos_hint1;
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetWidth();
pos_hint2.x = pos_hint2.x + hint1_size.x + m_home_bmp.GetBmpWidth();
if (hint2_size.x + pos_hint2.x + BORDER > DRAW_PANEL_SIZE.x) {
bool is_ch = false;

View file

@ -23,6 +23,7 @@
#include <algorithm>
#include "Plater.hpp"
#include "BitmapCache.hpp"
#include "slic3r/GUI/GUI_App.hpp"
namespace Slic3r { namespace GUI {
@ -293,7 +294,8 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
m_vebview_release_note->Bind(wxEVT_WEBVIEW_NAVIGATING,[=](wxWebViewEvent& event){
static bool load_url_first = false;
if(load_url_first){
wxLaunchDefaultBrowser(url_line);
// Orca: not used in Orca Slicer
// wxLaunchDefaultBrowser(url_line);
event.Veto();
}else{
load_url_first = true;
@ -317,11 +319,6 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
m_bitmap_open_in_browser = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("open_in_browser", this, 12), wxDefaultPosition, wxDefaultSize, 0 );
m_link_open_in_browser = new wxHyperlinkCtrl(this, wxID_ANY, "Open in browser", "");
m_link_open_in_browser->SetFont(Label::Body_12);
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
@ -357,6 +354,17 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
EndModal(wxID_NO);
});
m_cb_stable_only = new CheckBox(this);
m_cb_stable_only->SetValue(wxGetApp().app_config->get_bool("check_stable_update_only"));
m_cb_stable_only->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& e) {
wxGetApp().app_config->set_bool("check_stable_update_only", m_cb_stable_only->GetValue());
e.Skip();
});
auto stable_only_label = new Label(this, _L("Check for stable updates only"));
stable_only_label->SetFont(Label::Body_13);
stable_only_label->SetForegroundColour(wxColour(38, 46, 48));
stable_only_label->SetFont(Label::Body_12);
m_button_cancel = new Button(this, _L("Cancel"));
m_button_cancel->SetBackgroundColor(btn_bg_white);
@ -372,10 +380,10 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
m_sizer_main->Add(m_line_top, 0, wxEXPAND | wxBOTTOM, 0);
sizer_button->Add(m_bitmap_open_in_browser, 0, wxALIGN_CENTER | wxLEFT, FromDIP(7));
sizer_button->Add(m_link_open_in_browser, 0, wxALIGN_CENTER| wxLEFT, FromDIP(3));
//sizer_button->Add(m_remind_choice, 0, wxALL | wxEXPAND, FromDIP(5));
sizer_button->AddStretchSpacer();
sizer_button->Add(stable_only_label, 0, wxALIGN_CENTER | wxLEFT, FromDIP(7));
sizer_button->Add(m_cb_stable_only, 0, wxALIGN_CENTER | wxLEFT, FromDIP(5));
sizer_button->Add(m_button_download, 0, wxALL, FromDIP(5));
sizer_button->Add(m_button_skip_version, 0, wxALL, FromDIP(5));
sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
@ -510,7 +518,6 @@ void UpdateVersionDialog::update_version_info(wxString release_note, wxString ve
m_text_up_info->Hide();
m_simplebook_release_note->SetSelection(1);
m_vebview_release_note->LoadURL(from_u8(url_line));
m_link_open_in_browser->SetURL(url_line);
}
else {
m_simplebook_release_note->SetMaxSize(wxSize(FromDIP(560), FromDIP(430)));

View file

@ -99,8 +99,8 @@ public:
wxBoxSizer * sizer_text_release_note{nullptr};
Label * m_staticText_release_note{nullptr};
wxStaticBitmap* m_bitmap_open_in_browser;
wxHyperlinkCtrl* m_link_open_in_browser;
Button* m_button_skip_version;
CheckBox* m_cb_stable_only;
Button* m_button_download;
Button* m_button_cancel;
std::string url_line;

View file

@ -57,7 +57,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
label_top->SetForegroundColour(wxColour(38,46,48));
// m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, *get_bmp_bundle("blank_16"));
// m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, create_scaled_bitmap("blank_16", m_parent));
//
// 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)
@ -268,7 +268,7 @@ void SavePresetDialog::Item::update()
void SavePresetDialog::Item::update_valid_bmp()
{
std::string bmp_name = m_valid_type == Warning ? "obj_warning" : m_valid_type == NoValid ? "cross" : "blank_16";
m_valid_bmp->SetBitmap(*get_bmp_bundle(bmp_name));
m_valid_bmp->SetBitmap(create_scaled_bitmap(bmp_name, m_parent));
}
void SavePresetDialog::Item::accept()

View file

@ -829,9 +829,12 @@ void SearchDialog::msw_rescale()
{
/* const int &em = GUI::wxGetApp().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);
@ -849,7 +852,7 @@ void SearchDialog::msw_rescale()
//#endif
//
// // msw_rescale updates just icons, so use it
// search_list_model->sys_color_changed();
// search_list_model->msw_rescale();
//
// Refresh();
//}
@ -881,10 +884,9 @@ void SearchListModel::Prepend(const std::string &label)
RowPrepended();
}
void SearchListModel::sys_color_changed()
void SearchListModel::msw_rescale()
{
for (ScalableBitmap &bmp : m_icon)
bmp.sys_color_changed();
for (ScalableBitmap &bmp : m_icon) bmp.msw_rescale();
}
wxString SearchListModel::GetColumnType(unsigned int col) const
@ -896,7 +898,7 @@ wxString SearchListModel::GetColumnType(unsigned int col) const
void SearchListModel::GetValueByRow(wxVariant &variant, unsigned int row, unsigned int col) const
{
switch (col) {
case colIcon: variant << m_icon[m_values[row].second].bmp().GetBitmapFor(m_icon[m_values[row].second].parent()); break;
case colIcon: variant << m_icon[m_values[row].second].bmp(); break;
case colMarkedText: variant = m_values[row].first; break;
case colMax: wxFAIL_MSG("invalid column");
default: break;

View file

@ -270,7 +270,7 @@ public:
void Clear();
void Prepend(const std::string &text);
void sys_color_changed();
void msw_rescale();
// implementation of base class virtuals to define model

View file

@ -212,9 +212,9 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_state == PrinterState::IN_LAN) { dwbitmap = m_printer_in_lan; }
// dc.DrawCircle(left, size.y / 2, 3);
dc.DrawBitmap(dwbitmap.get_bitmap(), wxPoint(left, (size.y - dwbitmap.GetSize().y) / 2));
dc.DrawBitmap(dwbitmap.bmp(), wxPoint(left, (size.y - dwbitmap.GetBmpSize().y) / 2));
left += dwbitmap.GetSize().x + 8;
left += dwbitmap.GetBmpSize().x + 8;
dc.SetFont(Label::Body_13);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
@ -230,10 +230,10 @@ void MachineObjectPanel::doRender(wxDC &dc)
auto text_end = 0;
if (m_show_edit) {
text_end = size.x - m_unbind_img.GetSize().x - 30;
text_end = size.x - m_unbind_img.GetBmpSize().x - 30;
}
else {
text_end = size.x - m_unbind_img.GetSize().x;
text_end = size.x - m_unbind_img.GetBmpSize().x;
}
wxString finally_name = dev_name;
@ -261,14 +261,14 @@ void MachineObjectPanel::doRender(wxDC &dc)
if (m_show_bind) {
if (m_bind_state == ALLOW_UNBIND) {
left = size.x - m_unbind_img.GetSize().x - 6;
dc.DrawBitmap(m_unbind_img.get_bitmap(), left, (size.y - m_unbind_img.GetSize().y) / 2);
left = size.x - m_unbind_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_unbind_img.bmp(), left, (size.y - m_unbind_img.GetBmpSize().y) / 2);
}
}
if (m_show_edit) {
left = size.x - m_unbind_img.GetSize().x - 6 - m_edit_name_img.GetSize().x - 6;
dc.DrawBitmap(m_edit_name_img.get_bitmap(), left, (size.y - m_edit_name_img.GetSize().y) / 2);
left = size.x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6;
dc.DrawBitmap(m_edit_name_img.bmp(), left, (size.y - m_edit_name_img.GetBmpSize().y) / 2);
}
}
@ -298,10 +298,10 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
if (m_is_my_devices) {
// show edit
if (m_show_edit) {
auto edit_left = GetSize().x - m_unbind_img.GetSize().x - 6 - m_edit_name_img.GetSize().x - 6;
auto edit_right = edit_left + m_edit_name_img.GetSize().x;
auto edit_top = (GetSize().y - m_edit_name_img.GetSize().y) / 2;
auto edit_bottom = (GetSize().y - m_edit_name_img.GetSize().y) / 2 + m_edit_name_img.GetSize().y;
auto edit_left = GetSize().x - m_unbind_img.GetBmpSize().x - 6 - m_edit_name_img.GetBmpSize().x - 6;
auto edit_right = edit_left + m_edit_name_img.GetBmpSize().x;
auto edit_top = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2;
auto edit_bottom = (GetSize().y - m_edit_name_img.GetBmpSize().y) / 2 + m_edit_name_img.GetBmpSize().y;
if ((evt.GetPosition().x >= edit_left && evt.GetPosition().x <= edit_right) && evt.GetPosition().y >= edit_top && evt.GetPosition().y <= edit_bottom) {
wxCommandEvent event(EVT_EDIT_PRINT_NAME);
event.SetEventObject(this);
@ -310,10 +310,10 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
}
}
if (m_show_bind) {
auto left = GetSize().x - m_unbind_img.GetSize().x - 6;
auto right = left + m_unbind_img.GetSize().x;
auto top = (GetSize().y - m_unbind_img.GetSize().y) / 2;
auto bottom = (GetSize().y - m_unbind_img.GetSize().y) / 2 + m_unbind_img.GetSize().y;
auto left = GetSize().x - m_unbind_img.GetBmpSize().x - 6;
auto right = left + m_unbind_img.GetBmpSize().x;
auto top = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2;
auto bottom = (GetSize().y - m_unbind_img.GetBmpSize().y) / 2 + m_unbind_img.GetBmpSize().y;
if ((evt.GetPosition().x >= left && evt.GetPosition().x <= right) && evt.GetPosition().y >= top && evt.GetPosition().y <= bottom) {
wxCommandEvent event(EVT_UNBIND_MACHINE, GetId());
@ -433,7 +433,7 @@ void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus))
if (wxGetApp().is_user_login()) {
if (!get_print_info_thread) {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -2347,14 +2347,19 @@ bool SelectMachineDialog::is_same_printer_model()
const auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
const auto target_model = obj_->printer_type;
// Orca: ignore P1P -> P1S
if (source_model != target_model && !(preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == "C12") && !(target_model == "C11" && source_model == "C12")) {
if (source_model != target_model) {
if ((source_model == "C12" && target_model == "C11") || (source_model == "C11" && target_model == "C12") ||
(obj_->is_support_p1s_plus && (source_model == "C12"))) {
return true;
}
BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << source_model;
BOOST_LOG_TRIVIAL(info) << "printer_model: target = " << target_model;
return false;
}
if (obj_->is_support_p1s_plus) {
BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
BOOST_LOG_TRIVIAL(info) << "printer_model: source = " << source_model;
BOOST_LOG_TRIVIAL(info) << "printer_model: target = " << obj_->printer_type << " (plus)";
return false;
}
@ -2477,7 +2482,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
std::string info;
DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, in_blacklist, action, info);
if (in_blacklist && action == "prohibition") {
has_prohibited_filament = true;
prohibited_error = wxString::FromUTF8(info);
@ -2513,12 +2518,12 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
if (!is_same_nozzle_diameters(tag_nozzle_type, nozzle_diameter)) {
has_slice_warnings = true;
has_update_nozzle = true;
wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %s %s"),nozzle_diameter, "");
wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj_->nozzle_diameter, "");
confirm_text.push_back(_L("Your nozzle diameter in preset is not consistent with memorized nozzle diameter. Did you change your nozzle lately?")
+ "\n " + nozzle_in_preset
confirm_text.push_back(_L("Your nozzle diameter in preset is not consistent with memorized nozzle diameter. Did you change your nozzle lately?")
+ "\n " + nozzle_in_preset
+ "\n " + nozzle_in_printer
+ "\n");
}
@ -2531,7 +2536,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
confirm_text.push_back(nozzle_in_preset + "\n");
}
}
if (has_slice_warnings) {
wxString confirm_title = _L("Warning");
@ -2553,11 +2558,11 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
if (obj_ && !tag_nozzle_type.empty() && !nozzle_diameter.empty()) {
try
{
float diameter = std::stof(nozzle_diameter);
float diameter = std::stof(nozzle_diameter);
diameter = round(diameter * 10) / 10;
obj_->command_set_printer_nozzle(tag_nozzle_type, diameter);
}
catch (...) {}
catch (...) {}
}
});
@ -2833,7 +2838,7 @@ void SelectMachineDialog::update_user_machine_list()
{
NetworkAgent* m_agent = wxGetApp().getAgent();
if (m_agent && m_agent->is_user_login()) {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -3631,16 +3636,16 @@ void SelectMachineDialog::Enable_Send_Button(bool en)
void SelectMachineDialog::on_dpi_changed(const wxRect &suggested_rect)
{
print_time->sys_color_changed();
print_time->msw_rescale();
timeimg->SetBitmap(print_time->bmp());
print_weight->sys_color_changed();
print_weight->msw_rescale();
weightimg->SetBitmap(print_weight->bmp());
m_rename_button->sys_color_changed();
ams_editable->sys_color_changed();
ams_editable_light->sys_color_changed();
enable_ams_mapping->sys_color_changed();
m_rename_button->msw_rescale();
ams_editable->msw_rescale();
ams_editable_light->msw_rescale();
enable_ams_mapping->msw_rescale();
img_amsmapping_tip->SetBitmap(enable_ams_mapping->bmp());
enable_ams->sys_color_changed();
enable_ams->msw_rescale();
img_use_ams_tip->SetBitmap(enable_ams->bmp());
m_button_refresh->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
@ -3806,7 +3811,7 @@ void SelectMachineDialog::set_default()
else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) {
set_default_from_sdcard();
}
Layout();
Fit();
}
@ -3836,14 +3841,14 @@ void SelectMachineDialog::set_default_normal()
std::vector<std::string> display_materials;
std::vector<std::string> m_filaments_id;
auto preset_bundle = wxGetApp().preset_bundle;
for (auto filament_name : preset_bundle->filament_presets) {
for (int f_index = 0; f_index < preset_bundle->filaments.size(); f_index++) {
PresetCollection* filament_presets = &wxGetApp().preset_bundle->filaments;
Preset* preset = &filament_presets->preset(f_index);
if (preset && filament_name.compare(preset->name) == 0) {
std::string display_filament_type;
std::string filament_type = preset->config.get_filament_type(display_filament_type);
@ -3865,7 +3870,7 @@ void SelectMachineDialog::set_default_normal()
//init MaterialItem
auto extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders();
MaterialHash::iterator iter = m_materialList.begin();
while (iter != m_materialList.end()) {
int id = iter->first;
@ -3914,7 +3919,7 @@ void SelectMachineDialog::set_default_normal()
DeviceManager* dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev_manager) return;
MachineObject* obj_ = dev_manager->get_selected_machine();
if (obj_ && obj_->is_support_ams_mapping()) {
if (m_mapping_popup.IsShown()) return;
wxPoint pos = item->ClientToScreen(wxPoint(0, 0));
@ -4437,12 +4442,12 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
void ThumbnailPanel::set_thumbnail(wxImage img)
{
m_bitmap = img;
m_bitmap = img;
//Paint the background bitmap to the thumbnail bitmap with wxMemoryDC
wxMemoryDC dc;
bitmap_with_background.Create(wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()));
dc.SelectObject(bitmap_with_background);
dc.DrawBitmap(m_background_bitmap.get_bitmap(), 0, 0);
dc.DrawBitmap(m_background_bitmap.bmp(), 0, 0);
dc.DrawBitmap(m_bitmap, 0, 0);
dc.SelectObject(wxNullBitmap);
@ -4455,7 +4460,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
}
void ThumbnailPanel::render(wxDC& dc) {
if (wxGetApp().dark_mode()) {
#ifdef __WXMSW__
wxMemoryDC memdc;
@ -4469,7 +4474,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
}
else
dc.DrawBitmap(m_bitmap, 0, 0);
}
ThumbnailPanel::~ThumbnailPanel() {}

View file

@ -813,7 +813,7 @@ void SendToPrinterDialog::update_user_machine_list()
{
NetworkAgent* m_agent = wxGetApp().getAgent();
if (m_agent && m_agent->is_user_login()) {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr(m_token)] {
boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr<int>(m_token)] {
NetworkAgent* agent = wxGetApp().getAgent();
unsigned int http_code;
std::string body;
@ -1391,4 +1391,4 @@ SendToPrinterDialog::~SendToPrinterDialog()
}
}
}
}

View file

@ -271,7 +271,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
bSizer_task_btn->Add(FromDIP(10), 0, 0);
m_button_pause_resume = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_pause", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_button_pause_resume = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_pause", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER,true);
m_button_pause_resume->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
if (m_button_pause_resume->GetToolTipText() == _L("Pause")) {
@ -294,7 +294,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
}
});
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER);
m_button_abort = new ScalableButton(m_panel_progress, wxID_ANY, "print_control_stop", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, true);
m_button_abort->SetToolTip(_L("Stop"));
m_button_abort->Bind(wxEVT_ENTER_WINDOW, [this](auto &e) {
@ -498,7 +498,7 @@ void PrintingTaskPanel::create_panel(wxWindow* parent)
m_score_star.resize(5);
for (int i = 0; i < m_score_star.size(); ++i) {
m_score_star[i] = new ScalableButton(m_score_subtask_info, wxID_ANY, "score_star_dark", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
m_score_star[i]->Bind(wxEVT_LEFT_DOWN, [this, i](auto &e) {
for (int j = 0; j < m_score_star.size(); ++j) {
ScalableBitmap light_star = ScalableBitmap(nullptr, "score_star_light", 26);
@ -555,7 +555,7 @@ void PrintingTaskPanel::paint(wxPaintEvent&)
{
wxPaintDC dc(m_bitmap_thumbnail);
if (wxGetApp().dark_mode())
dc.DrawBitmap(m_bitmap_background.get_bitmap(), 0, 0);
dc.DrawBitmap(m_bitmap_background.bmp(), 0, 0);
dc.DrawBitmap(m_thumbnail_bmp_display, wxPoint(0, 0));
dc.SetTextForeground(*wxBLACK);
dc.SetFont(Label::Body_12);
@ -583,7 +583,7 @@ void PrintingTaskPanel::msw_rescale()
//m_staticText_printing->SetMinSize(wxSize(PAGE_TITLE_TEXT_WIDTH, PAGE_TITLE_HEIGHT));
m_gauge_progress->SetHeight(PROGRESSBAR_HEIGHT);
m_gauge_progress->Rescale();
m_button_abort->sys_color_changed();
m_button_abort->msw_rescale();
m_bitmap_thumbnail->SetSize(TASK_THUMBNAIL_SIZE);
}
@ -619,7 +619,7 @@ void PrintingTaskPanel::show_error_msg(wxString msg)
void PrintingTaskPanel::reset_printing_value()
{
this->set_thumbnail_img(m_thumbnail_placeholder.get_bitmap());
this->set_thumbnail_img(m_thumbnail_placeholder.bmp());
this->set_plate_index(-1);
}
@ -1920,7 +1920,7 @@ void StatusPanel::on_webrequest_state(wxWebRequestEvent &evt)
case wxWebRequest::State_Failed:
case wxWebRequest::State_Cancelled:
case wxWebRequest::State_Unauthorized: {
m_project_task_panel->set_thumbnail_img(m_thumbnail_brokenimg.get_bitmap());
m_project_task_panel->set_thumbnail_img(m_thumbnail_brokenimg.bmp());
m_project_task_panel->set_plate_index(-1);
task_thumbnail_state = ThumbnailState::BROKEN_IMG;
break;
@ -4046,8 +4046,8 @@ void StatusPanel::rescale_camera_icons()
void StatusPanel::on_sys_color_changed()
{
m_project_task_panel->msw_rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
m_bitmap_speed.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
m_ams_control->msw_rescale();
if (m_print_error_dlg) { m_print_error_dlg->msw_rescale(); }
@ -4086,8 +4086,8 @@ void StatusPanel::msw_rescale()
m_tempCtrl_chamber->SetMinSize(TEMP_CTRL_MIN_SIZE);
m_tempCtrl_chamber->Rescale();
m_bitmap_speed.sys_color_changed();
m_bitmap_speed_active.sys_color_changed();
m_bitmap_speed.msw_rescale();
m_bitmap_speed_active.msw_rescale();
m_switch_speed->SetImages(m_bitmap_speed, m_bitmap_speed);
m_switch_speed->SetMinSize(MISC_BUTTON_2FAN_SIZE);
@ -4352,10 +4352,10 @@ wxBoxSizer *ScoreDialog::get_star_sizer()
}
if (i < m_star_count) {
m_score_star[i] = new ScalableButton(this, wxID_ANY, "score_star_light", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
} else
m_score_star[i] = new ScalableButton(this, wxID_ANY, "score_star_dark", wxEmptyString, wxSize(FromDIP(26), FromDIP(26)), wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, 26);
wxBU_EXACTFIT | wxNO_BORDER, true, 26);
m_score_star[i]->Bind(wxEVT_LEFT_DOWN, [this, i](auto &e) {
if (!m_success_printed && i >= 3) {

View file

@ -95,8 +95,8 @@ SysInfoDialog::SysInfoDialog()
main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10);
// logo
m_logo = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle(wxGetApp().logo_name(), 192));
m_logo_bmp = ScalableBitmap(this, wxGetApp().logo_name(), 192);
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);

View file

@ -26,6 +26,7 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include "libslic3r/libslic3r.h"
#include "wxExtensions.hpp"
#include "PresetComboBoxes.hpp"
#include <wx/wupdlock.h>
@ -230,6 +231,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());
@ -396,7 +399,7 @@ void Tab::create_preset_tab()
#endif
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
const float scale_factor = em_unit(this)*0.1;// GetContentScaleFactor();
const float scale_factor = /*wxGetApp().*/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);
@ -445,8 +448,11 @@ void Tab::create_preset_tab()
m_tabctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable right select
m_tabctrl->SetFont(Label::Body_14);
//m_left_sizer->Add(m_tabctrl, 1, wxEXPAND);
// Index of the last icon inserted into m_tabctrl.
const int img_sz = int(32 * scale_factor + 0.5f);
m_icons = new wxImageList(img_sz, img_sz, false, 1);
// Index of the last icon inserted into $self->{icons}.
m_icon_count = -1;
m_tabctrl->AssignImageList(m_icons);
wxGetApp().UpdateDarkUI(m_tabctrl);
// Delay processing of the following handler until the message queue is flushed.
@ -524,22 +530,6 @@ void Tab::create_preset_tab()
// Initialize the DynamicPrintConfig by default keys/values.
build();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
// This instance was added by PS when updating wx
/* if (!m_scaled_icons_list.empty()) {
// update icons for tree_ctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->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_tabctrl->GetFirstVisibleItem(); returns zero
@ -555,7 +545,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);
*btn = new ScalableButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style, true);
(*btn)->SetBackgroundColour(parent->GetBackgroundColour());
m_scaled_buttons.push_back(*btn);
}
@ -586,6 +576,7 @@ 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, 32, false, true));
//m_icons->Add(m_scaled_icons_list.back().bmp());
icon_idx = ++m_icon_count;
m_icon_index[icon] = icon_idx;
}
@ -910,6 +901,18 @@ 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();
//BBS: GUI refactor
//Layout();
m_parent->Layout();
}
void TabSLAMaterial::init_options_list()
{
if (!m_options_list.empty())
@ -1185,30 +1188,35 @@ void Tab::msw_rescale()
m_top_sizer->SetMinSize(-1, 3 * m_em_unit);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->msw_rescale();
if (m_presets_choice)
m_presets_choice->msw_rescale();
m_tabctrl->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->sys_color_changed();
bmp->msw_rescale();
if (m_mode_view)
m_mode_view->Rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->sys_color_changed();
m_detach_preset_btn->msw_rescale();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// 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(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
// rescale options_groups
if (m_active_page)
@ -1228,24 +1236,21 @@ void Tab::sys_color_changed()
// update buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->sys_color_changed();
btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps)
bmp->sys_color_changed();
bmp->msw_rescale();
if (m_detach_preset_btn)
m_detach_preset_btn->sys_color_changed();
m_detach_preset_btn->msw_rescale();
update_show_hide_incompatible_button();
// Orca: shouldn't be needed bc TabCtrl doesn't use images passed through
// If needed, updated code is below. SetImages will need to be implemented in TabCtrl
// which should be easiest by adding wxWithImages mixin.
/* // update icons for m_tabctrl
wxVector <wxBitmapBundle> img_bundles;
for (ScalableBitmap& bmp : m_scaled_icons_list) {
bmp.sys_color_changed();
img_bundles.push_back(bmp.bmp());
}
m_tabctrl->SetImages(img_bundles);*/
// 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(), false);
for (ScalableBitmap& bmp : m_scaled_icons_list)
//m_icons->Add(bmp.bmp());
m_tabctrl->AssignImageList(m_icons);
// Colors for ui "decoration"
update_label_colours();
@ -1253,7 +1258,7 @@ void Tab::sys_color_changed()
wxWindowUpdateLocker noUpdates(this);
//BBS: GUI refactor
//if (m_mode_sizer)
// m_mode_sizer->sys_color_changed();
// m_mode_sizer->msw_rescale();
wxGetApp().UpdateDarkUI(this);
wxGetApp().UpdateDarkUI(m_tabctrl);
#endif
@ -1266,7 +1271,6 @@ void Tab::sys_color_changed()
//BBS: GUI refactor
//Layout();
m_parent->Layout();
m_parent->Refresh();
}
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
@ -1533,23 +1537,35 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
auto max_layer_height_from_nozzle=wxGetApp().preset_bundle->full_config().option<ConfigOptionFloats>("max_layer_height")->values;
auto layer_height_floor = *std::min_element(min_layer_height_from_nozzle.begin(), min_layer_height_from_nozzle.end());
auto layer_height_ceil = *std::max_element(max_layer_height_from_nozzle.begin(), max_layer_height_from_nozzle.end());
bool exceed_minimum_flag = m_config->opt_float("layer_height") < layer_height_floor;
bool exceed_maximum_flag = m_config->opt_float("layer_height") > layer_height_ceil;
const auto lh = m_config->opt_float("layer_height");
bool exceed_minimum_flag = lh < layer_height_floor;
bool exceed_maximum_flag = lh > layer_height_ceil;
if (exceed_maximum_flag || exceed_minimum_flag) {
wxString msg_text = _(L("Layer height exceeds the limit in Printer Settings -> Extruder -> Layer height limits ,this may cause printing quality issues."));
msg_text += "\n\n" + _(L("Adjust to the set range automatically? \n"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO);
dialog.SetButtonLabel(wxID_YES, _L("Adjust"));
dialog.SetButtonLabel(wxID_NO, _L("Ignore"));
auto answer = dialog.ShowModal();
auto new_conf = *m_config;
if (answer == wxID_YES) {
if (exceed_maximum_flag)
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_ceil));
if (exceed_minimum_flag)
new_conf.set_key_value("layer_height",new ConfigOptionFloat(layer_height_floor));
if (lh < EPSILON) {
auto msg_text = _(L("Layer height is too small.\nIt will set to min_layer_height\n"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxOK);
dialog.SetButtonLabel(wxID_OK, _L("OK"));
dialog.ShowModal();
auto new_conf = *m_config;
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_floor));
m_config_manipulation.apply(m_config, &new_conf);
} else {
wxString msg_text = _(L("Layer height exceeds the limit in Printer Settings -> Extruder -> Layer height limits ,this may "
"cause printing quality issues."));
msg_text += "\n\n" + _(L("Adjust to the set range automatically? \n"));
MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO);
dialog.SetButtonLabel(wxID_YES, _L("Adjust"));
dialog.SetButtonLabel(wxID_NO, _L("Ignore"));
auto answer = dialog.ShowModal();
auto new_conf = *m_config;
if (answer == wxID_YES) {
if (exceed_maximum_flag)
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_ceil));
if (exceed_minimum_flag)
new_conf.set_key_value("layer_height", new ConfigOptionFloat(layer_height_floor));
m_config_manipulation.apply(m_config, &new_conf);
}
}
wxGetApp().plater()->update();
}
@ -1752,7 +1768,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_normal_sys", "",
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = m_detach_preset_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -1926,6 +1942,7 @@ void TabPrint::build()
optgroup->append_single_option_line("role_based_wipe_speed","seam");
optgroup->append_single_option_line("wipe_speed", "seam");
optgroup->append_single_option_line("wipe_on_loops","seam");
optgroup->append_single_option_line("wipe_before_external_loop","seam");
optgroup = page->new_optgroup(L("Precision"), L"param_precision");
@ -1991,6 +2008,7 @@ void TabPrint::build()
page = add_options_page(L("Strength"), "empty");
optgroup = page->new_optgroup(L("Walls"), L"param_wall");
optgroup->append_single_option_line("wall_loops");
optgroup->append_single_option_line("alternate_extra_wall");
optgroup->append_single_option_line("detect_thin_wall");
optgroup = page->new_optgroup(L("Top/bottom shells"), L"param_shell");
@ -2217,7 +2235,7 @@ void TabPrint::build()
optgroup->append_single_option_line(option);
#if 0
//page = add_options_page(L("Dependencies"), "advanced");
//page = add_options_page(L("Dependencies"), "advanced.png");
// optgroup = page->new_optgroup(L("Profile dependencies"));
// create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -3680,7 +3698,7 @@ void TabPrinter::build_sla()
//optgroup->append_single_option_line("min_initial_exposure_time");
//optgroup->append_single_option_line("max_initial_exposure_time");
//page = add_options_page(L("Dependencies"), "wrench");
//page = add_options_page(L("Dependencies"), "wrench.png");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//build_preset_description_line(optgroup.get());
@ -3753,6 +3771,8 @@ PageShp TabPrinter::build_kinematics_page()
optgroup->append_line(line);
}
auto optgroup = page->new_optgroup(L("Advanced"), "param_advanced");
optgroup->append_single_option_line("emit_machine_limits_to_gcode");
const std::vector<std::string> speed_axes{
"machine_max_speed_x",
@ -3760,7 +3780,7 @@ PageShp TabPrinter::build_kinematics_page()
"machine_max_speed_z",
"machine_max_speed_e"
};
auto optgroup = page->new_optgroup(L("Speed limitation"), "param_speed");
optgroup = page->new_optgroup(L("Speed limitation"), "param_speed");
for (const std::string &speed_axis : speed_axes) {
append_option_line(optgroup, speed_axis);
}
@ -3952,7 +3972,7 @@ if (is_marlin_flavor)
//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);
// wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
// ScalableButton* btn = m_reset_to_filament_color;
// btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
// btn->SetSize(btn->GetBestSize());
@ -5315,7 +5335,8 @@ void Tab::toggle_show_hide_incompatible()
void Tab::update_show_hide_incompatible_button()
{
//BBS: GUI refactor
/*m_btn_hide_incompatible_presets->SetBitmap(*get_bmp_bundle(m_show_incompatible_presets ? "flag_red" : "flag_green"));
/*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->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.");*/
@ -5366,7 +5387,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);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
deps.btn->SetSize(deps.btn->GetBestSize());
@ -5441,7 +5462,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
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);
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
btn->SetFont(wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());
@ -5857,7 +5878,7 @@ void TabSLAMaterial::build()
//optgroup->append_line(line);
//page = add_options_page(L("Dependencies"), "wrench");
//page = add_options_page(L("Dependencies"), "wrench.png");
//optgroup = page->new_optgroup(L("Profile dependencies"));
//create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) {
@ -5878,7 +5899,7 @@ void TabSLAMaterial::build()
//build_preset_description_line(optgroup.get());
//page = add_options_page(L("Material printing profile"), "printer");
//page = add_options_page(L("Material printing profile"), "printer.png");
//optgroup = page->new_optgroup(L("Material printing profile"));
//option = optgroup->get_option("material_print_speed");
//optgroup->append_single_option_line(option);

View file

@ -154,6 +154,7 @@ protected:
//wxBoxSizer* m_hsizer;
//wxBoxSizer* m_left_sizer;
TabCtrl* m_tabctrl;
wxImageList* m_icons;
wxScrolledWindow* m_page_view {nullptr};
//wxBoxSizer* m_page_sizer {nullptr};
@ -188,6 +189,10 @@ protected:
StaticBox * m_search_item;
TextInput * m_search_input;
// 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;
@ -615,6 +620,7 @@ 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);

View file

@ -148,7 +148,7 @@ void TabButton::render(wxDC &dc)
// BBS norrow size between text and icon
szContent.x += 5;
}
szIcon = icon.GetSize();
szIcon = icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}
@ -169,9 +169,9 @@ void TabButton::render(wxDC &dc)
}
if (icon.bmp().IsOk()) {
pt.x = size.x - icon.GetWidth() - paddingSize.y;
pt.y = (size.y - icon.GetHeight()) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.x = size.x - icon.GetBmpWidth() - paddingSize.y;
pt.y = (size.y - icon.GetBmpHeight()) / 2;
dc.DrawBitmap(icon.bmp(), pt);
}
}
@ -189,7 +189,7 @@ void TabButton::messureSize()
// BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}

View file

@ -117,21 +117,29 @@ wxIcon ModelNode::get_bitmap(const wxString& color)
wxBitmap ModelNode::get_bitmap(const wxString& color)
#endif // __linux__
{
wxBitmap bmp = get_solid_bmp_bundle(64, 16, into_u8(color))->GetBitmapFor(m_parent_win);
if (!m_toggle)
bmp = bmp.ConvertToDisabled();
/* 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
#ifndef __linux__
return bmp;
return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
#else
wxIcon icon;
icon.CopyFromBitmap(bmp);
icon.CopyFromBitmap(bmp_cache.mksolid(icon_width, icon_height, rgb, true));
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 : ""),
@ -196,22 +204,18 @@ void ModelNode::UpdateIcons()
{
// update icons for the colors, if any exists
if (!m_old_color.IsEmpty())
m_old_color_bmp = get_bitmap(m_old_color);
m_old_color_bmp = get_bitmap(m_toggle ? m_old_color : wxString::FromUTF8(grey.c_str()));
if (!m_new_color.IsEmpty())
m_new_color_bmp = get_bitmap(m_new_color);
m_new_color_bmp = get_bitmap(m_toggle ? m_new_color : wxString::FromUTF8(grey.c_str()));
// 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(bmp);
m_icon.CopyFromBitmap(create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle));
#else
m_icon = bmp;
m_icon = create_scaled_bitmap(m_icon_name, m_parent_win, 16, !m_toggle);
#endif //__linux__
}
@ -1017,7 +1021,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
// "Save" button
if (ActionButtons::SAVE & m_buttons) add_btn(&m_save_btn, m_save_btn_id, "save", Action::Save, _L("Save"), false);
/* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, 24);
/* ScalableButton *cancel_btn = new ScalableButton(this, wxID_CANCEL, "cross", _L("Cancel"), wxDefaultSize, wxDefaultPosition, wxBORDER_DEFAULT, true, 24);
buttons->Add(cancel_btn, 1, wxLEFT | wxRIGHT, 5);
cancel_btn->SetFont(btn_font);*/
/* m_cancel_btn = new Button(this, _L("Cancel"));
@ -1704,7 +1708,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->sys_color_changed();
//btn->msw_rescale();
// msw_rescale updates just icons, so use it
//m_tree->Rescale();
@ -2111,16 +2115,10 @@ 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) {
rescale(preset_combos.presets_left);
rescale(preset_combos.presets_right);
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
}
m_tree->Rescale(em);
@ -2138,9 +2136,9 @@ void DiffPresetDialog::on_sys_color_changed()
#endif
for (auto preset_combos : m_preset_combos) {
preset_combos.presets_left->sys_color_changed();
preset_combos.equal_bmp->sys_color_changed();
preset_combos.presets_right->sys_color_changed();
preset_combos.presets_left->msw_rescale();
preset_combos.equal_bmp->msw_rescale();
preset_combos.presets_right->msw_rescale();
}
// msw_rescale updates just icons, so use it
m_tree->Rescale();

View file

@ -341,15 +341,15 @@ void MachineInfoPanel::init_bitmaps()
void MachineInfoPanel::rescale_bitmaps()
{
m_img_printer.sys_color_changed();
m_img_printer.msw_rescale();
m_printer_img->SetBitmap(m_img_printer.bmp());
m_img_monitor_ams.sys_color_changed();
m_img_monitor_ams.msw_rescale();
m_ams_img->SetBitmap(m_img_monitor_ams.bmp());
m_img_ext.sys_color_changed();
m_img_ext.msw_rescale();
m_ext_img->SetBitmap(m_img_ext.bmp());
upgrade_green_icon.sys_color_changed();
upgrade_gray_icon.sys_color_changed();
upgrade_yellow_icon.sys_color_changed();
upgrade_green_icon.msw_rescale();
upgrade_gray_icon.msw_rescale();
upgrade_yellow_icon.msw_rescale();
m_ota_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1287,8 +1287,8 @@ bool UpgradePanel::Show(bool show)
}
void AmsPanel::msw_rescale() {
upgrade_green_icon.sys_color_changed();
void AmsPanel::msw_rescale() {
upgrade_green_icon.msw_rescale();
m_ams_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}
@ -1361,8 +1361,8 @@ bool UpgradePanel::Show(bool show)
}
void ExtensionPanel::msw_rescale()
{
upgrade_green_icon.sys_color_changed();
{
upgrade_green_icon.msw_rescale();
m_ext_new_version_img->SetBitmap(upgrade_green_icon.bmp());
}

View file

@ -230,11 +230,11 @@ void AMSrefresh::paintEvent(wxPaintEvent &evt)
auto colour = StateColor::darkModeColorFor(AMS_CONTROL_GRAY700);
if (!wxWindow::IsEnabled()) { colour = AMS_CONTROL_GRAY500; }
auto pot = wxPoint((size.x - m_bitmap_selected.GetSize().x) / 2, (size.y - m_bitmap_selected.GetSize().y) / 2);
auto pot = wxPoint((size.x - m_bitmap_selected.GetBmpSize().x) / 2, (size.y - m_bitmap_selected.GetBmpSize().y) / 2);
if (!m_disable_mode) {
if (!m_play_loading) {
dc.DrawBitmap(m_selected ? m_bitmap_selected.get_bitmap() : m_bitmap_normal.get_bitmap(), pot);
dc.DrawBitmap(m_selected ? m_bitmap_selected.bmp() : m_bitmap_normal.bmp(), pot);
}
else {
/* m_bitmap_rotation = ScalableBitmap(this, "ams_refresh_normal", 30);
@ -249,7 +249,7 @@ void AMSrefresh::paintEvent(wxPaintEvent &evt)
m_rotation_angle = 0;
}
if (m_rfid_bitmap_list.size() <= 0)return;
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].get_bitmap(), pot);
dc.DrawBitmap(m_rfid_bitmap_list[m_rotation_angle].bmp(), pot);
}
}
@ -360,7 +360,7 @@ void AMSextruderImage::doRender(wxDC &dc)
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(m_colour);
dc.DrawRectangle(0, FromDIP(18), size.x, size.y - FromDIP(18) - FromDIP(5));
dc.DrawBitmap(m_ams_extruder.get_bitmap(), wxPoint((size.x - m_ams_extruder.GetSize().x) / 2, (size.y - m_ams_extruder.GetSize().y) / 2));
dc.DrawBitmap(m_ams_extruder.bmp(), wxPoint((size.x - m_ams_extruder.GetBmpSize().x) / 2, (size.y - m_ams_extruder.GetBmpSize().y) / 2));
}
@ -688,11 +688,11 @@ void AMSLib::on_left_down(wxMouseEvent &evt)
auto bottom = 0;
if (m_ams_model == AMSModel::GENERIC_AMS) {
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetSize().y);
top = (size.y - FromDIP(15) - m_bitmap_editable_light.GetBmpSize().y);
bottom = size.y - FromDIP(15);
}
else if (m_ams_model == AMSModel::EXTRA_AMS) {
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetSize().y);
top = (size.y - FromDIP(20) - m_bitmap_editable_light.GetBmpSize().y);
bottom = size.y - FromDIP(20);
}
@ -1022,21 +1022,21 @@ void AMSLib::render_extra_lib(wxDC& dc)
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
{
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL)
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetSize().y));
dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_third.GetBmpSize().y));
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetSize().y));
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2 + FromDIP(2), (size.y - FromDIP(18) - temp_bitmap_brand.GetBmpSize().y));
}
}
// selected & hover
if (m_selected) {
dc.DrawBitmap(tray_bitmap_selected.get_bitmap(), (size.x - tray_bitmap_selected.GetSize().x) / 2, (size.y - tray_bitmap_selected.GetSize().y) / 2);
dc.DrawBitmap(tray_bitmap_selected.bmp(), (size.x - tray_bitmap_selected.GetBmpSize().x) / 2, (size.y - tray_bitmap_selected.GetBmpSize().y) / 2);
}
else if (!m_selected && m_hover) {
dc.DrawBitmap(tray_bitmap_hover.get_bitmap(), (size.x - tray_bitmap_hover.GetSize().x) / 2, (size.y - tray_bitmap_hover.GetSize().y) / 2);
dc.DrawBitmap(tray_bitmap_hover.bmp(), (size.x - tray_bitmap_hover.GetBmpSize().x) / 2, (size.y - tray_bitmap_hover.GetBmpSize().y) / 2);
}
else {
dc.DrawBitmap(tray_bitmap.get_bitmap(), (size.x - tray_bitmap.GetSize().x) / 2, (size.y - tray_bitmap.GetSize().y) / 2);
dc.DrawBitmap(tray_bitmap.bmp(), (size.x - tray_bitmap.GetBmpSize().x) / 2, (size.y - tray_bitmap.GetBmpSize().y) / 2);
}
}
@ -1116,7 +1116,7 @@ void AMSLib::render_generic_lib(wxDC &dc)
//transparent
auto alpha = m_info.material_colour.Alpha();
if (alpha == 0) {
dc.DrawBitmap(m_bitmap_transparent.get_bitmap(), FromDIP(4), FromDIP(4));
dc.DrawBitmap(m_bitmap_transparent.bmp(), FromDIP(4), FromDIP(4));
}
//gradient
@ -1187,9 +1187,9 @@ void AMSLib::render_generic_lib(wxDC &dc)
if (m_info.material_state != AMSCanType::AMS_CAN_TYPE_EMPTY && m_info.material_state != AMSCanType::AMS_CAN_TYPE_NONE)
{
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_THIRDBRAND || m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL)
dc.DrawBitmap(temp_bitmap_third.get_bitmap(), (size.x - temp_bitmap_third.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetSize().y));
dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y));
if (m_info.material_state == AMSCanType::AMS_CAN_TYPE_BRAND)
dc.DrawBitmap(temp_bitmap_brand.get_bitmap(), (size.x - temp_bitmap_brand.GetSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetSize().y));
dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y));
}
}
}
@ -1244,7 +1244,8 @@ void AMSLib::UnSelected()
bool AMSLib::Enable(bool enable) { return wxWindow::Enable(enable); }
void AMSLib::msw_rescale()
{ m_bitmap_transparent.sys_color_changed();
{
m_bitmap_transparent.msw_rescale();
}
/*************************************************
@ -1451,20 +1452,20 @@ void AMSRoad::doRender(wxDC &dc)
else {m_show_humidity = false;}
if (m_amsinfo.ams_humidity == 5) {
dc.DrawBitmap(ams_humidity_4.get_bitmap(), wxPoint(size.x - ams_humidity_4.GetSize().x - FromDIP(4), size.y - ams_humidity_4.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_4.bmp(), wxPoint(size.x - ams_humidity_4.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_4.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 4) {
dc.DrawBitmap(ams_humidity_3.get_bitmap(), wxPoint(size.x - ams_humidity_3.GetSize().x - FromDIP(4), size.y - ams_humidity_3.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_3.bmp(), wxPoint(size.x - ams_humidity_3.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_3.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 3) {
dc.DrawBitmap(ams_humidity_2.get_bitmap(), wxPoint(size.x - ams_humidity_2.GetSize().x - FromDIP(4), size.y - ams_humidity_2.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_2.bmp(), wxPoint(size.x - ams_humidity_2.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_2.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 2) {
dc.DrawBitmap(ams_humidity_1.get_bitmap(), wxPoint(size.x - ams_humidity_1.GetSize().x - FromDIP(4), size.y - ams_humidity_1.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_1.bmp(), wxPoint(size.x - ams_humidity_1.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_1.GetBmpSize().y - FromDIP(8)));
}
else if (m_amsinfo.ams_humidity == 1) {
dc.DrawBitmap(ams_humidity_0.get_bitmap(), wxPoint(size.x - ams_humidity_0.GetSize().x - FromDIP(4), size.y - ams_humidity_0.GetSize().y - FromDIP(8)));
dc.DrawBitmap(ams_humidity_0.bmp(), wxPoint(size.x - ams_humidity_0.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_0.GetBmpSize().y - FromDIP(8)));
}
else {
/*dc.DrawBitmap(ams_humidity_4.bmp(), wxPoint(size.x - ams_humidity_4.GetBmpSize().x - FromDIP(4), size.y - ams_humidity_4.GetBmpSize().y - FromDIP(8)));*/
@ -1661,7 +1662,7 @@ void AMSItem::doRender(wxDC &dc)
}else {
if (iter->material_colour.Alpha() == 0) {
dc.DrawBitmap(m_ts_bitmap_cube->get_bitmap(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2);
}
else {
wxRect rect(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y);
@ -2091,7 +2092,7 @@ void AmsCans::render(wxDC& dc)
void AmsCans::doRender(wxDC& dc)
{
wxSize size = GetSize();
dc.DrawBitmap(m_bitmap_extra_framework.get_bitmap(), (size.x - m_bitmap_extra_framework.GetSize().x) / 2, (size.y - m_bitmap_extra_framework.GetSize().y) / 2);
dc.DrawBitmap(m_bitmap_extra_framework.bmp(), (size.x - m_bitmap_extra_framework.GetBmpSize().x) / 2, (size.y - m_bitmap_extra_framework.GetBmpSize().y) / 2);
//road for extra
if (m_ams_model == AMSModel::EXTRA_AMS) {
@ -2981,9 +2982,9 @@ void AMSControl::StopRridLoading(wxString amsid, wxString canid)
void AMSControl::msw_rescale()
{
m_button_ams_setting_normal.sys_color_changed();
m_button_ams_setting_hover.sys_color_changed();
m_button_ams_setting_press.sys_color_changed();
m_button_ams_setting_normal.msw_rescale();
m_button_ams_setting_hover.msw_rescale();
m_button_ams_setting_press.msw_rescale();
m_button_ams_setting->SetBitmap(m_button_ams_setting_normal.bmp());
m_extruder->msw_rescale();

View file

@ -212,8 +212,7 @@ void AxisCtrlButton::render(wxDC& dc)
gc->DrawPath(home_path);
if (m_icon.bmp().IsOk()) {
gc->DrawBitmap(m_icon.get_bitmap(), -1 * m_icon.GetWidth() / 2, -1 * m_icon.GetHeight() / 2, m_icon.GetWidth(),
m_icon.GetHeight());
gc->DrawBitmap(m_icon.bmp(), -1 * m_icon.GetBmpWidth() / 2, -1 * m_icon.GetBmpHeight() / 2, m_icon.GetBmpWidth(), m_icon.GetBmpHeight());
}
gc->PopState();

View file

@ -146,10 +146,10 @@ bool Button::GetValue() const { return state_handler.states() & StateHandler::Ch
void Button::Rescale()
{
if (this->active_icon.bmp().IsOk())
this->active_icon.sys_color_changed();
this->active_icon.msw_rescale();
if (this->inactive_icon.bmp().IsOk())
this->inactive_icon.sys_color_changed();
this->inactive_icon.msw_rescale();
messureSize();
}
@ -187,7 +187,7 @@ void Button::render(wxDC& dc)
//BBS norrow size between text and icon
szContent.x += padding;
}
szIcon = icon.GetSize();
szIcon = icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;
@ -206,7 +206,7 @@ void Button::render(wxDC& dc)
wxPoint pt = rcContent.GetLeftTop();
if (icon.bmp().IsOk()) {
pt.y += (rcContent.height - szIcon.y) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
dc.DrawBitmap(icon.bmp(), pt);
//BBS norrow size between text and icon
pt.x += szIcon.x + padding;
pt.y = rcContent.y;
@ -239,7 +239,7 @@ void Button::messureSize()
//BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->active_icon.GetSize();
wxSize szIcon = this->active_icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;

View file

@ -24,8 +24,8 @@ CheckBox::CheckBox(wxWindow *parent, int id)
Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this);
Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this);
#endif
SetSize(m_on.GetSize());
SetMinSize(m_on.GetSize());
SetSize(m_on.GetBmpSize());
SetMinSize(m_on.GetBmpSize());
update();
}
@ -43,16 +43,16 @@ void CheckBox::SetHalfChecked(bool value)
void CheckBox::Rescale()
{
m_on.sys_color_changed();
m_half.sys_color_changed();
m_off.sys_color_changed();
m_on_disabled.sys_color_changed();
m_half_disabled.sys_color_changed();
m_off_disabled.sys_color_changed();
m_on_focused.sys_color_changed();
m_half_focused.sys_color_changed();
m_off_focused.sys_color_changed();
SetSize(m_on.GetSize());
m_on.msw_rescale();
m_half.msw_rescale();
m_off.msw_rescale();
m_on_disabled.msw_rescale();
m_half_disabled.msw_rescale();
m_off_disabled.msw_rescale();
m_on_focused.msw_rescale();
m_half_focused.msw_rescale();
m_off_focused.msw_rescale();
SetSize(m_on.GetBmpSize());
update();
}

View file

@ -98,13 +98,6 @@ void ComboBox::Rescale()
drop.Rescale();
}
bool ComboBox::Enable(bool enable) {
bool ret = TextInput::Enable(enable);
if (ret && drop.selection >= 0 && drop.iconSize.y > 0)
SetIcon(icons[drop.selection]);
return ret;
}
wxString ComboBox::GetValue() const
{
return drop.GetSelection() >= 0 ? drop.GetValue() : GetLabel();
@ -152,17 +145,13 @@ bool ComboBox::SetFont(wxFont const& font)
return TextInput::SetFont(font);
}
void ComboBox::SetIcon(const wxBitmapBundle &icon) {
TextInput::SetIcon(m_isEnabled ? icon : icon.GetBitmapFor(this).ConvertToDisabled(128));
}
int ComboBox::Append(const wxString &item, const wxBitmapBundle &bitmap)
int ComboBox::Append(const wxString &item, const wxBitmap &bitmap)
{
return Append(item, bitmap, nullptr);
}
int ComboBox::Append(const wxString &item,
const wxBitmapBundle &bitmap,
const wxBitmap &bitmap,
void * clientData)
{
texts.push_back(item);
@ -207,9 +196,9 @@ void ComboBox::SetString(unsigned int n, wxString const &value)
if (n == drop.GetSelection()) SetLabel(value);
}
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n].GetBitmapFor(m_parent); }
wxBitmap ComboBox::GetItemBitmap(unsigned int n) { return icons[n]; }
void ComboBox::SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap)
void ComboBox::SetItemBitmap(unsigned int n, wxBitmap const &bitmap)
{
if (n >= texts.size()) return;
icons[n] = bitmap;
@ -241,7 +230,9 @@ void ComboBox::DoSetItemClientData(unsigned int n, void *data)
datas[n] = data;
}
void ComboBox::ToggleDropDown(){
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
if (drop_down) {
drop.Hide();
} else if (drop.HasDismissLongTime()) {
@ -253,12 +244,6 @@ void ComboBox::ToggleDropDown(){
}
}
void ComboBox::mouseDown(wxMouseEvent &event)
{
SetFocus();
ToggleDropDown();
}
void ComboBox::mouseWheelMoved(wxMouseEvent &event)
{
event.Skip();
@ -276,7 +261,15 @@ void ComboBox::keyDown(wxKeyEvent& event)
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_SPACE:
ToggleDropDown();
if (drop_down) {
drop.DismissAndNotify();
} else if (drop.HasDismissLongTime()) {
drop.autoPosition();
drop_down = true;
drop.Popup();
wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
GetEventHandler()->ProcessEvent(e);
}
break;
case WXK_UP:
case WXK_DOWN:

View file

@ -10,7 +10,7 @@
class ComboBox : public wxWindowWithItems<TextInput, wxItemContainer>
{
std::vector<wxString> texts;
std::vector<wxBitmapBundle> icons;
std::vector<wxBitmap> icons;
std::vector<void *> datas;
std::vector<wxClientDataType> types;
@ -32,9 +32,10 @@ public:
virtual bool SetFont(wxFont const & font) override;
int Append(const wxString &item, const wxBitmapBundle &bitmap = wxNullBitmap);
public:
int Append(const wxString &item, const wxBitmap &bitmap = wxNullBitmap);
int Append(const wxString &item, const wxBitmapBundle &bitmap, void *clientData);
int Append(const wxString &item, const wxBitmap &bitmap, void *clientData);
unsigned int GetCount() const override;
@ -59,12 +60,8 @@ public:
void SetString(unsigned int n, wxString const &value) override;
wxBitmap GetItemBitmap(unsigned int n);
void SetItemBitmap(unsigned int n, wxBitmapBundle const &bitmap);
void ToggleDropDown();
bool Enable(bool enable = true) override;
void SetIcon(const wxBitmapBundle &icon) override;
void SetItemBitmap(unsigned int n, wxBitmap const &bitmap);
bool is_drop_down(){return drop_down;}
protected:
virtual int DoInsertItems(const wxArrayStringsAdapter &items,
unsigned int pos,

View file

@ -29,7 +29,7 @@ END_EVENT_TABLE()
*/
DropDown::DropDown(std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons)
std::vector<wxBitmap> &icons)
: texts(texts)
, icons(icons)
, state_handler(this)
@ -44,7 +44,7 @@ DropDown::DropDown(std::vector<wxString> &texts,
DropDown::DropDown(wxWindow * parent,
std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons,
std::vector<wxBitmap> &icons,
long style)
: DropDown(texts, icons)
{
@ -188,6 +188,15 @@ void DropDown::paintNow()
Refresh();
}
static wxSize GetBmpSize(wxBitmap & bmp)
{
#ifdef __APPLE__
return bmp.GetScaledSize();
#else
return bmp.GetSize();
#endif
}
/*
* Here we do the actual rendering. I put it in a separate
* method so that it can work no matter what type of DC
@ -256,13 +265,13 @@ void DropDown::render(wxDC &dc)
rcContent.x += 5;
rcContent.width -= 5;
if (check_bitmap.bmp().IsOk()) {
auto szBmp = check_bitmap.GetSize();
auto szBmp = check_bitmap.GetBmpSize();
if (selection >= 0) {
wxPoint pt = rcContent.GetLeftTop();
pt.y += (rcContent.height - szBmp.y) / 2;
pt.y += rowSize.y * selection;
if (pt.y + szBmp.y > 0 && pt.y < size.y)
dc.DrawBitmap(check_bitmap.get_bitmap(), pt);
dc.DrawBitmap(check_bitmap.bmp(), pt);
}
rcContent.x += szBmp.x + 5;
rcContent.width -= szBmp.x + 5;
@ -277,17 +286,17 @@ void DropDown::render(wxDC &dc)
if (rcContent.y > size.y) break;
wxPoint pt = rcContent.GetLeftTop();
auto & icon = icons[i];
auto size2 = get_preferred_size(icon, m_parent);
auto size2 = GetBmpSize(icon);
if (iconSize.x > 0) {
if (icon.IsOk()) {
pt.y += (rcContent.height - size2.y) / 2;
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
dc.DrawBitmap(icon, pt);
}
pt.x += iconSize.x + 5;
pt.y = rcContent.y;
} else if (icon.IsOk()) {
pt.y += (rcContent.height - size2.y) / 2;
dc.DrawBitmap(icon.GetBitmapFor(m_parent), pt);
dc.DrawBitmap(icon, pt);
pt.x += size2.x + 5;
pt.y = rcContent.y;
}
@ -317,7 +326,7 @@ void DropDown::messureSize()
for (size_t i = 0; i < texts.size(); ++i) {
wxSize size1 = text_off ? wxSize() : dc.GetMultiLineTextExtent(texts[i]);
if (icons[i].IsOk()) {
wxSize size2 = get_preferred_size(icons[i], m_parent);
wxSize size2 = GetBmpSize(icons[i]);
if (size2.x > iconSize.x) iconSize = size2;
if (!align_icon) {
size1.x += size2.x + (text_off ? 0 : 5);
@ -329,7 +338,7 @@ void DropDown::messureSize()
wxSize szContent = textSize;
szContent.x += 10;
if (check_bitmap.bmp().IsOk()) {
auto szBmp = check_bitmap.GetSize();
auto szBmp = check_bitmap.GetBmpSize();
szContent.x += szBmp.x + 5;
}
if (iconSize.x > 0) szContent.x += iconSize.x + (text_off ? 0 : 5);

View file

@ -15,7 +15,7 @@ wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
class DropDown : public PopupWindow
{
std::vector<wxString> & texts;
std::vector<wxBitmapBundle> & icons;
std::vector<wxBitmap> & icons;
bool need_sync = false;
int selection = -1;
int hover_item = -1;
@ -44,11 +44,11 @@ class DropDown : public PopupWindow
public:
DropDown(std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons);
std::vector<wxBitmap> &icons);
DropDown(wxWindow * parent,
std::vector<wxString> &texts,
std::vector<wxBitmapBundle> &icons,
std::vector<wxBitmap> &icons,
long style = 0);
void Create(wxWindow * parent,

View file

@ -62,8 +62,8 @@ void Fan::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSi
// SetMinSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
// SetMaxSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
//#else
SetMinSize(wxSize(m_bitmap_bk.GetSize().x, m_bitmap_bk.GetSize().y + FromDIP(6)));
SetMaxSize(wxSize(m_bitmap_bk.GetSize().x, m_bitmap_bk.GetSize().y + FromDIP(6)));
SetMinSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
//#endif // __APPLE__
Bind(wxEVT_PAINT, &Fan::paintEvent, this);
@ -115,7 +115,7 @@ void Fan::doRender(wxDC& dc)
auto rpm = wxT("rpm");
wxSize size = GetSize();
dc.DrawBitmap(m_bitmap_bk.get_bitmap(), wxPoint(0,0));
dc.DrawBitmap(m_bitmap_bk.bmp(), wxPoint(0,0));
//fan scale
/*auto central_point = wxPoint(size.x / 2, size.y / 2 + FromDIP(15));
@ -133,8 +133,8 @@ void Fan::doRender(wxDC& dc)
//fan pointer
//auto pointer_central_point = wxPoint((size.x - m_img_pointer.GetSize().x) / 2, (size.y - m_img_pointer.GetSize().y) / 2);
//auto bmp = m_img_pointer.Rotate(m_rotate_offsets[m_current_speeds].rotate, wxPoint(size.x / 2,size.y / 2));
auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetSize().y) / 2 - FromDIP(4));
dc.DrawBitmap(m_bitmap_scales[m_current_speeds].get_bitmap(), central_point.x, central_point.y);
auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetBmpSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetBmpSize().y) / 2 - FromDIP(4));
dc.DrawBitmap(m_bitmap_scales[m_current_speeds].bmp(), central_point.x, central_point.y);
//fan val
dc.SetTextForeground(DRAW_TEXT_COLOUR);
@ -147,7 +147,8 @@ void Fan::doRender(wxDC& dc)
//dc.DrawText(rpm, (size.x - dc.GetTextExtent(rpm).x) / 2, size.y - dc.GetTextExtent(rpm).y);
}
void Fan::msw_rescale() { m_bitmap_bk.sys_color_changed();
void Fan::msw_rescale() {
m_bitmap_bk.msw_rescale();
}
void Fan::DoSetSize(int x, int y, int width, int height, int sizeFlags)
@ -279,8 +280,8 @@ void FanOperate::doRender(wxDC& dc)
dc.DrawLine(left_fir, FromDIP(4), left_fir, size.y - FromDIP(4));
dc.DrawLine(left_fir * 2, FromDIP(4), left_fir * 2, size.y - FromDIP(4));
dc.DrawBitmap(m_bitmap_decrease.get_bitmap(), (left_fir - m_bitmap_decrease.GetSize().x) / 2, (size.y - m_bitmap_decrease.GetSize().y) / 2);
dc.DrawBitmap(m_bitmap_add.get_bitmap(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetSize().x) / 2), (size.y - m_bitmap_add.GetSize().y) / 2);
dc.DrawBitmap(m_bitmap_decrease.bmp(), (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2, (size.y - m_bitmap_decrease.GetBmpSize().y) / 2);
dc.DrawBitmap(m_bitmap_add.bmp(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
//txt
dc.SetFont(::Label::Body_12);

View file

@ -110,12 +110,12 @@ void ImageSwitchButton::render(wxDC& dc)
wxSize szContent = textSize;
ScalableBitmap &icon = GetValue() ? m_on : m_off;
int content_height = icon.GetHeight() + textSize.y + m_padding;
int content_height = icon.GetBmpHeight() + textSize.y + m_padding;
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.y += m_padding + icon.GetHeight();
dc.DrawBitmap(icon.bmp(), pt);
pt.y += m_padding + icon.GetBmpHeight();
}
pt.x = (size.x - textSize.x) / 2;
dc.SetFont(GetFont());
@ -273,7 +273,7 @@ void FanSwitchButton::render(wxDC& dc)
//int content_height = icon.GetBmpHeight() + textSize.y + m_padding;
int content_height = m_padding;
wxPoint pt = wxPoint((size.x - icon.GetWidth()) / 2, (size.y - content_height) / 2);
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
pt.x = (size.x - textSize.x) / 2;
dc.SetFont(GetFont());
@ -298,10 +298,10 @@ void FanSwitchButton::render(wxDC& dc)
dc.DrawText(fina_txt, wxPoint(pt.x, content_height));
}
pt = wxPoint((size.x - icon.GetWidth()) / 2, content_height + textSize.y);
pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, content_height + textSize.y);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.get_bitmap(), pt);
pt.y += m_padding + icon.GetHeight();
dc.DrawBitmap(icon.bmp(), pt);
pt.y += m_padding + icon.GetBmpHeight();
}
auto speed = wxString::Format("%d%%", m_speed);

View file

@ -10,8 +10,8 @@ RadioBox::RadioBox(wxWindow *parent)
// SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
if (parent) SetBackgroundColour(parent->GetBackgroundColour());
// Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { update(); e.Skip(); });
SetSize(m_on.GetSize());
SetMinSize(m_on.GetSize());
SetSize(m_on.GetBmpSize());
SetMinSize(m_on.GetBmpSize());
update();
}
@ -29,9 +29,9 @@ bool RadioBox::GetValue()
void RadioBox::Rescale()
{
m_on.sys_color_changed();
m_off.sys_color_changed();
SetSize(m_on.GetSize());
m_on.msw_rescale();
m_off.msw_rescale();
SetSize(m_on.GetBmpSize());
update();
}

View file

@ -157,7 +157,7 @@ bool SideButton::Enable(bool enable)
void SideButton::Rescale()
{
if (this->icon.bmp().IsOk())
this->icon.sys_color_changed();
this->icon.msw_rescale();
messureSize();
}
@ -246,7 +246,7 @@ void SideButton::dorender(wxDC& dc, wxDC& text_dc)
//BBS norrow size between text and icon
szContent.x += 5;
}
szIcon = icon.GetSize();
szIcon = icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;
@ -270,7 +270,7 @@ void SideButton::dorender(wxDC& dc, wxDC& text_dc)
//BBS extra pixels for icon
pt.x += icon_offset;
pt.y += (rcContent.height - szIcon.y) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
dc.DrawBitmap(icon.bmp(), pt);
//BBS norrow size between text and icon
pt.x += szIcon.x + 5;
pt.y = rcContent.y;
@ -299,7 +299,7 @@ void SideButton::messureSize()
if (szContent.y > 0) {
szContent.x += 5;
}
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y)
szContent.y = szIcon.y;

View file

@ -150,19 +150,19 @@ void SideToolsPanel::doRender(wxDC &dc)
dc.SetBrush(SIDE_TOOLS_BRAND);
dc.DrawRectangle(0, 0, size.x, size.y);
dc.DrawBitmap(m_none_printing_img.get_bitmap(), left, (size.y - m_none_printing_img.GetSize().y) / 2);
dc.DrawBitmap(m_none_printing_img.bmp(), left, (size.y - m_none_printing_img.GetBmpSize().y) / 2);
left += (m_none_printing_img.GetSize().x + FromDIP(15));
dc.DrawBitmap(m_none_arrow_img.get_bitmap(), left, (size.y - m_none_arrow_img.GetSize().y) / 2);
left += (m_none_printing_img.GetBmpSize().x + FromDIP(15));
dc.DrawBitmap(m_none_arrow_img.bmp(), left, (size.y - m_none_arrow_img.GetBmpSize().y) / 2);
left += (m_none_arrow_img.GetSize().x + FromDIP(6));
left += (m_none_arrow_img.GetBmpSize().x + FromDIP(6));
dc.SetFont(::Label::Body_14);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(*wxWHITE);
wxString no_printer_str = _L("No printer");
auto sizet = dc.GetTextExtent(no_printer_str);
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x - m_none_add_img.GetSize().x;
auto left_add_bitmap = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x - m_none_add_img.GetBmpSize().x;
auto size_width = left_add_bitmap - left;
if (sizet.x > size_width) {
@ -181,21 +181,21 @@ void SideToolsPanel::doRender(wxDC &dc)
dc.DrawText(no_printer_str, wxPoint(left, (size.y - sizet.y) / 2));
left = size.x - FromDIP(30) - m_wifi_none_img.GetSize().x;
dc.DrawBitmap(m_none_add_img.get_bitmap(), left, (size.y - m_none_add_img.GetSize().y) / 2);
left = size.x - FromDIP(30) - m_wifi_none_img.GetBmpSize().x;
dc.DrawBitmap(m_none_add_img.bmp(), left, (size.y - m_none_add_img.GetBmpSize().y) / 2);
} else {
dc.DrawBitmap(m_printing_img.get_bitmap(), left, (size.y - m_printing_img.GetSize().y) / 2);
dc.DrawBitmap(m_printing_img.bmp(), left, (size.y - m_printing_img.GetBmpSize().y) / 2);
left += (m_printing_img.GetSize().x + FromDIP(5));
dc.DrawBitmap(m_arrow_img.get_bitmap(), left, (size.y - m_arrow_img.GetSize().y) / 2);
left += (m_printing_img.GetBmpSize().x + FromDIP(5));
dc.DrawBitmap(m_arrow_img.bmp(), left, (size.y - m_arrow_img.GetBmpSize().y) / 2);
left += (m_arrow_img.GetSize().x + FromDIP(6));
left += (m_arrow_img.GetBmpSize().x + FromDIP(6));
dc.SetFont(::Label::Body_14);
dc.SetBackgroundMode(wxTRANSPARENT);
dc.SetTextForeground(StateColor::darkModeColorFor(SIDE_TOOLS_GREY900));
auto sizet = dc.GetTextExtent(m_dev_name);
auto text_end = size.x - m_wifi_none_img.GetSize().x - 20;
auto text_end = size.x - m_wifi_none_img.GetBmpSize().x - 20;
std::string finally_name = m_dev_name.ToStdString();
if (sizet.x > (text_end - left)) {
@ -212,12 +212,12 @@ void SideToolsPanel::doRender(wxDC &dc)
dc.DrawText(finally_name, wxPoint(left, (size.y - sizet.y) / 2));
left = size.x - FromDIP(18) - m_wifi_none_img.GetSize().x;
if (m_wifi_type == WifiSignal::NONE) dc.DrawBitmap(m_wifi_none_img.get_bitmap(), left, (size.y - m_wifi_none_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::WEAK) dc.DrawBitmap(m_wifi_weak_img.get_bitmap(), left, (size.y - m_wifi_weak_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::MIDDLE) dc.DrawBitmap(m_wifi_middle_img.get_bitmap(), left, (size.y - m_wifi_middle_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::STRONG) dc.DrawBitmap(m_wifi_strong_img.get_bitmap(), left, (size.y - m_wifi_strong_img.GetSize().y) / 2);
if (m_wifi_type == WifiSignal::WIRED) dc.DrawBitmap(m_network_wired_img.get_bitmap(), left, (size.y - m_network_wired_img.GetSize().y) / 2);
left = size.x - FromDIP(18) - m_wifi_none_img.GetBmpSize().x;
if (m_wifi_type == WifiSignal::NONE) dc.DrawBitmap(m_wifi_none_img.bmp(), left, (size.y - m_wifi_none_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::WEAK) dc.DrawBitmap(m_wifi_weak_img.bmp(), left, (size.y - m_wifi_weak_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::MIDDLE) dc.DrawBitmap(m_wifi_middle_img.bmp(), left, (size.y - m_wifi_middle_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::STRONG) dc.DrawBitmap(m_wifi_strong_img.bmp(), left, (size.y - m_wifi_strong_img.GetBmpSize().y) / 2);
if (m_wifi_type == WifiSignal::WIRED) dc.DrawBitmap(m_network_wired_img.bmp(), left, (size.y - m_network_wired_img.GetBmpSize().y) / 2);
}
if (m_hover) {
@ -272,8 +272,8 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
wxBoxSizer* connection_sizer_V = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* connection_sizer_H = new wxBoxSizer(wxHORIZONTAL);
m_hyperlink = new wxHyperlinkCtrl(m_connection_info, wxID_ANY, _L("Failed to connect to the server"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
m_hyperlink->SetBackgroundColour(wxColour(255, 111, 0));
// m_hyperlink = new wxHyperlinkCtrl(m_connection_info, wxID_ANY, _L("Failed to connect to the server"), wxT("https://wiki.bambulab.com/en/software/bambu-studio/failed-to-connect-printer"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
// m_hyperlink->SetBackgroundColour(wxColour(255, 111, 0));
m_more_err_open = ScalableBitmap(this, "monitir_err_open", 16);
m_more_err_close = ScalableBitmap(this, "monitir_err_close", 16);
@ -302,7 +302,7 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
});
connection_sizer_H->Add(m_hyperlink, 0, wxALIGN_CENTER | wxALL, 5);
// connection_sizer_H->Add(m_hyperlink, 0, wxALIGN_CENTER | wxALL, 5);
connection_sizer_H->Add(m_more_button, 0, wxALIGN_CENTER | wxALL, 3);
connection_sizer_V->Add(connection_sizer_H, 0, wxALIGN_CENTER, 0);

View file

@ -46,7 +46,7 @@ void StaticLine::SetLineColour(wxColour color)
void StaticLine::Rescale()
{
if (this->icon.bmp().IsOk())
this->icon.sys_color_changed();
this->icon.msw_rescale();
messureSize();
}
@ -67,7 +67,7 @@ void StaticLine::messureSize()
// BBS norrow size between text and icon
szContent.x += 5;
}
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
szContent.x += szIcon.x;
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
}
@ -90,13 +90,13 @@ void StaticLine::render(wxDC& dc)
auto label = GetLabel();
if (!label.IsEmpty()) textSize = dc.GetTextExtent(label);
wxRect titleRect{{0, 0}, size};
titleRect.height = wxMax(icon.GetHeight(), textSize.GetHeight());
int contentWidth = icon.GetWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
titleRect.height = wxMax(icon.GetBmpHeight(), textSize.GetHeight());
int contentWidth = icon.GetBmpWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
textSize.GetWidth();
if (vertical) titleRect.Deflate((size.GetWidth() - contentWidth) / 2, 0);
if (icon.bmp().IsOk()) {
dc.DrawBitmap(icon.get_bitmap(), {0, (size.y - icon.GetHeight()) / 2});
titleRect.x += icon.GetWidth() + 5;
dc.DrawBitmap(icon.bmp(), {0, (size.y - icon.GetBmpHeight()) / 2});
titleRect.x += icon.GetBmpWidth() + 5;
}
if (!label.IsEmpty()) {
dc.SetTextForeground(StateColor::darkModeColorFor(GetForegroundColour()));

View file

@ -122,15 +122,15 @@ StepCtrl::StepCtrl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wx
, bmp_thumb(this, "step_thumb", 36)
{
StaticBox::border_width = 3;
radius = radius * bmp_thumb.GetHeight() / 36;
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
radius = radius * bmp_thumb.GetBmpHeight() / 36;
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
}
void StepCtrl::Rescale()
{
bmp_thumb.sys_color_changed();
radius = radius * bmp_thumb.GetHeight() / 36;
bar_width = bar_width * bmp_thumb.GetHeight() / 36;
bmp_thumb.msw_rescale();
radius = radius * bmp_thumb.GetBmpHeight() / 36;
bar_width = bar_width * bmp_thumb.GetBmpHeight() / 36;
}
void StepCtrl::mouseDown(wxMouseEvent &event)
@ -141,7 +141,7 @@ void StepCtrl::mouseDown(wxMouseEvent &event)
int itemWidth = size.x / steps.size();
wxRect rcBar = {0, (size.y - 60) / 2, size.x, 60};
int circleX = itemWidth / 2 + itemWidth * step;
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetSize()};
wxRect rcThumb = {{circleX, size.y / 2}, bmp_thumb.GetBmpSize()};
rcThumb.x -= rcThumb.width / 2;
rcThumb.y -= rcThumb.height / 2;
if (rcThumb.Contains(pt)) {
@ -235,8 +235,8 @@ void StepCtrl::doRender(wxDC &dc)
dc.SetTextForeground(clr_tip.colorForStates(states));
wxSize sz = dc.GetTextExtent(tips[i]);
dc.DrawText(tips[i], circleX - sz.x / 2, circleY - 20 - sz.y);
sz = bmp_thumb.GetSize();
dc.DrawBitmap(bmp_thumb.get_bitmap(), circleX - sz.x / 2, circleY - sz.y / 2);
sz = bmp_thumb.GetBmpSize();
dc.DrawBitmap(bmp_thumb.bmp(), circleX - sz.x / 2, circleY - sz.y / 2);
}
circleX += itemWidth;
}
@ -260,16 +260,16 @@ StepIndicator::StepIndicator(wxWindow *parent, wxWindowID id, const wxPoint &pos
std::make_pair(0x6B6B6B, 0));
clr_tip = *wxWHITE;
StaticBox::border_width = 0;
radius = bmp_ok.GetHeight() / 2;
bar_width = bmp_ok.GetHeight() / 20;
radius = bmp_ok.GetBmpHeight() / 2;
bar_width = bmp_ok.GetBmpHeight() / 20;
if (bar_width < 2) bar_width = 2;
}
void StepIndicator::Rescale()
{
bmp_ok.sys_color_changed();
radius = bmp_ok.GetHeight() / 2;
bar_width = bmp_ok.GetHeight() / 20;
bmp_ok.msw_rescale();
radius = bmp_ok.GetBmpHeight() / 2;
bar_width = bmp_ok.GetBmpHeight() / 20;
if (bar_width < 2) bar_width = 2;
}
@ -319,8 +319,8 @@ void StepIndicator::doRender(wxDC &dc)
dc.DrawEllipse(circleX - radius, circleY - radius, radius * 2, radius * 2);
// Draw content ( icon or text ) in circle
if (disabled) {
wxSize sz = bmp_ok.GetSize();
dc.DrawBitmap(bmp_ok.get_bitmap(), circleX - radius, circleY - radius);
wxSize sz = bmp_ok.GetBmpSize();
dc.DrawBitmap(bmp_ok.bmp(), circleX - radius, circleY - radius);
} else {
dc.SetFont(font_tip);
dc.SetTextForeground(clr_tip.colorForStates(states));

View file

@ -9,8 +9,8 @@
SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id)
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxBU_EXACTFIT)
, m_on(this, "toggle_on", 16, false, false, true)
, m_off(this, "toggle_off", 16, false, false, true)
, m_on(this, "toggle_on", 16)
, m_off(this, "toggle_off", 16)
, text_color(std::pair{0xfffffe, (int) StateColor::Checked}, std::pair{0x6B6B6B, (int) StateColor::Normal})
, track_color(0xD9D9D9)
, thumb_color(std::pair{0x009688, (int) StateColor::Checked}, std::pair{0xD9D9D9, (int) StateColor::Normal})
@ -58,8 +58,8 @@ void SwitchButton::SetValue(bool value)
void SwitchButton::Rescale()
{
if (labels[0].IsEmpty()) {
m_on.sys_color_changed();
m_off.sys_color_changed();
m_on.msw_rescale();
m_off.msw_rescale();
}
else {
SetBackgroundColour(StaticBox::GetParentBackgroundColor(GetParent()));
@ -138,7 +138,7 @@ void SwitchButton::Rescale()
(i == 0 ? m_off : m_on).bmp() = bmp;
}
}
SetSize(m_on.GetSize());
SetSize(m_on.GetBmpSize());
update();
}

View file

@ -43,7 +43,9 @@ TabCtrl::TabCtrl(wxWindow * parent,
}
TabCtrl::~TabCtrl()
{}
{
delete images;
}
int TabCtrl::GetSelection() const { return sel; }
@ -165,6 +167,13 @@ void TabCtrl::SetItemData(unsigned int item, void* clientData)
btns[item]->SetClientData(clientData);
}
void TabCtrl::AssignImageList(wxImageList* imageList)
{
if (images == imageList) return;
delete images;
images = imageList;
}
void TabCtrl::SetItemTextColour(unsigned int item, const StateColor &col)
{
if (item >= btns.size()) return;

View file

@ -9,6 +9,7 @@ wxDECLARE_EVENT( wxEVT_TAB_SEL_CHANGED, wxCommandEvent );
class TabCtrl : public StaticBox
{
std::vector<Button*> btns;
wxImageList* images = nullptr;
wxBoxSizer * sizer = nullptr;
int sel = -1;
@ -51,6 +52,8 @@ public:
void* GetItemData(unsigned int item) const;
void SetItemData(unsigned int item, void *clientData);
void AssignImageList(wxImageList *imageList);
void SetItemTextColour(unsigned int item, const StateColor& col);

View file

@ -280,10 +280,8 @@ void TempInput::SetLabelColor(StateColor const &color)
void TempInput::Rescale()
{
if (this->normal_icon.bmp().IsOk())
this->normal_icon.sys_color_changed();
if (this->degree_icon.bmp().IsOk())
this->degree_icon.sys_color_changed();
if (this->normal_icon.bmp().IsOk()) this->normal_icon.msw_rescale();
if (this->degree_icon.bmp().IsOk()) this->degree_icon.msw_rescale();
messureSize();
}
@ -319,7 +317,7 @@ void TempInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
auto left = padding_left;
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
left += szIcon.x;
}
@ -381,18 +379,18 @@ void TempInput::render(wxDC &dc)
// start draw
wxPoint pt = {padding_left, 0};
if (actice_icon.bmp().IsOk() && actice) {
wxSize szIcon = actice_icon.GetSize();
wxSize szIcon = actice_icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(actice_icon.get_bitmap(), pt);
dc.DrawBitmap(actice_icon.bmp(), pt);
pt.x += szIcon.x + 9;
} else {
actice = false;
}
if (normal_icon.bmp().IsOk() && !actice) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(normal_icon.get_bitmap(), pt);
dc.DrawBitmap(normal_icon.bmp(), pt);
pt.x += szIcon.x + 9;
}
@ -437,10 +435,10 @@ void TempInput::render(wxDC &dc)
// flag
if (degree_icon.bmp().IsOk()) {
auto pos = text_ctrl->GetPosition();
wxSize szIcon = degree_icon.GetSize();
wxSize szIcon = degree_icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
pt.x = pos.x + text_ctrl->GetSize().x;
dc.DrawBitmap(degree_icon.get_bitmap(), pt);
dc.DrawBitmap(degree_icon.bmp(), pt);
}
}
@ -454,7 +452,7 @@ void TempInput::messureMiniSize()
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
width += szIcon.x;
height = szIcon.y;
}
@ -483,7 +481,7 @@ void TempInput::messureMiniSize()
height = textSize.y > height ? textSize.y : height;
// flag flag
auto flagSize = degree_icon.GetSize();
auto flagSize = degree_icon.GetBmpSize();
width += flagSize.x;
height = flagSize.y > height ? flagSize.y : height;
@ -508,7 +506,7 @@ void TempInput::messureSize()
wxClientDC dc(this);
if (normal_icon.bmp().IsOk()) {
wxSize szIcon = normal_icon.GetSize();
wxSize szIcon = normal_icon.GetBmpSize();
width += szIcon.x;
height = szIcon.y;
}
@ -537,7 +535,7 @@ void TempInput::messureSize()
height = textSize.y > height ? textSize.y : height;
// flag flag
auto flagSize = degree_icon.GetSize();
auto flagSize = degree_icon.GetBmpSize();
width += flagSize.x;
height = flagSize.y > height ? flagSize.y : height;

View file

@ -94,10 +94,10 @@ void TextInput::SetLabel(const wxString& label)
Refresh();
}
void TextInput::SetIcon(const wxBitmapBundle &icon_in)
void TextInput::SetIcon(const wxBitmap &icon)
{
this->icon = ScalableBitmap();
this->icon.bmp() = icon_in;
this->icon.bmp() = icon;
Rescale();
}
@ -116,7 +116,7 @@ void TextInput::SetTextColor(StateColor const& color)
void TextInput::Rescale()
{
if (!this->icon.name().empty())
this->icon.sys_color_changed();
this->icon.msw_rescale();
messureSize();
Refresh();
}
@ -153,7 +153,7 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags)
wxSize size = GetSize();
wxPoint textPos = {5, 0};
if (this->icon.bmp().IsOk()) {
wxSize szIcon = this->icon.GetSize();
wxSize szIcon = this->icon.GetBmpSize();
textPos.x += szIcon.x;
}
bool align_right = GetWindowStyle() & wxRIGHT;
@ -194,9 +194,9 @@ void TextInput::render(wxDC& dc)
// start draw
wxPoint pt = {5, 0};
if (icon.bmp().IsOk()) {
wxSize szIcon = get_preferred_size(icon.bmp(), m_parent);
wxSize szIcon = icon.GetBmpSize();
pt.y = (size.y - szIcon.y) / 2;
dc.DrawBitmap(icon.get_bitmap(), pt);
dc.DrawBitmap(icon.bmp(), pt);
pt.x += szIcon.x + 0;
}
auto text = wxWindow::GetLabel();

View file

@ -40,7 +40,7 @@ public:
void SetLabel(const wxString& label);
virtual void SetIcon(const wxBitmapBundle & icon);
void SetIcon(const wxBitmap & icon);
void SetLabelColor(StateColor const &color);

View file

@ -14,6 +14,7 @@
#include <wx/sizer.h>
using namespace Slic3r::GUI;
int scale(const int val) { return val * Slic3r::GUI::wxGetApp().em_unit() / 10; }
@ -89,7 +90,7 @@ RammingDialog::RammingDialog(wxWindow* parent,const std::string& parameters)
#ifdef _WIN32
#define style wxSP_ARROW_KEYS | wxBORDER_SIMPLE
#else
#else
#define style wxSP_ARROW_KEYS
#endif
@ -125,9 +126,9 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
#endif
sizer_chart->Add(m_chart, 0, wxALL, 5);
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0.,5.0,3.,0.5);
m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0,10000,0);
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
m_widget_time = new wxSpinCtrlDouble(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0.,5.0,3.,0.5);
m_widget_volume = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,0,10000,0);
m_widget_ramming_line_width_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
m_widget_ramming_step_multiplicator = new wxSpinCtrl(this,wxID_ANY,wxEmptyString,wxDefaultPosition,wxSize(ITEM_WIDTH()*2.5, -1),style,10,200,100);
#ifdef _WIN32
@ -156,7 +157,7 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
m_widget_volume->SetValue(m_chart->get_volume());
m_widget_volume->Disable();
m_widget_ramming_line_width_multiplicator->SetValue(m_ramming_line_width_multiplicator);
m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator);
m_widget_ramming_step_multiplicator->SetValue(m_ramming_step_multiplicator);
m_widget_ramming_step_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
m_widget_ramming_line_width_multiplicator->Bind(wxEVT_TEXT,[this](wxCommandEvent&) { line_parameters_changed(); });
@ -170,7 +171,7 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
m_widget_time->Bind(wxEVT_TEXT,[this](wxCommandEvent&) {m_chart->set_xy_range(m_widget_time->GetValue(),-1);});
m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} );
Refresh(true); // erase background
}
@ -188,7 +189,7 @@ std::string RammingPanel::get_parameters()
stream << m_ramming_line_width_multiplicator << " " << m_ramming_step_multiplicator;
for (const float& speed_value : speeds)
stream << " " << speed_value;
stream << "|";
stream << "|";
for (const auto& button : buttons)
stream << " " << button.first << " " << button.second;
return stream.str();
@ -197,7 +198,7 @@ std::string RammingPanel::get_parameters()
#ifdef _WIN32
#define style wxSP_ARROW_KEYS | wxBORDER_SIMPLE
#else
#else
#define style wxSP_ARROW_KEYS
#endif
@ -253,7 +254,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
);
if (flags & wxRESET) {
Button *calc_btn = new Button(this, _L("Recalculate"));
Button *calc_btn = new Button(this, _L("Auto-Calc"));
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
calc_btn->SetCornerRadius(FromDIP(12));
calc_btn->SetBackgroundColor(calc_btn_bg);
@ -261,7 +262,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
calc_btn->SetTextColor(calc_btn_text);
calc_btn->SetFocus();
calc_btn->SetId(wxID_RESET);
btn_sizer->Add(calc_btn, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxRESET] = calc_btn;
}
if (flags & wxOK) {
@ -284,7 +285,7 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
cancel_btn->SetBorderColor(cancel_btn_bd_);
cancel_btn->SetTextColor(cancel_btn_text);
cancel_btn->SetId(wxID_CANCEL);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP / 2);
btn_sizer->Add(cancel_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
m_button_list[wxCANCEL] = cancel_btn;
}
@ -292,11 +293,40 @@ wxBoxSizer* WipingDialog::create_btn_sizer(long flags)
}
wxBoxSizer* WipingPanel::create_calc_btn_sizer(wxWindow* parent) {
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
StateColor calc_btn_bg(
std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
);
StateColor calc_btn_bd(
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal)
);
StateColor calc_btn_text(
std::pair<wxColour, int>(wxColour(255, 255, 254), StateColor::Normal)
);
Button* calc_btn = new Button(parent, _L("Re-calculate"));
calc_btn->SetFont(Label::Body_13);
calc_btn->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
calc_btn->SetCornerRadius(FromDIP(12));
calc_btn->SetBackgroundColor(calc_btn_bg);
calc_btn->SetBorderColor(calc_btn_bd);
calc_btn->SetTextColor(calc_btn_text);
calc_btn->SetFocus();
btn_sizer->Add(calc_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, BTN_GAP);
calc_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { calc_flushing_volumes(); });
return btn_sizer;
}
void WipingDialog::on_dpi_changed(const wxRect &suggested_rect)
{
for (auto button_item : m_button_list)
for (auto button_item : m_button_list)
{
if (button_item.first == wxRESET)
if (button_item.first == wxRESET)
{
button_item.second->SetMinSize(wxSize(FromDIP(75), FromDIP(24)));
button_item.second->SetCornerRadius(FromDIP(12));
@ -332,20 +362,20 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
this->SetBackgroundColour(*wxWHITE);
this->SetMinSize(wxSize(MIN_WIPING_DIALOG_WIDTH, -1));
m_panel_wiping = new WipingPanel(this, matrix, extruders, extruder_colours, nullptr, extra_flush_volume, flush_multiplier);
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(m_line_top, 0, wxEXPAND, 0);
// set min sizer width according to extruders count
auto sizer_width = (int)((sqrt(matrix.size()) + 2.8)*ITEM_WIDTH());
sizer_width = sizer_width > MIN_WIPING_DIALOG_WIDTH ? sizer_width : MIN_WIPING_DIALOG_WIDTH;
main_sizer->SetMinSize(wxSize(sizer_width, -1));
main_sizer->Add(m_panel_wiping, 1, wxEXPAND | wxALL, 0);
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL | wxRESET);
auto btn_sizer = create_btn_sizer(wxOK | wxCANCEL);
main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BTN_GAP);
SetSizer(main_sizer);
main_sizer->SetSizeHints(this);
@ -353,6 +383,7 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
if (this->FindWindowById(wxID_OK, this)) {
this->FindWindowById(wxID_OK, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { // if OK button is clicked..
m_output_matrix = m_panel_wiping->read_matrix_values(); // ..query wiping panel and save returned values
m_output_extruders = m_panel_wiping->read_extruders_values(); // so they can be recovered later by calling get_...()
EndModal(wxID_OK);
}, wxID_OK);
}
@ -362,16 +393,18 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<float>& matrix, c
}
/*
if (this->FindWindowById(wxID_RESET, this)) {
this->FindWindowById(wxID_RESET, this)->Bind(wxEVT_BUTTON, [this](wxCommandEvent &) { m_panel_wiping->calc_flushing_volumes(); });
}
*/
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& e) { EndModal(wxCANCEL); });
this->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
if (e.GetKeyCode() == WXK_ESCAPE) {
if (this->IsModal())
this->EndModal(wxID_CANCEL);
else
else
this->Close();
}
else
@ -394,7 +427,6 @@ void WipingPanel::create_panels(wxWindow* parent, const int num) {
icon->SetCanFocus(false);
icon_list2.push_back(icon);
sizer->AddStretchSpacer();
sizer->AddSpacer(ROW_BEG_PADDING);
sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, ROW_VERT_PADDING);
@ -406,9 +438,8 @@ void WipingPanel::create_panels(wxWindow* parent, const int num) {
sizer->Add(edit_boxes[j][i], 0, wxALIGN_CENTER_VERTICAL, 0);
}
sizer->AddSpacer(ROW_END_PADDING);
sizer->AddStretchSpacer();
m_sizer->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
m_sizer_advanced->Add(panel, 0, wxRIGHT | wxLEFT | wxEXPAND, TABLE_BORDER);
panel->Layout();
}
}
@ -426,12 +457,22 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
Slic3r::decode_color(color, rgb);
m_colours.push_back(wxColor(rgb.r_uchar(), rgb.g_uchar(), rgb.b_uchar()));
}
auto sizer_width = (int)((sqrt(matrix.size())) * ITEM_WIDTH() + (sqrt(matrix.size()) + 1) * HEADER_BEG_PADDING);
sizer_width = sizer_width > MIN_WIPING_DIALOG_WIDTH ? sizer_width : MIN_WIPING_DIALOG_WIDTH;
m_sizer = new wxBoxSizer(wxVERTICAL);
this->SetBackgroundColour(*wxWHITE);
update_ui(this);
// Create two switched panels with their own sizers
m_sizer_simple = new wxBoxSizer(wxVERTICAL);
m_sizer_advanced = new wxBoxSizer(wxVERTICAL);
m_page_simple = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_page_advanced = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_page_simple->SetSizer(m_sizer_simple);
m_page_advanced->SetSizer(m_sizer_advanced);
m_page_advanced->SetBackgroundColour(*wxWHITE);
update_ui(m_page_simple);
update_ui(m_page_advanced);
auto gridsizer_simple = new wxGridSizer(3, 5, 10);
m_gridsizer_advanced = new wxGridSizer(m_number_of_extruders + 1, 5, 1);
// First create controls for advanced mode and assign them to m_page_advanced:
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
@ -439,17 +480,17 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
for (unsigned int j = 0; j < m_number_of_extruders; ++j) {
#ifdef _WIN32
wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), wxTE_CENTER | wxBORDER_NONE | wxTE_PROCESS_ENTER);
wxTextCtrl* text = new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), wxTE_CENTER | wxBORDER_NONE | wxTE_PROCESS_ENTER);
update_ui(text);
edit_boxes.back().push_back(text);
#else
edit_boxes.back().push_back(new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1)));
edit_boxes.back().push_back(new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1)));
#endif
if (i == j) {
edit_boxes[i][j]->SetValue(wxString("-"));
edit_boxes[i][j]->SetEditable(false);
edit_boxes[i][j]->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent&) {});
edit_boxes[i][j]->Bind(wxEVT_SET_FOCUS, [this](wxFocusEvent&) {});
}
else {
edit_boxes[i][j]->SetValue(wxString("") << int(m_matrix[m_number_of_extruders * j + i] * flush_multiplier));
@ -478,13 +519,13 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
}
// BBS
m_sizer->AddSpacer(FromDIP(10));
auto tip_message_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
tip_message_panel->SetBackgroundColour(*wxWHITE);
m_sizer_advanced->AddSpacer(FromDIP(10));
auto tip_message_panel = new wxPanel(m_page_advanced, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
tip_message_panel->SetBackgroundColour(wxColour(238, 238, 238));
auto message_sizer = new wxBoxSizer(wxVERTICAL);
tip_message_panel->SetSizer(message_sizer);
{
wxString message = _L("Orca recalculates your flushing volumes everytime the filament colors change. You can change this behavior in Preferences.");
wxString message = _L("Orca would re-calculate your flushing volumes everytime the filaments color changed. You could disable the auto-calculate in Orca Slicer > Preferences");
m_tip_message_label = new Label(tip_message_panel, wxEmptyString);
wxClientDC dc(tip_message_panel);
wxString multiline_message;
@ -492,20 +533,21 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
m_tip_message_label->SetLabel(multiline_message);
m_tip_message_label->SetFont(Label::Body_13);
message_sizer->Add(m_tip_message_label, 0, wxEXPAND | wxALL, TIP_MESSAGES_PADDING);
update_ui(m_tip_message_label);
}
m_sizer->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
m_sizer_advanced->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
bool is_show = wxGetApp().app_config->get("auto_calculate") == "true";
tip_message_panel->Show(is_show);
m_sizer->AddSpacer(FromDIP(10));
m_sizer->AddSpacer(FromDIP(5));
header_line_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_sizer_advanced->AddSpacer(FromDIP(10));
auto calc_btn_sizer = create_calc_btn_sizer(m_page_advanced);
m_sizer_advanced->Add(calc_btn_sizer, 0, wxEXPAND | wxLEFT, FromDIP(30));
//m_sizer_advanced->AddSpacer(FromDIP(10));
m_sizer_advanced->AddSpacer(FromDIP(5));
header_line_panel = new wxPanel(m_page_advanced, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
header_line_panel->SetBackgroundColour(wxColour(238, 238, 238));
auto header_line_sizer = new wxBoxSizer(wxHORIZONTAL);
header_line_panel->SetSizer(header_line_sizer);
wxSizerItem* stretch_spacer = header_line_sizer->AddStretchSpacer();
header_line_sizer->AddSpacer(HEADER_BEG_PADDING);
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
wxButton* icon = new wxButton(header_line_panel, wxID_ANY, {}, wxDefaultPosition, ICON_SIZE, wxBORDER_NONE | wxBU_AUTODRAW);
@ -517,24 +559,23 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
header_line_sizer->Add(icon, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, HEADER_VERT_PADDING);
}
header_line_sizer->AddSpacer(HEADER_END_PADDING);
header_line_sizer->AddStretchSpacer();
m_sizer_advanced->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
create_panels(m_page_advanced, m_number_of_extruders);
m_sizer->Add(header_line_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
create_panels(this, m_number_of_extruders);
m_sizer->AddSpacer(FromDIP(5));
//m_sizer_advanced->AddSpacer(BTN_SIZE.y);
// BBS: for tunning flush volumes
{
auto multi_desc_label = new wxStaticText(this, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
auto multi_desc_label = new wxStaticText(m_page_advanced, wxID_ANY, _(L("Flushing volume (mm³) for each filament pair.")), wxDefaultPosition, wxDefaultSize, 0);
multi_desc_label->SetForegroundColour(g_text_color);
m_sizer->Add(multi_desc_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer_advanced->Add(multi_desc_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
wxString min_flush_str = wxString::Format(_L("Suggestion: Flushing Volume in range [%d, %d]"), m_min_flush_volume, m_max_flush_volume);
m_min_flush_label = new wxStaticText( this, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
m_min_flush_label = new wxStaticText(m_page_advanced, wxID_ANY, min_flush_str, wxDefaultPosition, wxDefaultSize, 0);
m_min_flush_label->SetForegroundColour(g_text_color);
m_sizer->Add(m_min_flush_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer_advanced->Add(m_min_flush_label, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
auto on_apply_text_modify = [this](wxEvent& e) {
wxString str = m_flush_multiplier_ebox->GetValue();
@ -549,8 +590,6 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
}
for (unsigned int i = 0; i < m_number_of_extruders; ++i) {
for (unsigned int j = 0; j < m_number_of_extruders; ++j) {
if (i == j)
continue; // if it is from/to the same extruder, don't change the value and continue
edit_boxes[i][j]->SetValue(to_string(int(m_matrix[m_number_of_extruders * j + i] * multiplier)));
}
}
@ -559,32 +598,91 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
e.Skip();
};
m_sizer->AddSpacer(10);
m_sizer_advanced->AddSpacer(10);
wxBoxSizer* param_sizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* flush_multiplier_title = new wxStaticText(this, wxID_ANY, _L("Multiplier"));
wxStaticText* flush_multiplier_title = new wxStaticText(m_page_advanced, wxID_ANY, _L("Multiplier"));
param_sizer->Add(flush_multiplier_title, 0, wxALIGN_CENTER | wxALL, 0);
param_sizer->AddSpacer(FromDIP(5));
m_flush_multiplier_ebox = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(50), -1), wxTE_PROCESS_ENTER);
m_flush_multiplier_ebox = new wxTextCtrl(m_page_advanced, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(50), -1), wxTE_PROCESS_ENTER);
char flush_multi_str[32] = { 0 };
snprintf(flush_multi_str, sizeof(flush_multi_str), "%.2f", flush_multiplier);
m_flush_multiplier_ebox->SetValue(flush_multi_str);
param_sizer->Add(m_flush_multiplier_ebox, 0, wxALIGN_CENTER | wxALL, 0);
param_sizer->AddStretchSpacer(1);
m_sizer->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_sizer->AddSpacer(BTN_SIZE.y);
m_sizer_advanced->Add(param_sizer, 0, wxEXPAND | wxLEFT, TEXT_BEG_PADDING);
m_flush_multiplier_ebox->Bind(wxEVT_TEXT_ENTER, on_apply_text_modify);
m_flush_multiplier_ebox->Bind(wxEVT_KILL_FOCUS, on_apply_text_modify);
}
this->update_warning_texts();
m_page_advanced->Hide();
// Now the same for simple mode:
gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString("")), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("unloaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(new wxStaticText(m_page_simple,wxID_ANY,wxString(_(L("loaded")))), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL);
auto add_spin_ctrl = [this](std::vector<wxSpinCtrl*>& vec, float initial)
{
wxSpinCtrl* spin_ctrl = new wxSpinCtrl(m_page_simple, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(ITEM_WIDTH(), -1), style | wxALIGN_RIGHT, 0, 300, (int)initial);
update_ui(spin_ctrl);
vec.push_back(spin_ctrl);
#ifdef __WXOSX__
// On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
// when it was changed from the text control, so the on_change callback
// gets the old one, and on_kill_focus resets the control to the old value.
// As a workaround, we get the new value from $event->GetString and store
// here temporarily so that we can return it from get_value()
spin_ctrl->Bind(wxEVT_TEXT, ([spin_ctrl](wxCommandEvent e)
{
long value;
const bool parsed = e.GetString().ToLong(&value);
int tmp_value = parsed && value >= INT_MIN && value <= INT_MAX ? (int)value : INT_MIN;
// Forcibly set the input value for SpinControl, since the value
// inserted from the keyboard or clipboard is not updated under OSX
if (tmp_value != INT_MIN) {
spin_ctrl->SetValue(tmp_value);
// But in SetValue() is executed m_text_ctrl->SelectAll(), so
// discard this selection and set insertion point to the end of string
spin_ctrl->GetText()->SetInsertionPointEnd();
}
}), spin_ctrl->GetId());
#endif
};
for (unsigned int i=0;i<m_number_of_extruders;++i) {
add_spin_ctrl(m_old, extruders[2 * i]);
add_spin_ctrl(m_new, extruders[2 * i+1]);
auto hsizer = new wxBoxSizer(wxHORIZONTAL);
wxWindow* w = new wxWindow(m_page_simple, wxID_ANY, wxDefaultPosition, ICON_SIZE, wxBORDER_SIMPLE);
w->SetCanFocus(false);
w->SetBackgroundColour(m_colours[i]);
hsizer->Add(w, wxALIGN_CENTER_VERTICAL);
hsizer->AddSpacer(10);
hsizer->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("Filament #"))) << i + 1 << ": "), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(hsizer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
gridsizer_simple->Add(m_old.back(),0);
gridsizer_simple->Add(m_new.back(),0);
}
m_sizer = new wxBoxSizer(wxVERTICAL);
m_sizer->Add(m_page_simple, 0, wxEXPAND, 0);
m_sizer->Add(m_page_advanced, 0, wxEXPAND, 0);
m_sizer->SetSizeHints(this);
SetSizer(m_sizer);
this->Layout();
header_line_panel->Bind(wxEVT_PAINT, [this, stretch_spacer](wxPaintEvent&) {
toggle_advanced(); // to show/hide what is appropriate
header_line_panel->Bind(wxEVT_PAINT, [this](wxPaintEvent&) {
wxPaintDC dc(header_line_panel);
wxString from_text = _L("From");
wxString to_text = _L("To");
@ -593,7 +691,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
int base_y = (header_line_panel->GetSize().y - from_text_size.y - to_text_size.y) / 2;
int vol_width = ROW_BEG_PADDING + EDIT_BOXES_GAP / 2 + ICON_SIZE.x;
int base_x = stretch_spacer->GetSize().x + (vol_width - from_text_size.x - to_text_size.x) / 2;
int base_x = (vol_width - from_text_size.x - to_text_size.x) / 2;
// draw from text
int x = base_x;
@ -635,7 +733,7 @@ void WipingPanel::update_warning_texts()
auto& box_vec = edit_boxes[i];
for (int j = 0; j < box_vec.size(); j++) {
if (i == j)
continue; // if it is from/to the same extruder, don't change the value and continue
continue;
auto text_box = box_vec[j];
wxString str = text_box->GetValue();
@ -660,8 +758,8 @@ void WipingPanel::update_warning_texts()
m_min_flush_label->SetForegroundColour(g_warning_color);
m_min_flush_label->Refresh();
}
else if (!has_exception_flush && m_min_flush_label->GetForegroundColour() != StateColor::darkModeColorFor(g_text_color)) {
m_min_flush_label->SetForegroundColour(StateColor::darkModeColorFor(g_text_color));
else if (!has_exception_flush && m_min_flush_label->GetForegroundColour() != g_text_color) {
m_min_flush_label->SetForegroundColour(g_text_color);
m_min_flush_label->Refresh();
}
}
@ -672,24 +770,27 @@ void WipingPanel::calc_flushing_volumes()
const wxColour& from = m_colours[from_idx];
bool is_from_support = is_support_filament(from_idx);
for (int to_idx = 0; to_idx < m_colours.size(); to_idx++) {
if (from_idx == to_idx)
continue; // if it is from/to the same extruder, don't change the value and continue
bool is_to_support = is_support_filament(to_idx);
int flushing_volume = 0;
if (is_to_support) {
flushing_volume = Slic3r::g_flush_volume_to_support;
if (from_idx == to_idx) {
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(0));
}
else {
const wxColour& to = m_colours[to_idx];
flushing_volume = calc_flushing_volume(from, to);
if (is_from_support) {
flushing_volume = std::max(Slic3r::g_min_flush_volume_from_support, flushing_volume);
int flushing_volume = 0;
if (is_to_support) {
flushing_volume = Slic3r::g_flush_volume_to_support;
}
else {
const wxColour& to = m_colours[to_idx];
flushing_volume = calc_flushing_volume(from, to);
if (is_from_support) {
flushing_volume = std::max(Slic3r::g_min_flush_volume_from_support, flushing_volume);
}
}
m_matrix[m_number_of_extruders * from_idx + to_idx] = flushing_volume;
flushing_volume = int(flushing_volume * get_flush_multiplier());
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(flushing_volume));
}
m_matrix[m_number_of_extruders * from_idx + to_idx] = flushing_volume;
flushing_volume = int(flushing_volume * get_flush_multiplier());
edit_boxes[to_idx][from_idx]->SetValue(std::to_string(flushing_volume));
}
}
@ -707,6 +808,8 @@ void WipingPanel::msw_rescale()
// Reads values from the (advanced) wiping matrix:
std::vector<float> WipingPanel::read_matrix_values() {
if (!m_advanced)
fill_in_matrix();
std::vector<float> output;
for (unsigned int i=0;i<m_number_of_extruders;++i) {
for (unsigned int j=0;j<m_number_of_extruders;++j) {
@ -722,4 +825,59 @@ std::vector<float> WipingPanel::read_matrix_values() {
}
}
return output;
}
}
// Reads values from simple mode to save them for next time:
std::vector<float> WipingPanel::read_extruders_values() {
std::vector<float> output;
for (unsigned int i=0;i<m_number_of_extruders;++i) {
output.push_back(m_old[i]->GetValue());
output.push_back(m_new[i]->GetValue());
}
return output;
}
// This updates the "advanced" matrix based on values from "simple" mode
void WipingPanel::fill_in_matrix() {
for (unsigned i=0;i<m_number_of_extruders;++i) {
for (unsigned j=0;j<m_number_of_extruders;++j) {
if (i==j) continue;
edit_boxes[j][i]->SetValue(wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue()));
}
}
}
// Function to check if simple and advanced settings are matching
bool WipingPanel::advanced_matches_simple() {
for (unsigned i=0;i<m_number_of_extruders;++i) {
for (unsigned j=0;j<m_number_of_extruders;++j) {
if (i==j) continue;
if (edit_boxes[j][i]->GetValue() != (wxString("")<< (m_old[i]->GetValue() + m_new[j]->GetValue())))
return false;
}
}
return true;
}
// Switches the dialog from simple to advanced mode and vice versa
void WipingPanel::toggle_advanced(bool user_action) {
if (user_action)
m_advanced = !m_advanced; // user demands a change -> toggle
else {
// BBS: show advanced mode by default
//m_advanced = !advanced_matches_simple(); // if called from constructor, show what is appropriate
m_advanced = true;
}
(m_advanced ? m_page_advanced : m_page_simple)->Show();
(!m_advanced ? m_page_advanced : m_page_simple)->Hide();
if (m_advanced)
if (user_action) fill_in_matrix(); // otherwise keep values loaded from config
m_sizer->Layout();
Refresh();
}

View file

@ -48,9 +48,12 @@ public:
WipingPanel(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours, Button* calc_button,
int extra_flush_volume, float flush_multiplier);
std::vector<float> read_matrix_values();
std::vector<float> read_extruders_values();
void toggle_advanced(bool user_action = false);
void create_panels(wxWindow* parent, const int num);
void calc_flushing_volumes();
void msw_rescale();
wxBoxSizer* create_calc_btn_sizer(wxWindow* parent);
float get_flush_multiplier()
{
@ -61,14 +64,25 @@ public:
}
private:
void fill_in_matrix();
bool advanced_matches_simple();
int calc_flushing_volume(const wxColour& from, const wxColour& to);
void update_warning_texts();
std::vector<wxSpinCtrl*> m_old;
std::vector<wxSpinCtrl*> m_new;
std::vector<std::vector<wxTextCtrl*>> edit_boxes;
std::vector<wxColour> m_colours;
unsigned int m_number_of_extruders = 0;
bool m_advanced = false;
wxPanel* m_page_simple = nullptr;
wxPanel* m_page_advanced = nullptr;
wxPanel* header_line_panel = nullptr;
wxBoxSizer* m_sizer = nullptr;
wxBoxSizer* m_sizer = nullptr;
wxBoxSizer* m_sizer_simple = nullptr;
wxBoxSizer* m_sizer_advanced = nullptr;
wxGridSizer* m_gridsizer_advanced = nullptr;
wxButton* m_widget_button = nullptr;
Label* m_tip_message_label = nullptr;
std::vector<wxButton *> icon_list1;
@ -93,6 +107,7 @@ public:
WipingDialog(wxWindow* parent, const std::vector<float>& matrix, const std::vector<float>& extruders, const std::vector<std::string>& extruder_colours,
int extra_flush_volume, float flush_multiplier);
std::vector<float> get_matrix() const { return m_output_matrix; }
std::vector<float> get_extruders() const { return m_output_extruders; }
wxBoxSizer* create_btn_sizer(long flags);
float get_flush_multiplier()
@ -108,6 +123,7 @@ public:
private:
WipingPanel* m_panel_wiping = nullptr;
std::vector<float> m_output_matrix;
std::vector<float> m_output_extruders;
std::unordered_map<int, Button *> m_button_list;
};

View file

@ -22,15 +22,16 @@
#ifndef __linux__
// msw_menuitem_bitmaps is used for MSW and OSX
static std::map<int, std::string> msw_menuitem_bitmaps;
void sys_color_changed_menu(wxMenu* menu)
#ifdef __WXMSW__
void msw_rescale_menu(wxMenu* menu)
{
struct update_icons {
static void run(wxMenuItem* item) {
const auto it = msw_menuitem_bitmaps.find(item->GetId());
if (it != msw_menuitem_bitmaps.end()) {
const wxBitmapBundle* item_icon = get_bmp_bundle(it->second);
if (item_icon->IsOk())
item->SetBitmap(*item_icon);
const wxBitmap& item_icon = create_menu_bitmap(it->second);
if (item_icon.IsOk())
item->SetBitmap(item_icon);
}
if (item->IsSubMenu())
for (wxMenuItem *sub_item : item->GetSubMenu()->GetMenuItems())
@ -41,24 +42,35 @@ void sys_color_changed_menu(wxMenu* menu)
for (wxMenuItem *item : menu->GetMenuItems())
update_icons::run(item);
}
#endif /* no __linux__ */
#endif /* __WXMSW__ */
#endif /* no __WXGTK__ */
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, wxBitmapBundle* icon, wxEvtHandler* event_handler,
std::function<void(wxCommandEvent& event)> cb, const wxBitmap& 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 && icon->IsOk()) {
item->SetBitmap(*icon);
if (icon.IsOk()) {
item->SetBitmap(icon);
}
if (insert_pos == wxNOT_FOUND)
menu->Append(item);
@ -87,12 +99,12 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
if (id == wxID_ANY)
id = wxNewId();
wxBitmapBundle* bmp = icon.empty() ? nullptr : get_bmp_bundle(icon);
#ifndef __linux__
if (bmp && bmp->IsOk())
const wxBitmap& bmp = !icon.empty() ? create_menu_bitmap(icon) : wxNullBitmap; // FIXME: pass window ptr
//#ifdef __WXMSW__
#ifndef __WXGTK__
if (bmp.IsOk())
msw_menuitem_bitmaps[id] = icon;
#endif /* no __linux__ */
#endif /* __WXMSW__ */
return append_menu_item(menu, id, string, description, cb, bmp, event_handler, cb_condition, parent, insert_pos);
}
@ -105,11 +117,11 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
wxMenuItem* item = new wxMenuItem(menu, id, string, description, wxITEM_NORMAL, sub_menu);
if (!icon.empty()) {
item->SetBitmap(*get_bmp_bundle(icon));
#ifndef __linux__
item->SetBitmap(create_menu_bitmap(icon)); // FIXME: pass window ptr
//#ifdef __WXMSW__
#ifndef __WXGTK__
msw_menuitem_bitmaps[id] = icon;
#endif // no __linux__
#endif /* __WXMSW__ */
}
menu->Append(item);
@ -406,49 +418,9 @@ int mode_icon_px_size()
#endif
}
#ifdef __WXGTK2__
static int scale()
wxBitmap create_menu_bitmap(const std::string& bmp_name)
{
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*/)
{
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;
#ifdef __WXGTK2__
return cache.mkclear_bndl(width * scale(), height * scale());
#else
return cache.mkclear_bndl(width, height);
#endif // __WXGTK2__
}
wxBitmapBundle* get_solid_bmp_bundle(int width, int height, const std::string& color )
{
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());
#endif // __WXGTK2__
return create_scaled_bitmap(bmp_name, nullptr, 16, false, "", true);
}
// win is used to get a correct em_unit value
@ -462,10 +434,6 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in,
const bool menu_bitmap/* = false*/,
const bool resize/* = false*/)
{
#ifdef __WXGTK2__
px_cnt *= scale();
#endif // __WXGTK2__
static Slic3r::GUI::BitmapCache cache;
unsigned int width = 0;
@ -532,46 +500,54 @@ wxBitmap* get_default_extruder_color_icon(bool thin_icon/* = false*/)
return bitmap;
}
std::vector<wxBitmapBundle*> get_extruder_color_icons(bool thin_icon/* = false*/)
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
{
// Create the bitmap with color bars.
std::vector<wxBitmapBundle*> bmps;
std::vector<wxBitmap*> 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 ? 2 : 4.4) * em);
const int icon_height = lround(2 * em);
int index = 0;
for (const std::string &color : colors) {
for (const std::string &color : colors)
{
auto label = std::to_string(++index);
bmps.emplace_back(get_extruder_color_icon(color, label, thin_icon ? 16 : 36, 16));
bmps.push_back(get_extruder_color_icon(color, label, icon_width, icon_height));
}
return bmps;
}
wxBitmapBundle *get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height)
wxBitmap *get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height)
{
static Slic3r::GUI::BitmapCache bmp_cache;
std::string bitmap_key = color + "-h" + std::to_string(icon_height) + "-w" + std::to_string(icon_width) + "-i" + label;
wxBitmapBundle *bmpbndl = bmp_cache.find_bndl(bitmap_key);
if (bmpbndl == nullptr) {
wxBitmap *bitmap = bmp_cache.find(bitmap_key);
if (bitmap == nullptr) {
// Paint the color icon.
// Slic3r::GUI::BitmapCache::parse_color(color, rgb);
// there is no neede to scale created solid bitmap
wxColor clr(color);
bmpbndl = bmp_cache.insert_bndl(bitmap_key, wxBitmap(icon_width, icon_height));
bitmap = bmp_cache.insert(bitmap_key, wxBitmap(icon_width, icon_height));
#ifndef __WXMSW__
wxMemoryDC dc;
#else
wxClientDC cdc((wxWindow *) Slic3r::GUI::wxGetApp().mainframe);
wxMemoryDC dc(&cdc);
#endif
wxBitmap bmp = bmpbndl->GetBitmap(wxSize(icon_width, icon_height));
dc.SetFont(::Label::Body_12);
dc.SelectObject(bmp);
dc.SelectObject(*bitmap);
if (clr.Alpha() == 0) {
int size = icon_height * 2;
static wxBitmap transparent = *Slic3r::GUI::BitmapCache().load_svg("transparent", size, size);
@ -596,9 +572,8 @@ wxBitmapBundle *get_extruder_color_icon(std::string color, std::string label, in
dc.SetTextForeground(clr.GetLuminance() < 0.51 ? *wxWHITE : *wxBLACK);
dc.DrawText(label, (icon_width - size.x) / 2, (icon_height - size.y) / 2);
dc.SelectObject(wxNullBitmap);
bmpbndl = bmp_cache.insert_bndl(bitmap_key, bmp);
}
return bmpbndl;
return bitmap;
}
@ -609,7 +584,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
wxSize size/* = wxDefaultSize*/,
bool use_thin_icon/* = false*/)
{
std::vector<wxBitmapBundle*> icons = get_extruder_color_icons(use_thin_icon);
std::vector<wxBitmap*> 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);
@ -635,7 +610,7 @@ void apply_extruder_selector(Slic3r::GUI::BitmapComboBox** ctrl,
int i = 0;
wxString str = _(L("Extruder"));
for (wxBitmapBundle* bmp : icons) {
for (wxBitmap* bmp : icons) {
if (i == 0) {
if (!first_item.empty())
(*ctrl)->Append(_(first_item), *bmp);
@ -669,7 +644,7 @@ LockButton::LockButton( wxWindow *parent,
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
SetBitmap(m_bmp_lock_open.bmp());
SetBitmapDisabled(m_bmp_lock_open.bmp());
SetBitmapCurrent(m_bmp_lock_closed_f.bmp());
SetBitmapHover(m_bmp_lock_closed_f.bmp());
//button events
Bind(wxEVT_BUTTON, &LockButton::OnButton, this);
@ -692,14 +667,12 @@ void LockButton::SetLock(bool lock)
update_button_bitmaps();
}
void LockButton::sys_color_changed()
void LockButton::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();
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();
update_button_bitmaps();
}
@ -708,7 +681,7 @@ void LockButton::update_button_bitmaps()
{
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
SetBitmap(m_is_pushed ? m_bmp_lock_closed.bmp() : m_bmp_lock_open.bmp());
SetBitmapCurrent(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
SetBitmapHover(m_is_pushed ? m_bmp_lock_closed_f.bmp() : m_bmp_lock_open_f.bmp());
Refresh();
Update();
@ -735,7 +708,7 @@ ModeButton::ModeButton( wxWindow* parent,
const wxString& mode/* = wxEmptyString*/,
const std::string& icon_name/* = ""*/,
int px_cnt/* = 16*/) :
ScalableButton(parent, wxID_ANY, icon_name, mode, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT, px_cnt)
ScalableButton(parent, wxID_ANY, ScalableBitmap(parent, icon_name, px_cnt), mode, wxBU_EXACTFIT)
{
Init(mode);
}
@ -844,10 +817,11 @@ void ModeSizer::set_items_border(int border)
item->SetBorder(border);
}
void ModeSizer::sys_color_changed()
void ModeSizer::msw_rescale()
{
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]->sys_color_changed();
m_mode_btns[m]->msw_rescale();
}
// ----------------------------------------------------------------------------
@ -884,35 +858,51 @@ ScalableBitmap::ScalableBitmap( wxWindow *parent,
const std::string& icon_name/* = ""*/,
const int px_cnt/* = 16*/,
const bool grayscale/* = false*/,
const bool resize/* = false*/,
const bool use_legacy_bmp/* = false*/):
m_parent(parent), m_icon_name(icon_name), m_legacy_bmp(use_legacy_bmp),
const bool resize/* = false*/):
m_parent(parent), m_icon_name(icon_name),
m_px_cnt(px_cnt), m_grayscale(grayscale), m_resize(resize) // BBS: support resize by fill border
{
// Orca: there is currently an issue causing the advanced SwitchButton to not scale properly
// when using get_bmp_bundle. This allows for the older method of getting a scaled bitmap to be
// used in this edge case while the underlying issue is determined.
if (m_legacy_bmp) {
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, m_grayscale, std::string(), false, resize);
if (px_cnt == 0) {
m_px_cnt = GetHeight(); // scale
unsigned int height = (unsigned int) (parent->FromDIP(m_px_cnt) + 0.5f);
if (height != GetHeight())
sys_color_changed();
}
} else {
m_bmp = *get_bmp_bundle(icon_name, px_cnt);
m_bmp = create_scaled_bitmap(icon_name, parent, px_cnt, m_grayscale, std::string(), false, resize);
if (px_cnt == 0) {
m_px_cnt = m_bmp.GetHeight(); // scale
unsigned int height = (unsigned int) (parent->FromDIP(m_px_cnt) + 0.5f);
if (height != GetBmpHeight())
msw_rescale();
}
}
void ScalableBitmap::sys_color_changed()
wxSize ScalableBitmap::GetBmpSize() const
{
#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()
{
if (m_legacy_bmp) {
// BBS: support resize by fill border
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt, m_grayscale, std::string(), false, m_resize);
} else
m_bmp = *get_bmp_bundle(m_icon_name, m_px_cnt);
m_bmp = create_scaled_bitmap(m_icon_name, m_parent, m_px_cnt, m_grayscale, std::string(), false, m_resize);
}
// ----------------------------------------------------------------------------
@ -926,9 +916,11 @@ 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))
{
@ -937,7 +929,9 @@ ScalableButton::ScalableButton( wxWindow * parent,
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
if (!icon_name.empty()) {
SetBitmap(*get_bmp_bundle(icon_name, m_px_cnt));
SetBitmap(create_scaled_bitmap(icon_name, parent, m_px_cnt));
if (m_use_default_disabled_bitmap)
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
if (!label.empty())
SetBitmapMargins(int(0.5* em_unit(parent)), 0);
}
@ -979,12 +973,13 @@ bool ScalableButton::SetBitmap_(const std::string& bmp_name)
if (m_current_icon_name.empty())
return false;
wxBitmapBundle bmp = *get_bmp_bundle(m_current_icon_name, m_px_cnt);
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
SetBitmap(bmp);
SetBitmapCurrent(bmp);
SetBitmapPressed(bmp);
SetBitmapFocus(bmp);
SetBitmapDisabled(bmp);
if (m_use_default_disabled_bitmap)
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
return true;
}
@ -1003,22 +998,38 @@ int ScalableButton::GetBitmapHeight()
#endif
}
void ScalableButton::sys_color_changed()
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()
{
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
if (!m_current_icon_name.empty()) {
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
SetBitmap(bmp);
// BBS: why disappear on hover? why current HBITMAP differ from other
//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));
}
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);
if (m_width > 0 || m_height>0)
{
const int em = em_unit(m_parent);
wxSize size(m_width * em, m_height * em);
SetMinSize(size);
}
}
// ----------------------------------------------------------------------------
// BlinkingBitmap
// ----------------------------------------------------------------------------
@ -1029,6 +1040,13 @@ 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);

View file

@ -18,17 +18,14 @@
#include "Widgets/PopupWindow.hpp"
#ifndef __linux__
void sys_color_changed_menu(wxMenu* menu);
#else
inline void sys_color_changed_menu(wxMenu* /* menu */) {}
#endif // no __linux__
[[deprecated("Function renamed to sys_color_changed_menu. This function now redirects to sys_color_changed_menu")]]
inline void msw_rescale_menu(wxMenu* menu) { sys_color_changed_menu(menu); }
#ifdef __WXMSW__
void msw_rescale_menu(wxMenu* menu);
#else /* __WXMSW__ */
inline void msw_rescale_menu(wxMenu* /* menu */) {}
#endif /* __WXMSW__ */
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
std::function<void(wxCommandEvent& event)> cb, wxBitmapBundle* icon, wxEvtHandler* event_handler = nullptr,
std::function<void(wxCommandEvent& event)> cb, const wxBitmap& 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,
@ -55,9 +52,7 @@ void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<
int em_unit(wxWindow* win);
int mode_icon_px_size();
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_menu_bitmap(const std::string& bmp_name);
// BBS: support resize by fill border
#if 1
@ -71,8 +66,8 @@ wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullp
#endif
wxBitmap* get_default_extruder_color_icon(bool thin_icon = false);
std::vector<wxBitmapBundle *> get_extruder_color_icons(bool thin_icon = false);
wxBitmapBundle * get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height);
std::vector<wxBitmap *> get_extruder_color_icons(bool thin_icon = false);
wxBitmap * get_extruder_color_icon(std::string color, std::string label, int icon_width, int icon_height);
namespace Slic3r {
namespace GUI {
@ -145,17 +140,6 @@ public:
void SetItemsCnt(int cnt) { m_cnt_open_items = cnt; }
};
inline wxSize get_preferred_size(const wxBitmapBundle& bmp, wxWindow* parent)
{
if (!bmp.IsOk())
return wxSize(0, 0);
#ifdef __WIN32__
return bmp.GetPreferredBitmapSizeFor(parent);
#else
return bmp.GetDefaultSize();
#endif
}
// ----------------------------------------------------------------------------
// ScalableBitmap
@ -167,42 +151,31 @@ public:
ScalableBitmap() {};
ScalableBitmap( wxWindow *parent,
const std::string& icon_name = "",
const int px_cnt = 16,
const int px_cnt = 16,
const bool grayscale = false,
const bool resize = false, // BBS: support resize by fill border
const bool use_legacy_bmp = false);
const bool resize = false); // BBS: support resize by fill border
~ScalableBitmap() {}
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
wxSize GetBmpSize() const;
int GetBmpWidth() const;
int GetBmpHeight() const;
const wxBitmapBundle& bmp() const { return m_bmp; }
wxBitmapBundle& bmp() { return m_bmp; }
wxBitmap get_bitmap() const { 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; }
void msw_rescale();
wxSize GetSize() const {
#ifdef __WIN32__
return m_bmp.GetPreferredBitmapSizeFor(m_parent);
#else
return m_bmp.GetDefaultSize();
#endif
}
int GetWidth() const { return GetSize().GetWidth(); }
int GetHeight() const { return GetSize().GetHeight(); }
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;}
private:
wxWindow* m_parent{ nullptr };
wxBitmapBundle m_bmp = wxBitmapBundle();
wxBitmap m_bmp = wxBitmap();
std::string m_icon_name = "";
int m_px_cnt {16};
bool m_grayscale{ false };
bool m_resize{ false };
bool m_legacy_bmp{ false };
};
@ -229,9 +202,7 @@ public:
void enable() { m_disabled = false; }
void disable() { m_disabled = true; }
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
void msw_rescale();
protected:
void update_button_bitmaps();
@ -263,6 +234,7 @@ 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(
@ -278,10 +250,9 @@ public:
bool SetBitmap_(const std::string& bmp_name);
void SetBitmapDisabled_(const ScalableBitmap &bmp);
int GetBitmapHeight();
void UseDefaultBitmapDisabled();
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
void msw_rescale();
private:
wxWindow* m_parent { nullptr };
@ -290,6 +261,8 @@ 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};
@ -355,9 +328,7 @@ public:
void set_items_flag(int flag);
void set_items_border(int border);
[[deprecated("Function renamed to sys_color_changed. This function now redirects to sys_color_changed")]]
inline void msw_rescale() { sys_color_changed(); }
void sys_color_changed();
void msw_rescale();
const std::vector<ModeButton*>& get_btns() { return m_mode_btns; }
private:
@ -405,11 +376,12 @@ public:
~BlinkingBitmap() {}
void msw_rescale();
void invalidate();
void activate();
void blink();
const wxBitmapBundle& get_bmp() const { return bmp.bmp(); }
const wxBitmap& get_bmp() const { return bmp.bmp(); }
private:
ScalableBitmap bmp;