FIX: [STUDIO-1360] media file image scale on macOS
Change-Id: I2a25ff53b9beb08a90aca07adad7accc69b6d2ed
This commit is contained in:
parent
cb83284b24
commit
64ae3c3a56
|
@ -72,7 +72,7 @@ void ImageGrid::SetFileSystem(boost::shared_ptr<PrinterFileSystem> file_sys)
|
|||
UpdateFileSystem();
|
||||
}
|
||||
|
||||
void ImageGrid::SetStatus(wxBitmap const & icon, wxString const &msg)
|
||||
void ImageGrid::SetStatus(ScalableBitmap const & icon, wxString const &msg)
|
||||
{
|
||||
int code = m_file_sys ? m_file_sys->GetLastError() : 1;
|
||||
m_status_icon = icon;
|
||||
|
@ -475,10 +475,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, 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);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
void SetFileSystem(boost::shared_ptr<PrinterFileSystem> file_sys);
|
||||
|
||||
void SetStatus(wxBitmap const & icon, wxString const &msg);
|
||||
void SetStatus(ScalableBitmap const & icon, wxString const &msg);
|
||||
|
||||
boost::shared_ptr<PrinterFileSystem> GetFileSystem() { return m_file_sys; }
|
||||
|
||||
|
@ -93,7 +93,7 @@ protected:
|
|||
|
||||
private:
|
||||
boost::shared_ptr<PrinterFileSystem> m_file_sys;
|
||||
wxBitmap m_status_icon;
|
||||
ScalableBitmap m_status_icon;
|
||||
wxString m_status_msg;
|
||||
|
||||
ScalableBitmap m_checked_icon;
|
||||
|
|
|
@ -108,7 +108,7 @@ MediaFilePanel::MediaFilePanel(wxWindow * parent)
|
|||
sizer->Add(top_sizer, 0, wxEXPAND);
|
||||
|
||||
m_image_grid = new ImageGrid(this);
|
||||
m_image_grid->SetStatus(m_bmp_failed.bmp(), _L("No printers."));
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("No printers."));
|
||||
sizer->Add(m_image_grid, 1, wxEXPAND);
|
||||
|
||||
SetSizer(sizer);
|
||||
|
@ -201,9 +201,9 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_button_management->Enable(false);
|
||||
SetSelecting(false);
|
||||
if (m_machine.empty()) {
|
||||
m_image_grid->SetStatus(m_bmp_failed.bmp(), _L("No printers."));
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("No printers."));
|
||||
} else if (!m_supported) {
|
||||
m_image_grid->SetStatus(m_bmp_failed.bmp(), _L("Not supported by this model of printer!"));
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("Not supported by this model of printer!"));
|
||||
} else {
|
||||
boost::shared_ptr<PrinterFileSystem> fs(new PrinterFileSystem);
|
||||
fs->Attached();
|
||||
|
@ -232,14 +232,14 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
boost::shared_ptr fs(wfs.lock());
|
||||
if (m_image_grid->GetFileSystem() != fs) // canceled
|
||||
return;
|
||||
wxBitmap icon;
|
||||
ScalableBitmap icon;
|
||||
wxString msg;
|
||||
switch (e.GetInt()) {
|
||||
case PrinterFileSystem::Initializing: icon = m_bmp_loading.bmp(); msg = _L("Initializing..."); break;
|
||||
case PrinterFileSystem::Connecting: icon = m_bmp_loading.bmp(); msg = _L("Connecting..."); break;
|
||||
case PrinterFileSystem::Failed: icon = m_bmp_failed.bmp(); msg = _L("Connect failed [%d]!"); break;
|
||||
case PrinterFileSystem::ListSyncing: icon = m_bmp_loading.bmp(); msg = _L("Loading file list..."); break;
|
||||
case PrinterFileSystem::ListReady: icon = m_bmp_empty.bmp(); msg = _L("No files"); break;
|
||||
case PrinterFileSystem::Initializing: icon = m_bmp_loading; msg = _L("Initializing..."); break;
|
||||
case PrinterFileSystem::Connecting: icon = m_bmp_loading; msg = _L("Connecting..."); break;
|
||||
case PrinterFileSystem::Failed: icon = m_bmp_failed; msg = _L("Connect failed [%d]!"); break;
|
||||
case PrinterFileSystem::ListSyncing: icon = m_bmp_loading; msg = _L("Loading file list..."); break;
|
||||
case PrinterFileSystem::ListReady: icon = m_bmp_empty; msg = _L("No files"); break;
|
||||
}
|
||||
if (fs->GetCount() == 0)
|
||||
m_image_grid->SetStatus(icon, msg);
|
||||
|
@ -311,11 +311,11 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
|||
return;
|
||||
}
|
||||
if (m_lan_mode ) { // not support tutk
|
||||
m_image_grid->SetStatus(m_bmp_failed.bmp(), _L("Not accessible in LAN-only mode!"));
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("Not accessible in LAN-only mode!"));
|
||||
return;
|
||||
}
|
||||
if (!m_tutk_support) { // not support tutk
|
||||
m_image_grid->SetStatus(m_bmp_failed.bmp(), _L("Missing LAN ip of printer!"));
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("Missing LAN ip of printer!"));
|
||||
return;
|
||||
}
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
|
@ -329,7 +329,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
|||
if (boost::algorithm::starts_with(url, "bambu:///"))
|
||||
fs->SetUrl(url);
|
||||
else
|
||||
m_image_grid->SetStatus(m_bmp_failed.bmp(), url.empty() ? _L("Network unreachable") : from_u8(url));
|
||||
m_image_grid->SetStatus(m_bmp_failed, url.empty() ? _L("Network unreachable") : from_u8(url));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -34,8 +34,12 @@ struct StaticBambuLib : BambuLib {
|
|||
PrinterFileSystem::PrinterFileSystem()
|
||||
: BambuLib(StaticBambuLib::get())
|
||||
{
|
||||
if (!default_thumbnail.IsOk())
|
||||
if (!default_thumbnail.IsOk()) {
|
||||
default_thumbnail = *Slic3r::GUI::BitmapCache().load_svg("printer_file", 0, 0);
|
||||
#ifdef __APPLE__
|
||||
default_thumbnail = wxBitmap(default_thumbnail.ConvertToImage(), -1, 1);
|
||||
#endif
|
||||
}
|
||||
m_session.owner = this;
|
||||
#ifdef PRINTER_FILE_SYSTEM_TEST
|
||||
auto time = wxDateTime::Now();
|
||||
|
|
Loading…
Reference in New Issue