Alignments of options in settings tabs

+ msw_rescale() is overridden for PrinterTab to rescale of all the option Pages and not just a respect to current print technology
+ A Setting of the option.width in PrintConfig is no need anymore
This commit is contained in:
YuSanka 2020-02-12 12:08:43 +01:00
parent 2e62f03ba8
commit fcd1cf371b
6 changed files with 85 additions and 57 deletions

View File

@ -573,7 +573,6 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("If layer print time is estimated below this number of seconds, fan will be enabled "
"and its speed will be calculated by interpolating the minimum and maximum speeds.");
def->sidetext = L("approximate seconds");
def->width = 6;
def->min = 0;
def->max = 1000;
def->mode = comExpert;
@ -1104,7 +1103,6 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true));
const int machine_limits_opt_width = 7;
{
struct AxisDefault {
std::string name;
@ -1136,7 +1134,6 @@ void PrintConfigDef::init_fff_params()
(void)L("Maximum feedrate of the E axis");
def->sidetext = L("mm/s");
def->min = 0;
def->width = machine_limits_opt_width;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats(axis.max_feedrate));
// Add the machine acceleration limits for XYZE axes (M201)
@ -1154,7 +1151,6 @@ void PrintConfigDef::init_fff_params()
(void)L("Maximum acceleration of the E axis");
def->sidetext = L("mm/s²");
def->min = 0;
def->width = machine_limits_opt_width;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats(axis.max_acceleration));
// Add the machine jerk limits for XYZE axes (M205)
@ -1172,7 +1168,6 @@ void PrintConfigDef::init_fff_params()
(void)L("Maximum jerk of the E axis");
def->sidetext = L("mm/s");
def->min = 0;
def->width = machine_limits_opt_width;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats(axis.max_jerk));
}
@ -1185,7 +1180,6 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Minimum feedrate when extruding (M205 S)");
def->sidetext = L("mm/s");
def->min = 0;
def->width = machine_limits_opt_width;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 0., 0. });
@ -1196,7 +1190,6 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Minimum travel feedrate (M205 T)");
def->sidetext = L("mm/s");
def->min = 0;
def->width = machine_limits_opt_width;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 0., 0. });
@ -1207,7 +1200,6 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Maximum acceleration when extruding (M204 S)");
def->sidetext = L("mm/s²");
def->min = 0;
def->width = machine_limits_opt_width;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
@ -1218,7 +1210,6 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("Maximum acceleration when retracting (M204 T)");
def->sidetext = L("mm/s²");
def->min = 0;
def->width = machine_limits_opt_width;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
@ -1715,7 +1706,6 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("If layer print time is estimated below this number of seconds, print moves "
"speed will be scaled down to extend duration to this value.");
def->sidetext = L("approximate seconds");
def->width = 6;
def->min = 0;
def->max = 1000;
def->mode = comExpert;

View File

@ -250,6 +250,23 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
}
}
void Field::msw_rescale(bool rescale_sidetext)
{
m_Undo_to_sys_btn->msw_rescale();
m_Undo_btn->msw_rescale();
// update em_unit value
m_em_unit = em_unit(m_parent);
// update sidetext if it is needed
if (m_side_text && rescale_sidetext)
{
auto size = wxSize(def_width_thinner() * m_em_unit, -1);
m_side_text->SetSize(size);
m_side_text->SetMinSize(size);
}
}
template<class T>
bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type)
{
@ -259,7 +276,7 @@ bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type)
}
void TextCtrl::BUILD() {
auto size = wxSize(wxDefaultSize);
auto size = wxSize(def_width()*m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
@ -455,10 +472,10 @@ boost::any& TextCtrl::get_value()
return m_value;
}
void TextCtrl::msw_rescale()
void TextCtrl::msw_rescale(bool rescale_sidetext/* = false*/)
{
Field::msw_rescale();
auto size = wxSize(wxDefaultSize);
Field::msw_rescale(rescale_sidetext);
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
@ -555,7 +572,7 @@ boost::any& CheckBox::get_value()
return m_value;
}
void CheckBox::msw_rescale()
void CheckBox::msw_rescale(bool rescale_sidetext/* = false*/)
{
Field::msw_rescale();
@ -565,7 +582,7 @@ void CheckBox::msw_rescale()
void SpinCtrl::BUILD() {
auto size = wxSize(wxDefaultSize);
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
@ -690,16 +707,16 @@ void SpinCtrl::propagate_value()
suppress_propagation = false;
}
void SpinCtrl::msw_rescale()
void SpinCtrl::msw_rescale(bool rescale_sidetext/* = false*/)
{
Field::msw_rescale();
Field::msw_rescale(rescale_sidetext);
wxSpinCtrl* field = dynamic_cast<wxSpinCtrl*>(window);
field->SetMinSize(wxSize(-1, int(1.9f*field->GetFont().GetPixelSize().y)));
field->SetMinSize(wxSize(def_width() * m_em_unit, int(1.9f*field->GetFont().GetPixelSize().y)));
}
void Choice::BUILD() {
wxSize size(m_width * m_em_unit, -1);
wxSize size(def_width_wider() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
@ -1018,7 +1035,7 @@ boost::any& Choice::get_value()
return m_value;
}
void Choice::msw_rescale()
void Choice::msw_rescale(bool rescale_sidetext/* = false*/)
{
Field::msw_rescale();
@ -1034,7 +1051,7 @@ void Choice::msw_rescale()
*/
field->Clear();
wxSize size(wxDefaultSize);
size.SetWidth((m_opt.width > 0 ? m_opt.width : m_width) * m_em_unit);
size.SetWidth((m_opt.width > 0 ? m_opt.width : def_width_wider()) * m_em_unit);
// Set rescaled min height to correct layout
field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y + 0.5f)));
@ -1065,7 +1082,7 @@ void Choice::msw_rescale()
void ColourPicker::BUILD()
{
auto size = wxSize(wxDefaultSize);
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
@ -1133,11 +1150,16 @@ boost::any& ColourPicker::get_value()
return m_value;
}
void ColourPicker::msw_rescale()
void ColourPicker::msw_rescale(bool rescale_sidetext/* = false*/)
{
Field::msw_rescale();
wxColourPickerCtrl* field = dynamic_cast<wxColourPickerCtrl*>(window);
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);
field->SetMinSize(size);
if (field->GetColour() == wxTransparentColour)
set_undef_value(field);
}
@ -1189,7 +1211,7 @@ void PointCtrl::BUILD()
y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
}
void PointCtrl::msw_rescale()
void PointCtrl::msw_rescale(bool rescale_sidetext/* = false*/)
{
Field::msw_rescale();
@ -1259,7 +1281,7 @@ void StaticText::BUILD()
temp->SetToolTip(get_tooltip_text(legend));
}
void StaticText::msw_rescale()
void StaticText::msw_rescale(bool rescale_sidetext/* = false*/)
{
Field::msw_rescale();

View File

@ -220,17 +220,16 @@ public:
m_side_text = side_text;
}
virtual void msw_rescale() {
m_Undo_to_sys_btn->msw_rescale();
m_Undo_btn->msw_rescale();
// update em_unit value
m_em_unit = em_unit(m_parent);
}
virtual void msw_rescale(bool rescale_sidetext = false);
bool get_enter_pressed() const { return bEnterPressed; }
void set_enter_pressed(bool pressed) { bEnterPressed = pressed; }
// Values of width to "systematic" alignments of fields
static int def_width() { return 7; }
static int def_width_wider() { return 14; }
static int def_width_thinner() { return 4; }
protected:
RevertButton* m_Undo_btn = nullptr;
// Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one.
@ -297,7 +296,7 @@ public:
boost::any& get_value() override;
void msw_rescale() override;
void msw_rescale(bool rescale_sidetext = false) override;
virtual void enable();
virtual void disable();
@ -325,7 +324,7 @@ public:
void set_na_value() override;
boost::any& get_value() override;
void msw_rescale() override;
void msw_rescale(bool rescale_sidetext = false) override;
void enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); }
void disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); }
@ -368,7 +367,7 @@ public:
return m_value = value;
}
void msw_rescale() override;
void msw_rescale(bool rescale_sidetext = false) override;
void enable() override { dynamic_cast<wxSpinCtrl*>(window)->Enable(); }
void disable() override { dynamic_cast<wxSpinCtrl*>(window)->Disable(); }
@ -377,7 +376,6 @@ public:
class Choice : public Field {
using Field::Field;
int m_width{ 15 };
public:
Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
@ -397,7 +395,7 @@ public:
void set_values(const std::vector<std::string> &values);
boost::any& get_value() override;
void msw_rescale() override;
void msw_rescale(bool rescale_sidetext = false) override;
void enable() override { dynamic_cast<wxBitmapComboBox*>(window)->Enable(); };
void disable() override{ dynamic_cast<wxBitmapComboBox*>(window)->Disable(); };
@ -423,7 +421,7 @@ public:
}
void set_value(const boost::any& value, bool change_event = false) override;
boost::any& get_value() override;
void msw_rescale() override;
void msw_rescale(bool rescale_sidetext = false) override;
void enable() override { dynamic_cast<wxColourPickerCtrl*>(window)->Enable(); };
void disable() override{ dynamic_cast<wxColourPickerCtrl*>(window)->Disable(); };
@ -448,7 +446,7 @@ public:
void set_value(const boost::any& value, bool change_event = false);
boost::any& get_value() override;
void msw_rescale() override;
void msw_rescale(bool rescale_sidetext = false) override;
void enable() override {
x_textctrl->Enable();
@ -482,7 +480,7 @@ public:
boost::any& get_value()override { return m_value; }
void msw_rescale() override;
void msw_rescale(bool rescale_sidetext = false) override;
void enable() override { dynamic_cast<wxStaticText*>(window)->Enable(); };
void disable() override{ dynamic_cast<wxStaticText*>(window)->Disable(); };

View File

@ -128,6 +128,10 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
for (auto opt : option_set)
m_options.emplace(opt.opt_id, opt);
// Set sidetext width for a better alignment of options in line
if (option_set.size() > 1)
sidetext_width = Field::def_width_thinner();
// add mode value for current line to m_options_mode
if (!option_set.empty())
m_options_mode.push_back(option_set[0].opt.mode);
@ -274,9 +278,9 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
sizer_tmp->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
// add sidetext if any
if (option.sidetext != "") {
if (!option.sidetext.empty() || sidetext_width > 0) {
auto sidetext = new wxStaticText( this->ctrl_parent(), wxID_ANY, _(option.sidetext), wxDefaultPosition,
wxSize(sidetext_width != -1 ? sidetext_width*wxGetApp().em_unit() : -1, -1) /*wxDefaultSize*/, wxALIGN_LEFT);
wxSize(sidetext_width != -1 ? sidetext_width*wxGetApp().em_unit() : -1, -1), wxALIGN_LEFT);
sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT);
sidetext->SetFont(wxGetApp().normal_font());
sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
@ -498,7 +502,7 @@ void ConfigOptionsGroup::msw_rescale()
// update undo buttons : rescale bitmaps
for (const auto& field : m_fields)
field.second->msw_rescale();
field.second->msw_rescale(sidetext_width>0);
const int em = em_unit(parent());

View File

@ -518,6 +518,18 @@ void TabPrinter::init_options_list()
m_options_list.emplace("extruders_count", m_opt_status_value);
}
void TabPrinter::msw_rescale()
{
Tab::msw_rescale();
// rescale missed options_groups
const std::vector<PageShp>& pages = m_printer_technology == ptFFF ? m_pages_sla : m_pages_fff;
for (auto page : pages)
page->msw_rescale();
Layout();
}
void TabSLAMaterial::init_options_list()
{
if (!m_options_list.empty())
@ -1221,18 +1233,14 @@ void TabPrint::build()
optgroup = page->new_optgroup(_(L("Sequential printing")));
optgroup->append_single_option_line("complete_objects");
line = { _(L("Extruder clearance (mm)")), "" };
Option option = optgroup->get_option("extruder_clearance_radius");
option.opt.width = 6;
line.append_option(option);
option = optgroup->get_option("extruder_clearance_height");
option.opt.width = 6;
line.append_option(option);
line.append_option(optgroup->get_option("extruder_clearance_radius"));
line.append_option(optgroup->get_option("extruder_clearance_height"));
optgroup->append_line(line);
optgroup = page->new_optgroup(_(L("Output file")));
optgroup->append_single_option_line("gcode_comments");
optgroup->append_single_option_line("gcode_label_objects");
option = optgroup->get_option("output_filename_format");
Option option = optgroup->get_option("output_filename_format");
option.opt.full_width = true;
optgroup->append_single_option_line(option);
@ -1463,7 +1471,10 @@ void TabFilament::build()
page = add_options_page(_(L("Advanced")), "wrench");
optgroup = page->new_optgroup(_(L("Filament properties")));
optgroup->append_single_option_line("filament_type");
// Set size as all another fields for a better alignment
Option option = optgroup->get_option("filament_type");
option.opt.width = Field::def_width();
optgroup->append_single_option_line(option);
optgroup->append_single_option_line("filament_soluble");
optgroup = page->new_optgroup(_(L("Print speed override")));
@ -1517,7 +1528,7 @@ void TabFilament::build()
page = add_options_page(_(L("Custom G-code")), "cog");
optgroup = page->new_optgroup(_(L("Start G-code")), 0);
Option option = optgroup->get_option("start_filament_gcode");
option = optgroup->get_option("start_filament_gcode");
option.opt.full_width = true;
option.opt.height = gcode_field_height;// 150;
optgroup->append_single_option_line(option);
@ -1690,7 +1701,10 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
return sizer;
};
Line host_line = optgroup->create_single_option_line("print_host");
// Set a wider width for a better alignment
Option option = optgroup->get_option("print_host");
option.opt.width = Field::def_width_wider();
Line host_line = optgroup->create_single_option_line(option);
host_line.append_widget(printhost_browse);
host_line.append_widget(print_host_test);
optgroup->append_line(host_line);
@ -3497,7 +3511,6 @@ void TabSLAMaterial::build()
for (auto& axis : axes) {
auto opt = optgroup->get_option(opt_key, id);
opt.opt.label = axis;
opt.opt.width = 6;
line.append_option(opt);
++id;
}

View File

@ -290,7 +290,7 @@ public:
virtual void reload_config();
void update_mode();
void update_visibility();
void msw_rescale();
virtual void msw_rescale();
Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const;
bool set_value(const t_config_option_key& opt_key, const boost::any& value);
wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText);
@ -403,6 +403,7 @@ public:
void build_unregular_pages();
void on_preset_loaded() override;
void init_options_list() override;
void msw_rescale() override;
bool supports_printer_technology(const PrinterTechnology /* tech */) override { return true; }
};