/indra/newview/llfloaterhandler.cpp
C++ | 72 lines | 41 code | 7 blank | 24 comment | 9 complexity | f7d9876fa747c4525cdcca0fc399b06b MD5 | raw file
Possible License(s): LGPL-2.1
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 25#include "llfloaterhandler.h" 26 27#include "llfloater.h" 28#include "llmediactrl.h" 29 30// register with dispatch via global object 31LLFloaterHandler gFloaterHandler; 32 33 34LLFloater* get_parent_floater(LLView* view) 35{ 36 LLFloater* floater = NULL; 37 LLView* parent = view->getParent(); 38 while (parent) 39 { 40 floater = dynamic_cast<LLFloater*>(parent); 41 if (floater) 42 { 43 break; 44 } 45 parent = parent->getParent(); 46 } 47 return floater; 48} 49 50 51bool LLFloaterHandler::handle(const LLSD ¶ms, const LLSD &query_map, LLMediaCtrl *web) 52{ 53 if (params.size() < 2) return false; 54 LLFloater* floater = NULL; 55 // *TODO: implement floater lookup by name 56 if (params[0].asString() == "self") 57 { 58 if (web) 59 { 60 floater = get_parent_floater(web); 61 } 62 } 63 if (params[1].asString() == "close") 64 { 65 if (floater) 66 { 67 floater->closeFloater(); 68 return true; 69 } 70 } 71 return false; 72}