From 3b5fc939fc964bc7f47b03910dc1f318235b63e1 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 20 Oct 2026 14:18:14 +0800 Subject: [PATCH] Show availability reasons in object table settings --- docs/HLSD/deferred-page-construction.md | 5 +++ src/slic3r/GUI/GUI_ObjectTableSettings.cpp | 36 +++++++++++++++++++--- src/slic3r/GUI/GUI_ObjectTableSettings.hpp | 4 +++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/docs/HLSD/deferred-page-construction.md b/docs/HLSD/deferred-page-construction.md index 7c1874baec..df212a5406 100644 --- a/docs/HLSD/deferred-page-construction.md +++ b/docs/HLSD/deferred-page-construction.md @@ -114,6 +114,11 @@ current-configuration explanation. Dependency rules supply complete translated messages describing their prerequisites; compound rules can choose the message for the failed prerequisite. The same recorded text reaches tooltips and search results. +The object table's settings form owns a separate registry because it builds option +groups outside a Tab. Its dependency callbacks retain their reasons and refresh +both input and native label tooltips. Rebuilding the form or reevaluating dependencies +clears its records, so restrictions follow the current object and effective configuration. + Settings search resolves the same owning Tab as option navigation: a matching model Tab in object mode, otherwise the global preset Tab. Results show the first line of the registry description beneath the option name, with the complete description in diff --git a/src/slic3r/GUI/GUI_ObjectTableSettings.cpp b/src/slic3r/GUI/GUI_ObjectTableSettings.cpp index dc812e97c9..310b49f2a7 100644 --- a/src/slic3r/GUI/GUI_ObjectTableSettings.cpp +++ b/src/slic3r/GUI/GUI_ObjectTableSettings.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "libslic3r/Config.hpp" #include #include @@ -97,6 +98,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_ m_settings_list_sizer->Clear(true); m_og_settings.resize(0); + m_option_state_registry.clear(); Show(true); if (!config || is_multiple_selection || !object) @@ -301,14 +303,16 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_ m_settings_list_sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 0); m_og_settings.push_back(optgroup); - auto toggle_field = [optgroup](const t_config_option_key & opt_key, bool toggle, int opt_index, const wxString&) + auto toggle_field = [this, optgroup](const t_config_option_key & opt_key, bool toggle, int opt_index, const wxString& reason) { - Field* field = optgroup->get_fieldc(opt_key, opt_index);; + m_option_state_registry.set_enabled(opt_key, toggle, reason); + Field* field = optgroup->get_fieldc(opt_key, opt_index); if (field) field->toggle(toggle); }; - auto toggle_line = [optgroup](const t_config_option_key &opt_key, bool toggle, int opt_index, const wxString&) + auto toggle_line = [this, optgroup](const t_config_option_key &opt_key, bool toggle, int opt_index, const wxString& reason) { + m_option_state_registry.set_visible(opt_key, toggle, reason); Line* line = optgroup->get_line(opt_key); if (line) line->toggle_visible = toggle; }; @@ -319,6 +323,7 @@ bool ObjectTableSettings::update_settings_list(bool is_object, bool is_multiple_ printer_technology == ptFFF ? config_manipulation.toggle_print_fff_options(&m_current_config, 0) : config_manipulation.toggle_print_sla_options(&m_current_config) ; + update_option_tooltips(*optgroup); optgroup->update_visibility(wxGetApp().get_mode()); } @@ -386,6 +391,22 @@ int ObjectTableSettings::update_extra_column_visible_status(ConfigOptionsGroup* return count; } +void ObjectTableSettings::update_option_tooltips(ConfigOptionsGroup& group) +{ + // Object-table settings have one option per row and use native text labels. + for (const Line& line : group.get_lines()) { + if (line.get_options().empty()) + continue; + const Option& option = line.get_options().front(); + const wxString availability = m_option_state_registry.description(option.opt_id); + const wxString prefix = availability.empty() ? wxString() : availability + "\n\n"; + if (line.label_widget) + line.label_widget->SetToolTip(prefix + line.label_tooltip); + if (Field* field = group.get_field(option.opt_id); field && field->getWindow()) + field->getWindow()->SetToolTip(prefix + field->get_tooltip_text(wxEmptyString)); + } +} + void ObjectTableSettings::update_config_values(bool is_object, ModelObject* object, ModelConfig* config, const std::string& category, const std::string& changed_opt_key) { int different_count = 0; @@ -394,12 +415,15 @@ void ObjectTableSettings::update_config_values(bool is_object, ModelObject* obje if (!object || !config) return; + m_option_state_registry.clear(); + // update config values according to configuration hierarchy DynamicPrintConfig &main_config = m_current_config; - auto toggle_field = [this](const t_config_option_key & opt_key, bool toggle, int opt_index, const wxString&) + auto toggle_field = [this](const t_config_option_key & opt_key, bool toggle, int opt_index, const wxString& reason) { + m_option_state_registry.set_enabled(opt_key, toggle, reason); Field* field = nullptr; for (auto og : m_og_settings) { field = og->get_fieldc(opt_key, opt_index); @@ -409,7 +433,8 @@ void ObjectTableSettings::update_config_values(bool is_object, ModelObject* obje if (field) field->toggle(toggle); }; - auto toggle_line = [this](const t_config_option_key &opt_key, bool toggle, int opt_index, const wxString&) { + auto toggle_line = [this](const t_config_option_key &opt_key, bool toggle, int opt_index, const wxString& reason) { + m_option_state_registry.set_visible(opt_key, toggle, reason); for (auto og : m_og_settings) { Line *line = og->get_line(opt_key); if (line) { line->toggle_visible = toggle; break; } @@ -429,6 +454,7 @@ void ObjectTableSettings::update_config_values(bool is_object, ModelObject* obje printer_technology == ptFFF ? config_manipulation.toggle_print_fff_options(&main_config, 0) : config_manipulation.toggle_print_sla_options(&main_config) ; for (auto og : m_og_settings) { + update_option_tooltips(*og); og->update_visibility(wxGetApp().get_mode()); } m_parent->Layout(); diff --git a/src/slic3r/GUI/GUI_ObjectTableSettings.hpp b/src/slic3r/GUI/GUI_ObjectTableSettings.hpp index 7808d6e87e..0d9355d74d 100644 --- a/src/slic3r/GUI/GUI_ObjectTableSettings.hpp +++ b/src/slic3r/GUI/GUI_ObjectTableSettings.hpp @@ -10,6 +10,7 @@ #include #include "wxExtensions.hpp" #include "libslic3r/PrintConfig.hpp" +#include "OptionStateRegistry.hpp" class wxSizer; class wxWindow; @@ -54,6 +55,7 @@ class ObjectTableSettings : public OTG_Settings DynamicPrintConfig m_current_config; DynamicPrintConfig m_origin_config; + OptionStateRegistry m_option_state_registry; ScalableBitmap m_bmp_reset; ScalableBitmap m_bmp_reset_focus; ScalableBitmap m_bmp_reset_disable; @@ -64,6 +66,8 @@ class ObjectTableSettings : public OTG_Settings int m_current_different { 0 }; std::map m_different_map; + void update_option_tooltips(ConfigOptionsGroup& group); + public: ObjectTableSettings(wxWindow* parent, ObjectGridTable* table); ~ObjectTableSettings()