Feature request: Rectangle<>::withHeightKeepingCentre(int height)

Rectangle withHeightKeepingCentre(int height)
{
return withSizeKeepingCentre(getWidth(), height);
}

and likewise for withWidthKeepingCentre.

These are annoying to express sometimes otherwise :wink:

1 Like

It’d be very nice if someone would come up with some template magic to implement a generic

changeKeeping (Rectangle <T> &, enum whatToChange, T changedValue, enum whatToKeep)

with the two enums expressing the Rectangle aspects like:

enum RectangleAspects
{
    x,
    y,
    rightX,
    bottomY,
    width,
    height,
    top,
    left,
    right,
    bottom,
    centreX,
    centreY,
}

I’ve expressed it as a free function that acts on a Rectangle, but I have nothing in contrary if someone at JUCE could implement it as a Rectangle member!