diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 21981ea47d..11dc569b5c 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -925,33 +926,44 @@ void StdCmdToggleTransparency::activated(int iMsg) if (!obj) continue; - if (!dynamic_cast(obj) && !dynamic_cast(obj)) { - Gui::ViewProvider* view = Application::Instance->getDocument(sel.pDoc)->getViewProvider(obj); + bool isGroup = dynamic_cast(obj) + || dynamic_cast(obj) + || dynamic_cast(obj); + + auto addObjects = [](App::DocumentObject* obj, std::vector& views) { + App::Document* doc = obj->getDocument(); + Gui::ViewProvider* view = Application::Instance->getDocument(doc)->getViewProvider(obj); App::Property* prop = view->getPropertyByName("Transparency"); if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { - viewsToToggle.push_back(view); + // To prevent toggling the tip of a PD body (see #11353), we check if the parent has a + // Tip prop. + const std::vector parents = obj->getInList(); + if (!parents.empty()) { + App::Document* parentDoc = parents[0]->getDocument(); + Gui::ViewProvider* parentView = Application::Instance->getDocument(parentDoc)->getViewProvider(parents[0]); + App::Property* parentProp = parents[0]->getPropertyByName("Tip"); + if (parentProp) { + // Make sure it has a transparency prop too + parentProp = parentView->getPropertyByName("Transparency"); + if (parentProp && parentProp->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { + view = parentView; + } + } + } + + if (std::find(views.begin(), views.end(), view) == views.end()) { + views.push_back(view); + } + } + }; + + if (isGroup) { + for (App::DocumentObject* subobj : obj->getOutListRecursive()) { + addObjects(subobj, viewsToToggle); } } else { - std::function&)> addSubObjects = - [&addSubObjects](App::DocumentObject* obj, std::vector& viewsToToggle) { - if (!dynamic_cast(obj) && !dynamic_cast(obj)) { - App::Document* doc = obj->getDocument(); - Gui::ViewProvider* view = Application::Instance->getDocument(doc)->getViewProvider(obj); - App::Property* prop = view->getPropertyByName("Transparency"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId()) - && std::find(viewsToToggle.begin(), viewsToToggle.end(), view) == viewsToToggle.end()) { - viewsToToggle.push_back(view); - } - } - else { - for (App::DocumentObject* subobj : obj->getOutList()) { - addSubObjects(subobj, viewsToToggle); - } - } - }; - - addSubObjects(obj, viewsToToggle); + addObjects(obj, viewsToToggle); } } diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index cc622d331f..c19b81848b 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -703,6 +703,7 @@ MenuItem* StdWorkbench::setupMenuBar() const << "Std_ToggleNavigation" << "Std_SetAppearance" << "Std_RandomColor" + << "Std_ToggleTransparency" << "Separator" << "Std_Workbench" << "Std_ToolBarMenu" @@ -711,7 +712,6 @@ MenuItem* StdWorkbench::setupMenuBar() const *view << "Std_DockOverlay"; } *view << "Separator" - << "Std_ToggleTransparency" << "Std_LinkSelectActions" << "Std_TreeViewActions" << "Std_ViewStatusBar";