summaryrefslogtreecommitdiff
path: root/indra/llui/lluictrlfactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lluictrlfactory.cpp')
-rw-r--r--indra/llui/lluictrlfactory.cpp258
1 files changed, 30 insertions, 228 deletions
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index a46d961709..5de96f9d48 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -2,31 +2,25 @@
* @file lluictrlfactory.cpp
* @brief Factory class for creating UI controls
*
- * $LicenseInfo:firstyear=2003&license=viewergpl$
- *
- * Copyright (c) 2003-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2003&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -48,7 +42,7 @@
#include "llquaternion.h"
// this library includes
-#include "llfloater.h"
+#include "llpanel.h"
LLFastTimer::DeclareTimer FTM_WIDGET_CONSTRUCTION("Widget Construction");
LLFastTimer::DeclareTimer FTM_INIT_FROM_PARAMS("Widget InitFromParams");
@@ -99,10 +93,12 @@ void LLUICtrlFactory::loadWidgetTemplate(const std::string& widget_tag, LLInitPa
std::string filename = std::string("widgets") + gDirUtilp->getDirDelimiter() + widget_tag + ".xml";
LLXMLNodePtr root_node;
- if (LLUICtrlFactory::getLayeredXMLNode(filename, root_node))
+ std::string full_filename = gDirUtilp->findSkinnedFilename(LLUI::getXUIPaths().front(), filename);
+ if (!full_filename.empty())
{
- LLUICtrlFactory::instance().pushFileName(filename);
- LLXUIParser::instance().readXUI(root_node, block, filename);
+ LLUICtrlFactory::instance().pushFileName(full_filename);
+ LLSimpleXUIParser parser;
+ parser.readXUI(full_filename, block);
LLUICtrlFactory::instance().popFileName();
}
}
@@ -177,70 +173,6 @@ bool LLUICtrlFactory::getLocalizedXMLNode(const std::string &xui_filename, LLXML
}
}
-static LLFastTimer::DeclareTimer FTM_BUILD_FLOATERS("Build Floaters");
-
-//-----------------------------------------------------------------------------
-// buildFloater()
-//-----------------------------------------------------------------------------
-bool LLUICtrlFactory::buildFloater(LLFloater* floaterp, const std::string& filename, LLXMLNodePtr output_node)
-{
- LLFastTimer timer(FTM_BUILD_FLOATERS);
- LLXMLNodePtr root;
-
- //if exporting, only load the language being exported,
- //instead of layering localized version on top of english
- if (output_node)
- {
- if (!LLUICtrlFactory::getLocalizedXMLNode(filename, root))
- {
- llwarns << "Couldn't parse floater from: " << LLUI::getLocalizedSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl;
- return false;
- }
- }
- else if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
- {
- llwarns << "Couldn't parse floater from: " << LLUI::getSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl;
- return false;
- }
-
- // root must be called floater
- if( !(root->hasName("floater") || root->hasName("multi_floater")) )
- {
- llwarns << "Root node should be named floater in: " << filename << llendl;
- return false;
- }
-
- bool res = true;
-
- lldebugs << "Building floater " << filename << llendl;
- pushFileName(filename);
- {
- if (!floaterp->getFactoryMap().empty())
- {
- mFactoryStack.push_front(&floaterp->getFactoryMap());
- }
-
- // for local registry callbacks; define in constructor, referenced in XUI or postBuild
- floaterp->getCommitCallbackRegistrar().pushScope();
- floaterp->getEnableCallbackRegistrar().pushScope();
-
- res = floaterp->initFloaterXML(root, floaterp->getParent(), filename, output_node);
-
- floaterp->setXMLFilename(filename);
-
- floaterp->getCommitCallbackRegistrar().popScope();
- floaterp->getEnableCallbackRegistrar().popScope();
-
- if (!floaterp->getFactoryMap().empty())
- {
- mFactoryStack.pop_front();
- }
- }
- popFileName();
-
- return res;
-}
-
//-----------------------------------------------------------------------------
// saveToXML()
//-----------------------------------------------------------------------------
@@ -249,69 +181,6 @@ S32 LLUICtrlFactory::saveToXML(LLView* viewp, const std::string& filename)
return 0;
}
-static LLFastTimer::DeclareTimer FTM_BUILD_PANELS("Build Panels");
-
-//-----------------------------------------------------------------------------
-// buildPanel()
-//-----------------------------------------------------------------------------
-BOOL LLUICtrlFactory::buildPanel(LLPanel* panelp, const std::string& filename, LLXMLNodePtr output_node)
-{
- LLFastTimer timer(FTM_BUILD_PANELS);
- BOOL didPost = FALSE;
- LLXMLNodePtr root;
-
- //if exporting, only load the language being exported,
- //instead of layering localized version on top of english
- if (output_node)
- {
- if (!LLUICtrlFactory::getLocalizedXMLNode(filename, root))
- {
- llwarns << "Couldn't parse panel from: " << LLUI::getLocalizedSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl;
- return didPost;
- }
- }
- else if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
- {
- llwarns << "Couldn't parse panel from: " << LLUI::getSkinPath() + gDirUtilp->getDirDelimiter() + filename << llendl;
- return didPost;
- }
-
- // root must be called panel
- if( !root->hasName("panel" ) )
- {
- llwarns << "Root node should be named panel in : " << filename << llendl;
- return didPost;
- }
-
- lldebugs << "Building panel " << filename << llendl;
-
- pushFileName(filename);
- {
- if (!panelp->getFactoryMap().empty())
- {
- mFactoryStack.push_front(&panelp->getFactoryMap());
- }
-
- // for local registry callbacks; define in constructor, referenced in XUI or postBuild
- panelp->getCommitCallbackRegistrar().pushScope();
- panelp->getEnableCallbackRegistrar().pushScope();
-
- didPost = panelp->initPanelXML(root, NULL, output_node);
-
- panelp->getCommitCallbackRegistrar().popScope();
- panelp->getEnableCallbackRegistrar().popScope();
-
- panelp->setXMLFilename(filename);
-
- if (!panelp->getFactoryMap().empty())
- {
- mFactoryStack.pop_front();
- }
- }
- popFileName();
- return didPost;
-}
-
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -343,29 +212,6 @@ LLView *LLUICtrlFactory::createFromXML(LLXMLNodePtr node, LLView* parent, const
return view;
}
-//-----------------------------------------------------------------------------
-// createFactoryPanel()
-//-----------------------------------------------------------------------------
-LLPanel* LLUICtrlFactory::createFactoryPanel(const std::string& name)
-{
- std::deque<const LLCallbackMap::map_t*>::iterator itor;
- for (itor = mFactoryStack.begin(); itor != mFactoryStack.end(); ++itor)
- {
- const LLCallbackMap::map_t* factory_map = *itor;
-
- // Look up this panel's name in the map.
- LLCallbackMap::map_const_iter_t iter = factory_map->find( name );
- if (iter != factory_map->end())
- {
- // Use the factory to create the panel, instead of using a default LLPanel.
- LLPanel *ret = (LLPanel*) iter->second.mCallback( iter->second.mData );
- return ret;
- }
- }
- LLPanel::Params panel_p;
- return create<LLPanel>(panel_p);
-}
-
std::string LLUICtrlFactory::getCurFileName()
{
return mFileNames.empty() ? "" : gDirUtilp->getWorkingDir() + gDirUtilp->getDirDelimiter() + mFileNames.back();
@@ -382,36 +228,6 @@ void LLUICtrlFactory::popFileName()
mFileNames.pop_back();
}
-
-//-----------------------------------------------------------------------------
-
-//static
-BOOL LLUICtrlFactory::getAttributeColor(LLXMLNodePtr node, const std::string& name, LLColor4& color)
-{
- std::string colorstring;
- BOOL res = node->getAttributeString(name.c_str(), colorstring);
- if (res)
- {
- if (LLUIColorTable::instance().colorExists(colorstring))
- {
- color.setVec(LLUIColorTable::instance().getColor(colorstring));
- }
- else
- {
- res = FALSE;
- }
- }
- if (!res)
- {
- res = LLColor4::parseColor(colorstring, &color);
- }
- if (!res)
- {
- res = node->getAttributeColor(name.c_str(), color);
- }
- return res;
-}
-
//static
void LLUICtrlFactory::setCtrlParent(LLView* view, LLView* parent, S32 tab_group)
{
@@ -427,28 +243,22 @@ std::string LLUICtrlFactory::findSkinnedFilename(const std::string& filename)
return gDirUtilp->findSkinnedFilename(LLUI::getSkinPath(), filename);
}
-void LLUICtrlFactory::pushFactoryFunctions(const LLCallbackMap::map_t* map)
-{
- mFactoryStack.push_back(map);
-}
-
-void LLUICtrlFactory::popFactoryFunctions()
-{
- if (!mFactoryStack.empty())
- {
- mFactoryStack.pop_back();
- }
-}
-
//static
void LLUICtrlFactory::copyName(LLXMLNodePtr src, LLXMLNodePtr dest)
{
dest->setName(src->getName()->mString);
}
+template<typename T>
+const LLInitParam::BaseBlock& get_empty_param_block()
+{
+ static typename T::Params params;
+ return params;
+}
+
// adds a widget and its param block to various registries
//static
-void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const std::type_info* param_block_type, dummy_widget_creator_func_t creator_func, const std::string& tag)
+void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const std::type_info* param_block_type, const std::string& tag)
{
// associate parameter block type with template .xml file
std::string* existing_tag = LLWidgetNameRegistry::instance().getValue(param_block_type);
@@ -468,17 +278,9 @@ void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const st
}
}
LLWidgetNameRegistry::instance().defaultRegistrar().add(param_block_type, tag);
- // associate widget type with factory function
- LLDefaultWidgetRegistry::instance().defaultRegistrar().add(widget_type, creator_func);
//FIXME: comment this in when working on schema generation
//LLWidgetTypeRegistry::instance().defaultRegistrar().add(tag, widget_type);
- //LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type, &getEmptyParamBlock<T>);
-}
-
-//static
-dummy_widget_creator_func_t* LLUICtrlFactory::getDefaultWidgetFunc(const std::type_info* widget_type)
-{
- return LLDefaultWidgetRegistry::instance().getValue(widget_type);
+ //LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type, &get_empty_param_block<T>);
}
//static