From 0faf1e59883f41a28f1762737c8da04d34f3c303 Mon Sep 17 00:00:00 2001 From: supermerill Date: Thu, 1 Aug 2024 18:06:22 +0200 Subject: [PATCH] fixes linux --- src/slic3r/GUI/Field.cpp | 59 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 312aeed3ad..cbccbe99d3 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1158,8 +1158,8 @@ bool TextCtrl::value_was_changed() case coPoints: if (m_opt_idx < 0) { return boost::any_cast>(m_value) != boost::any_cast>(val); - } else if (boost::any_cast>(m_value).size() > m_opt_idx - && boost::any_cast>(val).size() > m_opt_idx) { + } else if (int(boost::any_cast>(m_value).size()) > m_opt_idx + && int(boost::any_cast>(val).size()) > m_opt_idx) { return boost::any_cast>(m_value)[m_opt_idx] != boost::any_cast>(val)[m_opt_idx]; } case coPoint: @@ -1363,7 +1363,7 @@ void CheckBox::Rescale(wxWindow* win) } #ifdef __WXGTK2__ if (wxToggleButton* chk = dynamic_cast(win)) - chk->Rescale(); + chk->Update(); #endif } @@ -1402,12 +1402,14 @@ void CheckBox::BUILD() { #ifdef __WXGTK2__ //gtk2 can't resize checkboxes, so we are using togglable buttons instead window->Bind(wxEVT_TOGGLEBUTTON, ([this](wxCommandEvent e) { - m_is_na_val = false; - if (static_cast(window)->GetValue()) - static_cast(window)->SetLabel("X"); - else - static_cast(window)->SetLabel(""); - on_change_field(); + if (wxToggleButton* chk = dynamic_cast(window)) { + m_is_na_val = false; + if (chk->GetValue()) + chk->SetLabel("X"); + else + chk->SetLabel(""); + on_change_field(); + } }), window->GetId()); #else window->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent e) { @@ -1870,18 +1872,19 @@ void Choice::set_selection() field->SetSelection(*opt); else field->SetValue(text_value); - } + } } void Choice::set_text_value(const std::string &value, bool change_event) //! Redundant? { m_disable_change_event = !change_event; choice_ctrl* field = dynamic_cast(window); - if (auto opt = m_opt.enum_def->value_to_index(value); opt.has_value()) + if (auto opt = m_opt.enum_def->value_to_index(value); opt.has_value()) { // This enum has a value field of the same content as text_value. Select it. field->SetSelection(*opt); - else + } else { field->SetValue(value); + } m_disable_change_event = false; } @@ -2011,19 +2014,20 @@ boost::any& Choice::get_value() else if (m_opt.gui_type == ConfigOptionDef::GUIType::f_enum_open || m_opt.gui_type == ConfigOptionDef::GUIType::i_enum_open) { // Open enum: The combo box item index returned by the field const int ret_enum = field->GetSelection(); - if (m_opt.enum_def->has_values() && (m_opt.type == coString || m_opt.type == coStrings) && ret_enum >=0 && ret_enum < m_opt.enum_def->values().size()) { + if (m_opt.enum_def->has_values() && (m_opt.type == coString || m_opt.type == coStrings) && ret_enum >=0 && ret_enum < int(m_opt.enum_def->values().size())) { m_value = m_opt.enum_def->value(ret_enum); } else if (ret_enum < 0 || !m_opt.enum_def->has_values() || m_opt.type == coStrings || - (into_u8(ret_str) != m_opt.enum_def->value(ret_enum) && ret_str != _(m_opt.enum_def->label(ret_enum)))) + (into_u8(ret_str) != m_opt.enum_def->value(ret_enum) && ret_str != _(m_opt.enum_def->label(ret_enum)))) { // modifies ret_string! get_value_by_opt_type(ret_str); - else if (m_opt.type == coFloatOrPercent) { + } else if (m_opt.type == coFloatOrPercent) { m_value = FloatOrPercent{string_to_double_decimal_point(m_opt.enum_def->value(ret_enum)), (m_opt.enum_def->value(ret_enum).find('%') != std::string::npos)}; - } else if (m_opt.type == coInt) + } else if (m_opt.type == coInt) { m_value = atoi(m_opt.enum_def->value(ret_enum).c_str()); - else + } else { m_value = string_to_double_decimal_point(m_opt.enum_def->value(ret_enum)); + } } else // modifies ret_string! @@ -2095,16 +2099,15 @@ void ColourPicker::BUILD() // Validate the color wxColour clr = wxTransparentColour; if (m_opt.type == coStrings) - clr = wxColour{wxString{ m_opt.get_default_value()->get_at(m_opt_idx) }}; + clr = wxColour{wxString{m_opt.get_default_value()->get_at(m_opt_idx)}}; if (m_opt.type == coString) - clr = wxColour{ wxString{ m_opt.get_default_value()->value } }; + clr = wxColour{wxString{m_opt.get_default_value()->value}}; if (m_opt.type == coInts) - clr = wxColour{ (unsigned long)m_opt.get_default_value()->get_at(m_opt_idx) }; + clr = wxColour{(unsigned long) m_opt.get_default_value()->get_at(m_opt_idx)}; if (m_opt.type == coInt) - clr = wxColour{ (unsigned long)m_opt.get_default_value()->value }; - if (!clr.IsOk()) { - clr = wxTransparentColour; - } + clr = wxColour{(unsigned long) m_opt.get_default_value()->value}; + if (!clr.IsOk()) + clr = wxTransparentColour; auto temp = new wxColourPickerCtrl(m_parent, wxID_ANY, clr, wxDefaultPosition, size); if (parent_is_custom_ctrl && m_opt.height < 0) @@ -2320,11 +2323,13 @@ void PointCtrl::BUILD() const wxSize field_size(4 * m_em_unit, -1); Vec2d default_pt; - if (m_opt.type == coPoint) + if (m_opt.type == coPoint) { default_pt = m_opt.get_default_value()->value; - else // coPoints + } else { // coPoints + assert(m_opt.type == coPoints); default_pt = m_opt.get_default_value()->get_at(0); - double val = default_pt(0); + } + double val = default_pt.x(); wxString X = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); val = default_pt(1); wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);