Esempio n. 1
0
HierarchyTreeControlNode* HierarchyTreeAggregatorNode::CreateChild(HierarchyTreeNode* parentNode, const QString& name)
{
	UIAggregatorControl* control = new UIAggregatorControl();
	control->CopyDataFrom(GetScreen());
	HierarchyTreeControlNode* controlNode = new HierarchyTreeAggregatorControlNode(this, parentNode, control, name);
	childs.insert(controlNode);
	UpdateChilds();
	return controlNode;
}
Esempio n. 2
0
bool HierarchyTreeAggregatorNode::Save(YamlNode* node, const QString& path, bool saveAll)
{
	String relPath = ResourcesManageHelper::GetResourceRelativePath(path, true).toStdString();
	for (CHILDS::iterator iter = childs.begin(); iter != childs.end(); ++iter)
	{
		HierarchyTreeControlNode* controlNode = (*iter);
		
		UIAggregatorControl* aggregatorControl = dynamic_cast<UIAggregatorControl*>(controlNode->GetUIObject());
		DVASSERT(aggregatorControl);
		if (!aggregatorControl)
			continue;
		aggregatorControl->SetAggregatorPath(relPath);
	}
	
	node->Set(WIDTH_NODE, (int32)rect.dx);
	node->Set(HEIGHT_NODE, (int32)rect.dy);
	return HierarchyTreeScreenNode::Save(path, saveAll);
}
Esempio n. 3
0
void HierarchyTreeAggregatorNode::ReplaceAggregator(HierarchyTreeControlNode *node)
{
	UIAggregatorControl* uiAggregator = dynamic_cast<UIAggregatorControl*>(node->GetUIObject());
	String path1;
	if (uiAggregator && uiAggregator->GetAggregatorPath().compare(path) == 0)
	{
		Logger::Debug(uiAggregator->GetAggregatorPath().c_str());
		HIERARCHYTREENODESLIST childs = node->GetChildNodes();
		uint32 i = 0;
		for (HIERARCHYTREENODESLIST::iterator iter = childs.begin(); iter != childs.end(); ++iter)
		{
			HierarchyTreeNode* childNode = (*iter);
			node->RemoveTreeNode(childNode, true, false);
			if (++i == GetScreen()->GetChildren().size())
				break;
		}
	
		HierarchyTreeAggregatorControlNode* controlNode = dynamic_cast<HierarchyTreeAggregatorControlNode*>(node);
		DVASSERT(controlNode);
		if (controlNode)
			controlNode->SetAggregatorNode(this);
		this->childs.insert(node);
		UpdateChilds();
	}
	
	const HierarchyTreeNode::HIERARCHYTREENODESLIST& child = node->GetChildNodes();
	for (HierarchyTreeNode::HIERARCHYTREENODESLIST::const_iterator iter = child.begin();
		 iter != child.end();
		 ++iter)
	{
		HierarchyTreeControlNode* node = dynamic_cast<HierarchyTreeControlNode*>(*iter);
		DVASSERT(node);
		if (!node)
			continue;
		
		ReplaceAggregator(node);
	}
}
	UIListCell *EditorListDelegate::CellAtIndex(UIList *forList, int32 index)
	{
    	// Try to get cell from the reusable cells store
    	UIListCell *cell = forList->GetReusableCell("Cell");
		if (!cell)
		{
			cell = new UIListCell(Rect(0.0f, 0.0f, cellSize.x, cellSize.y), "Cell");
		}
		else
		{
			cell->SetSize(Vector2(cellSize.x, cellSize.y));
			// Reset reusable cells relative positions - new proper positions will be calculated at UIList::AddCellAtPost() method
			cell->SetPosition(Vector2(0.0f, 0.0f));
		}
	
		cell->RemoveAllControls();
		// Get aggregator control
		UIControl *aggregatorControl = GetCurrentAggregatorControl();
		if (aggregatorControl)
		{
			UIAggregatorControl* control = new UIAggregatorControl();
			control->CopyDataFrom(aggregatorControl);
			// DF-1770 - Reset aggregator's background draw type
			control->GetBackground()->SetDrawType(UIControlBackground::DRAW_ALIGNED);
			cell->AddControl(control);
            SafeRelease(control);
		}
		else
		{			
			cell->SetStateFont(UIControl::STATE_NORMAL, EditorFontManager::Instance()->GetDefaultFont());
			cell->SetStateText(UIControl::STATE_NORMAL, StringToWString(Format("Cell %d",index)));
			cell->SetSelected(true);
		}
   
    	return cell;
	}
Esempio n. 5
0
void HierarchyTreeAggregatorNode::UpdateChilds()
{
	for (CHILDS::iterator iter = childs.begin(); iter != childs.end(); ++iter)
	{
		HierarchyTreeControlNode* controlNode = (*iter);
		
		UIAggregatorControl* aggregatorControl = dynamic_cast<UIAggregatorControl*>(controlNode->GetUIObject());
		DVASSERT(aggregatorControl);
		if (!aggregatorControl)
			continue;
		
		// Remove any child controls of UIControl to prevent appearance of deleted
		// child in case when screen child is aggregator.
		/*List<UIControl*> aggregatorChilds = aggregatorControl->GetChildren();
		int size = GetScreen()->GetChildren().size();
		for (List<UIControl*>::iterator iter = aggregatorChilds.begin(); iter != aggregatorChilds.end();)
		{
			if (--size < 0)
				break;
			UIControl* child = (*iter);
			++iter;
			aggregatorControl->RemoveControl(child);
		}*/

		aggregatorControl->RemoveAllControls();
		
		const List<UIControl*> & childsList = screen->GetChildren();
		UIControl* belowControl = NULL;
		List<UIControl*>::const_iterator belowIter = aggregatorControl->GetChildren().begin();
		if (belowIter != aggregatorControl->GetChildren().end())
			belowControl = (*belowIter);
		for (List<UIControl*>::const_iterator iter = childsList.begin(); iter != childsList.end(); ++iter)
		{
			UIControl* control = (*iter);
			UIControl* newControl = control->Clone();
			aggregatorControl->InsertChildBelow(newControl, belowControl);
			aggregatorControl->AddAggregatorChild(newControl);
		}
		//aggregatorControl->SetSize(screen->GetSize()); TODO:// update child size 
		aggregatorControl->SetRect(aggregatorControl->GetRect());	//update childs size and position
	}
}
UIControl* UIAggregatorControl::Clone()
{
	UIAggregatorControl* c = new UIAggregatorControl(Rect(relativePosition.x, relativePosition.y, size.x, size.y));
	c->CopyDataFrom(this);
	return c;
}