示例#1
0
void GUIHelper::reposContainer(Ogre::OverlayContainer *o)
{
	ASSERT(o);
	if(!o->getParent()){
		debugWARNING("This overlay has no parent (%s)\n", o->getName().c_str());
		return;
	}
	// if we have parent then we call the other function
	Ogre::OverlayContainer *parent = o->getParent();
	reposContainer(o, parent->getLeft(), parent->getTop(),parent->getHeight(),
			parent->getWidth());
}
示例#2
0
/**
 * Bugfix for the nested overlay containers position. This function will
 * get a overlay and will iterate over all the (child) containers and will
 * set the new "relative" position
 * @param	overlay		The overlay to fix the childs positions
 */
void GUIHelper::fixOverlayPosition(Ogre::Overlay *overlay)
{
	ASSERT(overlay);

	Ogre::Overlay::Overlay2DElementsIterator it = overlay->get2DElementsIterator();

	Ogre::OverlayContainer *parent = 0;
	while(it.hasMoreElements()){
		parent = it.peekNext();
		if(!parent){
			break;
		}

		// else we have the parent... get the top left and sizes
		Ogre::Real top = parent->getTop();
		Ogre::Real left = parent->getLeft();
		Ogre::Real height = parent->getHeight();
		Ogre::Real width = parent->getWidth();


		Ogre::OverlayContainer::ChildIterator it2 = parent->getChildIterator();
		Ogre::OverlayContainer *child = 0;
		while(it2.hasMoreElements()){
			child = static_cast<Ogre::OverlayContainer *>(it2.peekNextValue());
			if(!child){
				break;
			}
			// else.. we have to configure this child with the parent size and
			// position
			reposContainer(child, left, top, height, width);

			it2.moveNext();
		}


		it.moveNext();
	}
}
示例#3
0
/**
 * Get the absolute position of the container
 * @param	cont	The container
 * @param	top		The absolute top
 * @param	left	The absolute left
 * @param	w		The absolute width
 * @param	h		The absolute height
 */
void GUIHelper::getAbsoluteGeometry(Ogre::OverlayContainer *cont, Ogre::Real &top,
		Ogre::Real &left, Ogre::Real &right, Ogre::Real &bottom)
{
	ASSERT(cont);
	Ogre::OverlayContainer *parnet = cont->getParent();
	if(parnet){
		if(parnet->getParent()){
			debugWARNING("TODO: tenemos que contemplar este caso... en el que "
					"haya mas de un parnet... tendriamos que calcular recursivamente"
					" las posiciones...\n");
			ASSERT(false);
		}
		top = cont->getTop() + parnet->getTop();
		left = cont->getLeft() + parnet->getLeft();
		right = left + cont->getWidth();
		bottom = top + cont->getHeight();
	} else {
		top = cont->getTop();
		left = cont->getLeft();
		right = left + cont->getWidth();
		bottom = top + cont->getHeight();
	}

}