void LLRadioGroup::initFromParams(const Params& p)
{
	for (LLInitParam::ParamIterator<ItemParams>::const_iterator it = p.items.begin();
		it != p.items.end();
		++it)
	{
		LLRadioGroup::ItemParams item_params(*it);

		item_params.font.setIfNotProvided(mFont); // apply radio group font by default
		item_params.commit_callback.function = boost::bind(&LLRadioGroup::onClickButton, this, _1);
		item_params.from_xui = p.from_xui;
		if (p.from_xui)
		{
			applyXUILayout(item_params, this);
		}

		LLRadioCtrl* item = LLUICtrlFactory::create<LLRadioCtrl>(item_params, this);
		mRadioButtons.push_back(item);
	}

	// call this *after* setting up mRadioButtons so we can handle setValue() calls
	LLUICtrl::initFromParams(p);
}
LLPanelClothingListItem::LLPanelClothingListItem(LLViewerInventoryItem* item, const LLPanelClothingListItem::Params& params)
    : LLPanelDeletableWearableListItem(item, params)
{
    LLButton::Params button_params = params.up_btn;
    applyXUILayout(button_params, this);
    addChild(LLUICtrlFactory::create<LLButton>(button_params));

    button_params = params.down_btn;
    applyXUILayout(button_params, this);
    addChild(LLUICtrlFactory::create<LLButton>(button_params));

    LLPanel::Params panel_params = params.lock_panel;
    applyXUILayout(panel_params, this);
    LLPanel* lock_panelp = LLUICtrlFactory::create<LLPanel>(panel_params);
    addChild(lock_panelp);

    panel_params = params.edit_panel;
    applyXUILayout(panel_params, this);
    LLPanel* edit_panelp = LLUICtrlFactory::create<LLPanel>(panel_params);
    addChild(edit_panelp);

    if (lock_panelp)
    {
        LLIconCtrl::Params icon_params = params.lock_icon;
        applyXUILayout(icon_params, this);
        lock_panelp->addChild(LLUICtrlFactory::create<LLIconCtrl>(icon_params));
    }

    if (edit_panelp)
    {
        button_params = params.edit_btn;
        applyXUILayout(button_params, this);
        edit_panelp->addChild(LLUICtrlFactory::create<LLButton>(button_params));
    }

    setSeparatorVisible(false);
}
Beispiel #3
0
BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node)
{
	const LLPanel::Params& default_params(LLUICtrlFactory::getDefaultParams<LLPanel>());
	Params params(default_params);

	{
		LLFastTimer timer(FTM_PANEL_SETUP);

		LLXMLNodePtr referenced_xml;
		std::string xml_filename = mXMLFilename;
		
		// if the panel didn't provide a filename, check the node
		if (xml_filename.empty())
		{
			node->getAttributeString("filename", xml_filename);
			setXMLFilename(xml_filename);
		}

		if (!xml_filename.empty())
		{
			LLUICtrlFactory::instance().pushFileName(xml_filename);

			LLFastTimer timer(FTM_EXTERNAL_PANEL_LOAD);
			if (output_node)
			{
				//if we are exporting, we want to export the current xml
				//not the referenced xml
				LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());
				Params output_params(params);
				setupParamsForExport(output_params, parent);
				output_node->setName(node->getName()->mString);
				LLXUIParser::instance().writeXUI(
					output_node, output_params, &default_params);
				return TRUE;
			}
		
			if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
			{
				llwarns << "Couldn't parse panel from: " << xml_filename << llendl;

				return FALSE;
			}

			LLXUIParser::instance().readXUI(referenced_xml, params, LLUICtrlFactory::getInstance()->getCurFileName());

			// add children using dimensions from referenced xml for consistent layout
			setShape(params.rect);
			LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());

			LLUICtrlFactory::instance().popFileName();
		}

		// ask LLUICtrlFactory for filename, since xml_filename might be empty
		LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName());

		if (output_node)
		{
			Params output_params(params);
			setupParamsForExport(output_params, parent);
			output_node->setName(node->getName()->mString);
			LLXUIParser::instance().writeXUI(
				output_node, output_params, &default_params);
		}
		
		params.from_xui = true;
		applyXUILayout(params, parent);
		{
			LLFastTimer timer(FTM_PANEL_CONSTRUCTION);
			initFromParams(params);
		}

		// add children
		LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);

		// Connect to parent after children are built, because tab containers
		// do a reshape() on their child panels, which requires that the children
		// be built/added. JC
		if (parent)
		{
			S32 tab_group = params.tab_group.isProvided() ? params.tab_group() : parent->getLastTabGroup();
			parent->addChild(this, tab_group);
		}

		{
			LLFastTimer timer(FTM_PANEL_POSTBUILD);
			postBuild();
		}
	}
	return TRUE;
}