Ejemplo n.º 1
0
void SetContentContainer(Content* content, Container* container, Content* behindContent)
{
	Surface* surface = nullptr;
	for (Container* c = container; surface == nullptr && c != nullptr; c = c->GetContainer())
		surface = dynamic_cast<Surface*>(c);

	Container* existing = content->GetContainer();
	if (existing != nullptr)
	{
		auto i = std::find(existing->_contents.begin(), existing->_contents.end(), content);
		existing->_contents.erase(i);
	}

	content->_surface = surface;
	content->_container = container;

	if (container != nullptr)
	{
		auto i = std::find(container->_contents.begin(), container->_contents.end(), behindContent);
		container->_contents.insert(i, content);
	}
}