Merge branch 'master' into stable - no conflicts fixed
This commit is contained in:
commit
ebb9041041
1005 changed files with 1029738 additions and 138540 deletions
src/slic3r/GUI
|
@ -13,9 +13,12 @@
|
|||
#include <wx/numformatter.h>
|
||||
#include <wx/tooltip.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/listbook.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include "OG_CustomCtrl.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "BitmapComboBox.hpp"
|
||||
|
||||
#ifdef __WXOSX__
|
||||
#define wxOSX true
|
||||
|
@ -36,12 +39,13 @@ wxString double_to_string(double const value, const int max_precision /*= 4*/)
|
|||
// with the exception that here one sets the decimal separator explicitely to dot.
|
||||
// If number is in scientific format, trailing zeroes belong to the exponent and cannot be removed.
|
||||
if (s.find_first_of("eE") == wxString::npos) {
|
||||
const size_t posDecSep = s.find(".");
|
||||
char dec_sep = is_decimal_separator_point() ? '.' : ',';
|
||||
const size_t posDecSep = s.find(dec_sep);
|
||||
// No decimal point => removing trailing zeroes irrelevant for integer number.
|
||||
if (posDecSep != wxString::npos) {
|
||||
// Find the last character to keep.
|
||||
size_t posLastNonZero = s.find_last_not_of("0");
|
||||
// If it's the decimal separator itself, don't keep it neither.
|
||||
// If it's the decimal separator itself, don't keep it either.
|
||||
if (posLastNonZero == posDecSep)
|
||||
-- posLastNonZero;
|
||||
s.erase(posLastNonZero + 1);
|
||||
|
@ -69,8 +73,6 @@ Field::~Field()
|
|||
{
|
||||
if (m_on_kill_focus)
|
||||
m_on_kill_focus = nullptr;
|
||||
if (m_on_set_focus)
|
||||
m_on_set_focus = nullptr;
|
||||
if (m_on_change)
|
||||
m_on_change = nullptr;
|
||||
if (m_back_to_initial_value)
|
||||
|
@ -92,8 +94,8 @@ void Field::PostInitialize()
|
|||
{
|
||||
case coPercents:
|
||||
case coFloats:
|
||||
case coStrings:
|
||||
case coBools:
|
||||
case coStrings:
|
||||
case coBools:
|
||||
case coInts: {
|
||||
auto tag_pos = m_opt_id.find("#");
|
||||
if (tag_pos != std::string::npos)
|
||||
|
@ -111,7 +113,7 @@ void Field::PostInitialize()
|
|||
BUILD();
|
||||
|
||||
// For the mode, when settings are in non-modal dialog, neither dialog nor tabpanel doesn't receive wxEVT_KEY_UP event, when some field is selected.
|
||||
// So, like a workaround check wxEVT_KEY_UP event for the Filed and switch between tabs if Ctrl+(1-4) was pressed
|
||||
// So, like a workaround check wxEVT_KEY_UP event for the Filed and switch between tabs if Ctrl+(1-4) was pressed
|
||||
if (getWindow())
|
||||
getWindow()->Bind(wxEVT_KEY_UP, [](wxKeyEvent& evt) {
|
||||
if ((evt.GetModifiers() & wxMOD_CONTROL) != 0) {
|
||||
|
@ -135,7 +137,7 @@ void Field::PostInitialize()
|
|||
// tab panel should be focused for correct navigation between tabs
|
||||
wxGetApp().tab_panel()->SetFocus();
|
||||
}
|
||||
|
||||
|
||||
evt.Skip();
|
||||
});
|
||||
}
|
||||
|
@ -148,19 +150,10 @@ int Field::def_width_thinner() { return 4; }
|
|||
void Field::on_kill_focus()
|
||||
{
|
||||
// call the registered function if it is available
|
||||
if (m_on_kill_focus!=nullptr)
|
||||
if (m_on_kill_focus!=nullptr)
|
||||
m_on_kill_focus(m_opt_id);
|
||||
}
|
||||
|
||||
void Field::on_set_focus(wxEvent& event)
|
||||
{
|
||||
// to allow the default behavior
|
||||
event.Skip();
|
||||
// call the registered function if it is available
|
||||
if (m_on_set_focus!=nullptr)
|
||||
m_on_set_focus(m_opt_id);
|
||||
}
|
||||
|
||||
void Field::on_change_field()
|
||||
{
|
||||
// std::cerr << "calling Field::_on_change \n";
|
||||
|
@ -196,7 +189,7 @@ wxString Field::get_tooltip_text(const wxString& default_string)
|
|||
if (tooltip.length() > 0)
|
||||
tooltip_text = tooltip + "\n" + _(L("default value")) + "\t: " +
|
||||
(boost::iends_with(opt_id, "_gcode") ? "\n" : "") + default_string +
|
||||
(boost::iends_with(opt_id, "_gcode") ? "" : "\n") +
|
||||
(boost::iends_with(opt_id, "_gcode") ? "" : "\n") +
|
||||
_(L("parameter name")) + "\t: " + opt_id;
|
||||
|
||||
return tooltip_text;
|
||||
|
@ -220,7 +213,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
case coPercents:
|
||||
case coFloats:
|
||||
case coFloat:{
|
||||
if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%')
|
||||
if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%')
|
||||
str.RemoveLast();
|
||||
else if (!str.IsEmpty() && str.Last() == '%')
|
||||
{
|
||||
|
@ -235,16 +228,25 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
m_value = double(m_opt.min);
|
||||
break;
|
||||
}
|
||||
double val;
|
||||
// Replace the first occurence of comma in decimal number.
|
||||
str.Replace(",", ".", false);
|
||||
if (str == ".")
|
||||
double val;
|
||||
|
||||
bool is_na_value = m_opt.nullable && str == na_value();
|
||||
|
||||
const char dec_sep = is_decimal_separator_point() ? '.' : ',';
|
||||
const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
|
||||
// Replace the first incorrect separator in decimal number,
|
||||
// if this value doesn't "N/A" value in some language
|
||||
// see https://github.com/prusa3d/PrusaSlicer/issues/6921
|
||||
if (!is_na_value && str.Replace(dec_sep_alt, dec_sep, false) != 0)
|
||||
set_value(str, false);
|
||||
|
||||
if (str == dec_sep)
|
||||
val = 0.0;
|
||||
else
|
||||
{
|
||||
if (m_opt.nullable && str == na_value())
|
||||
if (is_na_value)
|
||||
val = ConfigOptionFloatsNullable::nil_value();
|
||||
else if (!str.ToCDouble(&val))
|
||||
else if (!str.ToDouble(&val))
|
||||
{
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
|
@ -263,7 +265,8 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
if (m_value.empty() || boost::any_cast<double>(m_value) != val) {
|
||||
wxString msg_text = format_wxstr(_L("Input value is out of range\n"
|
||||
"Are you sure that %s is a correct value and that you want to continue?"), str);
|
||||
wxMessageDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxICON_WARNING | wxYES | wxNO);
|
||||
// wxMessageDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxICON_WARNING | wxYES | wxNO);
|
||||
WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO);
|
||||
if (dialog.ShowModal() == wxID_NO) {
|
||||
if (m_value.empty()) {
|
||||
if (m_opt.min > val) val = m_opt.min;
|
||||
|
@ -288,17 +291,31 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
case coString:
|
||||
case coStrings:
|
||||
case coFloatOrPercent: {
|
||||
if (m_opt.type == coFloatOrPercent && m_opt.opt_key == "first_layer_height" && !str.IsEmpty() && str.Last() == '%') {
|
||||
// Workaroud to avoid of using of the % for first layer height
|
||||
// see https://github.com/prusa3d/PrusaSlicer/issues/7418
|
||||
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()));
|
||||
const wxString stVal = double_to_string(0.01, 2);
|
||||
set_value(stVal, true);
|
||||
m_value = into_u8(stVal);;
|
||||
break;
|
||||
}
|
||||
if (m_opt.type == coFloatOrPercent && !str.IsEmpty() && str.Last() != '%')
|
||||
{
|
||||
double val = 0.;
|
||||
// Replace the first occurence of comma in decimal number.
|
||||
str.Replace(",", ".", false);
|
||||
const char dec_sep = is_decimal_separator_point() ? '.' : ',';
|
||||
const char dec_sep_alt = dec_sep == '.' ? ',' : '.';
|
||||
// Replace the first incorrect separator in decimal number.
|
||||
if (str.Replace(dec_sep_alt, dec_sep, false) != 0)
|
||||
set_value(str, false);
|
||||
|
||||
|
||||
// remove space and "mm" substring, if any exists
|
||||
str.Replace(" ", "", true);
|
||||
str.Replace("m", "", true);
|
||||
|
||||
if (!str.ToCDouble(&val))
|
||||
if (!str.ToDouble(&val))
|
||||
{
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
|
@ -308,8 +325,8 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
set_value(double_to_string(val), true);
|
||||
}
|
||||
else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
|
||||
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1)) &&
|
||||
(m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)))
|
||||
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > /*1*/m_opt.max_literal)) &&
|
||||
(m_value.empty() || into_u8(str) != boost::any_cast<std::string>(m_value)))
|
||||
{
|
||||
if (!check_value) {
|
||||
m_value.clear();
|
||||
|
@ -323,7 +340,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
const wxString msg_text = from_u8((boost::format(_utf8(L("Do you mean %s%% instead of %s %s?\n"
|
||||
"Select YES if you want to change this value to %s%%, \n"
|
||||
"or NO if you are sure that %s %s is a correct value."))) % stVal % stVal % sidetext % stVal % stVal % sidetext).str());
|
||||
wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id , wxICON_WARNING | wxYES | wxNO);
|
||||
WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES | wxNO);
|
||||
if ((!infill_anchors || val > 100) && dialog.ShowModal() == wxID_YES) {
|
||||
set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/);
|
||||
str += "%%";
|
||||
|
@ -332,8 +349,8 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "."
|
||||
}
|
||||
}
|
||||
|
||||
m_value = std::string(str.ToUTF8().data());
|
||||
|
||||
m_value = into_u8(str);
|
||||
break; }
|
||||
|
||||
case coPoints: {
|
||||
|
@ -359,8 +376,8 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
out_of_range_val = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
invalid_val = true;
|
||||
break;
|
||||
}
|
||||
|
@ -370,8 +387,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||
if (!m_value.empty())
|
||||
text_value = get_thumbnails_string(boost::any_cast<std::vector<Vec2d>>(m_value));
|
||||
set_value(text_value, true);
|
||||
show_error(m_parent, _L("Input value is out of range")
|
||||
);
|
||||
show_error(m_parent, _L("Input value is out of range"));
|
||||
}
|
||||
else if (invalid_val) {
|
||||
wxString text_value;
|
||||
|
@ -398,12 +414,16 @@ void Field::msw_rescale()
|
|||
|
||||
void Field::sys_color_changed()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (wxWindow* win = this->getWindow())
|
||||
wxGetApp().UpdateDarkUI(win);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type)
|
||||
{
|
||||
if (!win || (static_cast<T*>(win)->GetValue().empty() && type != coString && type != coStrings))
|
||||
if (!win || (static_cast<T*>(win)->GetValue().empty() && type != coString && type != coStrings && type != coPoints))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -413,7 +433,7 @@ void TextCtrl::BUILD() {
|
|||
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);
|
||||
|
||||
wxString text_value = wxString("");
|
||||
wxString text_value = wxString("");
|
||||
|
||||
switch (m_opt.type) {
|
||||
case coFloatOrPercent:
|
||||
|
@ -428,21 +448,21 @@ void TextCtrl::BUILD() {
|
|||
text_value = wxString::Format(_T("%i"), int(m_opt.default_value->getFloat()));
|
||||
text_value += "%";
|
||||
break;
|
||||
}
|
||||
}
|
||||
case coPercents:
|
||||
case coFloats:
|
||||
case coFloat:
|
||||
{
|
||||
double val = m_opt.type == coFloats ?
|
||||
m_opt.get_default_value<ConfigOptionFloats>()->get_at(m_opt_idx) :
|
||||
m_opt.type == coFloat ?
|
||||
m_opt.type == coFloat ?
|
||||
m_opt.default_value->getFloat() :
|
||||
m_opt.get_default_value<ConfigOptionPercents>()->get_at(m_opt_idx);
|
||||
text_value = double_to_string(val);
|
||||
m_last_meaningful_value = text_value;
|
||||
break;
|
||||
}
|
||||
case coString:
|
||||
case coString:
|
||||
text_value = m_opt.get_default_value<ConfigOptionString>()->value;
|
||||
break;
|
||||
case coStrings:
|
||||
|
@ -456,16 +476,20 @@ void TextCtrl::BUILD() {
|
|||
text_value = get_thumbnails_string(m_opt.get_default_value<ConfigOptionPoints>()->values);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/;
|
||||
long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER;
|
||||
#ifdef _WIN32
|
||||
style |= wxBORDER_SIMPLE;
|
||||
#endif
|
||||
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());
|
||||
wxGetApp().UpdateDarkUI(temp);
|
||||
|
||||
if (! m_opt.multiline && !wxOSX)
|
||||
// Only disable background refresh for single line input fields, as they are completely painted over by the edit control.
|
||||
|
@ -477,20 +501,18 @@ void TextCtrl::BUILD() {
|
|||
|
||||
temp->SetToolTip(get_tooltip_text(text_value));
|
||||
|
||||
if (style == wxTE_PROCESS_ENTER) {
|
||||
if (style & wxTE_PROCESS_ENTER) {
|
||||
temp->Bind(wxEVT_TEXT_ENTER, ([this, temp](wxEvent& e)
|
||||
{
|
||||
#if !defined(__WXGTK__)
|
||||
e.Skip();
|
||||
temp->GetToolTip()->Enable(true);
|
||||
#endif // __WXGTK__
|
||||
bEnterPressed = true;
|
||||
EnterPressed enter(this);
|
||||
propagate_value();
|
||||
}), temp->GetId());
|
||||
}
|
||||
|
||||
temp->Bind(wxEVT_SET_FOCUS, ([this](wxEvent& e) { on_set_focus(e); }), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_LEFT_DOWN, ([temp](wxEvent& event)
|
||||
{
|
||||
//! to allow the default handling
|
||||
|
@ -507,26 +529,11 @@ void TextCtrl::BUILD() {
|
|||
temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e)
|
||||
{
|
||||
e.Skip();
|
||||
#ifdef __WXOSX__
|
||||
// OSX issue: For some unknown reason wxEVT_KILL_FOCUS is emitted twice in a row in some cases
|
||||
// (like when information dialog is shown during an update of the option value)
|
||||
// Thus, suppress its second call
|
||||
if (bKilledFocus)
|
||||
return;
|
||||
bKilledFocus = true;
|
||||
#endif // __WXOSX__
|
||||
|
||||
#if !defined(__WXGTK__)
|
||||
temp->GetToolTip()->Enable(true);
|
||||
#endif // __WXGTK__
|
||||
if (bEnterPressed)
|
||||
bEnterPressed = false;
|
||||
else
|
||||
if (!bEnterPressed)
|
||||
propagate_value();
|
||||
#ifdef __WXOSX__
|
||||
// After processing of KILL_FOCUS event we should to invalidate a bKilledFocus flag
|
||||
bKilledFocus = false;
|
||||
#endif // __WXOSX__
|
||||
}), temp->GetId());
|
||||
/*
|
||||
// select all text using Ctrl+A
|
||||
|
@ -539,7 +546,7 @@ void TextCtrl::BUILD() {
|
|||
*/
|
||||
// recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
}
|
||||
|
||||
bool TextCtrl::value_was_changed()
|
||||
{
|
||||
|
@ -559,7 +566,7 @@ bool TextCtrl::value_was_changed()
|
|||
case coPercents:
|
||||
case coFloats:
|
||||
case coFloat: {
|
||||
if (m_opt.nullable && std::isnan(boost::any_cast<double>(m_value)) &&
|
||||
if (m_opt.nullable && std::isnan(boost::any_cast<double>(m_value)) &&
|
||||
std::isnan(boost::any_cast<double>(val)))
|
||||
return false;
|
||||
return boost::any_cast<double>(m_value) != boost::any_cast<double>(val);
|
||||
|
@ -597,9 +604,9 @@ void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/)
|
|||
|
||||
if (!change_event) {
|
||||
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
|
||||
/* Update m_value to correct work of next value_was_changed().
|
||||
* But after checking of entered value, don't fix the "incorrect" value and don't show a warning message,
|
||||
* just clear m_value in this case.
|
||||
/* Update m_value to correct work of next value_was_changed().
|
||||
* But after checking of entered value, don't fix the "incorrect" value and don't show a warning message,
|
||||
* just clear m_value in this case.
|
||||
*/
|
||||
get_value_by_opt_type(ret_str, false);
|
||||
}
|
||||
|
@ -631,7 +638,7 @@ void TextCtrl::msw_rescale()
|
|||
Field::msw_rescale();
|
||||
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
|
||||
|
||||
if (m_opt.height >= 0)
|
||||
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));
|
||||
|
@ -665,15 +672,15 @@ void CheckBox::BUILD() {
|
|||
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);
|
||||
|
||||
bool check_value = m_opt.type == coBool ?
|
||||
m_opt.default_value->getBool() : m_opt.type == coBools ?
|
||||
m_opt.get_default_value<ConfigOptionBools>()->get_at(m_opt_idx) :
|
||||
bool check_value = m_opt.type == coBool ?
|
||||
m_opt.default_value->getBool() : m_opt.type == coBools ?
|
||||
m_opt.get_default_value<ConfigOptionBools>()->get_at(m_opt_idx) :
|
||||
false;
|
||||
|
||||
m_last_meaningful_value = static_cast<unsigned char>(check_value);
|
||||
|
||||
// Set Label as a string of at least one space simbol to correct system scaling of a CheckBox
|
||||
auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(" "), wxDefaultPosition, size);
|
||||
// Set Label as a string of at least one space simbol to correct system scaling of a CheckBox
|
||||
auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(" "), wxDefaultPosition, size);
|
||||
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
temp->SetValue(check_value);
|
||||
|
@ -684,7 +691,7 @@ void CheckBox::BUILD() {
|
|||
on_change_field();
|
||||
}), temp->GetId());
|
||||
|
||||
temp->SetToolTip(get_tooltip_text(check_value ? "true" : "false"));
|
||||
temp->SetToolTip(get_tooltip_text(check_value ? "true" : "false"));
|
||||
|
||||
// recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
|
@ -770,20 +777,25 @@ void SpinCtrl::BUILD() {
|
|||
break;
|
||||
}
|
||||
|
||||
const int min_val = m_opt.min == INT_MIN
|
||||
const int min_val = m_opt.min == INT_MIN
|
||||
#ifdef __WXOSX__
|
||||
// We will forcibly set the input value for SpinControl, since the value
|
||||
// We will forcibly set the input value for SpinControl, since the value
|
||||
// inserted from the keyboard is not updated under OSX.
|
||||
// So, we can't set min control value bigger then 0.
|
||||
// Otherwise, it couldn't be possible to input from keyboard value
|
||||
// Otherwise, it couldn't be possible to input from keyboard value
|
||||
// less then min_val.
|
||||
|| m_opt.min > 0
|
||||
|| m_opt.min > 0
|
||||
#endif
|
||||
? 0 : m_opt.min;
|
||||
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
|
||||
|
||||
auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
|
||||
0|wxTE_PROCESS_ENTER, min_val, max_val, default_value);
|
||||
wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS
|
||||
#ifdef _WIN32
|
||||
| wxBORDER_SIMPLE
|
||||
#endif
|
||||
, min_val, max_val, default_value);
|
||||
|
||||
#ifdef __WXGTK3__
|
||||
wxSize best_sz = temp->GetBestSize();
|
||||
if (best_sz.x > size.x)
|
||||
|
@ -791,6 +803,7 @@ void SpinCtrl::BUILD() {
|
|||
#endif //__WXGTK3__
|
||||
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
wxGetApp().UpdateDarkUI(temp);
|
||||
|
||||
if (m_opt.height < 0 && parent_is_custom_ctrl)
|
||||
opt_height = (double)temp->GetSize().GetHeight() / m_em_unit;
|
||||
|
@ -813,8 +826,8 @@ void SpinCtrl::BUILD() {
|
|||
propagate_value();
|
||||
}));
|
||||
|
||||
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { propagate_value(); }), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { propagate_value(); }), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_TEXT_ENTER, ([this](wxCommandEvent e)
|
||||
{
|
||||
e.Skip();
|
||||
|
@ -822,7 +835,7 @@ void SpinCtrl::BUILD() {
|
|||
bEnterPressed = true;
|
||||
}), temp->GetId());
|
||||
|
||||
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e)
|
||||
temp->Bind(wxEVT_TEXT, ([this, temp](wxCommandEvent e)
|
||||
{
|
||||
// # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
|
||||
// # when it was changed from the text control, so the on_change callback
|
||||
|
@ -832,22 +845,30 @@ void SpinCtrl::BUILD() {
|
|||
|
||||
long value;
|
||||
const bool parsed = e.GetString().ToLong(&value);
|
||||
tmp_value = parsed && value >= INT_MIN && value <= INT_MAX ? (int)value : UNDEF_VALUE;
|
||||
|
||||
if (!parsed || value < INT_MIN || value > INT_MAX)
|
||||
tmp_value = UNDEF_VALUE;
|
||||
else {
|
||||
tmp_value = std::min(std::max((int)value, m_opt.min), m_opt.max);
|
||||
#ifdef __WXOSX__
|
||||
// Forcibly set the input value for SpinControl, since the value
|
||||
// inserted from the keyboard or clipboard is not updated under OSX
|
||||
if (tmp_value != UNDEF_VALUE) {
|
||||
wxSpinCtrl* spin = static_cast<wxSpinCtrl*>(window);
|
||||
spin->SetValue(tmp_value);
|
||||
|
||||
// Forcibly set the input value for SpinControl, since the value
|
||||
// inserted from the keyboard or clipboard is not updated under OSX
|
||||
temp->SetValue(tmp_value);
|
||||
// But in SetValue() is executed m_text_ctrl->SelectAll(), so
|
||||
// discard this selection and set insertion point to the end of string
|
||||
spin->GetText()->SetInsertionPointEnd();
|
||||
}
|
||||
temp->GetText()->SetInsertionPointEnd();
|
||||
#else
|
||||
// update value for the control only if it was changed in respect to the Min/max values
|
||||
if (tmp_value != (int)value) {
|
||||
temp->SetValue(tmp_value);
|
||||
// But after SetValue() cursor ison the first position
|
||||
// so put it to the end of string
|
||||
int pos = std::to_string(tmp_value).length();
|
||||
temp->SetSelection(pos, pos);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}), temp->GetId());
|
||||
|
||||
|
||||
temp->SetToolTip(get_tooltip_text(text_value));
|
||||
|
||||
// recast as a wxWindow to fit the calling convention
|
||||
|
@ -888,9 +909,14 @@ void SpinCtrl::msw_rescale()
|
|||
}
|
||||
|
||||
#ifdef __WXOSX__
|
||||
static_assert(wxMAJOR_VERSION >= 3, "Use of wxBitmapComboBox on Settings Tabs requires wxWidgets 3.0 and newer");
|
||||
using choice_ctrl = wxBitmapComboBox;
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
using choice_ctrl = BitmapComboBox;
|
||||
#else
|
||||
using choice_ctrl = wxComboBox;
|
||||
#endif
|
||||
#endif // __WXOSX__
|
||||
|
||||
void Choice::BUILD() {
|
||||
|
@ -898,10 +924,10 @@ void Choice::BUILD() {
|
|||
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);
|
||||
|
||||
choice_ctrl* temp;
|
||||
if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) {
|
||||
choice_ctrl* temp;
|
||||
if (m_opt.gui_type != ConfigOptionDef::GUIType::undefined && m_opt.gui_type != ConfigOptionDef::GUIType::select_open) {
|
||||
m_is_editable = true;
|
||||
temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
||||
temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxTE_PROCESS_ENTER);
|
||||
}
|
||||
else {
|
||||
#ifdef __WXOSX__
|
||||
|
@ -942,22 +968,6 @@ void Choice::BUILD() {
|
|||
set_selection();
|
||||
}
|
||||
|
||||
#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,
|
||||
* ! in this case wxBitmap.IsOK() return true.
|
||||
* 2. But then set width to 0 value for no using of bitmap left and right spacing
|
||||
* 3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
|
||||
*
|
||||
* Note: Set bitmap height to the Font size because of OSX rendering.
|
||||
*/
|
||||
wxBitmap empty_bmp(1, temp->GetFont().GetPixelSize().y + 2);
|
||||
empty_bmp.SetWidth(0);
|
||||
temp->SetItemBitmap(0, empty_bmp);
|
||||
#endif
|
||||
|
||||
temp->Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
|
||||
if (m_suppress_scroll && !m_is_dropped)
|
||||
e.StopPropagation();
|
||||
|
@ -970,34 +980,57 @@ void Choice::BUILD() {
|
|||
temp->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent&) { on_change_field(); }, temp->GetId());
|
||||
|
||||
if (m_is_editable) {
|
||||
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
|
||||
temp->Bind(wxEVT_KILL_FOCUS, [this](wxEvent& e) {
|
||||
e.Skip();
|
||||
if (m_opt.type == coStrings) {
|
||||
on_change_field();
|
||||
return;
|
||||
}
|
||||
if (!bEnterPressed)
|
||||
propagate_value();
|
||||
} );
|
||||
|
||||
if (is_defined_input_value<choice_ctrl>(window, m_opt.type)) {
|
||||
if (m_opt.type == coFloatOrPercent) {
|
||||
std::string old_val = !m_value.empty() ? boost::any_cast<std::string>(m_value) : "";
|
||||
if (old_val == boost::any_cast<std::string>(get_value()))
|
||||
return;
|
||||
}
|
||||
else {
|
||||
double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999;
|
||||
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
|
||||
return;
|
||||
}
|
||||
on_change_field();
|
||||
}
|
||||
else
|
||||
on_kill_focus();
|
||||
}), temp->GetId());
|
||||
temp->Bind(wxEVT_TEXT_ENTER, [this](wxEvent& e) {
|
||||
EnterPressed enter(this);
|
||||
propagate_value();
|
||||
} );
|
||||
}
|
||||
|
||||
temp->SetToolTip(get_tooltip_text(temp->GetValue()));
|
||||
}
|
||||
|
||||
void Choice::propagate_value()
|
||||
{
|
||||
if (m_opt.type == coStrings) {
|
||||
on_change_field();
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_defined_input_value<choice_ctrl>(window, m_opt.type)) {
|
||||
switch (m_opt.type) {
|
||||
case coFloatOrPercent:
|
||||
{
|
||||
std::string old_val = !m_value.empty() ? boost::any_cast<std::string>(m_value) : "";
|
||||
if (old_val == boost::any_cast<std::string>(get_value()))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case coInt:
|
||||
{
|
||||
int old_val = !m_value.empty() ? boost::any_cast<int>(m_value) : 0;
|
||||
if (old_val == boost::any_cast<int>(get_value()))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
double old_val = !m_value.empty() ? boost::any_cast<double>(m_value) : -99999;
|
||||
if (fabs(old_val - boost::any_cast<double>(get_value())) <= 0.0001)
|
||||
return;
|
||||
}
|
||||
}
|
||||
on_change_field();
|
||||
}
|
||||
else
|
||||
on_kill_focus();
|
||||
}
|
||||
|
||||
void Choice::suppress_scroll()
|
||||
{
|
||||
m_suppress_scroll = true;
|
||||
|
@ -1015,8 +1048,7 @@ void Choice::set_selection()
|
|||
choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
|
||||
switch (m_opt.type) {
|
||||
case coEnum:{
|
||||
int id_value = m_opt.get_default_value<ConfigOptionEnum<SeamPosition>>()->value; //!!
|
||||
field->SetSelection(id_value);
|
||||
field->SetSelection(m_opt.default_value->getInt());
|
||||
break;
|
||||
}
|
||||
case coFloat:
|
||||
|
@ -1043,7 +1075,7 @@ void Choice::set_selection()
|
|||
}
|
||||
|
||||
if (!text_value.IsEmpty()) {
|
||||
int idx = 0;
|
||||
size_t idx = 0;
|
||||
for (auto el : m_opt.enum_values) {
|
||||
if (el == text_value)
|
||||
break;
|
||||
|
@ -1066,10 +1098,10 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda
|
|||
}
|
||||
|
||||
choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
|
||||
idx == m_opt.enum_values.size() ?
|
||||
idx == m_opt.enum_values.size() ?
|
||||
field->SetValue(value) :
|
||||
field->SetSelection(idx);
|
||||
|
||||
|
||||
m_disable_change_event = false;
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1119,7 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||
case coString:
|
||||
case coStrings: {
|
||||
wxString text_value;
|
||||
if (m_opt.type == coInt)
|
||||
if (m_opt.type == coInt)
|
||||
text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value)));
|
||||
else
|
||||
text_value = boost::any_cast<wxString>(value);
|
||||
|
@ -1107,6 +1139,15 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||
}
|
||||
else
|
||||
field->SetSelection(idx);
|
||||
|
||||
if (!m_value.empty() && m_opt.opt_key == "fill_density") {
|
||||
// If m_value was changed before, then update m_value here too to avoid case
|
||||
// when control's value is already changed from the ConfigManipulation::update_print_fff_config(),
|
||||
// but m_value doesn't respect it.
|
||||
if (double val; text_value.ToDouble(&val))
|
||||
m_value = val;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case coEnum: {
|
||||
|
@ -1117,28 +1158,17 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||
|
||||
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern")
|
||||
{
|
||||
if (!m_opt.enum_values.empty()) {
|
||||
std::string key;
|
||||
t_config_enum_values map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
|
||||
for (auto it : map_names) {
|
||||
if (val == it.second) {
|
||||
key = it.first;
|
||||
break;
|
||||
}
|
||||
std::string key;
|
||||
const t_config_enum_values& map_names = ConfigOptionEnum<InfillPattern>::get_enum_values();
|
||||
for (auto it : map_names)
|
||||
if (val == it.second) {
|
||||
key = it.first;
|
||||
break;
|
||||
}
|
||||
|
||||
size_t idx = 0;
|
||||
for (auto el : m_opt.enum_values)
|
||||
{
|
||||
if (el == key)
|
||||
break;
|
||||
++idx;
|
||||
}
|
||||
|
||||
val = idx == m_opt.enum_values.size() ? 0 : idx;
|
||||
}
|
||||
else
|
||||
val = 0;
|
||||
const std::vector<std::string>& values = m_opt.enum_values;
|
||||
auto it = std::find(values.begin(), values.end(), key);
|
||||
val = it == values.end() ? 0 : it - values.begin();
|
||||
}
|
||||
field->SetSelection(val);
|
||||
break;
|
||||
|
@ -1194,7 +1224,7 @@ boost::any& Choice::get_value()
|
|||
{
|
||||
choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
|
||||
|
||||
wxString ret_str = field->GetValue();
|
||||
wxString ret_str = field->GetValue();
|
||||
|
||||
// options from right panel
|
||||
std::vector <std::string> right_panel_options{ "support", "pad", "scale_unit" };
|
||||
|
@ -1204,6 +1234,7 @@ boost::any& Choice::get_value()
|
|||
|
||||
if (m_opt.type == coEnum)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
int ret_enum = field->GetSelection();
|
||||
if (m_opt_id.compare("host_type") == 0 &&
|
||||
m_opt.enum_values.size() > field->GetCount()) // for case, when PrusaLink isn't used as a HostType
|
||||
|
@ -1220,27 +1251,19 @@ boost::any& Choice::get_value()
|
|||
}
|
||||
else
|
||||
m_value = static_cast<InfillPattern>(0);
|
||||
=======
|
||||
if (m_opt_id.compare("host_type") == 0 && m_opt.enum_values.size() > field->GetCount()) {
|
||||
// for case, when PrusaLink isn't used as a HostType
|
||||
m_value = field->GetSelection()+1;
|
||||
} else if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "fill_pattern") {
|
||||
const std::string& key = m_opt.enum_values[field->GetSelection()];
|
||||
m_value = int(ConfigOptionEnum<InfillPattern>::get_enum_values().at(key));
|
||||
>>>>>>> master
|
||||
}
|
||||
else if (m_opt_id.compare("ironing_type") == 0)
|
||||
m_value = static_cast<IroningType>(ret_enum);
|
||||
else if (m_opt_id.compare("gcode_flavor") == 0)
|
||||
m_value = static_cast<GCodeFlavor>(ret_enum);
|
||||
else if (m_opt_id.compare("machine_limits_usage") == 0)
|
||||
m_value = static_cast<MachineLimitsUsage>(ret_enum);
|
||||
else if (m_opt_id.compare("support_material_pattern") == 0)
|
||||
m_value = static_cast<SupportMaterialPattern>(ret_enum);
|
||||
else if (m_opt_id.compare("seam_position") == 0)
|
||||
m_value = static_cast<SeamPosition>(ret_enum);
|
||||
else if (m_opt_id.compare("host_type") == 0)
|
||||
m_value = static_cast<PrintHostType>(ret_enum);
|
||||
else if (m_opt_id.compare("display_orientation") == 0)
|
||||
m_value = static_cast<SLADisplayOrientation>(ret_enum);
|
||||
else if (m_opt_id.compare("support_pillar_connection_mode") == 0)
|
||||
m_value = static_cast<SLAPillarConnectionMode>(ret_enum);
|
||||
else if (m_opt_id == "printhost_authorization_type")
|
||||
m_value = static_cast<AuthorizationType>(ret_enum);
|
||||
else
|
||||
m_value = field->GetSelection();
|
||||
}
|
||||
else if (m_opt.gui_type == "f_enum_open") {
|
||||
else if (m_opt.gui_type == ConfigOptionDef::GUIType::f_enum_open || m_opt.gui_type == ConfigOptionDef::GUIType::i_enum_open) {
|
||||
const int ret_enum = field->GetSelection();
|
||||
if (ret_enum < 0 || m_opt.enum_values.empty() || m_opt.type == coStrings ||
|
||||
(ret_str != m_opt.enum_values[ret_enum] && ret_str != _(m_opt.enum_labels[ret_enum])))
|
||||
|
@ -1248,18 +1271,20 @@ boost::any& Choice::get_value()
|
|||
get_value_by_opt_type(ret_str);
|
||||
else if (m_opt.type == coFloatOrPercent)
|
||||
m_value = m_opt.enum_values[ret_enum];
|
||||
else if (m_opt.type == coInt)
|
||||
m_value = atoi(m_opt.enum_values[ret_enum].c_str());
|
||||
else
|
||||
m_value = atof(m_opt.enum_values[ret_enum].c_str());
|
||||
m_value = string_to_double_decimal_point(m_opt.enum_values[ret_enum]);
|
||||
}
|
||||
else
|
||||
else
|
||||
// modifies ret_string!
|
||||
get_value_by_opt_type(ret_str);
|
||||
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void Choice::enable() { dynamic_cast<choice_ctrl*>(window)->Enable(); };
|
||||
void Choice::disable() { dynamic_cast<choice_ctrl*>(window)->Disable(); };
|
||||
void Choice::enable() { dynamic_cast<choice_ctrl*>(window)->Enable(); }
|
||||
void Choice::disable() { dynamic_cast<choice_ctrl*>(window)->Disable(); }
|
||||
|
||||
void Choice::msw_rescale()
|
||||
{
|
||||
|
@ -1269,8 +1294,8 @@ void Choice::msw_rescale()
|
|||
#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 :
|
||||
/* To correct scaling (set new controll size) of a wxBitmapCombobox
|
||||
* we need to refill control with new bitmaps. So, in our case :
|
||||
* 1. clear control
|
||||
* 2. add content
|
||||
* 3. add scaled "empty" bitmap to the at least one item
|
||||
|
@ -1278,7 +1303,7 @@ void Choice::msw_rescale()
|
|||
field->Clear();
|
||||
wxSize size(wxDefaultSize);
|
||||
size.SetWidth((m_opt.width > 0 ? m_opt.width : def_width_wider()) * m_em_unit);
|
||||
|
||||
|
||||
// Set rescaled min height to correct layout
|
||||
field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y + 0.5f)));
|
||||
// Set rescaled size
|
||||
|
@ -1289,7 +1314,7 @@ void Choice::msw_rescale()
|
|||
size_t counter = 0;
|
||||
bool labels = ! m_opt.enum_labels.empty();
|
||||
for (const std::string &el : labels ? m_opt.enum_labels : m_opt.enum_values) {
|
||||
wxString text = labels ? _(el) : wxString::FromUTF8(el.c_str());
|
||||
wxString text = labels ? _(el) : from_u8(el);
|
||||
field->Append(text);
|
||||
if (text == selection)
|
||||
idx = counter;
|
||||
|
@ -1297,14 +1322,13 @@ void Choice::msw_rescale()
|
|||
}
|
||||
}
|
||||
|
||||
wxBitmap empty_bmp(1, field->GetFont().GetPixelSize().y + 2);
|
||||
empty_bmp.SetWidth(0);
|
||||
field->SetItemBitmap(0, empty_bmp);
|
||||
|
||||
idx == m_opt.enum_values.size() ?
|
||||
field->SetValue(selection) :
|
||||
field->SetSelection(idx);
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
field->Rescale();
|
||||
#endif
|
||||
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);
|
||||
|
@ -1323,7 +1347,7 @@ void ColourPicker::BUILD()
|
|||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
|
||||
|
||||
// Validate the color
|
||||
wxString clr_str(m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx));
|
||||
wxString clr_str(m_opt.type == coString ? m_opt.get_default_value<ConfigOptionString>()->value : m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx));
|
||||
wxColour clr(clr_str);
|
||||
if (clr_str.IsEmpty() || !clr.IsOk()) {
|
||||
clr = wxTransparentColour;
|
||||
|
@ -1335,6 +1359,8 @@ void ColourPicker::BUILD()
|
|||
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
|
||||
wxGetApp().UpdateDarkUI(temp->GetPickerCtrl());
|
||||
|
||||
// // recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
|
||||
|
@ -1394,11 +1420,11 @@ void ColourPicker::msw_rescale()
|
|||
|
||||
wxColourPickerCtrl* field = dynamic_cast<wxColourPickerCtrl*>(window);
|
||||
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
|
||||
if (m_opt.height >= 0)
|
||||
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 (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);
|
||||
if (parent_is_custom_ctrl)
|
||||
field->SetSize(size);
|
||||
else
|
||||
|
@ -1408,6 +1434,15 @@ void ColourPicker::msw_rescale()
|
|||
set_undef_value(field);
|
||||
}
|
||||
|
||||
void ColourPicker::sys_color_changed()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (wxWindow* win = this->getWindow())
|
||||
if (wxColourPickerCtrl* picker = dynamic_cast<wxColourPickerCtrl*>(win))
|
||||
wxGetApp().UpdateDarkUI(picker->GetPickerCtrl(), true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PointCtrl::BUILD()
|
||||
{
|
||||
auto temp = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -1420,12 +1455,16 @@ void PointCtrl::BUILD()
|
|||
val = default_pt(1);
|
||||
wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None);
|
||||
|
||||
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);
|
||||
long style = wxTE_PROCESS_ENTER;
|
||||
#ifdef _WIN32
|
||||
style |= wxBORDER_SIMPLE;
|
||||
#endif
|
||||
x_textctrl = new wxTextCtrl(m_parent, wxID_ANY, X, wxDefaultPosition, field_size, style);
|
||||
y_textctrl = new wxTextCtrl(m_parent, wxID_ANY, Y, wxDefaultPosition, field_size, style);
|
||||
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->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
x_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
y_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
y_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
|
@ -1437,6 +1476,11 @@ void PointCtrl::BUILD()
|
|||
static_text_y->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
static_text_y->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
|
||||
wxGetApp().UpdateDarkUI(x_textctrl);
|
||||
wxGetApp().UpdateDarkUI(y_textctrl);
|
||||
wxGetApp().UpdateDarkUI(static_text_x, false, true);
|
||||
wxGetApp().UpdateDarkUI(static_text_y, false, true);
|
||||
|
||||
temp->Add(static_text_x, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
temp->Add(x_textctrl);
|
||||
temp->Add(static_text_y, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
|
@ -1472,6 +1516,15 @@ void PointCtrl::msw_rescale()
|
|||
}
|
||||
}
|
||||
|
||||
void PointCtrl::sys_color_changed()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
for (wxSizerItem* item: sizer->GetChildren())
|
||||
if (item->IsWindow())
|
||||
wxGetApp().UpdateDarkUI(item->GetWindow());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PointCtrl::value_was_changed(wxTextCtrl* win)
|
||||
{
|
||||
if (m_value.empty())
|
||||
|
@ -1525,12 +1578,12 @@ boost::any& PointCtrl::get_value()
|
|||
!y_textctrl->GetValue().ToDouble(&y))
|
||||
{
|
||||
set_value(m_value.empty() ? Vec2d(0.0, 0.0) : m_value, true);
|
||||
show_error(m_parent, _L("Invalid numeric input."));
|
||||
show_error(m_parent, _L("Invalid numeric input."));
|
||||
}
|
||||
else
|
||||
if (m_opt.min > x || x > m_opt.max ||
|
||||
m_opt.min > y || y > m_opt.max)
|
||||
{
|
||||
{
|
||||
if (m_opt.min > x) x = m_opt.min;
|
||||
if (x > m_opt.max) x = m_opt.max;
|
||||
if (m_opt.min > y) y = m_opt.min;
|
||||
|
@ -1549,12 +1602,14 @@ void StaticText::BUILD()
|
|||
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);
|
||||
|
||||
const wxString legend = wxString::FromUTF8(m_opt.get_default_value<ConfigOptionString>()->value.c_str());
|
||||
const wxString legend = from_u8(m_opt.get_default_value<ConfigOptionString>()->value);
|
||||
auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE);
|
||||
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
temp->SetFont(wxGetApp().bold_font());
|
||||
|
||||
wxGetApp().UpdateDarkUI(temp);
|
||||
|
||||
// // recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
|
||||
|
@ -1596,7 +1651,7 @@ void SliderCtrl::BUILD()
|
|||
m_slider->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
wxSize field_size(40, -1);
|
||||
|
||||
m_textctrl = new wxTextCtrl(m_parent, wxID_ANY, wxString::Format("%d", m_slider->GetValue()/m_scale),
|
||||
m_textctrl = new wxTextCtrl(m_parent, wxID_ANY, wxString::Format("%d", m_slider->GetValue()/m_scale),
|
||||
wxDefaultPosition, field_size);
|
||||
m_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
m_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
|
@ -1646,5 +1701,3 @@ boost::any& SliderCtrl::get_value()
|
|||
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue