PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llimfloatercontainer.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 164 lines | 95 code | 26 blank | 43 comment | 13 complexity | 6b40821bbdd625afc294e92372596b62 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llimfloatercontainer.cpp
  3. * @brief Multifloater containing active IM sessions in separate tab container tabs
  4. *
  5. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llimfloatercontainer.h"
  28. #include "llfloaterreg.h"
  29. #include "llimview.h"
  30. #include "llavatariconctrl.h"
  31. #include "llgroupiconctrl.h"
  32. #include "llagent.h"
  33. #include "lltransientfloatermgr.h"
  34. //
  35. // LLIMFloaterContainer
  36. //
  37. LLIMFloaterContainer::LLIMFloaterContainer(const LLSD& seed)
  38. : LLMultiFloater(seed)
  39. {
  40. mAutoResize = FALSE;
  41. LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::IM, this);
  42. }
  43. LLIMFloaterContainer::~LLIMFloaterContainer()
  44. {
  45. mNewMessageConnection.disconnect();
  46. LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::IM, this);
  47. }
  48. BOOL LLIMFloaterContainer::postBuild()
  49. {
  50. mNewMessageConnection = LLIMModel::instance().mNewMsgSignal.connect(boost::bind(&LLIMFloaterContainer::onNewMessageReceived, this, _1));
  51. // Do not call base postBuild to not connect to mCloseSignal to not close all floaters via Close button
  52. // mTabContainer will be initialized in LLMultiFloater::addChild()
  53. return TRUE;
  54. }
  55. void LLIMFloaterContainer::onOpen(const LLSD& key)
  56. {
  57. LLMultiFloater::onOpen(key);
  58. /*
  59. if (key.isDefined())
  60. {
  61. LLIMFloater* im_floater = LLIMFloater::findInstance(key.asUUID());
  62. if (im_floater)
  63. {
  64. im_floater->openFloater();
  65. }
  66. }
  67. */
  68. }
  69. void LLIMFloaterContainer::addFloater(LLFloater* floaterp,
  70. BOOL select_added_floater,
  71. LLTabContainer::eInsertionPoint insertion_point)
  72. {
  73. if(!floaterp) return;
  74. // already here
  75. if (floaterp->getHost() == this)
  76. {
  77. openFloater(floaterp->getKey());
  78. return;
  79. }
  80. LLMultiFloater::addFloater(floaterp, select_added_floater, insertion_point);
  81. LLUUID session_id = floaterp->getKey();
  82. LLIconCtrl* icon = 0;
  83. if(gAgent.isInGroup(session_id, TRUE))
  84. {
  85. LLGroupIconCtrl::Params icon_params;
  86. icon_params.group_id = session_id;
  87. icon = LLUICtrlFactory::instance().create<LLGroupIconCtrl>(icon_params);
  88. mSessions[session_id] = floaterp;
  89. floaterp->mCloseSignal.connect(boost::bind(&LLIMFloaterContainer::onCloseFloater, this, session_id));
  90. }
  91. else
  92. {
  93. LLUUID avatar_id = LLIMModel::getInstance()->getOtherParticipantID(session_id);
  94. LLAvatarIconCtrl::Params icon_params;
  95. icon_params.avatar_id = avatar_id;
  96. icon = LLUICtrlFactory::instance().create<LLAvatarIconCtrl>(icon_params);
  97. mSessions[session_id] = floaterp;
  98. floaterp->mCloseSignal.connect(boost::bind(&LLIMFloaterContainer::onCloseFloater, this, session_id));
  99. }
  100. mTabContainer->setTabImage(floaterp, icon);
  101. }
  102. void LLIMFloaterContainer::onCloseFloater(LLUUID& id)
  103. {
  104. mSessions.erase(id);
  105. }
  106. void LLIMFloaterContainer::onNewMessageReceived(const LLSD& data)
  107. {
  108. LLUUID session_id = data["session_id"].asUUID();
  109. LLFloater* floaterp = get_ptr_in_map(mSessions, session_id);
  110. LLFloater* current_floater = LLMultiFloater::getActiveFloater();
  111. if(floaterp && current_floater && floaterp != current_floater)
  112. {
  113. if(LLMultiFloater::isFloaterFlashing(floaterp))
  114. LLMultiFloater::setFloaterFlashing(floaterp, FALSE);
  115. LLMultiFloater::setFloaterFlashing(floaterp, TRUE);
  116. }
  117. }
  118. LLIMFloaterContainer* LLIMFloaterContainer::findInstance()
  119. {
  120. return LLFloaterReg::findTypedInstance<LLIMFloaterContainer>("im_container");
  121. }
  122. LLIMFloaterContainer* LLIMFloaterContainer::getInstance()
  123. {
  124. return LLFloaterReg::getTypedInstance<LLIMFloaterContainer>("im_container");
  125. }
  126. void LLIMFloaterContainer::setMinimized(BOOL b)
  127. {
  128. if (isMinimized() == b) return;
  129. LLMultiFloater::setMinimized(b);
  130. // Hide minimized floater (see EXT-5315)
  131. setVisible(!b);
  132. if (isMinimized()) return;
  133. if (getActiveFloater())
  134. {
  135. getActiveFloater()->setVisible(TRUE);
  136. }
  137. }
  138. // EOF