From 5fd2e573a0c4469e4874395528a7c3fa811bdbfc Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 17 Apr 2019 14:56:44 +0200 Subject: [PATCH 1/3] GUI_App: Add a language code getter --- src/slic3r/GUI/GUI_App.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 41805702b..3537f98e4 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -139,6 +139,8 @@ public: bool checked_tab(Tab* tab); void load_current_presets(); + wxString current_language_code() { return m_wxLocale != nullptr ? m_wxLocale->GetCanonicalName() : wxString("en_US"); } + virtual bool OnExceptionInMainLoop(); #ifdef __APPLE__ From cfa7802a8ae5a8390aa478cd62dd5126ee299b49 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 18 Apr 2019 17:21:46 +0200 Subject: [PATCH 2/3] ConfigWizard: Attempt to fix width hint --- src/slic3r/GUI/ConfigWizard.cpp | 9 +++++---- src/slic3r/GUI/ConfigWizard_private.hpp | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 5da320830..0b5d7ffff 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -647,7 +647,7 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent) SetMinSize(bg.GetSize()); const wxSize size = GetTextExtent("m"); - em = size.x; + em_w = size.x; em_h = size.y; // Add logo bitmap. @@ -775,7 +775,7 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) unsigned y = 0; for (size_t i = 0; i < items.size(); i++) { const Item& item = items[i]; - unsigned x = em/2 + item.indent * em; + 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, x, y + yoff_icon, false); @@ -783,7 +783,7 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) else if (i < item_active) { dc.DrawBitmap(bullet_black, x, y + yoff_icon, false); } else if (i > item_active) { dc.DrawBitmap(bullet_white, x, y + yoff_icon, false); } - x += + bullet_w + em/2; + x += + bullet_w + em_w/2; const auto text_size = dc.GetTextExtent(item.label); dc.DrawText(item.label, x, y + yoff_text); @@ -794,6 +794,7 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt) if (GetMinSize().x < index_width) { CallAfter([this, index_width]() { SetMinSize(wxSize(index_width, GetMinSize().y)); + Refresh(); }); } } @@ -1073,7 +1074,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason) 9*disp_rect.width / 10, 9*disp_rect.height / 10); - const int width_hint = p->index->GetSize().GetWidth() + p->page_fff->get_width() + 300; // XXX: magic constant, I found no better solution + const int width_hint = p->index->GetSize().GetWidth() + p->page_fff->get_width() + 30 * p->em(); // XXX: magic constant, I found no better solution if (width_hint < window_rect.width) { window_rect.x += (window_rect.width - width_hint) / 2; window_rect.width = width_hint; diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index df7602adf..792b92015 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -211,6 +211,7 @@ public: void clear(); + int em() const { return em_w; } private: struct Item { @@ -221,7 +222,7 @@ private: bool operator==(ConfigWizardPage *page) const { return this->page == page; } }; - int em; + int em_w; int em_h; const wxBitmap bg; @@ -234,7 +235,7 @@ private: ssize_t item_hover; size_t last_page; - int item_height() const { return std::max(bullet_black.GetSize().GetHeight(), em) + em; } + int item_height() const { return std::max(bullet_black.GetSize().GetHeight(), em_w) + em_w; } void on_paint(wxPaintEvent &evt); void on_mouse_move(wxMouseEvent &evt); @@ -286,6 +287,8 @@ struct ConfigWizard::priv void on_custom_setup(bool custom_wanted); void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater); + + int em() const { return index->em(); } }; From 98c8cef65703c94f8cfbf4ff7f81a5915f6bea61 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Wed, 24 Apr 2019 16:02:49 +0200 Subject: [PATCH 3/3] ConfigWizard: Don't blow up if a printer bitmap is missing --- src/slic3r/GUI/ConfigWizard.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 0b5d7ffff..e0bfccf30 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "libslic3r/Utils.hpp" @@ -81,11 +82,17 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt for (const auto &model : models) { if (! filter(model)) { continue; } - wxBitmap bitmap(GUI::from_u8(Slic3r::var((boost::format("printers/%1%_%2%.png") % vendor.id % model.id).str())), wxBITMAP_TYPE_PNG); + wxBitmap bitmap; + int bitmap_width = 0; + const wxString bitmap_file = GUI::from_u8(Slic3r::var((boost::format("printers/%1%_%2%.png") % vendor.id % model.id).str())); + if (wxFileExists(bitmap_file)) { + bitmap.LoadFile(bitmap_file, wxBITMAP_TYPE_PNG); + bitmap_width = bitmap.GetWidth(); + } auto *title = new wxStaticText(this, wxID_ANY, model.name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); title->SetFont(font_name); - const int wrap_width = std::max((int)MODEL_MIN_WRAP, bitmap.GetWidth()); + const int wrap_width = std::max((int)MODEL_MIN_WRAP, bitmap_width); title->Wrap(wrap_width); current_row_width += wrap_width;