From bff172b374fa12e646d427e09f2ffac4289ab654 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Mon, 30 May 2011 15:38:37 -0700 Subject: EXP-824 Adding volume slider and block btn in basic mode IM panel --- indra/newview/llpanelimcontrolpanel.cpp | 92 +++++++- indra/newview/llpanelimcontrolpanel.h | 6 + .../minimal/xui/en/panel_im_control_panel.xml | 249 ++++++++++++++------- 3 files changed, 257 insertions(+), 90 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp index 0cc5dcda82..06c8d496ff 100644 --- a/indra/newview/llpanelimcontrolpanel.cpp +++ b/indra/newview/llpanelimcontrolpanel.cpp @@ -99,7 +99,8 @@ void LLPanelChatControlPanel::updateCallButton() void LLPanelChatControlPanel::updateButtons(bool is_call_started) { getChildView("end_call_btn_panel")->setVisible( is_call_started); - getChildView("voice_ctrls_btn_panel")->setVisible( is_call_started); + getChildView("volume_ctrl_panel")->setVisible( is_call_started); + getChildView("voice_ctrls_btn_panel")->setVisible( is_call_started && findChild("voice_ctrls_btn_panel")); getChildView("call_btn_panel")->setVisible( ! is_call_started); updateCallButton(); @@ -119,9 +120,9 @@ BOOL LLPanelChatControlPanel::postBuild() childSetAction("call_btn", boost::bind(&LLPanelChatControlPanel::onCallButtonClicked, this)); childSetAction("end_call_btn", boost::bind(&LLPanelChatControlPanel::onEndCallButtonClicked, this)); childSetAction("voice_ctrls_btn", boost::bind(&LLPanelChatControlPanel::onOpenVoiceControlsClicked, this)); - + LLVoiceClient::getInstance()->addObserver(this); - + return TRUE; } @@ -156,13 +157,93 @@ BOOL LLPanelIMControlPanel::postBuild() childSetAction("share_btn", boost::bind(&LLPanelIMControlPanel::onShareButtonClicked, this)); childSetAction("teleport_btn", boost::bind(&LLPanelIMControlPanel::onTeleportButtonClicked, this)); childSetAction("pay_btn", boost::bind(&LLPanelIMControlPanel::onPayButtonClicked, this)); + + childSetAction("mute_btn", boost::bind(&LLPanelIMControlPanel::onClickMuteVolume, this)); + childSetAction("block_btn", boost::bind(&LLPanelIMControlPanel::onClickBlock, this)); + childSetAction("unblock_btn", boost::bind(&LLPanelIMControlPanel::onClickUnblock, this)); + + getChild("volume_slider")->setCommitCallback(boost::bind(&LLPanelIMControlPanel::onVolumeChange, this, _2)); + getChildView("add_friend_btn")->setEnabled(!LLAvatarActions::isFriend(getChild("avatar_icon")->getAvatarId())); setFocusReceivedCallback(boost::bind(&LLPanelIMControlPanel::onFocusReceived, this)); - + return LLPanelChatControlPanel::postBuild(); } +void LLPanelIMControlPanel::draw() +{ + bool is_muted = LLMuteList::getInstance()->isMuted(mAvatarID); + + getChild("block_btn_panel")->setVisible(!is_muted); + getChild("unblock_btn_panel")->setVisible(is_muted); + + if (getChildView("volume_ctrl_panel")->getVisible()) + { + + bool is_muted_voice = LLMuteList::getInstance()->isMuted(mAvatarID, LLMute::flagVoiceChat); + + LLUICtrl* mute_btn = getChild("mute_btn"); + mute_btn->setValue( is_muted_voice ); + + LLUICtrl* volume_slider = getChild("volume_slider"); + volume_slider->setEnabled( !is_muted_voice ); + + F32 volume; + + if (is_muted_voice) + { + // it's clearer to display their volume as zero + volume = 0.f; + } + else + { + // actual volume + volume = LLVoiceClient::getInstance()->getUserVolume(mAvatarID); + } + volume_slider->setValue( (F64)volume ); + } + + LLPanelChatControlPanel::draw(); +} + +void LLPanelIMControlPanel::onClickMuteVolume() +{ + // By convention, we only display and toggle voice mutes, not all mutes + LLMuteList* mute_list = LLMuteList::getInstance(); + bool is_muted = mute_list->isMuted(mAvatarID, LLMute::flagVoiceChat); + + LLMute mute(mAvatarID, getChild("avatar_name")->getText(), LLMute::AGENT); + if (!is_muted) + { + mute_list->add(mute, LLMute::flagVoiceChat); + } + else + { + mute_list->remove(mute, LLMute::flagVoiceChat); + } +} + +void LLPanelIMControlPanel::onClickBlock() +{ + LLMute mute(mAvatarID, getChild("avatar_name")->getText(), LLMute::AGENT); + + LLMuteList::getInstance()->add(mute); +} + +void LLPanelIMControlPanel::onClickUnblock() +{ + LLMute mute(mAvatarID, getChild("avatar_name")->getText(), LLMute::AGENT); + + LLMuteList::getInstance()->remove(mute); +} + +void LLPanelIMControlPanel::onVolumeChange(const LLSD& data) +{ + F32 volume = (F32)data.asReal(); + LLVoiceClient::getInstance()->setUserVolume(mAvatarID, volume); +} + void LLPanelIMControlPanel::onTeleportButtonClicked() { LLAvatarActions::offerTeleport(mAvatarID); @@ -262,6 +343,9 @@ void LLPanelIMControlPanel::onNameCache(const LLUUID& id, const std::string& ful std::string avatar_name = full_name; getChild("avatar_name")->setValue(avatar_name); getChild("avatar_name")->setToolTip(avatar_name); + + bool is_linden = LLStringUtil::endsWith(full_name, " Linden"); + getChild("mute_btn")->setEnabled( !is_linden); } } diff --git a/indra/newview/llpanelimcontrolpanel.h b/indra/newview/llpanelimcontrolpanel.h index 3bbe24ecb9..76d4475b74 100644 --- a/indra/newview/llpanelimcontrolpanel.h +++ b/indra/newview/llpanelimcontrolpanel.h @@ -94,6 +94,12 @@ private: void onPayButtonClicked(); void onFocusReceived(); + void onClickMuteVolume(); + void onClickBlock(); + void onClickUnblock(); + /*virtual*/ void draw(); + void onVolumeChange(const LLSD& data); + LLUUID mAvatarID; }; diff --git a/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml b/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml index be13bc1bb7..a9c7b624fd 100644 --- a/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml +++ b/indra/newview/skins/minimal/xui/en/panel_im_control_panel.xml @@ -23,102 +23,179 @@ orientation="vertical" top_pad="5" width="145"> - -