From 05c8ef3f3c002e71805bb04e9eddc3280630fca1 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Fri, 1 Sep 2023 17:36:00 -0700 Subject: SL-20167: Grey out the clipboard when copying the material to clipboard is not allowed --- indra/newview/llmaterialeditor.cpp | 8 ++++++++ indra/newview/llmaterialeditor.h | 1 + indra/newview/llpanelface.cpp | 6 ++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 54d85c87ac..8f4e0658f6 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1947,6 +1947,14 @@ bool LLMaterialEditor::canSaveObjectsMaterial() return can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY}), permissions, item_out); } +bool LLMaterialEditor::canClipboardObjectsMaterial() +{ + LLSelectedTEGetMatData func(true); + LLPermissions permissions; + LLViewerInventoryItem* item_out; + return can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY, PERM_TRANSFER}), permissions, item_out); +} + void LLMaterialEditor::saveObjectsMaterialAs() { LLSelectedTEGetMatData func(true); diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 6b2f49e2fc..b29db706f8 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -115,6 +115,7 @@ class LLMaterialEditor : public LLPreview, public LLVOInventoryListener static bool canModifyObjectsMaterial(); static bool canSaveObjectsMaterial(); + static bool canClipboardObjectsMaterial(); static void saveObjectsMaterialAs(); static void onCopyObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions, const LLUUID& object_id, const LLUUID& item_id); static void onSaveObjectsMaterialAsMsgCallback(const LLSD& notification, const LLSD& response, const LLPermissions& permissions); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index b502fa3546..d86956e370 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1975,7 +1975,8 @@ void LLPanelFace::updateCopyTexButton() LLViewerObject* objectp = LLSelectMgr::getInstance()->getSelection()->getFirstObject(); mMenuClipboardTexture->setEnabled(objectp && objectp->getPCode() == LL_PCODE_VOLUME && objectp->permModify() && !objectp->isPermanentEnforced() && !objectp->isInventoryPending() - && (LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1)); + && (LLSelectMgr::getInstance()->getSelection()->getObjectCount() == 1) + && LLMaterialEditor::canClipboardObjectsMaterial()); std::string tooltip = (objectp && objectp->isInventoryPending()) ? LLTrans::getString("LoadingContents") : getString("paste_options"); mMenuClipboardTexture->setToolTip(tooltip); } @@ -4147,7 +4148,8 @@ void LLPanelFace::onCopyTexture() || objectp->getPCode() != LL_PCODE_VOLUME || !objectp->permModify() || objectp->isPermanentEnforced() - || selected_count > 1) + || selected_count > 1 + || !LLMaterialEditor::canClipboardObjectsMaterial()) { return; } -- cgit v1.2.3 From ab66df94cb7c4cc9a4530ea547aaf81dddec34de Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 6 Sep 2023 11:02:31 -0700 Subject: SL-20167: Also check permission on paste to be certain --- indra/newview/llpanelface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index d86956e370..df464bc7e5 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -4344,7 +4344,8 @@ void LLPanelFace::onPasteTexture() || objectp->getPCode() != LL_PCODE_VOLUME || !objectp->permModify() || objectp->isPermanentEnforced() - || selected_count > 1) + || selected_count > 1 + || !LLMaterialEditor::canClipboardObjectsMaterial()) { // not supposed to happen LL_WARNS() << "Failed to paste texture due to missing or wrong selection" << LL_ENDL; -- cgit v1.2.3 From c0bcc3740ea4c6662f9707d49ab5c7132bb2a0a8 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 6 Sep 2023 11:47:34 -0700 Subject: SL-20167: Don't block clipboard if GLTF material is null --- indra/newview/llmaterialeditor.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 8f4e0658f6..d4ea725af7 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -1949,6 +1949,24 @@ bool LLMaterialEditor::canSaveObjectsMaterial() bool LLMaterialEditor::canClipboardObjectsMaterial() { + if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() != 1) + { + return false; + } + + struct LLSelectedTEGetNullMat : public LLSelectedTEFunctor + { + bool apply(LLViewerObject* objectp, S32 te_index) + { + return objectp->getRenderMaterialID(te_index).isNull(); + } + } null_func; + + if (LLSelectMgr::getInstance()->getSelection()->applyToTEs(&null_func)) + { + return true; + } + LLSelectedTEGetMatData func(true); LLPermissions permissions; LLViewerInventoryItem* item_out; -- cgit v1.2.3