mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
code review
This commit is contained in:
@@ -156,12 +156,17 @@ void CIntObject::setRedrawParent(bool on)
|
||||
}
|
||||
|
||||
void CIntObject::fitToScreen(int borderWidth, bool propagate)
|
||||
{
|
||||
fitToRect(Rect(Point(0, 0), GH.screenDimensions()), borderWidth, propagate);
|
||||
}
|
||||
|
||||
void CIntObject::fitToRect(Rect rect, int borderWidth, bool propagate)
|
||||
{
|
||||
Point newPos = pos.topLeft();
|
||||
vstd::amax(newPos.x, borderWidth);
|
||||
vstd::amax(newPos.y, borderWidth);
|
||||
vstd::amin(newPos.x, GH.screenDimensions().x - borderWidth - pos.w);
|
||||
vstd::amin(newPos.y, GH.screenDimensions().y - borderWidth - pos.h);
|
||||
vstd::amax(newPos.x, rect.x + borderWidth);
|
||||
vstd::amax(newPos.y, rect.y + borderWidth);
|
||||
vstd::amin(newPos.x, rect.x + rect.w - borderWidth - pos.w);
|
||||
vstd::amin(newPos.y, rect.y + rect.h - borderWidth - pos.h);
|
||||
if (newPos != pos.topLeft())
|
||||
moveTo(newPos, propagate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user