Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_selection_rectangle

This commit is contained in:
Enrico Turri 2019-04-24 16:08:08 +02:00
commit 8b77a4c717
3 changed files with 21 additions and 8 deletions

View file

@ -18,6 +18,7 @@
#include <wx/dataview.h> #include <wx/dataview.h>
#include <wx/notebook.h> #include <wx/notebook.h>
#include <wx/display.h> #include <wx/display.h>
#include <wx/filefn.h>
#include <wx/debug.h> #include <wx/debug.h>
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
@ -81,11 +82,17 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
for (const auto &model : models) { for (const auto &model : models) {
if (! filter(model)) { continue; } 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); auto *title = new wxStaticText(this, wxID_ANY, model.name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
title->SetFont(font_name); 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); title->Wrap(wrap_width);
current_row_width += wrap_width; current_row_width += wrap_width;
@ -647,7 +654,7 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
SetMinSize(bg.GetSize()); SetMinSize(bg.GetSize());
const wxSize size = GetTextExtent("m"); const wxSize size = GetTextExtent("m");
em = size.x; em_w = size.x;
em_h = size.y; em_h = size.y;
// Add logo bitmap. // Add logo bitmap.
@ -775,7 +782,7 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
unsigned y = 0; unsigned y = 0;
for (size_t i = 0; i < items.size(); i++) { for (size_t i = 0; i < items.size(); i++) {
const Item& item = items[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) { if (i == item_active || item_hover >= 0 && i == (size_t)item_hover) {
dc.DrawBitmap(bullet_blue, x, y + yoff_icon, false); dc.DrawBitmap(bullet_blue, x, y + yoff_icon, false);
@ -783,7 +790,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_black, x, y + yoff_icon, false); }
else if (i > item_active) { dc.DrawBitmap(bullet_white, 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); const auto text_size = dc.GetTextExtent(item.label);
dc.DrawText(item.label, x, y + yoff_text); dc.DrawText(item.label, x, y + yoff_text);
@ -794,6 +801,7 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
if (GetMinSize().x < index_width) { if (GetMinSize().x < index_width) {
CallAfter([this, index_width]() { CallAfter([this, index_width]() {
SetMinSize(wxSize(index_width, GetMinSize().y)); SetMinSize(wxSize(index_width, GetMinSize().y));
Refresh();
}); });
} }
} }
@ -1073,7 +1081,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
9*disp_rect.width / 10, 9*disp_rect.width / 10,
9*disp_rect.height / 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) { if (width_hint < window_rect.width) {
window_rect.x += (window_rect.width - width_hint) / 2; window_rect.x += (window_rect.width - width_hint) / 2;
window_rect.width = width_hint; window_rect.width = width_hint;

View file

@ -211,6 +211,7 @@ public:
void clear(); void clear();
int em() const { return em_w; }
private: private:
struct Item struct Item
{ {
@ -221,7 +222,7 @@ private:
bool operator==(ConfigWizardPage *page) const { return this->page == page; } bool operator==(ConfigWizardPage *page) const { return this->page == page; }
}; };
int em; int em_w;
int em_h; int em_h;
const wxBitmap bg; const wxBitmap bg;
@ -234,7 +235,7 @@ private:
ssize_t item_hover; ssize_t item_hover;
size_t last_page; 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_paint(wxPaintEvent &evt);
void on_mouse_move(wxMouseEvent &evt); void on_mouse_move(wxMouseEvent &evt);
@ -286,6 +287,8 @@ struct ConfigWizard::priv
void on_custom_setup(bool custom_wanted); void on_custom_setup(bool custom_wanted);
void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater); void apply_config(AppConfig *app_config, PresetBundle *preset_bundle, const PresetUpdater *updater);
int em() const { return index->em(); }
}; };

View file

@ -139,6 +139,8 @@ public:
bool checked_tab(Tab* tab); bool checked_tab(Tab* tab);
void load_current_presets(); void load_current_presets();
wxString current_language_code() { return m_wxLocale != nullptr ? m_wxLocale->GetCanonicalName() : wxString("en_US"); }
virtual bool OnExceptionInMainLoop(); virtual bool OnExceptionInMainLoop();
#ifdef __APPLE__ #ifdef __APPLE__