Overrided on_dpi_changed() for some Dialogs:

BedShapeDialog, KBShortcutsDialog, ConfigWizard, Preferences
This commit is contained in:
YuSanka 2019-04-18 02:03:40 +02:00
parent 077321b228
commit e97e8c6af6
13 changed files with 178 additions and 45 deletions

View file

@ -18,6 +18,7 @@ namespace GUI {
void BedShapeDialog::build_dialog(ConfigOptionPoints* default_pt) void BedShapeDialog::build_dialog(ConfigOptionPoints* default_pt)
{ {
SetFont(wxGetApp().normal_font());
m_panel = new BedShapePanel(this); m_panel = new BedShapePanel(this);
m_panel->build_panel(default_pt); m_panel->build_panel(default_pt);
@ -36,6 +37,22 @@ void BedShapeDialog::build_dialog(ConfigOptionPoints* default_pt)
})); }));
} }
void BedShapeDialog::on_dpi_changed(const wxRect &suggested_rect)
{
const int& em = em_unit();
m_panel->m_shape_options_book->SetMinSize(wxSize(25 * em, -1));
for (auto og : m_panel->m_optgroups)
og->rescale();
const wxSize& size = wxSize(50 * em, -1);
SetMinSize(size);
SetSize(size);
Refresh();
}
void BedShapePanel::build_panel(ConfigOptionPoints* default_pt) void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
{ {
// on_change(nullptr); // on_change(nullptr);
@ -125,7 +142,7 @@ ConfigOptionsGroupShp BedShapePanel::init_shape_options_page(wxString title)
ConfigOptionsGroupShp optgroup; ConfigOptionsGroupShp optgroup;
optgroup = std::make_shared<ConfigOptionsGroup>(panel, _(L("Settings"))); optgroup = std::make_shared<ConfigOptionsGroup>(panel, _(L("Settings")));
optgroup->label_width = 10*wxGetApp().em_unit();//100; optgroup->label_width = 10;
optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) { optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
update_shape(); update_shape();
}; };

View file

@ -16,11 +16,8 @@ namespace GUI {
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>; using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class BedShapePanel : public wxPanel class BedShapePanel : public wxPanel
{ {
wxChoicebook* m_shape_options_book;
Bed_2D* m_canvas; Bed_2D* m_canvas;
std::vector <ConfigOptionsGroupShp> m_optgroups;
public: public:
BedShapePanel(wxWindow* parent) : wxPanel(parent, wxID_ANY) {} BedShapePanel(wxWindow* parent) : wxPanel(parent, wxID_ANY) {}
~BedShapePanel() {} ~BedShapePanel() {}
@ -35,18 +32,25 @@ public:
// Returns the resulting bed shape polygon. This value will be stored to the ini file. // Returns the resulting bed shape polygon. This value will be stored to the ini file.
std::vector<Vec2d> GetValue() { return m_canvas->m_bed_shape; } std::vector<Vec2d> GetValue() { return m_canvas->m_bed_shape; }
wxChoicebook* m_shape_options_book;
std::vector <ConfigOptionsGroupShp> m_optgroups;
}; };
class BedShapeDialog : public wxDialog class BedShapeDialog : public DPIDialog
{ {
BedShapePanel* m_panel; BedShapePanel* m_panel;
public: public:
BedShapeDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _(L("Bed Shape")), BedShapeDialog(wxWindow* parent) : DPIDialog(parent, wxID_ANY, _(L("Bed Shape")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {} wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {}
~BedShapeDialog() {} ~BedShapeDialog() {}
void build_dialog(ConfigOptionPoints* default_pt); void build_dialog(ConfigOptionPoints* default_pt);
std::vector<Vec2d> GetValue() { return m_panel->GetValue(); } std::vector<Vec2d> GetValue() { return m_panel->GetValue(); }
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
}; };
} // GUI } // GUI

View file

@ -632,15 +632,21 @@ void PageTemperatures::apply_custom_config(DynamicPrintConfig &config)
ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent) ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
: wxPanel(parent) : wxPanel(parent)
/* #ys_FIXME_delete_after_testing by VK
, bg(GUI::from_u8(Slic3r::var("Slic3r_192px_transparent.png")), wxBITMAP_TYPE_PNG) , bg(GUI::from_u8(Slic3r::var("Slic3r_192px_transparent.png")), wxBITMAP_TYPE_PNG)
, bullet_black(GUI::from_u8(Slic3r::var("bullet_black.png")), wxBITMAP_TYPE_PNG) , bullet_black(GUI::from_u8(Slic3r::var("bullet_black.png")), wxBITMAP_TYPE_PNG)
, bullet_blue(GUI::from_u8(Slic3r::var("bullet_blue.png")), wxBITMAP_TYPE_PNG) , bullet_blue(GUI::from_u8(Slic3r::var("bullet_blue.png")), wxBITMAP_TYPE_PNG)
, bullet_white(GUI::from_u8(Slic3r::var("bullet_white.png")), wxBITMAP_TYPE_PNG) , bullet_white(GUI::from_u8(Slic3r::var("bullet_white.png")), wxBITMAP_TYPE_PNG)
*/
, bg(PrusaBitmap(parent, "Slic3r_192px_transparent.png", 192))
, bullet_black(PrusaBitmap(parent, "bullet_black.png"))
, bullet_blue(PrusaBitmap(parent, "bullet_blue.png"))
, bullet_white(PrusaBitmap(parent, "bullet_white.png"))
, item_active(0) , item_active(0)
, item_hover(-1) , item_hover(-1)
, last_page((size_t)-1) , last_page((size_t)-1)
{ {
SetMinSize(bg.GetSize()); SetMinSize(bg.bmp().GetSize());
const wxSize size = GetTextExtent("m"); const wxSize size = GetTextExtent("m");
em = size.x; em = size.x;
@ -652,7 +658,10 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
// In some cases it didn't work at all. And so wxStaticBitmap is used here instead, // In some cases it didn't work at all. And so wxStaticBitmap is used here instead,
// because it has all the platform quirks figured out. // because it has all the platform quirks figured out.
auto *sizer = new wxBoxSizer(wxVERTICAL); auto *sizer = new wxBoxSizer(wxVERTICAL);
/* #ys_FIXME_delete_after_testing by VK
auto *logo = new wxStaticBitmap(this, wxID_ANY, bg); auto *logo = new wxStaticBitmap(this, wxID_ANY, bg);
*/
logo = new wxStaticBitmap(this, wxID_ANY, bg.bmp());
sizer->AddStretchSpacer(); sizer->AddStretchSpacer();
sizer->Add(logo); sizer->Add(logo);
SetSizer(sizer); SetSizer(sizer);
@ -760,8 +769,12 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
wxPaintDC dc(this); wxPaintDC dc(this);
/* #ys_FIXME_delete_after_testing by VK
const auto bullet_w = bullet_black.GetSize().GetWidth(); const auto bullet_w = bullet_black.GetSize().GetWidth();
const auto bullet_h = bullet_black.GetSize().GetHeight(); const auto bullet_h = bullet_black.GetSize().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_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 yoff_text = bullet_h > em_h ? (bullet_h - em_h) / 2 : 0;
const int yinc = item_height(); const int yinc = item_height();
@ -772,10 +785,16 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
unsigned x = em/2 + item.indent * em; unsigned x = em/2 + item.indent * em;
if (i == item_active || item_hover >= 0 && i == (size_t)item_hover) { if (i == item_active || item_hover >= 0 && i == (size_t)item_hover) {
/*#ys_FIXME_delete_after_testing by VK
dc.DrawBitmap(bullet_blue, x, y + yoff_icon, false); dc.DrawBitmap(bullet_blue, 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_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); }
*/
dc.DrawBitmap(bullet_blue.bmp(), 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); }
dc.DrawText(item.label, x + bullet_w + em/2, y + yoff_text); dc.DrawText(item.label, x + bullet_w + em/2, y + yoff_text);
y += yinc; y += yinc;
@ -797,6 +816,18 @@ void ConfigWizardIndex::on_mouse_move(wxMouseEvent &evt)
evt.Skip(); evt.Skip();
} }
void ConfigWizardIndex::rescale()
{
bg.rescale();
SetMinSize(bg.bmp().GetSize());
logo->SetBitmap(bg.bmp());
bullet_black.rescale();
bullet_blue.rescale();
bullet_white.rescale();
Refresh();
}
// priv // priv
@ -971,9 +1002,10 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
// Public // Public
ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason) ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
: wxDialog(parent, wxID_ANY, _(name().ToStdString()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) : DPIDialog(parent, wxID_ANY, _(name().ToStdString()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
, p(new priv(this)) , p(new priv(this))
{ {
this->SetFont(wxGetApp().normal_font());
p->run_reason = reason; p->run_reason = reason;
p->load_vendors(); p->load_vendors();
@ -1117,5 +1149,11 @@ const wxString& ConfigWizard::name(const bool from_menu/* = false*/)
return from_menu ? config_wizard_name_menu : config_wizard_name; return from_menu ? config_wizard_name_menu : config_wizard_name;
} }
void ConfigWizard::on_dpi_changed(const wxRect &suggested_rect)
{
p->index->rescale();
Refresh();
}
} }
} }

View file

@ -5,6 +5,8 @@
#include <wx/dialog.h> #include <wx/dialog.h>
#include "GUI_Utils.hpp"
namespace Slic3r { namespace Slic3r {
class PresetBundle; class PresetBundle;
@ -13,7 +15,7 @@ class PresetUpdater;
namespace GUI { namespace GUI {
class ConfigWizard: public wxDialog class ConfigWizard: public DPIDialog
{ {
public: public:
// Why is the Wizard run // Why is the Wizard run
@ -35,6 +37,10 @@ public:
bool run(PresetBundle *preset_bundle, const PresetUpdater *updater); bool run(PresetBundle *preset_bundle, const PresetUpdater *updater);
static const wxString& name(const bool from_menu = false); static const wxString& name(const bool from_menu = false);
protected:
void on_dpi_changed(const wxRect &suggested_rect) override ;
private: private:
struct priv; struct priv;
std::unique_ptr<priv> p; std::unique_ptr<priv> p;

View file

@ -210,6 +210,7 @@ public:
void go_to(ConfigWizardPage *page); void go_to(ConfigWizardPage *page);
void clear(); void clear();
void rescale();
private: private:
struct Item struct Item
@ -223,18 +224,27 @@ private:
int em; int em;
int em_h; int em_h;
/* #ys_FIXME_delete_after_testing by VK
const wxBitmap bg; const wxBitmap bg;
const wxBitmap bullet_black; const wxBitmap bullet_black;
const wxBitmap bullet_blue; const wxBitmap bullet_blue;
const wxBitmap bullet_white; const wxBitmap bullet_white;
*/
PrusaBitmap bg;
PrusaBitmap bullet_black;
PrusaBitmap bullet_blue;
PrusaBitmap bullet_white;
wxStaticBitmap* logo;
std::vector<Item> items; std::vector<Item> items;
size_t item_active; size_t item_active;
ssize_t item_hover; ssize_t item_hover;
size_t last_page; size_t last_page;
/* #ys_FIXME_delete_after_testing by VK
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) + em; }
*/
int item_height() const { return std::max(bullet_black.bmp().GetSize().GetHeight(), em) + em; }
void on_paint(wxPaintEvent &evt); void on_paint(wxPaintEvent &evt);
void on_mouse_move(wxMouseEvent &evt); void on_mouse_move(wxMouseEvent &evt);

View file

@ -325,11 +325,15 @@ void GUI_App::init_fonts()
#endif /*__WXMAC__*/ #endif /*__WXMAC__*/
} }
void GUI_App::scale_default_fonts(const float scale_f) void GUI_App::update_fonts()
{ {
m_small_font = m_small_font.Scaled(scale_f); /* Only normal and bold fonts are used for an application rescale,
m_bold_font = m_bold_font.Scaled(scale_f); * because of under MSW small and normal fonts are the same.
m_normal_font = m_normal_font.Scaled(scale_f); * To avoid same rescaling twice, just fill this values
* from rescaled MainFrame
*/
m_normal_font = mainframe->normal_font();
m_bold_font = mainframe->normal_font().Bold();
} }
void GUI_App::set_label_clr_modified(const wxColour& clr) { void GUI_App::set_label_clr_modified(const wxColour& clr) {

View file

@ -98,7 +98,7 @@ public:
void init_label_colours(); void init_label_colours();
void update_label_colours_from_appconfig(); void update_label_colours_from_appconfig();
void init_fonts(); void init_fonts();
void scale_default_fonts(const float scale_f); void update_fonts();
void set_label_clr_modified(const wxColour& clr); void set_label_clr_modified(const wxColour& clr);
void set_label_clr_sys(const wxColour& clr); void set_label_clr_sys(const wxColour& clr);

View file

@ -10,14 +10,15 @@ namespace Slic3r {
namespace GUI { namespace GUI {
KBShortcutsDialog::KBShortcutsDialog() KBShortcutsDialog::KBShortcutsDialog()
: wxDialog(NULL, wxID_ANY, _(L("Slic3r Prusa Edition - Keyboard Shortcuts")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) : DPIDialog(NULL, wxID_ANY, _(L("Slic3r Prusa Edition - Keyboard Shortcuts")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{ {
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer = new wxBoxSizer(wxVERTICAL);
// logo // logo
const wxBitmap logo_bmp = create_scaled_bitmap(this, "Slic3r_32px.png", 32); m_logo_bmp = PrusaBitmap(this, "Slic3r_32px.png", 32);
// fonts // fonts
wxFont head_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold(); wxFont head_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold();
@ -27,7 +28,7 @@ KBShortcutsDialog::KBShortcutsDialog()
head_font.SetPointSize(12); head_font.SetPointSize(12);
#endif // __WXOSX__ #endif // __WXOSX__
const wxFont& font = wxGetApp().small_font(); const wxFont& font = wxGetApp().normal_font();
const wxFont& bold_font = wxGetApp().bold_font(); const wxFont& bold_font = wxGetApp().bold_font();
fill_shortcuts(); fill_shortcuts();
@ -43,22 +44,25 @@ KBShortcutsDialog::KBShortcutsDialog()
wxBoxSizer* r_sizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* r_sizer = new wxBoxSizer(wxVERTICAL);
main_grid_sizer->Add(r_sizer, 0); main_grid_sizer->Add(r_sizer, 0);
m_head_bitmaps.reserve(m_full_shortcuts.size());
const wxSize topic_size = wxSize(10 * wxGetApp().em_unit(), -1);
for (auto& sc : m_full_shortcuts) for (auto& sc : m_full_shortcuts)
{ {
// auto sizer = sc.first == _(L("Main Shortcuts")) ? l_sizer : r_sizer; auto sizer = sc.second.second == szLeft ? l_sizer : r_sizer;
auto sizer = sc.second.second == 0 ? l_sizer : r_sizer;
wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(hsizer, 0, wxEXPAND | wxTOP | wxBOTTOM, 10); sizer->Add(hsizer, 0, wxEXPAND | wxTOP | wxBOTTOM, 10);
// logo // logo
auto *logo = new wxStaticBitmap(panel, wxID_ANY, logo_bmp); m_head_bitmaps.push_back(new wxStaticBitmap(panel, wxID_ANY, m_logo_bmp.bmp()));
hsizer->Add(logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 15); hsizer->Add(m_head_bitmaps.back(), 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
// head // head
wxStaticText* head = new wxStaticText(panel, wxID_ANY, sc.first, wxDefaultPosition, wxSize(20 * wxGetApp().em_unit(), -1)); wxStaticText* head = new wxStaticText(panel, wxID_ANY, sc.first, wxDefaultPosition, topic_size);
head->SetFont(head_font); head->SetFont(head_font);
hsizer->Add(head, 0, wxALIGN_CENTER_VERTICAL); hsizer->Add(head, 0, wxALIGN_CENTER_VERTICAL);
// Shortcuts list // Shortcuts list
auto grid_sizer = new wxFlexGridSizer(2, 5, 15); auto grid_sizer = new wxFlexGridSizer(2, 5, 15);
sizer->Add(grid_sizer, 0, wxEXPAND | wxLEFT| wxRIGHT, 15); sizer->Add(grid_sizer, 0, wxEXPAND | wxLEFT| wxRIGHT, 15);
@ -121,7 +125,7 @@ void KBShortcutsDialog::fill_shortcuts()
main_shortcuts.push_back(Shortcut("?" ,L("Show keyboard shortcuts list"))); main_shortcuts.push_back(Shortcut("?" ,L("Show keyboard shortcuts list")));
main_shortcuts.push_back(Shortcut(ctrl+"LeftMouse" ,L("Select multiple object/Move multiple object"))); main_shortcuts.push_back(Shortcut(ctrl+"LeftMouse" ,L("Select multiple object/Move multiple object")));
m_full_shortcuts.push_back(std::make_pair( _(L("Main Shortcuts")), std::make_pair(main_shortcuts, 0) )); m_full_shortcuts.push_back(std::make_pair(_(L("Main Shortcuts")), std::make_pair(main_shortcuts, szLeft)));
Shortcuts plater_shortcuts; Shortcuts plater_shortcuts;
@ -146,7 +150,7 @@ void KBShortcutsDialog::fill_shortcuts()
plater_shortcuts.push_back(Shortcut("O", L("Zoom out"))); plater_shortcuts.push_back(Shortcut("O", L("Zoom out")));
plater_shortcuts.push_back(Shortcut("ESC", L("Unselect gizmo, keep object selection"))); plater_shortcuts.push_back(Shortcut("ESC", L("Unselect gizmo, keep object selection")));
m_full_shortcuts.push_back(std::make_pair(_(L("Plater Shortcuts")), std::make_pair(plater_shortcuts, 1))); m_full_shortcuts.push_back(std::make_pair(_(L("Plater Shortcuts")), std::make_pair(plater_shortcuts, szRight)));
// Shortcuts gizmo_shortcuts; // Shortcuts gizmo_shortcuts;
@ -166,7 +170,7 @@ void KBShortcutsDialog::fill_shortcuts()
preview_shortcuts.push_back(Shortcut("U", L("Upper Layer"))); preview_shortcuts.push_back(Shortcut("U", L("Upper Layer")));
preview_shortcuts.push_back(Shortcut("D", L("Lower Layer"))); preview_shortcuts.push_back(Shortcut("D", L("Lower Layer")));
m_full_shortcuts.push_back(std::make_pair( _(L("Preview Shortcuts")), std::make_pair(preview_shortcuts, 0) )); m_full_shortcuts.push_back(std::make_pair(_(L("Preview Shortcuts")), std::make_pair(preview_shortcuts, szLeft)));
Shortcuts layers_slider_shortcuts; Shortcuts layers_slider_shortcuts;
@ -179,7 +183,23 @@ void KBShortcutsDialog::fill_shortcuts()
layers_slider_shortcuts.push_back(Shortcut("+", L("Add color change marker for current layer"))); layers_slider_shortcuts.push_back(Shortcut("+", L("Add color change marker for current layer")));
layers_slider_shortcuts.push_back(Shortcut("-", L("Delete color change marker for current layer"))); layers_slider_shortcuts.push_back(Shortcut("-", L("Delete color change marker for current layer")));
m_full_shortcuts.push_back(std::make_pair( _(L("Layers Slider Shortcuts")), std::make_pair(layers_slider_shortcuts, 1) )); m_full_shortcuts.push_back(std::make_pair(_(L("Layers Slider Shortcuts")), std::make_pair(layers_slider_shortcuts, szRight)));
}
void KBShortcutsDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bmp.rescale();
for (wxStaticBitmap* bmp : m_head_bitmaps)
bmp->SetBitmap(m_logo_bmp.bmp());
const int& em = em_unit();
const wxSize& size = wxSize(85 * em, 75 * em);
SetMinSize(size);
SetSize(size);
Refresh();
} }
void KBShortcutsDialog::onCloseDialog(wxEvent &) void KBShortcutsDialog::onCloseDialog(wxEvent &)

View file

@ -5,24 +5,39 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "GUI_Utils.hpp"
#include "wxExtensions.hpp"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
class KBShortcutsDialog : public wxDialog class KBShortcutsDialog : public DPIDialog/*wxDialog*/
{ {
enum PLACED_SIZER_ID
{
szLeft = 0,
szRight
};
typedef std::pair<std::string, std::string> Shortcut; typedef std::pair<std::string, std::string> Shortcut;
typedef std::vector< Shortcut > Shortcuts; typedef std::vector< Shortcut > Shortcuts;
typedef std::vector< std::pair<wxString, std::pair<Shortcuts, int>> > ShortcutsVec; typedef std::vector< std::pair<wxString, std::pair<Shortcuts, PLACED_SIZER_ID>> > ShortcutsVec;
wxString text_info {wxEmptyString}; wxString text_info {wxEmptyString};
ShortcutsVec m_full_shortcuts; ShortcutsVec m_full_shortcuts;
wxSizer* main_sizer;
PrusaBitmap m_logo_bmp;
std::vector<wxStaticBitmap*> m_head_bitmaps;
public: public:
KBShortcutsDialog(); KBShortcutsDialog();
void fill_shortcuts(); void fill_shortcuts();
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
private: private:
void onCloseDialog(wxEvent &); void onCloseDialog(wxEvent &);
}; };

View file

@ -258,18 +258,16 @@ bool MainFrame::can_delete_all() const
void MainFrame::on_dpi_changed(const wxRect &suggested_rect) void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
{ {
const float old_sc_factor = prev_scale_factor(); // const float old_sc_factor = prev_scale_factor();
const float new_sc_factor = scale_factor(); // const float new_sc_factor = scale_factor();
//
// printf("old_sc_factor: %.2f \n", old_sc_factor);
// printf("new_sc_factor: %.2f\n\n", new_sc_factor);
printf("old_sc_factor: %.2f \n", old_sc_factor); wxGetApp().update_fonts();
printf("new_sc_factor: %.2f\n\n", new_sc_factor);
const float relative_scale_factor = new_sc_factor / old_sc_factor;
wxGetApp().scale_default_fonts(relative_scale_factor);
// _strange_ workaround for correct em_unit calculation // _strange_ workaround for correct em_unit calculation
const int new_em_unit = new_sc_factor * 10;//int(relative_scale_factor*wxGetApp().em_unit()); const int new_em_unit = scale_factor() * 10;
wxGetApp().set_em_unit(std::max<size_t>(10, new_em_unit)); wxGetApp().set_em_unit(std::max<size_t>(10, new_em_unit));
/* Load default preset bitmaps before a tabpanel initialization, /* Load default preset bitmaps before a tabpanel initialization,

View file

@ -500,6 +500,8 @@ void ConfigOptionsGroup::rescale()
for (const auto& field : m_fields) for (const auto& field : m_fields)
field.second->rescale(); field.second->rescale();
const int em = em_unit(parent());
// rescale width of label column // rescale width of label column
if (!m_options_mode.empty() && label_width > 1) if (!m_options_mode.empty() && label_width > 1)
{ {
@ -514,7 +516,7 @@ void ConfigOptionsGroup::rescale()
{ {
auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow()); auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow());
if (label != nullptr) { if (label != nullptr) {
label->SetMinSize(wxSize(label_width*wxGetApp().em_unit(), -1)); label->SetMinSize(wxSize(label_width*em, -1));
} }
} }
else if (label_item->IsSizer()) // case when we nave near_label_widget else if (label_item->IsSizer()) // case when we nave near_label_widget
@ -524,7 +526,7 @@ void ConfigOptionsGroup::rescale()
{ {
auto label = dynamic_cast<wxStaticText*>(l_item->GetWindow()); auto label = dynamic_cast<wxStaticText*>(l_item->GetWindow());
if (label != nullptr) { if (label != nullptr) {
label->SetMinSize(wxSize(label_width*wxGetApp().em_unit(), -1)); label->SetMinSize(wxSize(label_width*em, -1));
} }
} }
} }

View file

@ -7,7 +7,9 @@ namespace Slic3r {
namespace GUI { namespace GUI {
PreferencesDialog::PreferencesDialog(wxWindow* parent) : PreferencesDialog::PreferencesDialog(wxWindow* parent) :
wxDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition, wxDefaultSize) { DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
build(); build();
} }
@ -15,7 +17,7 @@ void PreferencesDialog::build()
{ {
auto app_config = get_app_config(); auto app_config = get_app_config();
m_optgroup = std::make_shared<ConfigOptionsGroup>(this, _(L("General"))); m_optgroup = std::make_shared<ConfigOptionsGroup>(this, _(L("General")));
m_optgroup->label_width = 40; //400; m_optgroup->label_width = 40;
m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value){ m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value){
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0"; m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
}; };
@ -140,5 +142,18 @@ void PreferencesDialog::accept()
wxGetApp().update_ui_from_settings(); wxGetApp().update_ui_from_settings();
} }
void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_optgroup->rescale();
const int& em = em_unit();
const wxSize& size = wxSize(50 * em, 29 * em);
SetMinSize(size);
SetSize(size);
Refresh();
}
} // GUI } // GUI
} // Slic3r } // Slic3r

View file

@ -2,6 +2,7 @@
#define slic3r_Preferences_hpp_ #define slic3r_Preferences_hpp_
#include "GUI.hpp" #include "GUI.hpp"
#include "GUI_Utils.hpp"
#include <wx/dialog.h> #include <wx/dialog.h>
#include <map> #include <map>
@ -11,7 +12,7 @@ namespace GUI {
class ConfigOptionsGroup; class ConfigOptionsGroup;
class PreferencesDialog : public wxDialog class PreferencesDialog : public DPIDialog
{ {
std::map<std::string, std::string> m_values; std::map<std::string, std::string> m_values;
std::shared_ptr<ConfigOptionsGroup> m_optgroup; std::shared_ptr<ConfigOptionsGroup> m_optgroup;
@ -21,6 +22,9 @@ public:
void build(); void build();
void accept(); void accept();
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
}; };
} // GUI } // GUI