Fixed "hard_code" setting of the size for the Sidebar and Tabs

+ Fixed assert after config_wizard changing
This commit is contained in:
YuSanka 2019-02-04 10:35:16 +01:00
parent ba6206ab62
commit 4005d06452
15 changed files with 62 additions and 56 deletions

View file

@ -1,4 +1,5 @@
#include "2DBed.hpp"
#include "GUI_App.hpp"
#include <wx/dcbuffer.h>
@ -9,6 +10,19 @@
namespace Slic3r {
namespace GUI {
Bed_2D::Bed_2D(wxWindow* parent) :
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(20 * wxGetApp().em_unit(), -1), wxTAB_TRAVERSAL)
{
SetBackgroundStyle(wxBG_STYLE_PAINT); // to avoid assert message after wxAutoBufferedPaintDC
#ifdef __APPLE__
m_user_drawn_background = false;
#endif /*__APPLE__*/
Bind(wxEVT_PAINT, ([this](wxPaintEvent e) { repaint(); }));
Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent event) { mouse_event(event); }));
Bind(wxEVT_MOTION, ([this](wxMouseEvent event) { mouse_event(event); }));
Bind(wxEVT_SIZE, ([this](wxSizeEvent e) { Refresh(); }));
}
void Bed_2D::repaint()
{
wxAutoBufferedPaintDC dc(this);

View file

@ -25,21 +25,7 @@ class Bed_2D : public wxPanel
void set_pos(Vec2d pos);
public:
Bed_2D(wxWindow* parent)
{
Create(parent, wxID_ANY, wxDefaultPosition, wxSize(250, -1), wxTAB_TRAVERSAL);
SetBackgroundStyle(wxBG_STYLE_PAINT); // to avoid assert message after wxAutoBufferedPaintDC
// m_user_drawn_background = $^O ne 'darwin';
#ifdef __APPLE__
m_user_drawn_background = false;
#endif /*__APPLE__*/
Bind(wxEVT_PAINT, ([this](wxPaintEvent e) { repaint(); }));
// EVT_ERASE_BACKGROUND($self, sub{}) if $self->{user_drawn_background};
// Bind(EVT_MOUSE_EVENTS, ([this](wxMouseEvent event) {/*mouse_event()*/; }));
Bind(wxEVT_LEFT_DOWN, ([this](wxMouseEvent event) { mouse_event(event); }));
Bind(wxEVT_MOTION, ([this](wxMouseEvent event) { mouse_event(event); }));
Bind(wxEVT_SIZE, ([this](wxSizeEvent e) { Refresh(); }));
}
Bed_2D(wxWindow* parent);
~Bed_2D() {}
std::vector<Vec2d> m_bed_shape;

View file

@ -44,7 +44,7 @@ void BedShapePanel::build_panel(ConfigOptionPoints* default_pt)
auto sbsizer = new wxStaticBoxSizer(box, wxVERTICAL);
// shape options
m_shape_options_book = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(300, -1), wxCHB_TOP);
m_shape_options_book = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(23 * wxGetApp().em_unit(), -1), wxCHB_TOP);
sbsizer->Add(m_shape_options_book);
auto optgroup = init_shape_options_page(_(L("Rectangular")));

View file

@ -42,7 +42,7 @@ class BedShapeDialog : public wxDialog
BedShapePanel* m_panel;
public:
BedShapeDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, _(L("Bed Shape")),
wxDefaultPosition, wxSize(350, 700), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {}
wxDefaultPosition, wxSize(27 * wxGetApp().em_unit(), 54 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {}
~BedShapeDialog() {}
void build_dialog(ConfigOptionPoints* default_pt);

View file

@ -5,6 +5,7 @@
#include "../Utils/Time.hpp"
#include "libslic3r/Utils.hpp"
#include "GUI_App.hpp"
namespace Slic3r {
namespace GUI {
@ -94,7 +95,9 @@ static wxString generate_html_page(const Config::SnapshotDB &snapshot_db, const
}
ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &on_snapshot)
: wxDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition, wxSize(600, 500), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
: wxDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition,
wxSize(45 * wxGetApp().em_unit(), 40 * wxGetApp().em_unit()),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
{
this->SetBackgroundColour(*wxWHITE);

View file

@ -162,7 +162,7 @@ bool GUI_App::OnInit()
if (plater_ && sidebar().obj_list()->GetMinHeight() > 200)
{
wxWindowUpdateLocker noUpdates_sidebar(&sidebar());
sidebar().obj_list()->SetMinSize(wxSize(-1, 200));
sidebar().obj_list()->SetMinSize(wxSize(-1, 15 * wxGetApp().em_unit()));
// !!! to correct later layouts
update_mode(); // update view mode after fix of the object_list size

View file

@ -80,7 +80,8 @@ class GUI_App : public wxApp
wxFont m_small_font;
wxFont m_bold_font;
size_t m_width_unit;
size_t m_em_unit; // "m" string width in pixels.
// Used like a coefficient for a size setting of controls
wxLocale* m_wxLocale{ nullptr };
@ -108,8 +109,8 @@ public:
const wxFont& small_font() { return m_small_font; }
const wxFont& bold_font() { return m_bold_font; }
size_t width_unit() const { return m_width_unit; }
void set_width_unit(const size_t width_unit) { m_width_unit = width_unit; }
size_t em_unit() const { return m_em_unit; }
void set_em_unit(const size_t em_unit) { m_em_unit = em_unit; }
void recreate_GUI();
void system_info();

View file

@ -19,7 +19,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
OG_Settings(parent, true)
{
m_og->set_name(_(L("Object Manipulation")));
m_og->label_width = 125;
m_og->label_width = 9 * wxGetApp().em_unit();//125;
m_og->set_grid_vgap(5);
m_og->m_on_change = [this](const std::string& opt_key, const boost::any& value) {
@ -132,7 +132,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
auto line = Line{ "", "" };
def.label = "";
def.type = coString;
def.width = 50;
def.width = 3.8 * wxGetApp().em_unit()/*50*/;
std::vector<std::string> axes{ "x", "y", "z" };
for (const auto axis : axes) {
@ -150,7 +150,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
ConfigOptionDef def;
def.type = coFloat;
def.default_value = new ConfigOptionFloat(0.0);
def.width = 50;
def.width = 3.8 * wxGetApp().em_unit()/*50*/;
if (option_name == "Rotation")
{

View file

@ -259,7 +259,7 @@ bool Preview::init(wxWindow* parent, DynamicPrintConfig* config, BackgroundSlici
m_label_show_features = new wxStaticText(this, wxID_ANY, _(L("Show")));
m_combochecklist_features = new wxComboCtrl();
m_combochecklist_features->Create(this, wxID_ANY, _(L("Feature types")), wxDefaultPosition, wxSize(200, -1), wxCB_READONLY);
m_combochecklist_features->Create(this, wxID_ANY, _(L("Feature types")), wxDefaultPosition, wxSize(15 * wxGetApp().em_unit(), -1), wxCB_READONLY);
std::string feature_text = GUI::into_u8(_(L("Feature types")));
std::string feature_items = GUI::into_u8(
_(L("Perimeter")) + "|" +

View file

@ -54,7 +54,7 @@ KBShortcutsDialog::KBShortcutsDialog()
hsizer->Add(logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
// head
wxStaticText* head = new wxStaticText(panel, wxID_ANY, sc.first, wxDefaultPosition, wxSize(200,-1));
wxStaticText* head = new wxStaticText(panel, wxID_ANY, sc.first, wxDefaultPosition, wxSize(15 * wxGetApp().em_unit(), -1));
head->SetFont(head_font);
hsizer->Add(head, 0, wxALIGN_CENTER_VERTICAL);

View file

@ -55,9 +55,8 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
// initialize default width_unit according to the width of the one symbol ("x") of the current system font
const wxString x_str = "x";
const wxSize size = GetTextExtent(x_str);
wxGetApp().set_width_unit(size.x);
const wxSize size = GetTextExtent("m");
wxGetApp().set_em_unit(size.x);
// initialize tabpanel and menubar
init_tabpanel();

View file

@ -213,7 +213,7 @@ void SlicedInfo::SetTextAndShow(SlisedInfoIdx idx, const wxString& text, const w
}
PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) :
wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(30 * wxGetApp().width_unit()/*200*/, -1), 0, nullptr, wxCB_READONLY),
wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 * wxGetApp().em_unit(), -1), 0, nullptr, wxCB_READONLY),
preset_type(preset_type),
last_selected(wxNOT_FOUND)
{
@ -519,7 +519,7 @@ void Sidebar::priv::show_preset_comboboxes()
Sidebar::Sidebar(Plater *parent)
: wxPanel(parent), p(new priv(parent))
{
p->scrolled = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(60 * wxGetApp().width_unit()/*400*/, -1));
p->scrolled = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(30 * wxGetApp().em_unit(), -1));
p->scrolled->SetScrollbars(0, 20, 1, 2);
// Sizer in the scrolled area
@ -562,7 +562,7 @@ Sidebar::Sidebar(Plater *parent)
// calculate width of the preset labels
p->sizer_presets->Layout();
const wxArrayInt& ar = p->sizer_presets->GetColWidths();
int label_width = ar.IsEmpty() ? 100 : ar.front()-4;
int label_width = ar.IsEmpty() ? 7.7*wxGetApp().em_unit() : ar.front()-4;
p->sizer_params = new wxBoxSizer(wxVERTICAL);

View file

@ -5,6 +5,7 @@
#include <wx/clipbrd.h>
#include <wx/platinfo.h>
#include "GUI_App.hpp"
namespace Slic3r {
namespace GUI {
@ -42,7 +43,7 @@ SysInfoDialog::SysInfoDialog()
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
SetBackgroundColour(bgr_clr);
wxBoxSizer* hsizer = new wxBoxSizer(wxHORIZONTAL);
hsizer->SetMinSize(wxSize(600, -1));
hsizer->SetMinSize(wxSize(45 * wxGetApp().em_unit(), -1));
auto main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 10);
@ -95,7 +96,7 @@ SysInfoDialog::SysInfoDialog()
// opengl_info
wxHtmlWindow* opengl_info_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
{
opengl_info_html->SetMinSize(wxSize(-1, 200));
opengl_info_html->SetMinSize(wxSize(-1, 15 * wxGetApp().em_unit()));
opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), size);
opengl_info_html->SetBorders(10);
const auto text = wxString::Format(

View file

@ -96,7 +96,7 @@ void Tab::create_preset_tab()
#endif //__WXOSX__
// preset chooser
m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(40 * wxGetApp().width_unit()/*270*/, -1), 0, 0, wxCB_READONLY);
m_presets_choice = new wxBitmapComboBox(panel, wxID_ANY, "", wxDefaultPosition, wxSize(20 * wxGetApp().em_unit(), -1), 0, 0, wxCB_READONLY);
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
@ -201,7 +201,7 @@ void Tab::create_preset_tab()
m_hsizer->Add(m_left_sizer, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 3);
// tree
m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(30 * wxGetApp().width_unit()/*185*/, -1),
m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(15 * wxGetApp().em_unit(), -1),
wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
m_left_sizer->Add(m_treectrl, 1, wxEXPAND);
m_icons = new wxImageList(16, 16, true, 1);
@ -497,6 +497,8 @@ void TabSLAMaterial::init_options_list()
void Tab::get_sys_and_mod_flags(const std::string& opt_key, bool& sys_page, bool& modified_page)
{
if (m_options_list.empty())
return;
auto opt = m_options_list.find(opt_key);
if (sys_page) sys_page = (opt->second & osSystemValue) != 0;
modified_page |= (opt->second & osInitValue) == 0;
@ -689,9 +691,9 @@ void Tab::update_visibility()
Thaw();
// to update tree items color
wxTheApp->CallAfter([this]() {
// wxTheApp->CallAfter([this]() {
update_changed_tree_ui();
});
// });
}
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
@ -1102,14 +1104,14 @@ void TabPrint::build()
optgroup = page->new_optgroup(_(L("Post-processing scripts")), 0);
option = optgroup->get_option("post_process");
option.opt.full_width = true;
option.opt.height = 50;
option.opt.height = 4 * wxGetApp().em_unit();//50;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Notes")), "note.png");
optgroup = page->new_optgroup(_(L("Notes")), 0);
option = optgroup->get_option("notes");
option.opt.full_width = true;
option.opt.height = 250;
option.opt.height = 19 * wxGetApp().em_unit();//250;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Dependencies")), "wrench.png");
@ -1470,13 +1472,13 @@ void TabFilament::build()
optgroup = page->new_optgroup(_(L("Start G-code")), 0);
Option option = optgroup->get_option("start_filament_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();// 150;
optgroup->append_single_option_line(option);
optgroup = page->new_optgroup(_(L("End G-code")), 0);
option = optgroup->get_option("end_filament_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();// 150;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Notes")), "note.png");
@ -1484,7 +1486,7 @@ void TabFilament::build()
optgroup->label_width = 0;
option = optgroup->get_option("filament_notes");
option.opt.full_width = true;
option.opt.height = 250;
option.opt.height = 19 * wxGetApp().em_unit();// 250;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Dependencies")), "wrench.png");
@ -1847,44 +1849,44 @@ void TabPrinter::build_fff()
optgroup = page->new_optgroup(_(L("Start G-code")), 0);
option = optgroup->get_option("start_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();//150;
optgroup->append_single_option_line(option);
optgroup = page->new_optgroup(_(L("End G-code")), 0);
option = optgroup->get_option("end_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();//150;
optgroup->append_single_option_line(option);
optgroup = page->new_optgroup(_(L("Before layer change G-code")), 0);
option = optgroup->get_option("before_layer_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();//150;
optgroup->append_single_option_line(option);
optgroup = page->new_optgroup(_(L("After layer change G-code")), 0);
option = optgroup->get_option("layer_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();//150;
optgroup->append_single_option_line(option);
optgroup = page->new_optgroup(_(L("Tool change G-code")), 0);
option = optgroup->get_option("toolchange_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();//150;
optgroup->append_single_option_line(option);
optgroup = page->new_optgroup(_(L("Between objects G-code (for sequential printing)")), 0);
option = optgroup->get_option("between_objects_gcode");
option.opt.full_width = true;
option.opt.height = 150;
option.opt.height = 11.5 * wxGetApp().em_unit();//150;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Notes")), "note.png");
optgroup = page->new_optgroup(_(L("Notes")), 0);
option = optgroup->get_option("printer_notes");
option.opt.full_width = true;
option.opt.height = 250;
option.opt.height = 19 * wxGetApp().em_unit();//250;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Dependencies")), "wrench.png");
@ -1965,7 +1967,7 @@ void TabPrinter::build_sla()
optgroup = page->new_optgroup(_(L("Notes")), 0);
option = optgroup->get_option("printer_notes");
option.opt.full_width = true;
option.opt.height = 250;
option.opt.height = 19*wxGetApp().em_unit();//250;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Dependencies")), "wrench.png");
@ -2014,7 +2016,7 @@ PageShp TabPrinter::build_kinematics_page()
// Legend for OptionsGroups
auto optgroup = page->new_optgroup("");
optgroup->set_show_modified_btns_val(false);
optgroup->label_width = 230;
optgroup->label_width = 18 * wxGetApp().em_unit();// 230;
auto line = Line{ "", "" };
ConfigOptionDef def;
@ -3100,7 +3102,7 @@ void TabSLAMaterial::build()
optgroup->append_single_option_line("initial_exposure_time");
optgroup = page->new_optgroup(_(L("Corrections")));
optgroup->label_width = 190;
optgroup->label_width = 14.5 * wxGetApp().em_unit();//190;
std::vector<std::string> corrections = { "material_correction_printing", "material_correction_curing" };
std::vector<std::string> axes{ "X", "Y", "Z" };
for (auto& opt_key : corrections) {
@ -3121,7 +3123,7 @@ void TabSLAMaterial::build()
optgroup->label_width = 0;
Option option = optgroup->get_option("material_notes");
option.opt.full_width = true;
option.opt.height = 250;
option.opt.height = 19 * wxGetApp().em_unit();//250;
optgroup->append_single_option_line(option);
page = add_options_page(_(L("Dependencies")), "wrench.png");

View file

@ -1480,7 +1480,7 @@ wxSize PrusaDoubleSlider::DoGetBestSize() const
const wxSize size = wxControl::DoGetBestSize();
if (size.x > 1 && size.y > 1)
return size;
const int new_size = is_horizontal() ? 80 : 120;
const int new_size = is_horizontal() ? 6 * Slic3r::GUI::wxGetApp().em_unit() : 10 * Slic3r::GUI::wxGetApp().em_unit();
return wxSize(new_size, new_size);
}