コード例 #1
0
ファイル: uiviewfactory.cpp プロジェクト: agangzz/vstgui
//-----------------------------------------------------------------------------
void UIViewFactory::evaluateAttributesAndRemember (CView* view, const UIAttributes& attributes, UIAttributes& evaluatedAttributes, const IUIDescription* description) const
{
	std::string evaluatedValue;
	typedef std::pair<std::string, std::string> StringPair;
	VSTGUI_RANGE_BASED_FOR_LOOP (UIAttributesMap, attributes, StringPair, attr)
		const std::string& value = attr.second;
		if (description && description->getVariable (value.c_str (), evaluatedValue))
		{
		#if VSTGUI_LIVE_EDITING
			rememberAttribute (view, attr.first.c_str (), value.c_str ());
		#endif
			evaluatedAttributes.setAttribute (attr.first, evaluatedValue);
		}
		else
		{
		#if VSTGUI_LIVE_EDITING
			IViewCreator::AttrType type = getAttributeType (view, attr.first);
			switch (type)
			{
				case IViewCreator::kColorType:
				case IViewCreator::kTagType:
				case IViewCreator::kFontType:
				case IViewCreator::kGradientType:
					rememberAttribute (view, attr.first.c_str (), value.c_str ());
					break;
				default:
					break;
			}
		#endif
			evaluatedAttributes.setAttribute (attr.first, value);
		}
	VSTGUI_RANGE_BASED_FOR_LOOP_END
}
コード例 #2
0
ファイル: sync.cpp プロジェクト: sporst/Pythia
/**
* Synchronizes the properties of a DFM tree with elements of a VMT tree.
**/
void synchronizeProperties(DFMResource* dfm, const std::string& classname, DFMProperty& property, const VMTDir& vmtdir, const DFMData& dfmres)
{
	while (dfm && dfm->parent) dfm = dfm->parent;
	
	// Order is important.
	synchronizePropertyValue(*dfm->classname, property.value, vmtdir, dfmres);
	synchronizePropertyValue(classname, property.name, vmtdir, dfmres);

	for (unsigned int i=0;i<property.values.size();++i)
	{
		if (property.values[i].name.size() == 0) continue;
		
		VMT* vmt = handleCollections(find<FindByName>(vmtdir, classname), vmtdir);
		if (!vmt) continue;
		std::string* x = getAttributeType(vmt, *property.name.front(), vmtdir);
		if (!x) continue;
		vmt = find<FindByName>(vmtdir, *x);
		if (!vmt) continue;
		synchronizeProperties(dfm, *vmt->name, property.values[i], vmtdir, dfmres);
	}
}
コード例 #3
0
ファイル: sync.cpp プロジェクト: sporst/Pythia
/**
* Synchronizes one element of a DFM tree with an element of a VMT tree.
* @param classname Class of the element the property belongs to.
* @param value Name of value of a property.
* @param vmtdir VMT tree.
* @param dfmres DFM tree.
**/
void synchronizePropertyValue(const std::string& classname, std::vector<std::string*>& value, const VMTDir& vmtdir, const DFMData& dfmres)
{
	splitName(value);
	
	VMT* vmt = handleCollections(find<FindByName>(vmtdir, classname), vmtdir);
	if (!vmt) return;

	for (unsigned int i=0;i<value.size();++i)
	{
		if (!value[i]->size()) continue;
		
		VMT* vmt2;
		if (vmt2 = findVMT<FindByPropertyName>(vmt, *value[i]))
		{
			std::string* y = getVMTAttribute(vmt2->typeinfo, *value[i]);
			if (!y) break;
			delete value[i];
			value[i] = y;

			std::string* x = getAttributeType(vmt2, *value[i], vmtdir);
			if (!x) break;

			// Special handling. Figure out a better way.
			if (*x == "TCustomActionBarColorMap")
			{
				x = new std::string("TXPColorMap");
			}

			vmt2 = find<FindByName>(vmtdir, *x);
			if (!vmt2) break;
		}
		else if (vmt2 = findVMT<FindByMethodName>(vmt, *value[i]))
		{
			std::string* x = getValue(vmt2->methods, *value[i], true);
			delete value[i];
			value[i] = x;
		}
		else if (vmt2 = findVMT<FindByFieldName>(vmt, *value[i]))
		{
			std::string* x = getValue(vmt2->fields, *value[i]);
			delete value[i];
			value[i] = x;
		}
		else if (DFMResource* res = find<FindByName>(dfmres, *value[i]))
		{
			delete value[i];
			value[i] = res->name;
			vmt2 = find<FindByName>(vmtdir, *res->classname);
		}
		else if (vmt2 = find<FindByName>(vmtdir, *value[i]))
		{
			// This last if-branch is required for bitmaps.
			// value[i] should be TBitmap or TIcon here.
			delete value[i];
			value[i] = vmt2->name;
		}
		else
		{
//			std::cout << "Couldn't find " << *value[i] << std::endl;
		}
		
		vmt = vmt2;
		
		if (!vmt) break;
	}
}