LayerItem 渲染attachNode 的作用

LayerItem

其成员变量:

	private:
		// render to which Layer
		// Here just record the Layer's reference
		ILayer* mLayer;
		// Layer nodes 
		ILayerNode * mLayerNode;
		ILayerNode * mSaveLayerNode;

		typedef std::vector<LayerItem*> VectorLayerItem;
		// It's own layerItem for render
		VectorLayerItem mLayerItems;
		// It's sub layerItem for records
		VectorLayerItem mLayerNodes;

		// record the sub widget
		VectorSubWidget mDrawItems;

		ITexture* mTexture;

有趣的是 SubWidget终于出现了。 

其虚函数 虚函数都被实现了,想是实现默认的,然后又子类进行修改 :

		virtual void attachItemToNode(ILayer* _layer, ILayerNode* _node);
		virtual void detachFromLayer();
		virtual void upLayerItem();
分析 attacheLayerNode

	void LayerItem::attachToLayerItemNode(ILayerNode* _item, bool _deep)
	{
		MYGUI_DEBUG_ASSERT(nullptr != _item, "attached item must be valid");

		// Initialise the mLayerNode member value
		mLayerNode = _item;
		// The subwidget has been assigned to mDrawItems
		for (VectorSubWidget::iterator skin = mDrawItems.begin(); skin != mDrawItems.end(); ++skin)
		{
			(*skin)->createDrawItem(mTexture, _item);
		}

		for (VectorLayerItem::iterator item = mLayerItems.begin(); item != mLayerItems.end(); ++item)
		{
			(*item)->attachToLayerItemNode(_item, _deep);
		}

		for (VectorLayerItem::iterator item = mLayerNodes.begin(); item != mLayerNodes.end(); ++item)
		{
			// deep copy to the LayerNode
			if (_deep)
			{
				ILayerNode* child_node = _item->createChildItemNode();
				(*item)->attachToLayerItemNode(child_node, _deep);
			}
		}
	}

谁是根节点?    

ILayerNode

(*skin)->createDrawItem(mTexture, _item); 跳转SubWedget

至此建立起ISubWedget与Widget的关系


你可能感兴趣的:(LayerItem 渲染attachNode 的作用)