diff --git a/resources/profiles/Creality.ini b/resources/profiles/Creality.ini index 2ce36e176..3f7893342 100644 --- a/resources/profiles/Creality.ini +++ b/resources/profiles/Creality.ini @@ -32,6 +32,15 @@ bed_model = ender3_bed.stl bed_texture = ender3.svg default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY +[printer_model:ENDER5] +name = Creality Ender-5 +variants = 0.4 +technology = FFF +family = ENDER +bed_model = ender3_bed.stl +bed_texture = ender3.svg +default_materials = Creality PLA @CREALITY; Generic PLA @CREALITY; Generic PETG @CREALITY; Generic ABS @CREALITY; Prusament PLA @CREALITY; Prusament PETG @CREALITY + [printer_model:ENDER5PLUS] name = Creality Ender-5 Plus variants = 0.4 @@ -326,7 +335,7 @@ compatible_printers_condition = printer_notes=~/.*PRINTER_VENDOR_CREALITY.*/ [filament:*PLA*] inherits = *common* -bed_temperature = 40 +bed_temperature = 60 fan_below_layer_time = 100 filament_colour = #FF3232 filament_max_volumetric_speed = 15 @@ -450,6 +459,36 @@ first_layer_bed_temperature = 70 filament_cost = 24.99 filament_density = 1.27 +[filament:Devil Design PLA @CREALITY] +inherits = *PLA* +filament_vendor = Devil Design +temperature = 215 +bed_temperature = 60 +first_layer_temperature = 215 +first_layer_bed_temperature = 60 +filament_cost = 19.00 +filament_density = 1.24 + +[filament:Extrudr PLA NX2 @CREALITY] +inherits = *PLA* +filament_vendor = Extrudr +temperature = 200 +bed_temperature = 60 +first_layer_temperature = 205 +first_layer_bed_temperature = 60 +filament_cost = 23.63 +filament_density = 1.3 + +[filament:Real Filament PLA @CREALITY] +inherits = *PLA* +filament_vendor = Real Filament +temperature = 195 +bed_temperature = 60 +first_layer_temperature = 200 +first_layer_bed_temperature = 60 +filament_cost = 24.99 +filament_density = 1.24 + # Common printer preset [printer:*common*] printer_technology = FFF @@ -542,20 +581,31 @@ retract_before_wipe = 70% default_print_profile = 0.15mm OPTIMAL @CREALITY default_filament_profile = Creality PLA @CREALITY start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM104 S[first_layer_temperature] ; set extruder temp\nM140 S[first_layer_bed_temperature] ; set bed temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG28 ; home all\nG1 Z2 F240\nG1 X2 Y10 F3000\nG1 Z0.28 F240\nG92 E0.0\nG1 Y190 E15.0 F1500.0 ; intro line\nG1 X2.3 F5000\nG1 Y10 E15.0 F1200.0 ; intro line\nG92 E0.0 -end_gcode = M104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\n{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+5, max_print_height)} F600{endif} ; Move print head up\nG1 X5 Y170 F3000 ; present print\n{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+70, max_print_height)} F600{endif} ; Move print head up\nM84 X Y E ; disable motors +end_gcode = M104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\n{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+5, max_print_height)} F600{endif} ; Move print head up\nG1 X5 Y170 F3000 ; present print\n{if layer_z < max_print_height-10}G1 Z{z_offset+min(layer_z+70, max_print_height-10)} F600{endif} ; Move print head up\nM84 X Y E ; disable motors [printer:*abl*] start_gcode = G90 ; use absolute coordinates\nM83 ; extruder relative mode\nM104 S150 ; set extruder temp for auto bed leveling\nM140 S[first_layer_bed_temperature] ; set bed temp\nG28 ; home all\nG29 ; auto bed levelling\nG1 Z50 F240\nG1 X2 Y10 F3000\nM104 S[first_layer_temperature] ; set extruder temp\nM190 S[first_layer_bed_temperature] ; wait for bed temp\nM109 S[first_layer_temperature] ; wait for extruder temp\nG1 Z0.28 F240\nG92 E0.0\nG1 Y190 E15.0 F1500.0 ; intro line\nG1 X2.3 F5000\nG1 Y10 E15.0 F1200.0 ; intro line\nG92 E0.0 +[printer:*invertedz*] +end_gcode = M104 S0 ; turn off temperature\nM140 S0 ; turn off heatbed\nM107 ; turn off fan\n{if layer_z < max_print_height}G1 Z{z_offset+min(layer_z+5, max_print_height)} F600{endif} ; Move print bed down\nG1 X50 Y50 F3000 ; present print\n{if layer_z < max_print_height-10}G1 Z{z_offset+max_print_height-10} F600{endif} ; Move print bed down\nM84 X Y E ; disable motors + [printer:Creality Ender-3 BLTouch] inherits = Creality Ender-3; *abl* renamed_from = "Creality ENDER-3 BLTouch" printer_model = ENDER3BLTOUCH -[printer:Creality Ender-5 Plus] -inherits = Creality Ender-3; *abl* +[printer:Creality Ender-5] +inherits = Creality Ender-3; *invertedz* retract_length = 6 -bed_shape = 10x10,360x10,360x360,10x360 +bed_shape = 5x2.5,225x2.5,225x222.5,5x222.5 +printer_model = ENDER5 +printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER5\nPRINTER_HAS_BOWDEN +max_print_height = 300 + +[printer:Creality Ender-5 Plus] +inherits = Creality Ender-3; *abl*; *invertedz* +retract_length = 6 +bed_shape = 5x5,355x5,355x355,5x355 printer_model = ENDER5PLUS printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_CREALITY\nPRINTER_MODEL_ENDER5PLUS\nPRINTER_HAS_BOWDEN max_print_height = 400 diff --git a/resources/profiles/Creality/ENDER5_thumbnail.png b/resources/profiles/Creality/ENDER5_thumbnail.png new file mode 100644 index 000000000..eb9d117db Binary files /dev/null and b/resources/profiles/Creality/ENDER5_thumbnail.png differ diff --git a/resources/profiles/TriLAB.idx b/resources/profiles/TriLAB.idx index a43bf4e00..eda36c227 100644 --- a/resources/profiles/TriLAB.idx +++ b/resources/profiles/TriLAB.idx @@ -1,2 +1,3 @@ -min_slic3r_version = 2.3.0-alpha0 -0.0.1 Initial TriLAB bundle +min_slic3r_version = 2.3.0-alpha0 +0.0.2 Added 0.15mm print profile +0.0.1 Initial TriLAB bundle diff --git a/resources/profiles/TriLAB.ini b/resources/profiles/TriLAB.ini index 2412cf115..1c9bda0c1 100644 --- a/resources/profiles/TriLAB.ini +++ b/resources/profiles/TriLAB.ini @@ -4,13 +4,13 @@ [vendor] # Vendor name will be shown by the Config Wizard. -name = TRILAB +name = TriLAB # Configuration version of this file. Config file will only be installed, if the config_version differs. # This means, the server may force the PrusaSlicer configuration to be downgraded. -config_version = 0.0.1 +config_version = 0.0.2 # Where to get the updates from? -config_update_url = http://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/TriLAB/ -# changelog_url = http://files.prusa3d.com/?latest=slicer-profiles&lng=%1% +config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/TriLAB/ +# changelog_url = https://files.prusa3d.com/?latest=slicer-profiles&lng=%1% # The printer models will be shown by the Configuration Wizard in this order, # also the first model installed & the first nozzle installed will be activated after install. @@ -43,10 +43,15 @@ default_materials = DeltiQ PLA; DeltiQ ASA; DeltiQ PET; DeltiQ ABS; DeltiQ CPE # All presets starting with asterisk, for example *common*, are intermediate and they will # not make it into the user interface. +[print:DeltiQ 0.15mm] +inherits = DeltiQ 0.2mm +layer_height = 0.15 +bottom_solid_layers = 5 +top_solid_layers = 6 [print:DeltiQ 0.2mm] avoid_crossing_perimeters = 0 -bottom_solid_layers = 3 +bottom_solid_layers = 4 bridge_acceleration = 1000 bridge_angle = 0 bridge_flow_ratio = 0.95 @@ -143,7 +148,7 @@ thin_walls = 0 threads = 4 top_infill_extrusion_width = 0.4 top_solid_infill_speed = 30 -top_solid_layers = 4 +top_solid_layers = 5 travel_speed = 150 wipe_tower = 0 wipe_tower_bridging = 10 @@ -254,7 +259,6 @@ extra_loading_move = -2 extruder_colour = "" extruder_offset = 0x0 gcode_flavor = repetier -host_type = octoprint layer_gcode = ;AFTER_LAYER_CHANGE\nM117 layer [layer_num] at [layer_z]mm\n;[layer_z]\n machine_max_acceleration_e = 10000,5000 machine_max_acceleration_extruding = 1500,1250 @@ -277,14 +281,11 @@ max_print_height = 320 min_layer_height = 0.15 nozzle_diameter = 0.4 parking_pos_retraction = 92 -print_host = printer_model = printer_notes = TRILAB printer_settings_id = printer_variant = printer_vendor = -printhost_apikey = -printhost_cafile = remaining_times = 0 retract_before_travel = 2 retract_before_wipe = 100% @@ -297,8 +298,6 @@ retract_lift_below = 0 retract_restart_extra = 0 retract_restart_extra_toolchange = 0 retract_speed = 33 -serial_port = -serial_speed = 250000 silent_mode = 1 single_extruder_multi_material = 0 start_gcode = ;START\nM220 S100 ; Set feedmultiply back to 100percent\nG90 ; Absolute positioning\nM83 ; Relative extruder\nM107 ; Layer fan OFF\nM190 S[first_layer_bed_temperature] ; Set bed temperature and wait\nM104 S[first_layer_temperature] ; Set extruder temperature\nG28 ; Home all axes\nG33 ; auto leveling rutine\nG1 X-62 Y-108 Z0.3 F6000 ; Go to purge position start\nG92 E0 ; Zero extruder\nM109 S[first_layer_temperature] ; Set and wait - hotend temperature\nG3 X62 Y-108 I62 J108 E10 F200 ; Go ARC to purge end\nG92 E0 ; Zero extruder diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 105d02613..c44b76970 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -111,6 +111,8 @@ set(SLIC3R_GUI_SOURCES GUI/Field.hpp GUI/OptionsGroup.cpp GUI/OptionsGroup.hpp + GUI/OG_CustomCtrl.cpp + GUI/OG_CustomCtrl.hpp GUI/BedShapeDialog.cpp GUI/BedShapeDialog.hpp GUI/2DBed.cpp diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 0bb3f0068..d0a76053f 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -13,6 +13,7 @@ #include #include #include +#include "OG_CustomCtrl.hpp" #ifdef __WXOSX__ #define wxOSX true @@ -63,18 +64,16 @@ Field::~Field() m_back_to_initial_value = nullptr; if (m_back_to_sys_value) m_back_to_sys_value = nullptr; + if (getWindow()) { + wxWindow* win = getWindow(); + win->Destroy(); + win = nullptr; + } } void Field::PostInitialize() { auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - m_Undo_btn = new RevertButton(m_parent, "bullet_white.png"); - m_Undo_to_sys_btn = new RevertButton(m_parent, "bullet_white.png"); - - m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_initial_value(); })); - m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); })); - - m_blinking_bmp = new BlinkingBitmap(m_parent); switch (m_opt.type) { @@ -94,6 +93,7 @@ void Field::PostInitialize() // initialize m_unit_value m_em_unit = em_unit(m_parent); + parent_is_custom_ctrl = dynamic_cast(m_parent) != nullptr; BUILD(); @@ -216,10 +216,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true break; } - wxString label = m_Label->GetLabel(); - if (label.Last() == '\n') label.RemoveLast(); - while (label.Last() == ' ') label.RemoveLast(); - if (label.Last() == ':') label.RemoveLast(); + wxString label = m_opt.full_label.empty() ? _(m_opt.label) : _(m_opt.full_label); show_error(m_parent, from_u8((boost::format(_utf8(L("%s doesn't support percentage"))) % label).str())); set_value(double_to_string(m_opt.min), true); m_value = double(m_opt.min); @@ -305,28 +302,14 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } } -void Field::msw_rescale(bool rescale_sidetext) +void Field::msw_rescale() { - m_Undo_to_sys_btn->msw_rescale(); - m_Undo_btn->msw_rescale(); - m_blinking_bmp->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); - } } void Field::sys_color_changed() { - m_Undo_to_sys_btn->msw_rescale(); - m_Undo_btn->msw_rescale(); } template @@ -387,6 +370,8 @@ void TextCtrl::BUILD() { const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/; auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, style); + if (parent_is_custom_ctrl && m_opt.height < 0) + opt_height = (double)temp->GetSize().GetHeight()/m_em_unit; temp->SetFont(m_opt.is_code ? Slic3r::GUI::wxGetApp().code_font(): Slic3r::GUI::wxGetApp().normal_font()); @@ -550,17 +535,24 @@ boost::any& TextCtrl::get_value() return m_value; } -void TextCtrl::msw_rescale(bool rescale_sidetext/* = false*/) +void TextCtrl::msw_rescale() { - Field::msw_rescale(rescale_sidetext); + Field::msw_rescale(); 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.height >= 0) + size.SetHeight(m_opt.height*m_em_unit); + else if (parent_is_custom_ctrl && opt_height > 0) + size.SetHeight(lround(opt_height*m_em_unit)); if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); if (size != wxDefaultSize) { wxTextCtrl* field = dynamic_cast(window); - field->SetMinSize(size); + if (parent_is_custom_ctrl) + field->SetSize(size); + else + field->SetMinSize(size); } } @@ -650,7 +642,7 @@ boost::any& CheckBox::get_value() return m_value; } -void CheckBox::msw_rescale(bool rescale_sidetext/* = false*/) +void CheckBox::msw_rescale() { Field::msw_rescale(); @@ -704,6 +696,9 @@ void SpinCtrl::BUILD() { temp->SetFont(Slic3r::GUI::wxGetApp().normal_font()); if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT); + if (m_opt.height < 0 && parent_is_custom_ctrl) + opt_height = (double)temp->GetSize().GetHeight() / m_em_unit; + // XXX: On OS X the wxSpinCtrl widget is made up of two subwidgets, unfortunatelly // the kill focus event is not propagated to the encompassing widget, // so we need to bind it on the inner text widget instead. (Ugh.) @@ -785,23 +780,32 @@ void SpinCtrl::propagate_value() suppress_propagation = false; } -void SpinCtrl::msw_rescale(bool rescale_sidetext/* = false*/) +void SpinCtrl::msw_rescale() { - Field::msw_rescale(rescale_sidetext); + Field::msw_rescale(); wxSpinCtrl* field = dynamic_cast(window); - field->SetMinSize(wxSize(def_width() * m_em_unit, int(1.9f*field->GetFont().GetPixelSize().y))); + if (parent_is_custom_ctrl) + field->SetSize(wxSize(def_width() * m_em_unit, lround(opt_height * m_em_unit))); + else + field->SetMinSize(wxSize(def_width() * m_em_unit, int(1.9f*field->GetFont().GetPixelSize().y))); } +#ifdef __WXOSX__ +using choice_ctrl = wxBitmapComboBox; +#else +using choice_ctrl = wxComboBox; +#endif // __WXOSX__ + void Choice::BUILD() { 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); - wxBitmapComboBox* temp; + choice_ctrl* temp; if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) { m_is_editable = true; - temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size); + temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size); } else { #ifdef __WXOSX__ @@ -809,11 +813,11 @@ void Choice::BUILD() { * so ToolTip doesn't shown. * Next workaround helps to solve this problem */ - temp = new wxBitmapComboBox(); + temp = new choice_ctrl(); temp->SetTextCtrlStyle(wxTE_READONLY); temp->Create(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr); #else - temp = new wxBitmapComboBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY); + temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY); #endif //__WXOSX__ } @@ -836,7 +840,8 @@ void Choice::BUILD() { set_selection(); } -#ifndef __WXGTK__ +#ifdef __WXOSX__ +//#ifndef __WXGTK__ /* Workaround for a correct rendering of the control without Bitmap (under MSW and OSX): * * 1. We should create small Bitmap to fill Bitmaps RefData, @@ -863,7 +868,7 @@ void Choice::BUILD() { } double old_val = !m_value.empty() ? boost::any_cast(m_value) : -99999; - if (is_defined_input_value(window, m_opt.type)) { + if (is_defined_input_value(window, m_opt.type)) { if (fabs(old_val - boost::any_cast(get_value())) <= 0.0001) return; else @@ -886,7 +891,7 @@ void Choice::set_selection() wxString text_value = wxString(""); - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); switch (m_opt.type) { case coFloat: case coPercent: { @@ -956,7 +961,7 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda ++idx; } - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); idx == m_opt.enum_values.size() ? field->SetValue(value) : field->SetSelection(idx); @@ -968,7 +973,7 @@ void Choice::set_value(const boost::any& value, bool change_event) { m_disable_change_event = !change_event; - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); switch (m_opt.type) { case coInt: @@ -1044,7 +1049,7 @@ void Choice::set_values(const std::vector& values) // # it looks that Clear() also clears the text field in recent wxWidgets versions, // # but we want to preserve it - auto ww = dynamic_cast(window); + auto ww = dynamic_cast(window); auto value = ww->GetValue(); ww->Clear(); ww->Append(""); @@ -1077,7 +1082,7 @@ void Choice::set_values(const wxArrayString &values) boost::any& Choice::get_value() { - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); wxString ret_str = field->GetValue(); @@ -1137,16 +1142,20 @@ boost::any& Choice::get_value() return m_value; } -void Choice::msw_rescale(bool rescale_sidetext/* = false*/) +void Choice::enable() { dynamic_cast(window)->Enable(); }; +void Choice::disable() { dynamic_cast(window)->Disable(); }; + +void Choice::msw_rescale() { Field::msw_rescale(); - wxBitmapComboBox* field = dynamic_cast(window); + choice_ctrl* field = dynamic_cast(window); +#ifdef __WXOSX__ const wxString selection = field->GetValue();// field->GetString(index); /* To correct scaling (set new controll size) of a wxBitmapCombobox * we need to refill control with new bitmaps. So, in our case : - * 1. clear conrol + * 1. clear control * 2. add content * 3. add scaled "empty" bitmap to the at least one item */ @@ -1179,6 +1188,16 @@ void Choice::msw_rescale(bool rescale_sidetext/* = false*/) idx == m_opt.enum_values.size() ? field->SetValue(selection) : field->SetSelection(idx); +#else + auto size = wxSize(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); + + if (parent_is_custom_ctrl) + field->SetSize(size); + else + field->SetMinSize(size); +#endif } void ColourPicker::BUILD() @@ -1195,6 +1214,8 @@ void ColourPicker::BUILD() } auto temp = new wxColourPickerCtrl(m_parent, wxID_ANY, clr, wxDefaultPosition, size); + if (parent_is_custom_ctrl && m_opt.height < 0) + opt_height = (double)temp->GetSize().GetHeight() / m_em_unit; temp->SetFont(Slic3r::GUI::wxGetApp().normal_font()); if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT); @@ -1251,15 +1272,21 @@ boost::any& ColourPicker::get_value() return m_value; } -void ColourPicker::msw_rescale(bool rescale_sidetext/* = false*/) +void ColourPicker::msw_rescale() { Field::msw_rescale(); wxColourPickerCtrl* field = dynamic_cast(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.height >= 0) + size.SetHeight(m_opt.height * m_em_unit); + else if (parent_is_custom_ctrl && opt_height > 0) + size.SetHeight(lround(opt_height * m_em_unit)); if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit); - field->SetMinSize(size); + if (parent_is_custom_ctrl) + field->SetSize(size); + else + field->SetMinSize(size); if (field->GetColour() == wxTransparentColour) set_undef_value(field); @@ -1279,6 +1306,9 @@ void PointCtrl::BUILD() x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size, wxTE_PROCESS_ENTER); y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size, wxTE_PROCESS_ENTER); + if (parent_is_custom_ctrl && m_opt.height < 0) + opt_height = (double)x_textctrl->GetSize().GetHeight() / m_em_unit; + x_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font()); x_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT); y_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font()); @@ -1296,9 +1326,6 @@ void PointCtrl::BUILD() temp->Add(static_text_y, 0, wxALIGN_CENTER_VERTICAL, 0); temp->Add(y_textctrl); -// x_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), x_textctrl->GetId()); -// y_textctrl->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) { on_change_field(); }), y_textctrl->GetId()); - x_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_value(x_textctrl); }), x_textctrl->GetId()); y_textctrl->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e) { propagate_value(y_textctrl); }), y_textctrl->GetId()); @@ -1312,14 +1339,21 @@ void PointCtrl::BUILD() y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y)); } -void PointCtrl::msw_rescale(bool rescale_sidetext/* = false*/) +void PointCtrl::msw_rescale() { Field::msw_rescale(); - const wxSize field_size(4 * m_em_unit, -1); + wxSize field_size(4 * m_em_unit, -1); - x_textctrl->SetMinSize(field_size); - y_textctrl->SetMinSize(field_size); + if (parent_is_custom_ctrl) { + field_size.SetHeight(lround(opt_height * m_em_unit)); + x_textctrl->SetSize(field_size); + y_textctrl->SetSize(field_size); + } + else { + x_textctrl->SetMinSize(field_size); + y_textctrl->SetMinSize(field_size); + } } bool PointCtrl::value_was_changed(wxTextCtrl* win) @@ -1411,7 +1445,7 @@ void StaticText::BUILD() temp->SetToolTip(get_tooltip_text(legend)); } -void StaticText::msw_rescale(bool rescale_sidetext/* = false*/) +void StaticText::msw_rescale() { Field::msw_rescale(); diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index aa047d030..b4bcf9f33 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -87,6 +87,8 @@ protected: void on_set_focus(wxEvent& event); /// Call the attached on_change method. void on_change_field(); + +public: /// Call the attached m_back_to_initial_value method. void on_back_to_initial_value(); /// Call the attached m_back_to_sys_value method. @@ -119,6 +121,9 @@ public: const t_config_option_key m_opt_id;//! {""}; int m_opt_idx = 0; + double opt_height{ 0.0 }; + bool parent_is_custom_ctrl{ false }; + /// Sets a value for this control. /// subclasses should overload with a specific version /// Postcondition: Method does not fire the on_change event. @@ -140,9 +145,6 @@ public: void field_changed() { on_change_field(); } - // set icon to "UndoToSystemValue" button according to an inheritance of preset -// void set_nonsys_btn_icon(const wxBitmap& icon); - Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {}; Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {}; virtual ~Field(); @@ -151,8 +153,6 @@ public: virtual wxSizer* getSizer() { return nullptr; } virtual wxWindow* getWindow() { return nullptr; } - wxStaticText* getLabel() { return m_Label; } - bool is_matched(const std::string& string, const std::string& pattern); void get_value_by_opt_type(wxString& str, const bool check_value = true); @@ -168,7 +168,6 @@ public: bool set_undo_bitmap(const ScalableBitmap *bmp) { if (m_undo_bitmap != bmp) { m_undo_bitmap = bmp; - m_Undo_btn->SetBitmap_(*bmp); return true; } return false; @@ -177,33 +176,21 @@ public: bool set_undo_to_sys_bitmap(const ScalableBitmap *bmp) { if (m_undo_to_sys_bitmap != bmp) { m_undo_to_sys_bitmap = bmp; - m_Undo_to_sys_btn->SetBitmap_(*bmp); return true; } return false; } bool set_label_colour(const wxColour *clr) { - if (m_Label == nullptr) return false; if (m_label_color != clr) { m_label_color = clr; - m_Label->SetForegroundColour(*clr); - m_Label->Refresh(true); } return false; } - bool set_label_colour_force(const wxColour *clr) { - if (m_Label == nullptr) return false; - m_Label->SetForegroundColour(*clr); - m_Label->Refresh(true); - return false; - } - bool set_undo_tooltip(const wxString *tip) { if (m_undo_tooltip != tip) { m_undo_tooltip = tip; - m_Undo_btn->SetToolTip(*tip); return true; } return false; @@ -212,17 +199,16 @@ public: bool set_undo_to_sys_tooltip(const wxString *tip) { if (m_undo_to_sys_tooltip != tip) { m_undo_to_sys_tooltip = tip; - m_Undo_to_sys_btn->SetToolTip(*tip); return true; } return false; } - void set_side_text_ptr(wxStaticText* side_text) { - m_side_text = side_text; + bool* get_blink_ptr() { + return &m_blink; } - virtual void msw_rescale(bool rescale_sidetext = false); + virtual void msw_rescale(); void sys_color_changed(); bool get_enter_pressed() const { return bEnterPressed; } @@ -233,26 +219,26 @@ public: static int def_width_wider() ; static int def_width_thinner() ; - BlinkingBitmap* blinking_bitmap() const { return m_blinking_bmp;} + const ScalableBitmap* undo_bitmap() { return m_undo_bitmap; } + const wxString* undo_tooltip() { return m_undo_tooltip; } + const ScalableBitmap* undo_to_sys_bitmap() { return m_undo_to_sys_bitmap; } + const wxString* undo_to_sys_tooltip() { return m_undo_to_sys_tooltip; } + const wxColour* label_color() { return m_label_color; } + const bool blink() { return m_blink; } 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. const ScalableBitmap* m_undo_bitmap = nullptr; const wxString* m_undo_tooltip = nullptr; - RevertButton* m_Undo_to_sys_btn = nullptr; // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const ScalableBitmap* m_undo_to_sys_bitmap = nullptr; const wxString* m_undo_to_sys_tooltip = nullptr; - BlinkingBitmap* m_blinking_bmp{ nullptr }; + bool m_blink{ false }; - wxStaticText* m_Label = nullptr; // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. const wxColour* m_label_color = nullptr; - wxStaticText* m_side_text = nullptr; - // current value boost::any m_value; // last maeningful value @@ -308,7 +294,7 @@ public: boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override; void disable() override; @@ -336,7 +322,7 @@ public: void set_na_value() override; boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); } void disable() override { dynamic_cast(window)->Disable(); } @@ -379,7 +365,7 @@ public: return m_value = value; } - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); } void disable() override { dynamic_cast(window)->Disable(); } @@ -408,10 +394,10 @@ public: void set_values(const wxArrayString &values); boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; - void enable() override { dynamic_cast(window)->Enable(); }; - void disable() override{ dynamic_cast(window)->Disable(); }; + void enable() override ;//{ dynamic_cast(window)->Enable(); }; + void disable() override;//{ dynamic_cast(window)->Disable(); }; wxWindow* getWindow() override { return window; } }; @@ -434,7 +420,7 @@ public: } void set_value(const boost::any& value, bool change_event = false) override; boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; @@ -460,7 +446,7 @@ public: void set_value(const boost::any& value, bool change_event = false); boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { x_textctrl->Enable(); @@ -495,7 +481,7 @@ public: boost::any& get_value()override { return m_value; } - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp new file mode 100644 index 000000000..145d97189 --- /dev/null +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -0,0 +1,646 @@ +#include "OG_CustomCtrl.hpp" +#include "OptionsGroup.hpp" +#include "Plater.hpp" +#include "GUI_App.hpp" +#include "libslic3r/AppConfig.hpp" + +#include +#include +#include "libslic3r/Utils.hpp" +#include "I18N.hpp" + +namespace Slic3r { namespace GUI { + +static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect) +{ + return rect.GetLeft() <= pt.x && pt.x <= rect.GetRight() && + rect.GetTop() <= pt.y && pt.y <= rect.GetBottom(); +} + +static wxSize get_bitmap_size(const wxBitmap& bmp) +{ +#ifdef __APPLE__ + return bmp.GetScaledSize(); +#else + return bmp.GetSize(); +#endif +} + +static wxString get_url(const wxString& path_end, bool get_default = false) +{ + if (path_end.IsEmpty()) + return wxEmptyString; + + wxString language = wxGetApp().app_config->get("translation_language"); + wxString lang_marker = language.IsEmpty() ? "en" : language.BeforeFirst('_'); + + return wxString("https://help.prusa3d.com/") + lang_marker + "/article/" + path_end; +} + +OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent, + OptionsGroup* og, + const wxPoint& pos /* = wxDefaultPosition*/, + const wxSize& size/* = wxDefaultSize*/, + const wxValidator& val /* = wxDefaultValidator*/, + const wxString& name/* = wxEmptyString*/) : + wxPanel(parent, wxID_ANY, pos, size, /*wxWANTS_CHARS |*/ wxBORDER_NONE | wxTAB_TRAVERSAL), + opt_group(og) +{ + if (!wxOSX) + SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX + + m_font = wxGetApp().normal_font(); + m_em_unit = em_unit(m_parent); + m_v_gap = lround(1.0 * m_em_unit); + m_h_gap = lround(0.2 * m_em_unit); + + m_bmp_mode_sz = get_bitmap_size(create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12)); + m_bmp_blinking_sz = get_bitmap_size(create_scaled_bitmap("search_blink", this)); + + init_ctrl_lines();// from og.lines() + + this->Bind(wxEVT_PAINT, &OG_CustomCtrl::OnPaint, this); + this->Bind(wxEVT_MOTION, &OG_CustomCtrl::OnMotion, this); + this->Bind(wxEVT_LEFT_DOWN, &OG_CustomCtrl::OnLeftDown, this); +} + +void OG_CustomCtrl::init_ctrl_lines() +{ + const std::vector& og_lines = opt_group->get_lines(); + for (const Line& line : og_lines) + { + if (line.full_width && ( + // description line + line.widget != nullptr || + // description line with widget (button) + !line.get_extra_widgets().empty()) + ) + continue; + + const std::vector