Skip to content

Commit

Permalink
some fixes on setting layout
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Nov 23, 2020
1 parent 7a10e82 commit e0d6a95
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
15 changes: 8 additions & 7 deletions resources/ui_layout/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ each parameter is separated by ':'
* Page:
page[:idx]:STR:STR
* 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
* 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
* 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.
Expand All @@ -35,21 +35,22 @@ each parameter is separated by ':'
* 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.
* Line:
line:STR
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. 0 for auto.
* 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.
* full_label: to override the label by the "full one".
* full_width: to tell to create a field that span the full width.
* sidetext$STR: the suffix at the right of the widget (like 'mm').
* sidetext_width$INT: the suffix label length (override the group one). -& for auto.
* sidetext_width$INT: the suffix label length (override the group one). -1 for auto.
* simple|advanced|expert: add one of these to modify the mode in which this setting appear.
* width$INT: change the width of the field. Shouod work on most type of settings.
* height$INT: change the height of the field. Don't works with every type of setting.
* id $INT : for setting only a single value of a setting array.
* idx : for setting only a single value of a setting array, with the index of the page (for extruder ui page)
* url$STR: the url to call when clicking on it.
* id $INT: for setting only a single value of a setting array.
* idx: for setting only a single value of a setting array, with the index of the page (for extruder ui page)
* recommended_thin_wall_thickness_description: create a text widget to explain recommended thin wall thickness (only in a fff print tab).
* parent_preset_description: create a text widget to explain parent preset.
* cooling_description: create a text widget to explain cooling (only in a filament tab).
Expand Down
3 changes: 3 additions & 0 deletions src/slic3r/GUI/ConfigManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
for (auto el : { "thin_walls_min_width", "thin_walls_overlap" })
toggle_field(el, config->opt_bool("thin_walls"));

for (auto el : { "seam_angle_cost", "seam_travel_cost" })
toggle_field(el, config->option<ConfigOptionEnum<SeamPosition>>("seam_position")->value == SeamPosition::spNearest);

toggle_field("perimeter_loop_seam", config->opt_bool("perimeter_loop"));

toggle_field("gap_fill_min_area", config->opt_bool("gap_fill"));
Expand Down
3 changes: 2 additions & 1 deletion src/slic3r/GUI/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt
config.set_key_value(opt_key, new ConfigOptionEnum<GCodeFlavor>(boost::any_cast<GCodeFlavor>(value)));
else if (opt_key.compare("host_type") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<PrintHostType>(boost::any_cast<PrintHostType>(value)));
else if (opt_key.compare("infill_connection") == 0)
else if (opt_key =="infill_connection" || opt_key =="infill_connection_solid"
|| opt_key =="infill_connection_top" || opt_key =="infill_connection_bottom")
config.set_key_value(opt_key, new ConfigOptionEnum<InfillConnection>(boost::any_cast<InfillConnection>(value)));
else if (opt_key.compare("infill_dense_algo") == 0)
config.set_key_value(opt_key, new ConfigOptionEnum<DenseInfillAlgo>(boost::any_cast<DenseInfillAlgo>(value)));
Expand Down
22 changes: 18 additions & 4 deletions src/slic3r/GUI/OG_CustomCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,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);

// If we have a single option with no sidetext
const std::vector<Option>& option_set = line.get_options();
if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
Expand Down Expand Up @@ -180,7 +183,7 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
if (!no_dots)
label += ":";

if (!label.empty()) {
if (!label.empty() || option.label_width > 0) {
wxCoord label_w, label_h;
#ifdef __WXMSW__
// when we use 2 monitors with different DPIs, GetTextExtent() return value for the primary display
Expand Down Expand Up @@ -221,7 +224,12 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
#endif //__WXMSW__
h_pos += m_h_gap;
}
}
}

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

// size of little widget before the real one
h_pos += 2 * blinking_button_width;

if (field == field_in)
Expand All @@ -236,7 +244,7 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
}
}
} else
h_pos += field->getWindow()->GetSize().x;
h_pos += field->getWindow()->GetSize().x + m_h_gap;

if (option_set.size() == 1 && option_set.front().opt.full_width)
break;
Expand Down Expand Up @@ -557,6 +565,9 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
return;
}

//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);

// If we're here, we have more than one option or a single option with sidetext
// so we need a horizontal sizer to arrange these things

Expand Down Expand Up @@ -589,7 +600,7 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
bool no_dots = label.empty() || option.label.back() == '_';
if (!no_dots)
label += ":";
if (!label.empty()) {
if (!label.empty() || option.label_width > 0) {
int width = ctrl->opt_group->sublabel_width * ctrl->m_em_unit;
if (option.label_width >= 0) {
if (option.label_width != 0) {
Expand All @@ -609,6 +620,9 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
}
}

//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);

if (field && field->undo_to_sys_bitmap()) {
h_pos = draw_act_bmps(dc, wxPoint(h_pos, v_pos), field->undo_to_sys_bitmap()->bmp(), field->undo_bitmap()->bmp(), field->blink(), bmp_rect_id++);
if (field->getSizer())
Expand Down
4 changes: 4 additions & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,10 @@ bool Tab::create_pages(std::string setting_type_name, int idx_page)
}

Option option = current_group->get_option(setting_id, id);
if (current_group->label_width >= 0)
option.opt.label_width = current_group->label_width;
if (current_group->sidetext_width >= 0)
option.opt.sidetext_width = current_group->sidetext_width;

bool colored = false;
wxString label_path;
Expand Down

0 comments on commit e0d6a95

Please sign in to comment.