diff options
author | Aimee Linden <aimee@lindenlab.com> | 2010-05-23 02:22:48 +0100 |
---|---|---|
committer | Aimee Linden <aimee@lindenlab.com> | 2010-05-23 02:22:48 +0100 |
commit | 1ebbe196910110eb51497f272abde277f8f0f69a (patch) | |
tree | f3b9ad65823adfb1ce355a5bafbc472915fbbae1 /indra/newview/llfloatervoiceeffect.cpp | |
parent | 32826f31ebfe19f57a1d8cc7c2f3e81df9b5de74 (diff) |
EXT-7337 WIP Voice morph previewing
Separate Play and Stop callbacks, to allow single click previews in the effect list.
Diffstat (limited to 'indra/newview/llfloatervoiceeffect.cpp')
-rw-r--r-- | indra/newview/llfloatervoiceeffect.cpp | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/indra/newview/llfloatervoiceeffect.cpp b/indra/newview/llfloatervoiceeffect.cpp index f38a56a06d..0fa6135da2 100644 --- a/indra/newview/llfloatervoiceeffect.cpp +++ b/indra/newview/llfloatervoiceeffect.cpp @@ -43,6 +43,7 @@ LLFloaterVoiceEffect::LLFloaterVoiceEffect(const LLSD& key) { mCommitCallbackRegistrar.add("VoiceEffect.Record", boost::bind(&LLFloaterVoiceEffect::onClickRecord, this)); mCommitCallbackRegistrar.add("VoiceEffect.Play", boost::bind(&LLFloaterVoiceEffect::onClickPlay, this)); + mCommitCallbackRegistrar.add("VoiceEffect.Stop", boost::bind(&LLFloaterVoiceEffect::onClickStop, this)); mCommitCallbackRegistrar.add("VoiceEffect.Add", boost::bind(&LLFloaterVoiceEffect::onClickAdd, this)); mCommitCallbackRegistrar.add("VoiceEffect.Activate", boost::bind(&LLFloaterVoiceEffect::onClickActivate, this)); } @@ -68,6 +69,7 @@ BOOL LLFloaterVoiceEffect::postBuild() mVoiceEffectList = getChild<LLScrollListCtrl>("voice_effect_list"); if (mVoiceEffectList) { + mVoiceEffectList->setCommitCallback(boost::bind(&LLFloaterVoiceEffect::onClickPlay, this)); mVoiceEffectList->setDoubleClickCallback(boost::bind(&LLFloaterVoiceEffect::onClickActivate, this)); } @@ -80,7 +82,8 @@ BOOL LLFloaterVoiceEffect::postBuild() effect_interface->enablePreviewBuffer(true); } - update(); + refreshEffectList(); + updateControls(); return TRUE; } @@ -95,7 +98,7 @@ void LLFloaterVoiceEffect::onClose(bool app_quitting) } } -void LLFloaterVoiceEffect::update() +void LLFloaterVoiceEffect::refreshEffectList() { if (!mVoiceEffectList) { @@ -194,23 +197,42 @@ void LLFloaterVoiceEffect::update() mVoiceEffectList->setValue(effect_interface->getVoiceEffect()); mVoiceEffectList->setEnabled(true); +} + +void LLFloaterVoiceEffect::updateControls() +{ + bool recording = false; + bool playing = false; + + LLVoiceEffectInterface* effect_interface = LLVoiceClient::instance().getVoiceEffectInterface(); + if (effect_interface) + { + recording = effect_interface->isPreviewRecording(); + playing = effect_interface->isPreviewPlaying(); + } - // Update button states - // *TODO: Should separate this from rebuilding the effects list, to avoid rebuilding it unnecessarily - bool recording = effect_interface->isPreviewRecording(); getChild<LLButton>("record_btn")->setVisible(!recording); getChild<LLButton>("record_stop_btn")->setVisible(recording); - getChild<LLButton>("play_btn")->setEnabled(effect_interface->isPreviewReady()); - bool playing = effect_interface->isPreviewPlaying(); getChild<LLButton>("play_btn")->setVisible(!playing); getChild<LLButton>("play_stop_btn")->setVisible(playing); + + getChild<LLButton>("play_btn")->setEnabled(effect_interface->isPreviewReady()); + + if (!mVoiceEffectList) + { + mVoiceEffectList->setValue(effect_interface->getVoiceEffect()); + } } // virtual void LLFloaterVoiceEffect::onVoiceEffectChanged(bool new_effects) { - update(); + if (new_effects) + { + refreshEffectList(); + } + updateControls(); } void LLFloaterVoiceEffect::onClickRecord() @@ -219,11 +241,9 @@ void LLFloaterVoiceEffect::onClickRecord() LLVoiceEffectInterface* effect_interface = LLVoiceClient::instance().getVoiceEffectInterface(); if (effect_interface) { - bool record = !effect_interface->isPreviewRecording(); - effect_interface->recordPreviewBuffer(record); - getChild<LLButton>("record_btn")->setVisible(!record); - getChild<LLButton>("record_stop_btn")->setVisible(record); + effect_interface->recordPreviewBuffer(); } + updateControls(); } void LLFloaterVoiceEffect::onClickPlay() @@ -239,11 +259,20 @@ void LLFloaterVoiceEffect::onClickPlay() LLVoiceEffectInterface* effect_interface = LLVoiceClient::instance().getVoiceEffectInterface(); if (effect_interface) { - bool play = !effect_interface->isPreviewPlaying(); - effect_interface->playPreviewBuffer(play, effect_id); - getChild<LLButton>("play_btn")->setVisible(!play); - getChild<LLButton>("play_stop_btn")->setVisible(play); + effect_interface->playPreviewBuffer(effect_id); + } + updateControls(); +} + +void LLFloaterVoiceEffect::onClickStop() +{ + LL_DEBUGS("Voice") << "Stop clicked" << LL_ENDL; + LLVoiceEffectInterface* effect_interface = LLVoiceClient::instance().getVoiceEffectInterface(); + if (effect_interface) + { + effect_interface->stopPreviewBuffer(); } + updateControls(); } void LLFloaterVoiceEffect::onClickAdd() |