/indra/newview/llfloaterhandler.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 72 lines · 41 code · 7 blank · 24 comment · 9 complexity · f7d9876fa747c4525cdcca0fc399b06b MD5 · raw file

  1. /**
  2. * $LicenseInfo:firstyear=2008&license=viewerlgpl$
  3. * Second Life Viewer Source Code
  4. * Copyright (C) 2010, Linden Research, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation;
  9. * version 2.1 of the License only.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  21. * $/LicenseInfo$
  22. */
  23. #include "llviewerprecompiledheaders.h"
  24. #include "llfloaterhandler.h"
  25. #include "llfloater.h"
  26. #include "llmediactrl.h"
  27. // register with dispatch via global object
  28. LLFloaterHandler gFloaterHandler;
  29. LLFloater* get_parent_floater(LLView* view)
  30. {
  31. LLFloater* floater = NULL;
  32. LLView* parent = view->getParent();
  33. while (parent)
  34. {
  35. floater = dynamic_cast<LLFloater*>(parent);
  36. if (floater)
  37. {
  38. break;
  39. }
  40. parent = parent->getParent();
  41. }
  42. return floater;
  43. }
  44. bool LLFloaterHandler::handle(const LLSD &params, const LLSD &query_map, LLMediaCtrl *web)
  45. {
  46. if (params.size() < 2) return false;
  47. LLFloater* floater = NULL;
  48. // *TODO: implement floater lookup by name
  49. if (params[0].asString() == "self")
  50. {
  51. if (web)
  52. {
  53. floater = get_parent_floater(web);
  54. }
  55. }
  56. if (params[1].asString() == "close")
  57. {
  58. if (floater)
  59. {
  60. floater->closeFloater();
  61. return true;
  62. }
  63. }
  64. return false;
  65. }