Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/slic3r/GUI/Field.cpp')
-rw-r--r--src/slic3r/GUI/Field.cpp147
1 files changed, 105 insertions, 42 deletions
diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp
index b90a89e73..793652f26 100644
--- a/src/slic3r/GUI/Field.cpp
+++ b/src/slic3r/GUI/Field.cpp
@@ -206,8 +206,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" : "") + default_string + "\n" +
_(L("parameter name")) + "\t: " + opt_id;
return tooltip_text;
@@ -218,6 +217,8 @@ wxString Field::get_rich_tooltip_text(const wxString& default_string)
wxString tooltip_text("");
wxString tooltip = _(m_opt.tooltip);
update_Slic3r_string(tooltip);
+ std::wstring wtooltip = tooltip.ToStdWstring();
+ std::wstring wtooltip_text;
std::string opt_id = m_opt_id;
auto hash_pos = opt_id.find("#");
@@ -226,8 +227,20 @@ wxString Field::get_rich_tooltip_text(const wxString& default_string)
opt_id += "]";
}
+ //add "\n" to long tooltip lines
+ int length = 0;
+ for (int i = 0; i < wtooltip.size(); i++) {
+ if (length >= 80 && wtooltip[i] == u' ')
+ wtooltip_text.push_back(u'\n');
+ else
+ wtooltip_text.push_back(wtooltip[i]);
+ length++;
+ if (wtooltip_text.back() == u'\n')
+ length = 0;
+ }
+
if (tooltip.length() > 0)
- tooltip_text = tooltip + "\n" + _(L("default value")) + ": " +
+ tooltip_text = wtooltip_text + "\n" + _(L("default value")) + ": " +
(boost::iends_with(opt_id, "_gcode") ? "\n" : "") + default_string;
return tooltip_text;
@@ -252,7 +265,11 @@ void Field::set_tooltip(const wxString& default_string, wxWindow* window) {
if (get_app_config()->get("use_rich_tooltip") == "1") {
this->m_rich_tooltip_timer.m_value = default_string;
window->Bind(wxEVT_ENTER_WINDOW, [this, window](wxMouseEvent& event) {
- if (wxGetActiveWindow() && !this->m_rich_tooltip_timer.IsRunning()) {
+ if (!this->m_rich_tooltip_timer.IsRunning()
+#ifdef __WXMSW__
+ && wxGetActiveWindow() //don't activate if the currrent app is not the focus. (deactivated for linux as it check the field instead)
+#endif /* __WXMSW__ */
+ ) {
this->m_rich_tooltip_timer.m_current_window = window;
this->m_rich_tooltip_timer.m_is_rich_tooltip_ready = true;
this->m_rich_tooltip_timer.StartOnce(500);
@@ -263,16 +280,22 @@ void Field::set_tooltip(const wxString& default_string, wxWindow* window) {
wxWindowList tipWindow = this->getWindow()->GetChildren();
if (tipWindow.size() > 0) {
wxWindow* tooltipWindow = tipWindow.GetLast()->GetData();
- if (tooltipWindow && tooltipWindow == this->m_rich_tooltip_timer.m_current_rich_tooltip)
+ if (tooltipWindow && tooltipWindow == this->m_rich_tooltip_timer.m_current_rich_tooltip) {
tooltipWindow->Hide();// DismissAndNotify();
+ }
}
});
- }else
+ } else
window->SetToolTip(get_tooltip_text(default_string));
}
void RichTooltipTimer::Notify() {
- if (wxGetActiveWindow() && this->m_is_rich_tooltip_ready && m_current_window) {
+ if (this->m_is_rich_tooltip_ready && m_current_window && !m_current_window->HasFocus()
+#ifdef __WXMSW__
+ && wxGetActiveWindow() //don't activate if the currrent app is not the focus. (deactivated for linux as it check the field instead)
+#endif /* __WXMSW__ */
+ ) {
+ this->m_previous_focus = wxGetActiveWindow()->FindFocus();
this->m_current_rich_tooltip = nullptr;
wxRichToolTip richTooltip(
m_field->get_rich_tooltip_title(this->m_value),
@@ -281,6 +304,23 @@ void RichTooltipTimer::Notify() {
richTooltip.ShowFor(m_current_window);
wxWindowList tipWindow = m_current_window->GetChildren();
this->m_current_rich_tooltip = tipWindow.GetLast()->GetData();
+ this->m_current_rich_tooltip->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND));
+ this->m_current_rich_tooltip->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
+ this->m_current_rich_tooltip->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& event) {
+ this->m_is_rich_tooltip_ready = false;
+ wxWindowList tipWindow = m_current_window->GetChildren();
+ if (tipWindow.size() > 0) {
+ wxWindow* tooltipWindow = tipWindow.GetLast()->GetData();
+ if (tooltipWindow && tooltipWindow == this->m_current_rich_tooltip) {
+ tooltipWindow->Hide();// DismissAndNotify();
+ }
+ }
+ });
+ this->m_current_rich_tooltip->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent& event) {
+ CallAfter([this]() {
+ if (this->m_previous_focus) this->m_previous_focus->SetFocus();
+ });
+ });
}
}
@@ -405,45 +445,68 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
show_error(m_parent, _(L("Input value is out of range")));
if (m_opt.min > val) val = m_opt.min;
set_value(double_to_string(val, m_opt.precision), 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)))
- {
- // exceptions
- if (std::set<t_config_option_key>{"infill_anchor", "infill_anchor_max", "avoid_crossing_perimeters_max_detour"}.count(m_opt.opt_key) > 0) {
- m_value = std::string(str.ToUTF8().data());
- break;
- }
- if (m_opt.opt_key.find("extrusion_width") != std::string::npos || m_opt.opt_key.find("extrusion_spacing") != std::string::npos) {
- const DynamicPrintConfig& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
- const std::vector<double>& nozzle_diameters = printer_config.option<ConfigOptionFloats>("nozzle_diameter")->values;
- double nozzle_diameter = 0;
- for (double diameter : nozzle_diameters)
- nozzle_diameter = std::max(nozzle_diameter, diameter);
- if (val < nozzle_diameter * 10) {
- m_value = std::string(str.ToUTF8().data());
+ } else if (m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)) {
+ bool not_ok = (m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max);
+ if( !not_ok && m_opt.max_literal.value != 0 )
+ if (m_opt.max_literal.percent) {
+ const DynamicPrintConfig& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
+ const std::vector<double>& nozzle_diameters = printer_config.option<ConfigOptionFloats>("nozzle_diameter")->values;
+ double nozzle_diameter = 0;
+ for (double diameter : nozzle_diameters)
+ nozzle_diameter = std::max(nozzle_diameter, diameter);
+ if (m_opt.max_literal.value > 0)
+ not_ok = val > nozzle_diameter * m_opt.max_literal.value;
+ else
+ not_ok = val < nozzle_diameter * (-m_opt.max_literal.value);
+ }else{
+ if(m_opt.max_literal.value > 0)
+ not_ok = val > m_opt.max_literal.value;
+ else
+ not_ok = val < -m_opt.max_literal.value;
+ }
+ if (not_ok) {
+
+ // if (
+ // (
+ // (m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max)
+ // ||
+ // (m_opt.sidetext.rfind("mm ") != std::string::npos && val > m_opt.max_literal)
+ // )
+ // &&
+ // (m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)))
+ //{
+ // if (m_opt.opt_key.find("extrusion_width") != std::string::npos || m_opt.opt_key.find("extrusion_spacing") != std::string::npos) {
+ // const DynamicPrintConfig& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
+ // const std::vector<double>& nozzle_diameters = printer_config.option<ConfigOptionFloats>("nozzle_diameter")->values;
+ // double nozzle_diameter = 0;
+ // for (double diameter : nozzle_diameters)
+ // nozzle_diameter = std::max(nozzle_diameter, diameter);
+ // if (val < nozzle_diameter * 10) {
+ // m_value = std::string(str.ToUTF8().data());
+ // break;
+ // }
+ // }
+ //TODO: chack for infill_overlap from diameter% => allow max_literal to be a %
+
+ if (!check_value) {
+ m_value.clear();
break;
}
- }
- if (!check_value) {
- m_value.clear();
- break;
+ bool infill_anchors = m_opt.opt_key == "infill_anchor" || m_opt.opt_key == "infill_anchor_max";
+
+ const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
+ const wxString stVal = double_to_string(val, m_opt.precision);
+ 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);
+ if ((!infill_anchors || val > 100) && dialog.ShowModal() == wxID_YES) {
+ set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/);
+ str += "%%";
+ } else
+ set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "."
}
-
- bool infill_anchors = m_opt.opt_key == "infill_anchor" || m_opt.opt_key == "infill_anchor_max";
-
- const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
- const wxString stVal = double_to_string(val, m_opt.precision);
- 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);
- if ((!infill_anchors || val > 100) && dialog.ShowModal() == wxID_YES) {
- set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/);
- str += "%%";
- } else
- set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "."
}
}
}