Example #1
0
void HierarchyTreeAggregatorNode::UpdateHierarchyTree()
{
	const HierarchyTreeNode::HIERARCHYTREENODESLIST& child = parent->GetChildNodes();
	for (HierarchyTreeNode::HIERARCHYTREENODESLIST::const_iterator iter = child.begin();
		 iter != child.end();
		 ++iter)
	{
		HierarchyTreeScreenNode* node = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
		DVASSERT(node);
		if (!node)
			continue;
		
		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);
		}
	}
}
bool HierarchyTreePlatformNode::Load(YamlNode* platform)
{
	YamlNode* width = platform->Get(WIDTH_NODE);
	YamlNode* height = platform->Get(HEIGHT_NODE);
	if (!width || !height)
		return false;
	
	bool result = true;
	SetSize(width->AsInt(), height->AsInt());
	ActivatePlatform();
	
	YamlNode* screens = platform->Get(SCREENS_NODE);
	if (screens)
	{
		for (int i = 0; i < screens->GetCount(); i++)
		{
			YamlNode* screen = screens->Get(i);
			if (!screen)
				continue;
			String screenName = screen->AsString();
			
			QString screenPath = QString(SCREEN_PATH).arg(GetResourceFolder()).arg(QString::fromStdString(screenName));
			HierarchyTreeScreenNode* screenNode = new HierarchyTreeScreenNode(this, QString::fromStdString(screenName));
			result &= screenNode->Load(screenPath);
			AddTreeNode(screenNode);
		}
	}
	return result;
}
void ScreenMetadata::SetName(const QString& name)
{
    HierarchyTreeScreenNode* screenNode = GetScreenNode();
    if (screenNode)
    {
        screenNode->SetName(name);
    }
}
Example #4
0
void HierarchyTreeWidget::on_treeWidget_itemSelectionChanged()
{
	QTreeWidgetItem* selectedItem = ui->treeWidget->currentItem();
	if (!selectedItem)
	{
		return;
	}

	if (internalSelectionChanged)
	{
		return;
	}

	QVariant data = selectedItem->data(ITEM_ID);
	HierarchyTreeNode::HIERARCHYTREENODEID id = data.toInt();
	HierarchyTreeNode* baseNode = HierarchyTreeController::Instance()->GetTree().GetNode(id);
	HierarchyTreePlatformNode* selectedPlatform = dynamic_cast<HierarchyTreePlatformNode* >(baseNode);
	HierarchyTreeScreenNode* selectedScreen =  dynamic_cast<HierarchyTreeScreenNode* >(baseNode);
	HierarchyTreeControlNode* selectedControl = dynamic_cast<HierarchyTreeControlNode* >(baseNode);
	
	if (!selectedPlatform && !selectedScreen && !selectedControl)
		return;
	
	internalSelectionChanged = true;
	
	//only platform or screen node can be seleted
	if (selectedPlatform || selectedScreen)
	{
		ResetSelection();
		HierarchyTreeController::Instance()->ResetSelectedControl();
		selectedItem->setSelected(true);
	}
	
	if (selectedControl)
	{
		selectedScreen = selectedControl->GetScreenNode();
		selectedPlatform = selectedScreen->GetPlatform();
	}
	else if (selectedScreen)
	{
		selectedPlatform = selectedScreen->GetPlatform();
	}
		
	HierarchyTreeController::Instance()->UpdateSelection(selectedPlatform, selectedScreen);
	HierarchyTreeController::Instance()->UpdateSelection(baseNode);
	
	internalSelectionChanged = false;
	
	if (selectedControl)
	{
		if (ui->treeWidget->selectedItems().size() == 1)
			HierarchyTreeController::Instance()->ResetSelectedControl();
		HierarchyTreeController::Instance()->SelectControl(selectedControl);
	}
}
Example #5
0
HierarchyTreeScreenNode* HierarchyTreeController::AddScreen(const QString& name, HierarchyTreeNode::HIERARCHYTREENODEID platform)
{
	HierarchyTreeScreenNode* screenNode = hierarchyTree.AddScreen(name, platform);
	if (screenNode)
	{
		UpdateSelection(screenNode->GetPlatform(), screenNode);
		EmitHierarchyTreeUpdated();
	}
	
	return screenNode;
}
void HierarchyTreePlatformNode::SetSize(int width, int height)
{
	this->width = width;
	this->height = height;
	
	for (HIERARCHYTREENODESLIST::iterator iter = childNodes.begin(); iter != childNodes.end(); ++iter)
	{
		HierarchyTreeNode* node = (*iter);
		HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(node);
		if (screenNode)
		{
			screenNode->GetScreen()->SetRect(Rect(0, 0, width, height));
		}
	}
}
void DeleteSelectedNodeCommand::StoreParentsOfRemovingAggregatorControls(const HierarchyTreeNode::HIERARCHYTREENODESLIST& nodes)
{
	HierarchyTreeNode::HIERARCHYTREENODESCONSTITER it;
	for (it = nodes.begin(); it != nodes.end(); ++it)
	{
		if (!dynamic_cast<HierarchyTreeAggregatorNode*>(*it))
		{
			HierarchyTreeScreenNode* screen = HierarchyTreeController::Instance()->GetScreenNodeForNode(*it);

			if (screen)
			{
				parentsOfRemovingAggregatorControls.insert(screen->GetId());
			}
		}
	}
}
void HierarchyTreeControlNode::SetParent(HierarchyTreeNode* node, HierarchyTreeNode* insertAfter)
{
	if (this == insertAfter)
		return;
	
	if (parent)
		parent->RemoveTreeNode(this, false, false);
	
	HierarchyTreeControlNode* newParentControl = dynamic_cast<HierarchyTreeControlNode* >(node);
	HierarchyTreeScreenNode* newParentScreen = dynamic_cast<HierarchyTreeScreenNode* >(node);
	DVASSERT(newParentControl || newParentScreen);
	if (!newParentControl && !newParentScreen)
		return;

	UIControl* afterControl = NULL;
	HierarchyTreeControlNode* insertAfterControl = dynamic_cast<HierarchyTreeControlNode* >(insertAfter);
	if (insertAfterControl)
		afterControl = insertAfterControl->GetUIObject();
	
	UIControl* newParentUI = NULL;
	if (newParentControl)
		newParentUI = newParentControl->GetUIObject();
	else if (newParentScreen)
		newParentUI = newParentScreen->GetScreen();
	
	node->AddTreeNode(this, insertAfter);
	if (newParentUI && uiObject)
	{
		if (insertAfter != node)
		{
			newParentUI->InsertChildAbove(uiObject, afterControl);
		}
		else
		{
			UIControl* belowControl = NULL;
			const List<UIControl*> & controls = newParentUI->GetChildren();
			if (controls.size())
			{
				belowControl = *controls.begin();
			}
			newParentUI->InsertChildBelow(uiObject, belowControl);
		}
	}
	
	parent = node;
}
bool HierarchyTreePlatformNode::Save(YamlNode* node)
{
	YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP);
	platform->Set(WIDTH_NODE, GetWidth());
	platform->Set(HEIGHT_NODE, GetHeight());

	Map<String, YamlNode*> &platformsMap = node->AsMap();
	platformsMap[GetName().toStdString()] = platform;
	ActivatePlatform();
	
	Map<String, YamlNode*> &platformMap = platform->AsMap();
	YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY);
	platformMap[SCREENS_NODE] = screens;

    // Add the Localization info - specific for each Platform.
    SaveLocalization(platform);

	QString projectFolder = GetResourceFolder();
	projectFolder += "UI";
	QDir dir;
	dir.mkpath(projectFolder);
	
	bool result = true;
	for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
		 iter != GetChildNodes().end();
		 ++iter)
	{
		HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
		if (!screenNode)
			continue;
		
		QString screenPath = QString(SCREEN_PATH).arg(GetResourceFolder()).arg(screenNode->GetName());
		result &= screenNode->Save(screenPath);
		
		screens->AddValueToArray(screenNode->GetName().toStdString());
	}
	return result;
}
Example #10
0
void HierarchyTreeController::DeleteNodesFiles(const HierarchyTreeNode::HIERARCHYTREENODESLIST &nodes)
{
	HierarchyTreeNode::HIERARCHYTREENODESLIST::const_iterator iter;
	for (iter = nodes.begin(); iter != nodes.end(); ++iter)
	{
		HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
		HierarchyTreePlatformNode* platformNode = dynamic_cast<HierarchyTreePlatformNode*>(*iter);

		if (screenNode)
		{
			screenNode->SetMarked(true);
			QString path = screenNode->GetPlatform()->GetScreenPath(screenNode->GetName());
			FileSystem::Instance()->DeleteFile(path.toStdString());
		}

		if (platformNode)
		{
			platformNode->SetMarked(true);
			platformNode->SetChildrenMarked(true);
			FileSystem::Instance()->DeleteDirectory(platformNode->GetPlatformFolder(), true);
		}
	}
}
void HierarchyTreeControlNode::AddControlToParent()
{
	if (!parent)
		return;
	
	DVASSERT(uiObject);
	
	HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(parent);
	if (screenNode)
	{
		screenNode->GetScreen()->AddControl(this->uiObject);
	}
	else
	{
		//HierarchyTreeControlNode* controlNode = GetControlNode();
		HierarchyTreeControlNode* controlNode = dynamic_cast<HierarchyTreeControlNode*>(parent);
		if (controlNode)
		{
			UIControl* control = controlNode->GetUIObject();
			if (control)
				control->AddControl(this->uiObject);
		}
	}	
}
Example #12
0
bool HierarchyTreePlatformNode::Save(YamlNode* node, bool saveAll)
{
	YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP);
	platform->Set(WIDTH_NODE, GetWidth());
	platform->Set(HEIGHT_NODE, GetHeight());

	MultiMap<String, YamlNode*> &platformsMap = node->AsMap();
	platformsMap.erase(GetName().toStdString());
	platformsMap.insert(std::pair<String, YamlNode*>(GetName().toStdString(), platform));
	ActivatePlatform();
	
	MultiMap<String, YamlNode*> &platformMap = platform->AsMap();
	YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY);
	platformMap.erase(SCREENS_NODE);
	platformMap.insert(std::pair<String, YamlNode*>(SCREENS_NODE, screens));
	
	YamlNode* aggregators = new YamlNode(YamlNode::TYPE_MAP);
	platformMap.erase(AGGREGATORS_NODE);
	platformMap.insert(std::pair<String, YamlNode*>(AGGREGATORS_NODE, aggregators));

    // Add the Localization info - specific for each Platform.
    SaveLocalization(platform);

	QString platformFolder = GetPlatformFolder();

	QDir dir;
	dir.mkpath(platformFolder);
	
	bool result = true;
	
	//save aggregators node before save screens
	for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
		 iter != GetChildNodes().end();
		 ++iter)
	{
		HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter);
		if (!node)
			continue;

		QString path = QString(SCREEN_PATH).arg(platformFolder).arg(node->GetName());
		MultiMap<String, YamlNode*> &aggregatorsMap = aggregators->AsMap();
		
		YamlNode* aggregator = new YamlNode(YamlNode::TYPE_MAP);
		result &= node->Save(aggregator, path, saveAll);
		
		aggregatorsMap.erase(node->GetName().toStdString());
		aggregatorsMap.insert(std::pair<String, YamlNode*>(node->GetName().toStdString(), aggregator));
	}
		
	
	for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
		 iter != GetChildNodes().end();
		 ++iter)
	{
		HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter);
		if (node)
			continue;	//skip aggregators
		
		HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
		if (!screenNode)
			continue;
		
		QString screenPath = QString(SCREEN_PATH).arg(platformFolder).arg(screenNode->GetName());
		result &= screenNode->Save(screenPath, saveAll);
		
		screens->AddValueToArray(screenNode->GetName().toStdString());
	}
	return result;
}
void HierarchyTreeControlNode::SetParent(HierarchyTreeNode* node, HierarchyTreeNode* insertAfter)
{
    if (this == insertAfter)
        return;

    if (parent)
        parent->RemoveTreeNode(this, false, false);

    HierarchyTreeControlNode* newParentControl = dynamic_cast<HierarchyTreeControlNode* >(node);
    HierarchyTreeScreenNode* newParentScreen = dynamic_cast<HierarchyTreeScreenNode* >(node);
    DVASSERT(newParentControl || newParentScreen);
    if (!newParentControl && !newParentScreen)
        return;

    UIControl* afterControl = NULL;
    HierarchyTreeControlNode* insertAfterControl = dynamic_cast<HierarchyTreeControlNode* >(insertAfter);
    if (insertAfterControl)
        afterControl = insertAfterControl->GetUIObject();

    UIControl* newParentUI = NULL;
    if (newParentControl)
        newParentUI = newParentControl->GetUIObject();
    else if (newParentScreen)
        newParentUI = newParentScreen->GetScreen();

    node->AddTreeNode(this, insertAfter);
    if (newParentUI && uiObject)
    {
        Rect controlAbsoluteRect = uiObject->GetRect(true);
        Rect parentAbsoluteRect = newParentUI->GetRect(true);

        if (insertAfter != node)
        {
            newParentUI->InsertChildAbove(uiObject, afterControl);
        }
        else
        {
            UIControl* belowControl = NULL;
            const List<UIControl*> & controls = newParentUI->GetChildren();
            if (controls.size())
            {
                belowControl = *controls.begin();
            }
            newParentUI->InsertChildBelow(uiObject, belowControl);
        }

        // Recalculate the relative coords of the moved object to don't change its position.
        Vector2 newControlOffset = controlAbsoluteRect.GetPosition() - parentAbsoluteRect.GetPosition();
        uiObject->SetRect(Rect(newControlOffset, uiObject->GetRect().GetSize()));

        // Fix
        // DF-2395 - Recalculate scrollContainer content each time we add controls to it
        UIScrollViewContainer *container = dynamic_cast<UIScrollViewContainer*>(newParentUI);
        if (container)
        {
            UIScrollView *scroll =  dynamic_cast<UIScrollView*>(container->GetParent());
            if (scroll)
            {
                scroll->RecalculateContentSize();
            }
        }
    }

    parent = node;
}