Meta Position
// 2D meta position is used for resolution independent positioning 2D elements on an overlay.
// Coordinates for pos, handle or dims can be normalized or in pixels. If the coordinate is
// in range -1 to 1 the coordinate is normalized. Outside this range, the coordinate is in pixels.
// Negative coordinates are relative to the opposite side. Pixel coordinates use a virtual screen
// size of 1920x1080. Internally Rayve will scale the virtual pixel coordinates to match the
// real screen resolution.
class RVAPI MetaPos
{
public:
// Position.
S2f pos;
// Local origin.
S2f handle;
// Dimensions.
S2f dims;
// Flags.
uint flags;
// Flags.
enum Flags
{
// Don't DPI scale x position.
NOSCALE_POSX = 0x0001,
// Don't DPI scale y position.
NOSCALE_POSY = 0x0002,
// Don't DPI scale z position.
NOSCALE_POS = 0x0003,
// Don't DPI scale handle x.
NOSCALE_HDLX = 0x0004,
// Don't DPI scale handle y.
NOSCALE_HDLY = 0x0008,
// Don't DPI scale handle z.
NOSCALE_HDL = 0x000C,
// Don't DPI scale x dimension.
NOSCALE_DIMSX = 0x0010,
// Don't DPI scale y dimension.
NOSCALE_DIMSY = 0x0020,
// Don't DPI scale z dimension.
NOSCALE_DIMS = 0x0030,
// Don't normalize x position.
NONORM_POSX = 0x0040,
// Don't normalize y position.
NONORM_POSY = 0x0080,
// Don't normalize position.
NONORM_POS = 0x00C0,
// Don't DPI scale.
NOSCALE = 0x003F,
// Don't wrap negative coordinates.
NOWRAP = 0x0100
};
// Resolve meta position to real screen coordinates based on the
// real screen coordinates of the parent rectangle [pRect].
B2i Resolve(const B2i &pRect) const;
// Construct meta position using position scalar, handle scalar and dimension scalar.
MetaPos(const S2f &pos, const S2f &handle, const S2f &dims, uint flags = 0)
: pos(pos), handle(handle), dims(dims), flags(flags) {}
// Construct meta position using position coordinates, handl coordinates and dimension coordinates.
MetaPos(float px, float py, float hx, float hy, float dx, float dy, uint flags = 0)
: pos(px, py), handle(hx, hy), dims(dx, dy), flags(flags) {}
// Constructor.
MetaPos() {}
// Destructor.
~MetaPos() {}
};