From cfa7802a8ae5a8390aa478cd62dd5126ee299b49 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Thu, 18 Apr 2019 17:21:46 +0200 Subject: [PATCH] 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(); } };