Next: 1.7 Expanding views over Up: 1. Renaissance AutoLayout Previous: 1.5 The minimum size

# 1.6 Renaissance AutoLayout support for minimum sizes

Renaissance AutoLayout adds two methods to NSView in order to support minimum size:

- `-(void)sizeToFitContent`, which should be implemented in all views embedded in an autolayout window, and should resize the view to the minimum size required to properly display its current contents, with the current attributes.
- `-(NSSize)minimumSizeForContent`, which should return the minimum size needed to display the view's current contents, with the current attributes.

`-minimumSizeForContent` is somewhat more primitive than `-sizeToFitContent`, and the natural implementation of `-sizeToFitContent` would simply be

    - (void) sizeToFitContent
    {
      [self setFrameSize: [self minimumSizeForContent]];
    }

Unfortunately, the OpenStep API works the other way round: it does not provide anything equivalent to `-minimumSizeForContent`, while for most views and controls in the AppKit, it provides a `-sizeToFit` which is often roughly equivalent to `-sizeToFitContent`, or enough to implement it modulo adjustments.

So the standard implementation of `-sizeToFitContent` for most of the AppKit views and controls is done by calling `-sizeToFit`, while the default NSView's implementation of `-minimumSizeForContent` works by saving the view's frame, then resizing the view to its minimum frame by calling `-sizeToFitContent`, grasping the resulting frame, then setting back the view's frame to its original size.

Because of this very clumsy and inefficient implementation, it is recommended that you try to avoid using `-minimumSizeForContent` if you can.

Next: 1.7 Expanding views over Up: 1. Renaissance AutoLayout Previous: 1.5 The minimum size