Skip to content

Commit

Permalink
Add label_left option for setting ui to print the label aligned to th…
Browse files Browse the repository at this point in the history
…e left instead of the right

Better spacing for infill lines, allowing larger infill % field
fix #1573
  • Loading branch information
supermerill committed Sep 26, 2021
1 parent 51d5b71 commit 30c380c
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 39 deletions.
7 changes: 4 additions & 3 deletions resources/ui_layout/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ each parameter is separated by ':'
* first STR is for the label and the second for the icon, with or without the .svg / .png
* idx: append the index of the page (for extruder ui) to the name
* Group:
group[:nolabel][:title_width$INT][:label_width$INT][:sidetext_width$INT][:EVENT][:id$INT][:idx]:STR
group[:no_title][:title_width$INT][:label_width$INT][:sidetext_width$INT][:EVENT][:id$INT][:idx]:STR
* EVENT can be extruders_count_event if the group contains extruders_count and is a printer tab ; silent_mode_event if the group contains silent_mode and is a printer tab ; material_density_event if the group contains material_density.
* title_width$INT is used to set the size of the left column, where labels are draw.
* title_width$INT is used to set the size of the left column, where titles are draw.
* label_width$INT is used to set the size of the labels on lines.
* sidetext_width$INT is used to set the size of the suffix label (see sidetext in setting).
* EVENT can be extruders_count_event (TabPrinter only), silent_mode_event (TabPrinter only), material_density_event.
* nolabel is used to remove the left column, where labels are draw.
* no_title is used to remove the left column, where titles are draw.
* Line:
line:STR*
* setting:
setting[label$STR][label_width$INT][:full_label][:full_width][:sidetext$STR][sidetext_width$INT][:simple|advanced|expert][:width$INT][:height$INT][:id$INT]:STR
* STR, the last parameter: the id name of the setting.
* label$STR: to override the label by this new one (if it ends with '_' it won't have a ':' ; if empty it won't have a length).
* label_width$INT: change the width of the label. Only works if it's in a line. Override the group one. -1 for auto.
* label_left: Draw the label aligned to the left instead of the right.
* full_label$STR: to override the full_label by this new one (full_label is used on modifiers).
* full_label: to override the label by the "full one".
* full_width: to tell to create a field that span the full width.
Expand Down
4 changes: 2 additions & 2 deletions resources/ui_layout/filament.ui
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ group:Toolchange parameters with single extruder MM printers
filament_overrides_page

page:Custom G-code:cog
group:nolabel:Start G-code
group:no_title:Start G-code
setting:full_width:height$35:start_filament_gcode
group:nolabel:End G-code
group:no_title:End G-code
setting:full_width:height$35:end_filament_gcode

page:Notes:note.png
Expand Down
24 changes: 12 additions & 12 deletions resources/ui_layout/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,26 @@ group:Other
setting:allow_empty_layers

page:Infill:infill
group:title_width$8:Infill
line:Sparse
setting:width$5:label$_:sidetext_width$1:fill_density
setting:label_width$1:label$_:fill_pattern
group:title_width$0:Infill
line:_
setting:label_left:label_width$6:label$Sparse:width$8:sidetext_width$1:fill_density
setting:label_width$0:label$_:fill_pattern
setting:label$_:width$18:infill_connection
end_line
line:_
setting:label$Connection length:label_width$20:sidetext_width$7:width$12:infill_anchor_max
setting:label$Connection length:label_width$25:sidetext_width$7:width$12:infill_anchor_max
setting:label$Perimeter anchor:sidetext_width$7:width$12:infill_anchor
end_line
line:Solid
setting:label_width$11:label$_:solid_fill_pattern
line:_
setting:label_left:label_width$20:label$Solid:solid_fill_pattern
setting:label$_:width$18:infill_connection_solid
end_line
line:Top
setting:label_width$11:label$_:top_fill_pattern
line:_
setting:label_left:label_width$20:label$Top:top_fill_pattern
setting:label$_:width$18:infill_connection_top
end_line
line:Bottom
setting:label_width$11:label$_:bottom_fill_pattern
line:_
setting:label_left:label_width$20:label$Bottom:bottom_fill_pattern
setting:label$_:width$18:infill_connection_bottom
end_line
group:Reducing printing time
Expand Down Expand Up @@ -382,7 +382,7 @@ group:Post-processing script
setting:full_width:height$5:post_process

page:Notes:note
group:nolabel:Notes
group:no_title:Notes
setting:full_width:height$25:notes

page:Dependencies:wrench
Expand Down
2 changes: 1 addition & 1 deletion resources/ui_layout/print.ui.legacy
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ group:Post-processing scripts
setting:full_width:height$5:post_process

page:Notes:note
group:nolabel:Notes
group:no_title:Notes
setting:full_width:height$25:notes

page:Dependencies:wrench
Expand Down
16 changes: 8 additions & 8 deletions resources/ui_layout/printer_fff.ui
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,24 @@ page:Custom G-code:cog
group:
setting:start_gcode_manual
height:15
group:nolabel:Start G-code
group:no_title:Start G-code
setting:full_width:start_gcode
group:nolabel:End G-code
group:no_title:End G-code
setting:full_width:end_gcode
group:nolabel:Before layer change G-code
group:no_title:Before layer change G-code
setting:full_width:before_layer_gcode
group:nolabel:After layer change G-code
group:no_title:After layer change G-code
setting:full_width:layer_gcode
group:nolabel:Tool change G-code
group:no_title:Tool change G-code
setting:full_width:toolchange_gcode
group:nolabel:Between objects G-code (for sequential printing)
group:no_title:Between objects G-code (for sequential printing)
setting:full_width:between_objects_gcode
group:nolabel:Between extrusion role change G-code
group:no_title:Between extrusion role change G-code
setting:full_width:feature_gcode
height:0

page:Notes:note.png
group:nolabel:Notes
group:no_title:Notes
setting:full_width:height$25:printer_notes

page:Dependencies:wrench.png
Expand Down
2 changes: 1 addition & 1 deletion resources/ui_layout/printer_sla.ui
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ group:Print Host upload
build_printhost

page:Notes:note.png
group:nolabel:Notes
group:no_title:Notes
setting:full_width:height$25:printer_notes

page:Dependencies:wrench.png
Expand Down
2 changes: 1 addition & 1 deletion resources/ui_layout/sla_material.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ group:label_width$19:Corrections
end_line

page:Notes:note
group:label_width$0:nolabel:Notes
group:label_width$0:no_title:Notes
setting:full_width:height$25:material_notes

page:Dependencies:wrench
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,8 @@ class ConfigOptionDef
int width = -1;
// Optional label width of the label (if in a line).
int label_width = -1;
// Optional label alignement to the left instead of the right
bool aligned_label_left = false;
// Optional label width of the sidetext (if in a line).
int sidetext_width = -1;
// <min, max> limit of a numeric input.
Expand Down
13 changes: 11 additions & 2 deletions src/slic3r/GUI/OG_CustomCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ void OG_CustomCtrl::init_ctrl_lines()
ctrl_lines.emplace_back(CtrlLine(height, this, line, false, opt_group->staticbox));
}
else
int i = 0;
{
height = m_bmp_blinking_sz.GetHeight() + m_v_gap;
ctrl_lines.emplace_back(CtrlLine(height, this, line, opt_group->no_title, opt_group->staticbox));
}
}
}

Expand Down Expand Up @@ -135,6 +138,9 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
break;
}

//round it to next m_em_unit
h_pos += (h_pos % m_em_unit == 0) ? 0 : m_em_unit - (h_pos % m_em_unit);

wxString label = line.label;
if (opt_group->title_width != 0)
h_pos += opt_group->title_width * m_em_unit + m_h_gap;
Expand Down Expand Up @@ -556,6 +562,9 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)

const std::vector<Option>& option_set = og_line.get_options();

//round it to next m_em_unit
h_pos += (h_pos % ctrl->m_em_unit == 0) ? 0 : ctrl->m_em_unit - (h_pos % ctrl->m_em_unit);

bool is_url_string = false;
if (ctrl->opt_group->title_width != 0 && !og_line.label.IsEmpty()) {
const wxColour* text_clr = (option_set.size() == 1 && field ? field->label_color() : og_line.full_Label_color);
Expand Down Expand Up @@ -626,7 +635,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
is_url_string = false;
else if (opt == option_set.front())
is_url_string = !suppress_hyperlinks && !og_line.label_path.IsEmpty();
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? field->label_color() : nullptr, width, is_url_string, true);
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? field->label_color() : nullptr, width, is_url_string, !field->m_opt.aligned_label_left);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/slic3r/GUI/OptionsGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class OptionsGroup {
public:
const bool staticbox {true};
const wxString title;
size_t title_width = 20;// {200};
int title_width = 20;// {200};
bool no_title = false;
wxSizer* sizer {nullptr};
OG_CustomCtrl* custom_ctrl{ nullptr };
column_t extra_column {nullptr};
Expand Down
21 changes: 14 additions & 7 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,15 +1592,18 @@ bool Tab::create_pages(std::string setting_type_name, int idx_page)
while (str.size() > 1 && (str.front() == ' ' || str.front() == '\t')) str = str.substr(1, str.size() - 1);
while (str.size() > 1 && (str.back() == ' ' || str.back() == '\t')) str = str.substr(0, str.size() - 1);
}
bool nolabel = false;
bool no_title = false;
for (int i = 1; i < params.size() - 1; i++) {
if (params[i] == "nolabel")
{
nolabel = true;
no_title = true;
std::cerr << "Warning: 'nolabel' is deprecated, please replace it by 'no_title' in your " << setting_type_name << " ui file";
}
if (params[i] == "no_title")
no_title = true;
}

current_group = current_page->new_optgroup(_(params.back()), nolabel?0:-1);
current_group = current_page->new_optgroup(_(params.back()), no_title);
for (int i = 1; i < params.size() - 1; i++) {
if (boost::starts_with(params[i], "title_width$")) {
current_group->title_width = atoi(params[i].substr(12, params[i].size() - 12).c_str());
Expand Down Expand Up @@ -1835,6 +1838,9 @@ bool Tab::create_pages(std::string setting_type_name, int idx_page)
else if (boost::starts_with(params[i], "label_width$")) {
option.opt.label_width = atoi(params[i].substr(12, params[i].size() - 12).c_str());
}
else if (boost::starts_with(params[i], "label_left")) {
option.opt.aligned_label_left = true;
}
else if (boost::starts_with(params[i], "sidetext$"))
{
option.opt.sidetext = (params[i].substr(9, params[i].size() - 9));
Expand Down Expand Up @@ -4179,13 +4185,14 @@ bool Page::set_value(const t_config_option_key& opt_key, const boost::any& value
}

// package Slic3r::GUI::Tab::Page;
ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_title_width /*= -1*/)
ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, bool no_title /*= false*/)
{
//! config_ have to be "right"
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(m_parent, title, m_config, true);
optgroup->set_config_category(m_title.ToStdString());
if (noncommon_title_width >= 0)
optgroup->title_width = noncommon_title_width;
optgroup->no_title = no_title;
if (no_title)
optgroup->title_width = 0;

#ifdef __WXOSX__
auto tab = parent()->GetParent()->GetParent();// GetParent()->GetParent();
Expand Down Expand Up @@ -4294,7 +4301,7 @@ void TabSLAMaterial::build()
}

page = add_options_page(L("Notes"), "note");
optgroup = page->new_optgroup(L("Notes"), 0);
optgroup = page->new_optgroup(L("Notes"), true);
optgroup->title_width = 0;
Option option = optgroup->get_option("material_notes");
option.opt.full_width = true;
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/Tab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Page// : public wxScrolledWindow
void refresh();
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);
ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_title_width = -1);
ConfigOptionsGroupShp new_optgroup(const wxString& title, bool no_title = false);

bool set_item_colour(const wxColour *clr) {
if (m_item_color != clr) {
Expand Down

0 comments on commit 30c380c

Please sign in to comment.