当前位置: 首页>>代码示例>>C++>>正文


C++ ListView::GetItems方法代码示例

本文整理汇总了C++中ListView::GetItems方法的典型用法代码示例。如果您正苦于以下问题:C++ ListView::GetItems方法的具体用法?C++ ListView::GetItems怎么用?C++ ListView::GetItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListView的用法示例。


在下文中一共展示了ListView::GetItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleHierarchyListSelectionChange

	void InGameEditor::HandleHierarchyListSelectionChange(StringHash eventType, VariantMap& eventData)
	{
		ListView* hierarchyList = hierarchyWindow_->GetHierarchyList();
		const PODVector<UIElement*>& items = hierarchyList->GetItems();
		const PODVector<unsigned>& indices = hierarchyList->GetSelections();

		editorData_->ClearSelection();

		for (unsigned int i = 0; i < indices.Size(); ++i)
		{
			unsigned int index = indices[i];
			UIElement* item = items[index];
			int type = item->GetVar(TYPE_VAR).GetInt();
			if (type == ITEM_COMPONENT)
			{
				Component* comp = GetListComponent(item);

				editorData_->AddSelectedComponent(comp);
			}
			else if (type == ITEM_NODE)
			{
				Node* node = GetListNode(item);

				editorData_->AddSelectedNode(node);
			}
			else if (type == ITEM_UI_ELEMENT)
			{
				UIElement* element = GetListUIElement(item);
				editorData_->AddSelectedUIElement(element);
			}
		}

		// If only one node/UIElement selected, use it for editing
		if (editorData_->GetNumSelectedNodes() == 1)
			editorData_->SetEditNode(editorData_->GetSelectedNodes()[0]);
		if (editorData_->GetNumSelectedUIElements() == 1)
			editorData_->SetEditUIElement(editorData_->GetSelectedUIElements()[0]);

		// If selection contains only components, and they have a common node, use it for editing
		if (editorData_->GetSelectedNodes().Empty() && !editorData_->GetSelectedComponents().Empty())
		{
			Node* commonNode = NULL;
			for (unsigned int i = 0; i < editorData_->GetNumSelectedComponents(); ++i)
			{
				if (i == 0)
					commonNode = editorData_->GetSelectedComponents()[i]->GetNode();
				else
				{
					if (editorData_->GetSelectedComponents()[i]->GetNode() != commonNode)
						commonNode = NULL;
				}
			}
			editorData_->SetEditNode(commonNode);
		}

		// Now check if the component(s) can be edited. If many selected, must have same type or have same edit node
		if (!editorData_->GetSelectedComponents().Empty())
		{
			if (editorData_->GetEditNode() == NULL)
			{
				StringHash compType = editorData_->GetSelectedComponents()[0]->GetType();
				bool sameType = true;
				for (unsigned int i = 1; i < editorData_->GetNumSelectedComponents(); ++i)
				{
					if (editorData_->GetSelectedComponents()[i]->GetType() != compType)
					{
						sameType = false;
						break;
					}
				}
				if (sameType)
					editorData_->SetEditComponents(editorData_->GetSelectedComponents());
			}
			else
			{
				editorData_->SetEditComponents(editorData_->GetSelectedComponents());
				editorData_->SetNumEditableComponentsPerNode(editorData_->GetNumSelectedComponents());
			}
		}

		// If just nodes selected, and no components, show as many matching components for editing as possible
		if (!editorData_->GetSelectedNodes().Empty() && editorData_->GetSelectedComponents().Empty() && editorData_->GetSelectedNodes()[0]->GetNumComponents() > 0)
		{
			unsigned int count = 0;
			for (unsigned int j = 0; j < editorData_->GetSelectedNodes()[0]->GetNumComponents(); ++j)
			{
				StringHash compType = editorData_->GetSelectedNodes()[0]->GetComponents()[j]->GetType();
				bool sameType = true;
				for (unsigned int i = 1; i < editorData_->GetNumSelectedNodes(); ++i)
				{
					if (editorData_->GetSelectedNodes()[i]->GetNumComponents() <= j || editorData_->GetSelectedNodes()[i]->GetComponents()[j]->GetType() != compType)
					{
						sameType = false;
						break;
					}
				}

				if (sameType)
				{
					++count;
//.........这里部分代码省略.........
开发者ID:PeaceSells50,项目名称:Urho3DIDE,代码行数:101,代码来源:InGameEditor.cpp


注:本文中的ListView::GetItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。