mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-09 07:20:40 +00:00
adds 3 new horizontal relative gui entries for dealing with swapping elements between 4:3 and 16:9 aspect ratios. "relativeToYL" maintains the initial aspect ratio, keeping the leftmost edge the same, "relativeToYR" also shifts it so the right hand side is shifted over so that edge would match, and "relativeToYC" takes/adds space from both sides
This commit is contained in:
parent
8a55feebef
commit
6b0c6ae8ac
2 changed files with 36 additions and 0 deletions
|
|
@ -175,6 +175,9 @@ ImplementEnumType( GuiHorizontalSizing,
|
|||
{ GuiControl::horizResizeLeft, "left" },
|
||||
{ GuiControl::horizResizeCenter, "center" },
|
||||
{ GuiControl::horizResizeRelative, "relative" },
|
||||
{ GuiControl::horizResizeRelativeToYL, "relativeToYL" },
|
||||
{ GuiControl::horizResizeRelativeToYR, "relativeToYR" },
|
||||
{ GuiControl::horizResizeRelativeToYC, "relativeToYC" },
|
||||
{ GuiControl::horizResizeWindowRelative, "windowRelative" }
|
||||
EndImplementEnumType;
|
||||
|
||||
|
|
@ -1366,6 +1369,36 @@ void GuiControl::parentResized(const RectI &oldParentRect, const RectI &newParen
|
|||
newPosition.x = newLeft;
|
||||
newExtent.x = newWidth;
|
||||
}
|
||||
else if (mHorizSizing == horizResizeRelativeToYL && oldParentRect.extent.x != 0)
|
||||
{
|
||||
S32 newLeft = mRoundToNearest((F32(newPosition.x) / F32(oldParentRect.extent.x)) * F32(newParentRect.extent.x));
|
||||
S32 newWidth = mRoundToNearest((F32(newExtent.x) / F32(oldParentRect.extent.y)) * F32(newParentRect.extent.y));
|
||||
|
||||
newPosition.x = newLeft;
|
||||
newExtent.x = newWidth;
|
||||
}
|
||||
else if (mHorizSizing == horizResizeRelativeToYR && oldParentRect.extent.x != 0)
|
||||
{
|
||||
S32 newLeft = mRoundToNearest((F32(newPosition.x) / F32(oldParentRect.extent.x)) * F32(newParentRect.extent.x));
|
||||
S32 newWidth = mRoundToNearest((F32(newExtent.x) / F32(oldParentRect.extent.y)) * F32(newParentRect.extent.y)); //origional aspect ratio corrected width
|
||||
S32 rWidth = mRoundToNearest((F32(newExtent.x) / F32(oldParentRect.extent.x)) * F32(newParentRect.extent.x)); //parent aspect ratio relative width
|
||||
|
||||
S32 offset = rWidth - newWidth; // account for change in relative width
|
||||
newLeft += offset;
|
||||
newPosition.x = newLeft;
|
||||
newExtent.x = newWidth;
|
||||
}
|
||||
else if (mHorizSizing == horizResizeRelativeToYC && oldParentRect.extent.x != 0)
|
||||
{
|
||||
S32 newLeft = mRoundToNearest((F32(newPosition.x) / F32(oldParentRect.extent.x)) * F32(newParentRect.extent.x));
|
||||
S32 newWidth = mRoundToNearest((F32(newExtent.x) / F32(oldParentRect.extent.y)) * F32(newParentRect.extent.y)); //origional aspect ratio corrected width
|
||||
S32 rWidth = mRoundToNearest((F32(newExtent.x) / F32(oldParentRect.extent.x)) * F32(newParentRect.extent.x)); //parent aspect ratio relative width
|
||||
|
||||
S32 offset = rWidth - newWidth; // account for change in relative width
|
||||
newLeft += offset/2;
|
||||
newPosition.x = newLeft;
|
||||
newExtent.x = newWidth;
|
||||
}
|
||||
|
||||
if (mVertSizing == vertResizeCenter)
|
||||
newPosition.y = (newParentRect.extent.y - getHeight()) >> 1;
|
||||
|
|
|
|||
|
|
@ -121,6 +121,9 @@ class GuiControl : public SimGroup
|
|||
horizResizeLeft, ///< fixed on the right and width
|
||||
horizResizeCenter,
|
||||
horizResizeRelative, ///< resize relative
|
||||
horizResizeRelativeToYL, ///< resize relative to hieght delta (offset Left)
|
||||
horizResizeRelativeToYR, ///< resize relative to hieght delta (offset Right)
|
||||
horizResizeRelativeToYC, ///< resize relative to hieght delta (offset Right)
|
||||
horizResizeWindowRelative ///< resize window relative
|
||||
};
|
||||
enum vertSizingOptions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue