From 34b9ef2f04a6e48bf31d130497dfe83e20a12b68 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 30 Sep 2009 15:24:29 -0700 Subject: Fixed Unlink not enabling when Edit Linked Parts enabled --- linden/indra/newview/llfloatertools.cpp | 44 +++++++++++++++++++++++++++------ linden/indra/newview/llviewermenu.cpp | 44 +++++++++++++++++++++++++++------ 2 files changed, 74 insertions(+), 14 deletions(-) (limited to 'linden/indra/newview') diff --git a/linden/indra/newview/llfloatertools.cpp b/linden/indra/newview/llfloatertools.cpp index d2a8040..4aca133 100644 --- a/linden/indra/newview/llfloatertools.cpp +++ b/linden/indra/newview/llfloatertools.cpp @@ -667,6 +667,7 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask) if (mBtnLink) mBtnLink->setVisible( edit_visible ); if (mBtnUnlink) mBtnUnlink->setVisible( edit_visible ); + //TODO: Move these into llselectmgr // Check to see if we can link things bool can_link = false; if (!gSavedSettings.getBOOL("EditLinkedParts")) @@ -689,15 +690,44 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask) // Check to see if we can unlink things bool can_unlink = false; - if (LLSelectMgr::getInstance()->selectGetAllRootsValid() && - LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() && - !LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject()->isAttachment()) + if (tool != LLToolFace::getInstance()) { - if (LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() > 0 && - LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != - LLSelectMgr::getInstance()->getSelection()->getObjectCount()) + if (LLSelectMgr::getInstance()->selectGetAllRootsValid() && + LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() && + !LLSelectMgr::getInstance()->getSelection()->isAttachment()) { - can_unlink = true; + // LL's viewer unlinks the last linkset selected, + // regardless of how many linksets or prims are selected total. + // Preserve that behavior when enabling the unlink option. + if (gSavedSettings.getBOOL("EditLinkedParts")) + { + struct f : public LLSelectedNodeFunctor + { + virtual bool apply(LLSelectNode* pNode) + { + // Return the first selection node that is + // 1) not a root prim + // 2) or a root prim that has child prims + // or in other words: any prim that is part of a linkset + return (pNode->getObject() != pNode->getObject()->getRootEdit()) || + (pNode->getObject()->numChildren() != 0); + } + } func; + + if (LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(&func, TRUE)) + { + // the selection contains at least one prim (child or root) that is part of a linkset + can_unlink = true; + } + } + else + { + if (LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != + LLSelectMgr::getInstance()->getSelection()->getObjectCount()) + { + can_unlink = true; + } + } } } mBtnUnlink->setEnabled(can_unlink); diff --git a/linden/indra/newview/llviewermenu.cpp b/linden/indra/newview/llviewermenu.cpp index ba24c16..f9ae401 100644 --- a/linden/indra/newview/llviewermenu.cpp +++ b/linden/indra/newview/llviewermenu.cpp @@ -169,6 +169,7 @@ #include "lltool.h" #include "lltoolbar.h" #include "lltoolcomp.h" +#include "lltoolface.h" #include "lltoolfocus.h" #include "lltoolgrab.h" #include "lltoolmgr.h" @@ -4594,15 +4595,44 @@ class LLToolsEnableUnlink : public view_listener_t bool handleEvent(LLPointer event, const LLSD& userdata) { bool new_value = false; - if (LLSelectMgr::getInstance()->selectGetAllRootsValid() && - LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() && - !LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject()->isAttachment()) + if (LLToolMgr::getInstance()->getCurrentTool() != LLToolFace::getInstance()) { - if (LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() > 0 && - LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != - LLSelectMgr::getInstance()->getSelection()->getObjectCount()) + if (LLSelectMgr::getInstance()->selectGetAllRootsValid() && + LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() && + !LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject()->isAttachment()) { - new_value = true; + // LL's viewer unlinks the last linkset selected, + // regardless of how many linksets or prims are selected total. + // Preserve that behavior when enabling the unlink option. + if (gSavedSettings.getBOOL("EditLinkedParts")) + { + struct f : public LLSelectedNodeFunctor + { + virtual bool apply(LLSelectNode* pNode) + { + // Return the first selection node that is + // 1) not a root prim + // 2) or a root prim that has child prims + // or in other words: any prim that is part of a linkset + return (pNode->getObject() != pNode->getObject()->getRootEdit()) || + (pNode->getObject()->numChildren() != 0); + } + } func; + + if (LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(&func, TRUE)) + { + // the selection contains at least one prim (child or root) that is part of a linkset + new_value = true; + } + } + else + { + if (LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != + LLSelectMgr::getInstance()->getSelection()->getObjectCount()) + { + new_value = true; + } + } } } -- cgit v1.1