/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. #include "llviewerprecompiledheaders.h"
  27. #include "llfloaterreg.h"
  28. #include "llfloatersidepanelcontainer.h"
  29. // newview includes
  30. #include "llsidetraypanelcontainer.h"
  31. #include "lltransientfloatermgr.h"
  32. //static
  33. const std::string LLFloaterSidePanelContainer::sMainPanelName("main_panel");
  34. LLFloaterSidePanelContainer::LLFloaterSidePanelContainer(const LLSD& key, const Params& params)
  35. : LLFloater(key, params)
  36. {
  37. // Prevent transient floaters (e.g. IM windows) from hiding
  38. // when this floater is clicked.
  39. LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::GLOBAL, this);
  40. }
  41. LLFloaterSidePanelContainer::~LLFloaterSidePanelContainer()
  42. {
  43. LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::GLOBAL, this);
  44. }
  45. void LLFloaterSidePanelContainer::onOpen(const LLSD& key)
  46. {
  47. getChild<LLPanel>(sMainPanelName)->onOpen(key);
  48. }
  49. LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_name, const LLSD& params)
  50. {
  51. LLView* view = findChildView(panel_name, true);
  52. if (!view) return NULL;
  53. openFloater();
  54. LLPanel* panel = NULL;
  55. LLSideTrayPanelContainer* container = dynamic_cast<LLSideTrayPanelContainer*>(view->getParent());
  56. if (container)
  57. {
  58. LLSD new_params = params;
  59. new_params[LLSideTrayPanelContainer::PARAM_SUB_PANEL_NAME] = panel_name;
  60. container->onOpen(new_params);
  61. panel = container->getCurrentPanel();
  62. }
  63. else if ((panel = dynamic_cast<LLPanel*>(view)) != NULL)
  64. {
  65. panel->onOpen(params);
  66. }
  67. return panel;
  68. }
  69. void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const LLSD& key)
  70. {
  71. LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name);
  72. if (floaterp)
  73. {
  74. floaterp->openChildPanel(sMainPanelName, key);
  75. }
  76. }
  77. void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key)
  78. {
  79. LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name);
  80. if (floaterp)
  81. {
  82. floaterp->openChildPanel(panel_name, key);
  83. }
  84. }
  85. LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, const std::string& panel_name)
  86. {
  87. LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name);
  88. if (floaterp)
  89. {
  90. return floaterp->findChild<LLPanel>(panel_name, true);
  91. }
  92. return NULL;
  93. }