summaryrefslogtreecommitdiff
path: root/indra/newview/llchiclet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r--indra/newview/llchiclet.cpp325
1 files changed, 83 insertions, 242 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 041baf06e7..53c4bb32ca 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -51,10 +51,9 @@
#include "lltransientfloatermgr.h"
static LLDefaultChildRegistry::Register<LLChicletPanel> t1("chiclet_panel");
-static LLDefaultChildRegistry::Register<LLTalkButton> t2("talk_button");
-static LLDefaultChildRegistry::Register<LLNotificationChiclet> t3("chiclet_notification");
-static LLDefaultChildRegistry::Register<LLIMP2PChiclet> t4("chiclet_im_p2p");
-static LLDefaultChildRegistry::Register<LLIMGroupChiclet> t5("chiclet_im_group");
+static LLDefaultChildRegistry::Register<LLNotificationChiclet> t2("chiclet_notification");
+static LLDefaultChildRegistry::Register<LLIMP2PChiclet> t3("chiclet_im_p2p");
+static LLDefaultChildRegistry::Register<LLIMGroupChiclet> t4("chiclet_im_group");
S32 LLNotificationChiclet::mUreadSystemNotifications = 0;
@@ -200,9 +199,7 @@ void LLChiclet::setValue(const LLSD& value)
LLIMChiclet::LLIMChiclet(const LLIMChiclet::Params& p)
: LLChiclet(p)
-, mShowSpeaker(false)
, mNewMessagesIcon(NULL)
-, mSpeakerCtrl(NULL)
, mCounterCtrl(NULL)
{
// initialize an overlay icon for new messages
@@ -221,40 +218,6 @@ LLIMChiclet::LLIMChiclet(const LLIMChiclet::Params& p)
setShowCounter(false);
}
-void LLIMChiclet::setShowSpeaker(bool show)
-{
- bool needs_resize = getShowSpeaker() != show;
- if(needs_resize)
- {
- mShowSpeaker = show;
- toggleSpeakerControl();
- onChicletSizeChanged();
- }
-}
-void LLIMChiclet::initSpeakerControl()
-{
- mSpeakerCtrl->setSpeakerId(getOtherParticipantId());
-}
-
-void LLIMChiclet::toggleSpeakerControl()
-{
- LLRect speaker_rect = mSpeakerCtrl->getRect();
- S32 required_width = getRect().getWidth();
-
- if(getShowSpeaker())
- {
- required_width = required_width + speaker_rect.getWidth();
- initSpeakerControl();
- }
- else
- {
- required_width = required_width - speaker_rect.getWidth();
- }
-
- reshape(required_width, getRect().getHeight());
- mSpeakerCtrl->setVisible(getShowSpeaker());
-}
-
void LLIMChiclet::setShowNewMessagesIcon(bool show)
{
if(mNewMessagesIcon)
@@ -346,7 +309,7 @@ LLIMP2PChiclet::Params::Params()
// Changed icon height from 25 to 24 to fix ticket EXT-794.
// In some cases(after changing UI scale) 25 pixel height icon was
// drawn incorrectly, i'm not sure why.
- avatar_icon.rect(LLRect(0, 24, 24, 0));
+ avatar_icon.rect(LLRect(0, 24, 25, 0));
avatar_icon.mouse_opaque(false);
unread_notifications.name("unread");
@@ -359,9 +322,7 @@ LLIMP2PChiclet::Params::Params()
unread_notifications.visible(false);
speaker.name("speaker");
- speaker.rect(LLRect(25, 25, 45, 0));
- speaker.auto_update(true);
- speaker.draw_border(false);
+ speaker.rect(LLRect(45, 25, 65, 0));
show_speaker = false;
}
@@ -369,6 +330,7 @@ LLIMP2PChiclet::Params::Params()
LLIMP2PChiclet::LLIMP2PChiclet(const Params& p)
: LLIMChiclet(p)
, mChicletIconCtrl(NULL)
+, mSpeakerCtrl(NULL)
, mPopupMenu(NULL)
{
LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon;
@@ -396,9 +358,18 @@ void LLIMP2PChiclet::setCounter(S32 counter)
setShowNewMessagesIcon(counter);
}
-void LLIMP2PChiclet::initSpeakerControl()
+LLRect LLIMP2PChiclet::getRequiredRect()
{
- mSpeakerCtrl->setSpeakerId(getOtherParticipantId());
+ LLRect rect(0, 0, mChicletIconCtrl->getRect().getWidth(), 0);
+ if(getShowCounter())
+ {
+ rect.mRight += mCounterCtrl->getRequiredRect().getWidth();
+ }
+ if(getShowSpeaker())
+ {
+ rect.mRight += mSpeakerCtrl->getRect().getWidth();
+ }
+ return rect;
}
void LLIMP2PChiclet::setOtherParticipantId(const LLUUID& other_participant_id)
@@ -475,6 +446,18 @@ void LLIMP2PChiclet::onMenuItemClicked(const LLSD& user_data)
}
}
+void LLIMP2PChiclet::setShowSpeaker(bool show)
+{
+ LLIMChiclet::setShowSpeaker(show);
+
+ bool needs_resize = getShowSpeaker() != show;
+ mSpeakerCtrl->setVisible(getShowSpeaker());
+ if(needs_resize)
+ {
+ onChicletSizeChanged();
+ }
+}
+
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -510,9 +493,7 @@ LLAdHocChiclet::Params::Params()
speaker.name("speaker");
- speaker.rect(LLRect(25, 25, 45, 0));
- speaker.auto_update(true);
- speaker.draw_border(false);
+ speaker.rect(LLRect(45, 25, 65, 0));
show_speaker = false;
}
@@ -520,6 +501,7 @@ LLAdHocChiclet::Params::Params()
LLAdHocChiclet::LLAdHocChiclet(const Params& p)
: LLIMChiclet(p)
, mChicletIconCtrl(NULL)
+, mSpeakerCtrl(NULL)
, mPopupMenu(NULL)
{
LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon;
@@ -550,35 +532,24 @@ void LLAdHocChiclet::setSessionId(const LLUUID& session_id)
mChicletIconCtrl->setValue(im_session->mOtherParticipantID);
}
-void LLAdHocChiclet::draw()
+void LLAdHocChiclet::setCounter(S32 counter)
{
- initSpeakerControl();
- LLIMChiclet::draw();
+ mCounterCtrl->setCounter(counter);
+ setShowNewMessagesIcon(counter);
}
-void LLAdHocChiclet::initSpeakerControl()
+LLRect LLAdHocChiclet::getRequiredRect()
{
- LLUUID speaker_id;
- LLSpeakerMgr::speaker_list_t speaker_list;
-
- LLIMModel::getInstance()->findIMSession(getSessionId())->mSpeakers->getSpeakerList(&speaker_list, FALSE);
- for (LLSpeakerMgr::speaker_list_t::iterator i = speaker_list.begin(); i != speaker_list.end(); ++i)
+ LLRect rect(0, 0, mChicletIconCtrl->getRect().getWidth(), 0);
+ if(getShowCounter())
{
- LLPointer<LLSpeaker> s = *i;
- if (s->mSpeechVolume > 0 || s->mStatus == LLSpeaker::STATUS_SPEAKING)
- {
- speaker_id = s->mID;
- break;
- }
+ rect.mRight += mCounterCtrl->getRequiredRect().getWidth();
}
-
- mSpeakerCtrl->setSpeakerId(speaker_id);
-}
-
-void LLAdHocChiclet::setCounter(S32 counter)
-{
- mCounterCtrl->setCounter(counter);
- setShowNewMessagesIcon(counter);
+ if(getShowSpeaker())
+ {
+ rect.mRight += mSpeakerCtrl->getRect().getWidth();
+ }
+ return rect;
}
BOOL LLAdHocChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask)
@@ -612,9 +583,7 @@ LLIMGroupChiclet::Params::Params()
unread_notifications.visible(false);
speaker.name("speaker");
- speaker.rect(LLRect(25, 25, 45, 0));
- speaker.auto_update(true);
- speaker.draw_border(false);
+ speaker.rect(LLRect(45, 25, 65, 0));
show_speaker = false;
}
@@ -623,6 +592,7 @@ LLIMGroupChiclet::LLIMGroupChiclet(const Params& p)
: LLIMChiclet(p)
, LLGroupMgrObserver(LLUUID::null)
, mChicletIconCtrl(NULL)
+, mSpeakerCtrl(NULL)
, mPopupMenu(NULL)
{
LLChicletGroupIconCtrl::Params avatar_params = p.group_icon;
@@ -655,32 +625,18 @@ void LLIMGroupChiclet::setCounter(S32 counter)
setShowNewMessagesIcon(counter);
}
-void LLIMGroupChiclet::draw()
+LLRect LLIMGroupChiclet::getRequiredRect()
{
- initSpeakerControl();
- LLIMChiclet::draw();
-}
-
-void LLIMGroupChiclet::initSpeakerControl()
-{
- LLUUID speaker_id;
- LLSpeakerMgr* speaker_mgr = NULL;
- LLSpeakerMgr::speaker_list_t speaker_list;
-
- speaker_mgr = LLIMModel::getInstance()->findIMSession(getSessionId())->mSpeakers;
- speaker_mgr->update(TRUE);
- speaker_mgr->getSpeakerList(&speaker_list, FALSE);
- for (LLSpeakerMgr::speaker_list_t::iterator i = speaker_list.begin(); i != speaker_list.end(); ++i)
+ LLRect rect(0, 0, mChicletIconCtrl->getRect().getWidth(), 0);
+ if(getShowCounter())
{
- LLPointer<LLSpeaker> s = *i;
- if (s->mSpeechVolume > 0 || s->mStatus == LLSpeaker::STATUS_SPEAKING)
- {
- speaker_id = s->mID;
- break;
- }
+ rect.mRight += mCounterCtrl->getRequiredRect().getWidth();
}
-
- mSpeakerCtrl->setSpeakerId(speaker_id);
+ if(getShowSpeaker())
+ {
+ rect.mRight += mSpeakerCtrl->getRect().getWidth();
+ }
+ return rect;
}
void LLIMGroupChiclet::setSessionId(const LLUUID& session_id)
@@ -767,6 +723,17 @@ void LLIMGroupChiclet::onMenuItemClicked(const LLSD& user_data)
}
}
+void LLIMGroupChiclet::setShowSpeaker(bool show)
+{
+ LLIMChiclet::setShowSpeaker(show);
+
+ bool needs_resize = getShowSpeaker() != show;
+ mSpeakerCtrl->setVisible(getShowSpeaker());
+ if(needs_resize)
+ {
+ onChicletSizeChanged();
+ }
+}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
@@ -882,28 +849,10 @@ BOOL LLChicletPanel::postBuild()
LLIMModel::instance().addNewMsgCallback(boost::bind(im_chiclet_callback, this, _1));
LLIMModel::instance().addNoUnreadMsgsCallback(boost::bind(im_chiclet_callback, this, _1));
LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLChicletPanel::findChiclet<LLChiclet>, this, _1));
- LLVoiceChannel::setOnCurrentVoiceChannelChanged(boost::bind(&LLChicletPanel::onCurrentVoiceChannelChanged, this, _1));
return TRUE;
}
-void LLChicletPanel::onCurrentVoiceChannelChanged(const LLUUID& session_id)
-{
- for(chiclet_list_t::iterator it = mChicletList.begin(); it != mChicletList.end(); ++it)
- {
- LLIMChiclet* chiclet = dynamic_cast<LLIMChiclet*>(*it);
- if(chiclet)
- {
- if(chiclet->getSessionId() == session_id)
- {
- chiclet->setShowSpeaker(true);
- continue;
- }
- chiclet->setShowSpeaker(false);
- }
- }
-}
-
S32 LLChicletPanel::calcChickletPanleWidth()
{
S32 res = 0;
@@ -947,7 +896,23 @@ bool LLChicletPanel::addChiclet(LLChiclet* chiclet, S32 index)
void LLChicletPanel::onChicletSizeChanged(LLChiclet* ctrl, const LLSD& param)
{
- arrange();
+ S32 chiclet_width = ctrl->getRect().getWidth();
+ S32 chiclet_new_width = ctrl->getRequiredRect().getWidth();
+
+ if(chiclet_new_width == chiclet_width)
+ {
+ return;
+ }
+
+ LLRect chiclet_rect = ctrl->getRect();
+ chiclet_rect.mRight = chiclet_rect.mLeft + chiclet_new_width;
+
+ ctrl->setRect(chiclet_rect);
+
+ S32 offset = chiclet_new_width - chiclet_width;
+ S32 index = getChicletIndex(ctrl);
+
+ shiftChiclets(offset, index + 1);
trimChiclets();
showScrollButtonsIfNeeded();
}
@@ -1281,130 +1246,6 @@ bool LLChicletPanel::isAnyIMFloaterDoked()
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
-// *TODO Vadim: Move this out of llchiclet.cpp.
-
-LLTalkButton::Params::Params()
- : speak_button("speak_button")
- , show_button("show_button")
- , monitor("monitor")
-{
- // See widgets/talk_button.xml
-}
-
-LLTalkButton::LLTalkButton(const Params& p)
-: LLUICtrl(p)
-, mPrivateCallPanel(NULL)
-, mOutputMonitor(NULL)
-, mSpeakBtn(NULL)
-, mShowBtn(NULL)
-{
- LLRect rect = p.rect();
- LLRect speak_rect(0, rect.getHeight(), rect.getWidth(), 0);
- LLRect show_rect = p.show_button.rect();
- show_rect.set(0, rect.getHeight(), show_rect.getWidth(), 0);
-
- speak_rect.mRight -= show_rect.getWidth();
- show_rect.mLeft = speak_rect.getWidth();
- show_rect.mRight = rect.getWidth();
-
- LLButton::Params speak_params = p.speak_button;
- speak_params.rect(speak_rect);
- mSpeakBtn = LLUICtrlFactory::create<LLButton>(speak_params);
- addChild(mSpeakBtn);
- LLTransientFloaterMgr::getInstance()->addControlView(mSpeakBtn);
-
- mSpeakBtn->setClickedCallback(boost::bind(&LLTalkButton::onClick_SpeakBtn, this));
- mSpeakBtn->setToggleState(FALSE);
-
- LLButton::Params show_params = p.show_button;
- show_params.rect(show_rect);
- mShowBtn = LLUICtrlFactory::create<LLButton>(show_params);
- addChild(mShowBtn);
- LLTransientFloaterMgr::getInstance()->addControlView(mShowBtn);
-
- mShowBtn->setClickedCallback(boost::bind(&LLTalkButton::onClick_ShowBtn, this));
- mShowBtn->setToggleState(FALSE);
-
- static const S32 MONITOR_RIGHT_PAD = 2;
-
- LLRect monitor_rect = p.monitor.rect();
- S32 monitor_height = monitor_rect.getHeight();
- monitor_rect.mLeft = speak_rect.getWidth() - monitor_rect.getWidth() - MONITOR_RIGHT_PAD;
- monitor_rect.mRight = speak_rect.getWidth() - MONITOR_RIGHT_PAD;
- monitor_rect.mBottom = (rect.getHeight() / 2) - (monitor_height / 2);
- monitor_rect.mTop = monitor_rect.mBottom + monitor_height;
-
- LLOutputMonitorCtrl::Params monitor_params = p.monitor;
- monitor_params.draw_border(false);
- monitor_params.rect(monitor_rect);
- monitor_params.auto_update(true);
- monitor_params.speaker_id(gAgentID);
- mOutputMonitor = LLUICtrlFactory::create<LLOutputMonitorCtrl>(monitor_params);
- mSpeakBtn->addChild(mOutputMonitor);
-
- // never show "muted" because you can't mute yourself
- mOutputMonitor->setIsMuted(false);
- mOutputMonitor->setIsAgentControl(true);
-}
-
-LLTalkButton::~LLTalkButton()
-{
-}
-
-void LLTalkButton::setSpeakBtnToggleState(bool state)
-{
- mSpeakBtn->setToggleState(state);
-}
-
-void LLTalkButton::onClick_SpeakBtn()
-{
- bool speaking = mSpeakBtn->getToggleState();
- gVoiceClient->setUserPTTState(speaking);
-}
-
-void LLTalkButton::onClick_ShowBtn()
-{
- if(!mShowBtn->getToggleState())
- {
- mPrivateCallPanel->onClickClose(mPrivateCallPanel);
- delete mPrivateCallPanel;
- mPrivateCallPanel = NULL;
- mShowBtn->setToggleState(FALSE);
- return;
- }
-
- S32 x = mSpeakBtn->getRect().mLeft;
- S32 y = 0;
-
- localPointToScreen(x, y, &x, &y);
-
- mPrivateCallPanel = new LLVoiceControlPanel;
- getRootView()->addChild(mPrivateCallPanel);
-
- y = LLBottomTray::getInstance()->getRect().getHeight() + mPrivateCallPanel->getRect().getHeight();
-
- LLRect rect;
- rect.setLeftTopAndSize(x, y, mPrivateCallPanel->getRect().getWidth(), mPrivateCallPanel->getRect().getHeight());
- mPrivateCallPanel->setRect(rect);
-
-
- LLAvatarListItem* item = new LLAvatarListItem();
- item->showLastInteractionTime(false);
- item->showInfoBtn(true);
- item->showSpeakingIndicator(true);
- item->reshape(mPrivateCallPanel->getRect().getWidth(), item->getRect().getHeight(), FALSE);
-
- mPrivateCallPanel->addItem(item);
- mPrivateCallPanel->setVisible(TRUE);
- mPrivateCallPanel->setFrontmost(TRUE);
-
- mShowBtn->setToggleState(TRUE);
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////
-
LLChicletNotificationCounterCtrl::LLChicletNotificationCounterCtrl(const Params& p)
: LLTextBox(p)
, mCounter(0)
@@ -1486,6 +1327,6 @@ void LLChicletGroupIconCtrl::setValue(const LLSD& value )
//////////////////////////////////////////////////////////////////////////
LLChicletSpeakerCtrl::LLChicletSpeakerCtrl(const Params&p)
- : LLOutputMonitorCtrl(p)
+ : LLIconCtrl(p)
{
}