diff -r 0a41a8750048 -r f3cc490be44a doc/contributions.txt --- a/doc/contributions.txt Mon Feb 06 10:01:09 2012 -0500 +++ b/doc/contributions.txt Sat Feb 18 08:22:59 2012 -0500 @@ -610,6 +610,7 @@ STORM-1788 STORM-1799 STORM-1796 + STORM-1807 Kadah Coba STORM-1060 Jondan Lundquist diff -r 0a41a8750048 -r f3cc490be44a indra/newview/llinventorybridge.cpp --- a/indra/newview/llinventorybridge.cpp Mon Feb 06 10:01:09 2012 -0500 +++ b/indra/newview/llinventorybridge.cpp Sat Feb 18 08:22:59 2012 -0500 @@ -4633,14 +4633,14 @@ { if (getItem()) { - LLPreviewAnim::e_activation_type activate = LLPreviewAnim::NONE; - if ("playworld" == action) activate = LLPreviewAnim::PLAY; - if ("playlocal" == action) activate = LLPreviewAnim::AUDITION; + LLSD::String activate = "NONE"; + if ("playworld" == action) activate = "Inworld"; + if ("playlocal" == action) activate = "Locally"; LLPreviewAnim* preview = LLFloaterReg::showTypedInstance("preview_anim", LLSD(mUUID)); if (preview) { - preview->activate(activate); + preview->play(activate); } } } diff -r 0a41a8750048 -r f3cc490be44a indra/newview/llpreviewanim.h --- a/indra/newview/llpreviewanim.h Mon Feb 06 10:01:09 2012 -0500 +++ b/indra/newview/llpreviewanim.h Sat Feb 18 08:22:59 2012 -0500 @@ -33,24 +33,18 @@ class LLPreviewAnim : public LLPreview { public: - enum e_activation_type { NONE = 0, PLAY = 1, AUDITION = 2 }; + LLPreviewAnim(const LLSD& key); - - static void playAnim( void* userdata ); - static void auditionAnim( void* userdata ); - static void endAnimCallback( void *userdata ); /*virtual*/ BOOL postBuild(); /*virtual*/ void onClose(bool app_quitting); - void activate(e_activation_type type); + void draw(); + void cleanup(); + void play(const LLSD& param); protected: - LLAnimPauseRequest mPauseRequest; - LLUUID mItemID; - std::string mTitle; - LLUUID mObjectID; - LLButton* mPlayBtn; - LLButton* mAuditionBtn; + LLUUID mItemID; + bool mDidStart; }; -#endif // LL_LLPREVIEWSOUND_H +#endif // LL_LLPREVIEWANIM_H diff -r 0a41a8750048 -r f3cc490be44a indra/newview/llpreviewanim.cpp --- a/indra/newview/llpreviewanim.cpp Mon Feb 06 10:01:09 2012 -0500 +++ b/indra/newview/llpreviewanim.cpp Sat Feb 18 08:22:59 2012 -0500 @@ -43,19 +43,7 @@ LLPreviewAnim::LLPreviewAnim(const LLSD& key) : LLPreview( key ) { -} - -// static -void LLPreviewAnim::endAnimCallback( void *userdata ) -{ - LLHandle* handlep = ((LLHandle*)userdata); - LLFloater* self = handlep->get(); - delete handlep; // done with the handle - if (self) - { - self->getChild("Anim play btn")->setValue(FALSE); - self->getChild("Anim audition btn")->setValue(FALSE); - } + mCommitCallbackRegistrar.add("PreviewAnim.Play", boost::bind(&LLPreviewAnim::play, this, _2)); } // virtual @@ -68,106 +56,115 @@ getChild("desc")->setValue(item->getDescription()); } - childSetAction("Anim play btn",playAnim, this); - childSetAction("Anim audition btn",auditionAnim, this); - childSetCommitCallback("desc", LLPreview::onText, this); getChild("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe); - + return LLPreview::postBuild(); } -void LLPreviewAnim::activate(e_activation_type type) +// static +// llinventorybridge also calls into here +void LLPreviewAnim::play(const LLSD& param) { - switch ( type ) - { - case PLAY: - { - playAnim( (void *) this ); - break; - } - case AUDITION: - { - auditionAnim( (void *) this ); - break; - } - default: - { - //do nothing - } - } -} - -// static -void LLPreviewAnim::playAnim( void *userdata ) -{ - LLPreviewAnim* self = (LLPreviewAnim*) userdata; - const LLInventoryItem *item = self->getItem(); + const LLInventoryItem *item = getItem(); if(item) { LLUUID itemID=item->getAssetUUID(); - LLButton* btn = self->getChild("Anim play btn"); - if (btn) + std::string btn_name = param.asString(); + LLButton* btn_inuse; + LLButton* btn_other; + + if ("Inworld" == btn_name) { - btn->toggleState(); + btn_inuse = getChild("Inworld"); + btn_other = getChild("Locally"); + } + else if ("Locally" == btn_name) + { + btn_inuse = getChild("Locally"); + btn_other = getChild("Inworld"); + } + else + { + return; + } + + if (btn_inuse) + { + btn_inuse->toggleState(); + } + + if (btn_other) + { + btn_other->setEnabled(false); } - if (self->getChild("Anim play btn")->getValue().asBoolean() ) + if (getChild(btn_name)->getValue().asBoolean() ) { - self->mPauseRequest = NULL; - gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START); + if("Inworld" == btn_name) + { + gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START); + } + else + { + gAgentAvatarp->startMotion(item->getAssetUUID()); + } + LLMotion* motion = gAgentAvatarp->findMotion(itemID); if (motion) { - motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle(self->getHandle()))); + mItemID = itemID; + mDidStart = false; } } else { gAgentAvatarp->stopMotion(itemID); gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP); + + if (btn_other) + { + btn_other->setEnabled(true); + } } } } -// static -void LLPreviewAnim::auditionAnim( void *userdata ) +// virtual +void LLPreviewAnim::draw() { - LLPreviewAnim* self = (LLPreviewAnim*) userdata; - const LLInventoryItem *item = self->getItem(); - - if(item) + LLPreview::draw(); + if (!this->mItemID.isNull()) { - LLUUID itemID=item->getAssetUUID(); - - LLButton* btn = self->getChild("Anim audition btn"); - if (btn) + LLMotion* motion = gAgentAvatarp->findMotion(this->mItemID); + if (motion) { - btn->toggleState(); - } - - if (self->getChild("Anim audition btn")->getValue().asBoolean() ) - { - self->mPauseRequest = NULL; - gAgentAvatarp->startMotion(item->getAssetUUID()); - LLMotion* motion = gAgentAvatarp->findMotion(itemID); - - if (motion) + if (motion->isStopped() && this->mDidStart) { - motion->setDeactivateCallback(&endAnimCallback, (void *)(new LLHandle(self->getHandle()))); + cleanup(); + } + if(gAgentAvatarp->isMotionActive(this->mItemID) && !this->mDidStart) + { + this->mDidStart = true; } } - else - { - gAgentAvatarp->stopMotion(itemID); - gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_STOP); - } } } // virtual +void LLPreviewAnim::cleanup() +{ + this->mItemID = LLUUID::null; + this->mDidStart = false; + getChild("Inworld")->setValue(FALSE); + getChild("Locally")->setValue(FALSE); + getChild("Inworld")->setEnabled(true); + getChild("Locally")->setEnabled(true); +} + +// virtual void LLPreviewAnim::onClose(bool app_quitting) { const LLInventoryItem *item = getItem(); @@ -176,12 +173,5 @@ { gAgentAvatarp->stopMotion(item->getAssetUUID()); gAgent.sendAnimationRequest(item->getAssetUUID(), ANIM_REQUEST_STOP); - LLMotion* motion = gAgentAvatarp->findMotion(item->getAssetUUID()); - - if (motion) - { - // *TODO: minor memory leak here, user data is never deleted (Use real callbacks) - motion->setDeactivateCallback(NULL, (void *)NULL); - } } } diff -r 0a41a8750048 -r f3cc490be44a indra/newview/skins/default/xui/en/floater_preview_animation.xml --- a/indra/newview/skins/default/xui/en/floater_preview_animation.xml Mon Feb 06 10:01:09 2012 -0500 +++ b/indra/newview/skins/default/xui/en/floater_preview_animation.xml Sat Feb 18 08:22:59 2012 -0500 @@ -41,18 +41,26 @@ label_selected="Stop" layout="topleft" left="10" - name="Anim play btn" + name="Inworld" tool_tip="Play this animation so that others can see it" top="47" - width="125" /> + width="125"> + +