PageRenderTime 88ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llinspecttoast.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 127 lines | 76 code | 18 blank | 33 comment | 8 complexity | 138c466bebc19cf8a9b63d066ee64e93 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llinspecttoast.cpp
  3. * @brief Toast inspector implementation.
  4. *
  5. * $LicenseInfo:firstyear=2003&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" // must be first include
  27. #include "llinspecttoast.h"
  28. #include "llinspect.h"
  29. #include "llfloaterreg.h"
  30. #include "llscreenchannel.h"
  31. #include "llchannelmanager.h"
  32. #include "lltransientfloatermgr.h"
  33. using namespace LLNotificationsUI;
  34. /**
  35. * Represents inspectable toast .
  36. */
  37. class LLInspectToast: public LLInspect
  38. {
  39. public:
  40. LLInspectToast(const LLSD& notification_idl);
  41. virtual ~LLInspectToast();
  42. /*virtual*/ void onOpen(const LLSD& notification_id);
  43. /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
  44. private:
  45. void onToastDestroy(LLToast * toast);
  46. boost::signals2::scoped_connection mConnection;
  47. LLPanel* mPanel;
  48. LLScreenChannel* mScreenChannel;
  49. };
  50. LLInspectToast::LLInspectToast(const LLSD& notification_id) :
  51. LLInspect(LLSD()), mPanel(NULL)
  52. {
  53. LLScreenChannelBase* channel = LLChannelManager::getInstance()->findChannelByID(
  54. LLUUID(gSavedSettings.getString("NotificationChannelUUID")));
  55. mScreenChannel = dynamic_cast<LLScreenChannel*>(channel);
  56. if(NULL == mScreenChannel)
  57. {
  58. llwarns << "Could not get requested screen channel." << llendl;
  59. return;
  60. }
  61. LLTransientFloaterMgr::getInstance()->addControlView(this);
  62. }
  63. LLInspectToast::~LLInspectToast()
  64. {
  65. LLTransientFloaterMgr::getInstance()->removeControlView(this);
  66. }
  67. // virtual
  68. void LLInspectToast::onOpen(const LLSD& notification_id)
  69. {
  70. LLInspect::onOpen(notification_id);
  71. LLToast* toast = mScreenChannel->getToastByNotificationID(notification_id);
  72. if (toast == NULL)
  73. {
  74. llwarns << "Could not get requested toast from screen channel." << llendl;
  75. return;
  76. }
  77. mConnection = toast->setOnToastDestroyedCallback(boost::bind(&LLInspectToast::onToastDestroy, this, _1));
  78. LLPanel * panel = toast->getPanel();
  79. panel->setVisible(TRUE);
  80. panel->setMouseOpaque(FALSE);
  81. if(mPanel != NULL && mPanel->getParent() == this)
  82. {
  83. removeChild(mPanel);
  84. }
  85. addChild(panel);
  86. panel->setFocus(TRUE);
  87. mPanel = panel;
  88. LLRect panel_rect;
  89. panel_rect = panel->getRect();
  90. reshape(panel_rect.getWidth(), panel_rect.getHeight());
  91. LLUI::positionViewNearMouse(this);
  92. }
  93. // virtual
  94. BOOL LLInspectToast::handleToolTip(S32 x, S32 y, MASK mask)
  95. {
  96. // We don't like the way LLInspect handles tooltips
  97. // (black tooltips look weird),
  98. // so force using the default implementation (STORM-511).
  99. return LLFloater::handleToolTip(x, y, mask);
  100. }
  101. void LLInspectToast::onToastDestroy(LLToast * toast)
  102. {
  103. closeFloater(false);
  104. }
  105. void LLNotificationsUI::registerFloater()
  106. {
  107. LLFloaterReg::add("inspect_toast", "inspect_toast.xml",
  108. &LLFloaterReg::build<LLInspectToast>);
  109. }