mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 05:37:52 -06:00
Add fix for linux
Original Commit: prusa3d/PrusaSlicer@361ef22 Co-authored-by: YuSanka <yusanka@gmail.com>
This commit is contained in:
parent
8c6100ea21
commit
7a1d782ce1
2 changed files with 67 additions and 37 deletions
|
@ -50,7 +50,7 @@ EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const
|
||||||
auto* grid_sizer = new wxFlexGridSizer(1, 3, 5, 15);
|
auto* grid_sizer = new wxFlexGridSizer(1, 3, 5, 15);
|
||||||
grid_sizer->SetFlexibleDirection(wxBOTH);
|
grid_sizer->SetFlexibleDirection(wxBOTH);
|
||||||
|
|
||||||
m_params_list = new ParamsViewCtrl(this, wxSize(em * 30, em * 70));
|
m_params_list = new ParamsViewCtrl(this, wxSize(em * 45, em * 70));
|
||||||
m_params_list->SetFont(wxGetApp().code_font());
|
m_params_list->SetFont(wxGetApp().code_font());
|
||||||
wxGetApp().UpdateDarkUI(m_params_list);
|
wxGetApp().UpdateDarkUI(m_params_list);
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
m_gcode_editor->SetFont(wxGetApp().code_font());
|
m_gcode_editor->SetFont(wxGetApp().code_font());
|
||||||
|
m_gcode_editor->SetInsertionPointEnd();
|
||||||
wxGetApp().UpdateDarkUI(m_gcode_editor);
|
wxGetApp().UpdateDarkUI(m_gcode_editor);
|
||||||
|
|
||||||
grid_sizer->Add(m_params_list, 1, wxEXPAND);
|
grid_sizer->Add(m_params_list, 1, wxEXPAND);
|
||||||
|
@ -103,6 +104,13 @@ EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const
|
||||||
bind_list_and_button();
|
bind_list_and_button();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditGCodeDialog::~EditGCodeDialog()
|
||||||
|
{
|
||||||
|
// To avoid redundant process of wxEVT_DATAVIEW_SELECTION_CHANGED after dialog distroing (on Linux)
|
||||||
|
// unbind this event from params_list
|
||||||
|
m_params_list->Unbind(wxEVT_DATAVIEW_SELECTION_CHANGED, &EditGCodeDialog::selection_changed, this);
|
||||||
|
}
|
||||||
|
|
||||||
std::string EditGCodeDialog::get_edited_gcode() const
|
std::string EditGCodeDialog::get_edited_gcode() const
|
||||||
{
|
{
|
||||||
return into_u8(m_gcode_editor->GetValue());
|
return into_u8(m_gcode_editor->GetValue());
|
||||||
|
@ -234,13 +242,25 @@ wxDataViewItem EditGCodeDialog::add_presets_placeholders()
|
||||||
void EditGCodeDialog::add_selected_value_to_gcode()
|
void EditGCodeDialog::add_selected_value_to_gcode()
|
||||||
{
|
{
|
||||||
const wxString val = m_params_list->GetSelectedValue();
|
const wxString val = m_params_list->GetSelectedValue();
|
||||||
if (!val.IsEmpty())
|
if (val.IsEmpty())
|
||||||
m_gcode_editor->WriteText(val + "\n");
|
return;
|
||||||
|
|
||||||
|
const long pos = m_gcode_editor->GetInsertionPoint();
|
||||||
|
m_gcode_editor->WriteText(m_gcode_editor->GetInsertionPoint() == m_gcode_editor->GetLastPosition() ? "\n" + val : val);
|
||||||
|
|
||||||
|
if (val.Last() == ']') {
|
||||||
|
const long new_pos = m_gcode_editor->GetInsertionPoint();
|
||||||
|
if (val[val.Len() - 2] == '[')
|
||||||
|
m_gcode_editor->SetInsertionPoint(new_pos - 1); // set cursor into brackets
|
||||||
|
else
|
||||||
|
m_gcode_editor->SetSelection(new_pos - 17, new_pos - 1); // select "current_extruder"
|
||||||
|
}
|
||||||
|
|
||||||
|
m_gcode_editor->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditGCodeDialog::bind_list_and_button()
|
void EditGCodeDialog::selection_changed(wxDataViewEvent& evt)
|
||||||
{
|
{
|
||||||
m_params_list->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [this](wxDataViewEvent& evt) {
|
|
||||||
wxString label;
|
wxString label;
|
||||||
wxString description;
|
wxString description;
|
||||||
|
|
||||||
|
@ -296,12 +316,19 @@ void EditGCodeDialog::bind_list_and_button()
|
||||||
else
|
else
|
||||||
label = "Undef optptr";
|
label = "Undef optptr";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
label = "Undef optptr";
|
||||||
|
}
|
||||||
|
|
||||||
m_param_label->SetLabel(label);
|
m_param_label->SetLabel(label);
|
||||||
m_param_description->SetLabel(description);
|
m_param_description->SetLabel(description);
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
});
|
}
|
||||||
|
|
||||||
|
void EditGCodeDialog::bind_list_and_button()
|
||||||
|
{
|
||||||
|
m_params_list->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &EditGCodeDialog::selection_changed, this);
|
||||||
|
|
||||||
m_params_list->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [this](wxDataViewEvent& ) {
|
m_params_list->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [this](wxDataViewEvent& ) {
|
||||||
add_selected_value_to_gcode();
|
add_selected_value_to_gcode();
|
||||||
|
|
|
@ -44,7 +44,7 @@ class EditGCodeDialog : public DPIDialog
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EditGCodeDialog(wxWindow*parent, const std::string&key, const std::string&value);
|
EditGCodeDialog(wxWindow*parent, const std::string&key, const std::string&value);
|
||||||
~EditGCodeDialog() {}
|
~EditGCodeDialog();
|
||||||
|
|
||||||
std::string get_edited_gcode() const;
|
std::string get_edited_gcode() const;
|
||||||
|
|
||||||
|
@ -59,6 +59,9 @@ protected:
|
||||||
|
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
void on_sys_color_changed() override;
|
void on_sys_color_changed() override;
|
||||||
|
|
||||||
|
void selection_changed(wxDataViewEvent& evt);
|
||||||
|
|
||||||
wxBoxSizer* EditGCodeDialog::create_btn_sizer(long flags);
|
wxBoxSizer* EditGCodeDialog::create_btn_sizer(long flags);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue