Changed: More control to extend_over_text layout from xml

feature/pre-code-move
Nimetu 5 years ago
parent e3df74eaee
commit af221b7118

@ -1190,6 +1190,10 @@ namespace NLGUI
CViewText *vtDst = dynamic_cast<CViewText*>(groupOver->getView("text")); CViewText *vtDst = dynamic_cast<CViewText*>(groupOver->getView("text"));
if (vtDst != NULL) if (vtDst != NULL)
{ {
groupOver->setParentPos(vtSrc);
sint32 backupX = groupOver->getX();
// Copy all aspects to the view // Copy all aspects to the view
vtDst->setText (vtSrc->getText()); vtDst->setText (vtSrc->getText());
vtDst->setFontSize (vtSrc->getFontSize()); vtDst->setFontSize (vtSrc->getFontSize());
@ -1212,42 +1216,36 @@ namespace NLGUI
pOutline->setModulateGlobalColor(vtSrc->getModulateGlobalColor()); pOutline->setModulateGlobalColor(vtSrc->getModulateGlobalColor());
} }
// the group is the position of the overed text, but apply the delta of borders (vtDst X/Y)
sint32 x = vtSrc->getXReal() - vtDst->getX();
sint32 y = vtSrc->getYReal() - vtDst->getY();
// update one time only to get correct W/H // update one time only to get correct W/H
groupOver->updateCoords (); groupOver->updateCoords ();
if(!vtSrc->isClampRight()) // align and clamp to screen coords
sint32 x = -backupX;
if (vtSrc->isClampRight())
{ {
// clamped from the left part x += std::max(0, (groupOver->getXReal() + groupOver->getWReal()) - (groupOver->getParent()->getXReal() + groupOver->getParent()->getWReal()));
x += vtSrc->getWReal() - vtDst->getWReal();
} }
else
{
x += vtDst->getWReal() - vtSrc->getWReal();
if ( x > (groupOver->getXReal() - groupOver->getParent()->getXReal()) )
{
x -= x - (groupOver->getXReal() - groupOver->getParent()->getXReal());
}
}
if (x != 0) groupOver->setX(-x);
// clamp to screen coords, and set // TODO: there should be no overflow on y, unless barely visible and next to screen border
if ((x+groupOver->getW()) > groupOver->getParent()->getWReal())
x = groupOver->getParent()->getWReal() - groupOver->getW(); groupOver->updateCoords();
if (x < 0)
x = 0;
if ((y+groupOver->getH()) > groupOver->getParent()->getHReal())
y = groupOver->getParent()->getHReal() - groupOver->getH();
if (y < 0)
y = 0;
// set pos
groupOver->setX (x);
groupOver->setY (y);
// update coords 3 times is required
groupOver->updateCoords ();
groupOver->updateCoords ();
groupOver->updateCoords ();
// draw // draw
groupOver->draw (); groupOver->draw ();
// flush layers // flush layers
CViewRenderer::getInstance()->flush(); CViewRenderer::getInstance()->flush();
// restore backup values
if (x != 0) groupOver->setX(backupX);
} }
} }

Loading…
Cancel
Save