PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llfloatersidepanelcontainer.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 111 lines | 64 code | 18 blank | 29 comment | 8 complexity | 5684b2ec7639ecb921eaa6b49aa6d704 MD5 | raw file
  1/** 
  2 * @file llfloatersidepanelcontainer.cpp
  3 * @brief LLFloaterSidePanelContainer class definition
  4 *
  5 * $LicenseInfo:firstyear=2011&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2011, 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"
 28
 29#include "llfloaterreg.h"
 30#include "llfloatersidepanelcontainer.h"
 31
 32// newview includes
 33#include "llsidetraypanelcontainer.h"
 34#include "lltransientfloatermgr.h"
 35
 36//static
 37const std::string LLFloaterSidePanelContainer::sMainPanelName("main_panel");
 38
 39LLFloaterSidePanelContainer::LLFloaterSidePanelContainer(const LLSD& key, const Params& params)
 40:	LLFloater(key, params)
 41{
 42	// Prevent transient floaters (e.g. IM windows) from hiding
 43	// when this floater is clicked.
 44	LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::GLOBAL, this);
 45}
 46
 47LLFloaterSidePanelContainer::~LLFloaterSidePanelContainer()
 48{
 49	LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::GLOBAL, this);
 50}
 51
 52void LLFloaterSidePanelContainer::onOpen(const LLSD& key)
 53{
 54	getChild<LLPanel>(sMainPanelName)->onOpen(key);
 55}
 56
 57LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_name, const LLSD& params)
 58{
 59	LLView* view = findChildView(panel_name, true);
 60	if (!view) return NULL;
 61
 62	openFloater();
 63
 64	LLPanel* panel = NULL;
 65
 66	LLSideTrayPanelContainer* container = dynamic_cast<LLSideTrayPanelContainer*>(view->getParent());
 67	if (container)
 68	{
 69		LLSD new_params = params;
 70		new_params[LLSideTrayPanelContainer::PARAM_SUB_PANEL_NAME] = panel_name;
 71		container->onOpen(new_params);
 72
 73		panel = container->getCurrentPanel();
 74	}
 75	else if ((panel = dynamic_cast<LLPanel*>(view)) != NULL)
 76	{
 77		panel->onOpen(params);
 78	}
 79
 80	return panel;
 81}
 82
 83void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const LLSD& key)
 84{
 85	LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name);
 86	if (floaterp)
 87	{
 88		floaterp->openChildPanel(sMainPanelName, key);
 89	}
 90}
 91
 92void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key)
 93{
 94	LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name);
 95	if (floaterp)
 96	{
 97		floaterp->openChildPanel(panel_name, key);
 98	}
 99}
100
101LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, const std::string& panel_name)
102{
103	LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name);
104
105	if (floaterp)
106	{
107		return floaterp->findChild<LLPanel>(panel_name, true);
108	}
109
110	return NULL;
111}