From 039c50f2b4831a4caad3313b3e8e1c992793ae90 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Wed, 8 Feb 2012 15:41:27 -0500 Subject: STORM-1807 Play animation floater 2nd play button active while animation is playing --- indra/newview/llpreviewanim.cpp | 140 ++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 78 deletions(-) (limited to 'indra/newview/llpreviewanim.cpp') diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp index 8e8b530e13..dcb8bca512 100644 --- a/indra/newview/llpreviewanim.cpp +++ b/indra/newview/llpreviewanim.cpp @@ -43,19 +43,7 @@ extern LLAgent gAgent; 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,105 +56,108 @@ BOOL LLPreviewAnim::postBuild() 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 ) + const LLInventoryItem *item = getItem(); + + if(item) { - case PLAY: + LLUUID itemID=item->getAssetUUID(); + + std::string btn_name = param.asString(); + LLButton* btn_inuse; + LLButton* btn_other; + + if ("Inworld" == btn_name) { - playAnim( (void *) this ); - break; + btn_inuse = getChild("Inworld"); + btn_other = getChild("Locally"); } - case AUDITION: + else if ("Locally" == btn_name) { - auditionAnim( (void *) this ); - break; + btn_inuse = getChild("Locally"); + btn_other = getChild("Inworld"); } - default: + else { - //do nothing + return; } - } -} -// static -void LLPreviewAnim::playAnim( void *userdata ) -{ - LLPreviewAnim* self = (LLPreviewAnim*) userdata; - const LLInventoryItem *item = self->getItem(); - - if(item) - { - LLUUID itemID=item->getAssetUUID(); + if (btn_inuse) + { + btn_inuse->toggleState(); + } - LLButton* btn = self->getChild("Anim play btn"); - if (btn) + if (btn_other) { - btn->toggleState(); + 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); + "Inworld" == btn_name ? gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START) : + 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) - { - btn->toggleState(); - } - - if (self->getChild("Anim audition btn")->getValue().asBoolean() ) + LLMotion* motion = gAgentAvatarp->findMotion(this->mItemID); + if (motion) { - 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) { @@ -176,12 +167,5 @@ void LLPreviewAnim::onClose(bool app_quitting) { 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); - } } } -- cgit v1.2.3 From 092c0eda65eedd606ae7cbacd74445dcff496998 Mon Sep 17 00:00:00 2001 From: Jonathan Yap Date: Sat, 18 Feb 2012 08:22:59 -0500 Subject: STORM-1807 Fix possible Linux compiling issue --- indra/newview/llpreviewanim.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpreviewanim.cpp') diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp index dcb8bca512..35ac0537a3 100644 --- a/indra/newview/llpreviewanim.cpp +++ b/indra/newview/llpreviewanim.cpp @@ -103,8 +103,14 @@ void LLPreviewAnim::play(const LLSD& param) if (getChild(btn_name)->getValue().asBoolean() ) { - "Inworld" == btn_name ? gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START) : - gAgentAvatarp->startMotion(item->getAssetUUID()); + if("Inworld" == btn_name) + { + gAgent.sendAnimationRequest(itemID, ANIM_REQUEST_START); + } + else + { + gAgentAvatarp->startMotion(item->getAssetUUID()); + } LLMotion* motion = gAgentAvatarp->findMotion(itemID); if (motion) -- cgit v1.2.3