PageRenderTime 49ms CodeModel.GetById 17ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 1ms

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