Пример #1
0
// ----------------------------------------------------------------------------
void CViewBitmap::draw ()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	CViewRenderer &rVR = pIM->getViewRenderer();

	CRGBA col;
	if(getModulateGlobalColor())
	{
		col.modulateFromColor (_Color, pIM->getGlobalColorForContent());
	}
	else
	{
		col= _Color;
		col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8);
	}

	if (_InheritGCAlpha)
	{
		// search a parent container
		CInterfaceGroup *gr = getParent();
		while (gr)
		{
			if (gr->isGroupContainer())
			{
				CGroupContainer *gc = static_cast<CGroupContainer *>(gr);
				col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8);
				break;
			}
			gr = gr->getParent();
		}
	}
Пример #2
0
// ***************************************************************************
void	CGroupTab::setup()
{
	if(_Setuped)
		return;
	_Setuped= true;

	_Buttons.clear();
	_Groups.clear();

	/* Buttons must be named tab0,tab1,tab2...
		and tab_array0_0, tab_array0_1 .... (for vector of tab)
		Only 10 tab array are allowed
	*/
	for(sint tabArrayIndex= -1;tabArrayIndex<10;tabArrayIndex++)
	{
		// prefix according to array or not
		string	prefix;
		if(tabArrayIndex==-1)
			prefix= "tab";
		else
			prefix= toString("tab_array%d_", tabArrayIndex);

		// for all tab of this type (standard tab or array of tab), find the Buttons and groups.
		uint	tabIndex=0;
		for(;;)
		{
			// find the ctrl named "tab0"
			CCtrlTabButton	*but= dynamic_cast<CCtrlTabButton*>(getCtrl(toString("%s%d", prefix.c_str(), tabIndex)));
			if(!but)
				break;

			// find the associated group
			CInterfaceGroup	*pGroup = NULL;
			CInterfaceGroup	*pFather = this;

			while ((pGroup == NULL) && (pFather != NULL))
			{
				pGroup = pFather->getGroup(but->_AssociatedGroup);
				pFather = pFather->getParent();
			}

			// add to the button and group list
			_Buttons.push_back(but);
			_Groups.push_back(pGroup);

			// try next
			tabIndex++;
		}
	}

	// at the first setup, select by default the 1st
	if(_Selection<0)
		select(0);
}
Пример #3
0
	bool CInterfaceElement::isInGroup( CInterfaceGroup *group )
	{
		CInterfaceGroup *parent = getParent();
		while( parent != NULL )
		{
			if( parent == group )
				return true;
			else
				parent = parent->getParent();
		}
		return false;
	}
Пример #4
0
	// ----------------------------------------------------------------------------
	void CGroupList::draw ()
	{
		// TEMP TEMP
		//CViewRenderer &rVR = *CViewRenderer::getInstance();
		//rVR.drawRotFlipBitmap _RenderLayer,   (_XReal,   _YReal,   _WReal,   _HReal,   0,   false,   rVR.getBlankTextureId(),   CRGBA(0,  255,  0,  255) );
		if (_Over)
		{
			CViewRenderer &rVR = *CViewRenderer::getInstance();

			if (CWidgetManager::getInstance()->getModalWindow() == NULL)
			{
				sint32 x = CWidgetManager::getInstance()->getPointer()->getX();
				sint32 y = CWidgetManager::getInstance()->getPointer()->getY();

				CInterfaceGroup	*pIG = CWidgetManager::getInstance()->getWindowUnder(x,  y);
				CInterfaceGroup	*pParent = this;
				bool bFound = false;
				while (pParent != NULL)
				{
					if (pParent == pIG)
					{
						bFound = true;
						break;
					}
					pParent = pParent->getParent();
				}

				sint32 clipx,  clipy,  clipw,  cliph;
				getClip(clipx,  clipy,  clipw,  cliph);
				if ((x < clipx) ||
					(x > (clipx + clipw)) ||
					(y < clipy) ||
					(y > (clipy + cliph)) || !bFound)
				{
					_OverElt = -1;
				}
				else
				{
					for (uint32 i = 0; i < _Elements.size(); ++i)
					if (_Elements[i].Element->getActive())
					{
						CViewBase *pVB = _Elements[i].Element;
						if ((x >= pVB->getXReal()) &&
							(x < (pVB->getXReal() + pVB->getWReal()))&&
							(y >= pVB->getYReal()) &&
							(y < (pVB->getYReal() + pVB->getHReal())))
						{
							_OverElt = i;
						}
					}
				}
			}

			if (_OverElt != -1)
			{
				// Find the first container
				CInterfaceGroup *pIG = _Parent;
				CGroupContainerBase *pGC = dynamic_cast<CGroupContainerBase*>(pIG);
				while (pIG != NULL)
				{
					pIG = pIG->_Parent;
					if (pIG == NULL) break;
					if (dynamic_cast<CGroupContainerBase*>(pIG) != NULL)
						pGC = dynamic_cast<CGroupContainerBase*>(pIG);
				}

				bool bDisplayOverSelection = true;
				if (pGC != NULL)
				{
					if (pGC->isGrayed())
						bDisplayOverSelection = false;
				}

				if (bDisplayOverSelection)
				{
					CViewBase *pVB = _Elements[_OverElt].Element;
					CRGBA col = _OverColor;
					if(getModulateGlobalColor())
					{
						col.modulateFromColor (_OverColor,   CWidgetManager::getInstance()->getGlobalColorForContent());
					}
					else
					{
						col= _OverColor;
						col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8);
					}
					rVR.drawRotFlipBitmap (_RenderLayer,   pVB->getXReal(),   pVB->getYReal(),
											pVB->getWReal(),   pVB->getHReal(),   0,   false,   rVR.getBlankTextureId(),
											col );
				}

			}
		}
Пример #5
0
//*****************************************************************************************************************
void CGroupHeader::enlargeColumns(sint32 margin)
{
	std::vector<CGroupHeaderEntry *> entries;
	getEntries(entries);
	sint32 totalWidth = 0;
	for (uint k = 0; k < entries.size(); ++k)
	{
		CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn();
		if (colEnclosing && !colEnclosing->getGroups().empty())
		{
			CInterfaceGroup *col = colEnclosing->getGroups()[0];
			if (col)
			{
				// enlarge to the max to be able to measure the sub text (they may clamp themselves based
				// on their first non-"child resizing" parent (see CViewText::updateCoords)
				colEnclosing->setW(16384);
				colEnclosing->invalidateCoords();
				colEnclosing->updateCoords();

				// assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList)
				entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin));
				entries[k]->invalidateCoords();
				totalWidth += entries[k]->getW();
			}
		}
	}
	// if total width bigger than allowed, reduce proportionnally
	if (totalWidth > _HeaderMaxSize)
	{
		while (totalWidth > _HeaderMaxSize)
		{
			bool adjusted = false;
			// stupid algo here, but ponctual ...
			for (uint k = 0; k < entries.size() && totalWidth > _HeaderMaxSize; ++k)
			{
				if (entries[k]->getW() > entries[k]->getMinSize())
				{
					entries[k]->setW(entries[k]->getW() - 1);
					entries[k]->invalidateCoords();
					--totalWidth;
					adjusted = true;
				}
			}
			// if all at min size, just exit ...
			if (!adjusted) break;
		}
	}
	else
	{
		// search first parent that limit size, if it is larger then enlarge to fit size
		CInterfaceGroup *limitingParent = getParent();
		while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast<CGroupList *>(limitingParent)))
		{
			// NB nico : the dynamic_cast for CGroupList is bad!!
			// can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords
			// ...
			limitingParent = limitingParent->getParent();
		}
		if (limitingParent && limitingParent->getWReal() > totalWidth)
		{
			while (limitingParent->getWReal() > totalWidth && totalWidth < _HeaderMaxSize)
			{
				// enlarge to matche parent size
				// stupid algo here, but ponctual ...
				for (uint k = 0; k < entries.size(); ++k)
				{
					entries[k]->setW(entries[k]->getW() + 1);
					entries[k]->invalidateCoords();
					++totalWidth;
					if (limitingParent->getWReal() <= totalWidth || totalWidth >= _HeaderMaxSize) break;
				}
			}
		}
	}
	invalidateCoords();
}
Пример #6
0
//*****************************************************************************************************************
void CGroupHeader::resizeColumnsAndContainer(sint32 margin)
{
	std::vector<CGroupHeaderEntry *> entries;
	getEntries(entries);
	sint32 totalWidth = 0;
	for (uint k = 0; k < entries.size(); ++k)
	{
		CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn();
		if (colEnclosing && !colEnclosing->getGroups().empty())
		{
			CInterfaceGroup *col = colEnclosing->getGroups()[0];
			if (col)
			{
				// enlarge to the max to be able to measure the sub text (they may clamp themselves based
				// on their first non-"child resizing" parent (see CViewText::updateCoords)
				colEnclosing->setW(16384);
				colEnclosing->invalidateCoords();
				colEnclosing->updateCoords();

				// assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList)
				entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin));
				entries[k]->invalidateCoords();
				totalWidth += entries[k]->getW();
			}
		}
	}

	// resize W
	if (totalWidth <= _HeaderMaxSize)
	{
		// search first parent that limit size, if it is larger then enlarge to fit size
		CInterfaceGroup *limitingParent = getParent();
		while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast<CGroupList *>(limitingParent)))
		{
			// NB nico : the dynamic_cast for CGroupList is bad!!
			// can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords
			// ...
			limitingParent = limitingParent->getParent();
		}

		getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal());
	}

	// resize H
	if(entries.size()>0)
	{
		CInterfaceGroup *colEnclosing = entries[0]->getTargetColumn();
		if (colEnclosing && !colEnclosing->getGroups().empty())
		{
			CInterfaceGroup *col = colEnclosing->getGroups()[0];
			if (col)
			{
				// search first parent that limit size, if it is larger then enlarge to fit size
				CInterfaceGroup *limitingParent = colEnclosing->getParent();
				while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast<CGroupList *>(limitingParent)))
					limitingParent = limitingParent->getParent();

				getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal());
			}
		}
	}


	invalidateCoords();
}