I'll repeat my answer from the Atlas forums:
This is strange. Cocoa and Cappuccino doesn't seem to use the
autoresizing masks the same way, but Cappuccino seems to do what the
Cocoa docs says:
The Cocoa docs for setAutoresizingMask: says:
“Where more than one option along an axis is set,
resizeWithOldSuperviewSize: by default distributes the size difference
as evenly as possible among the flexible portions. For example, if
NSViewWidthSizable and NSViewMaxXMargin are set and the superview’s
width has increased by 10.0 units, the receiver’s frame and right
margin are each widened by 5.0 units.”
That means that if the window is made 10 pixels wider, your leftmost
view should get 5 pixels wider and it’s right margin should get 5
pixels wider. And this is exactly what happens in Cappuccino. And I
checked the source of NSView in GNUStep and it behaves exactly like
capp too.
This is however not how how it works in Cocoa. It seems to distribute
the extra space proportionally among the flexible parts. If the width
is half the size of the right margin, then if you resize the superview
the width gets 1/3 of the extra space and the right margin 2/3 of
that.
This is a patch that makes you example work like Cocoa (but it's not
tested on so many other cases).
diff --git a/AppKit/CPView.j b/AppKit/CPView.j
index c53892f..b718342 100644
--- a/AppKit/CPView.j
+++ b/AppKit/CPView.j
@@ -911,20 +911,22 @@ var CPViewFlags = { },
var frame = _superview._frame,
newFrame = _CGRectMakeCopy(_frame),
- dX = (_CGRectGetWidth(frame) - aSize.width) /
- (((mask & CPViewMinXMargin) ? 1 : 0) + (mask &
CPViewWidthSizable ? 1 : 0) + (mask & CPViewMaxXMargin ? 1 : 0)),
- dY = (_CGRectGetHeight(frame) - aSize.height) /
- ((mask & CPViewMinYMargin ? 1 : 0) + (mask &
CPViewHeightSizable ? 1 : 0) + (mask & CPViewMaxYMargin ? 1 : 0));
+
+ dX = (_CGRectGetWidth(frame) - aSize.width);
+ flexibleX = (((mask & CPViewMinXMargin) ?
_frame.origin.x : 0) + (mask & CPViewWidthSizable ?
_frame.size.width : 0) + (mask & CPViewMaxXMargin ? aSize.width -
_frame.size.width - _frame.origin.x : 0));
+ dY = (_CGRectGetHeight(frame) - aSize.height);
+ flexibleY = (((mask & CPViewMinYMargin) ?
_frame.origin.y : 0) + (mask & CPViewHeightSizable ?
_frame.size.height : 0) + (mask & CPViewMaxYMargin ? aSize.height -
_frame.size.height - _frame.origin.y : 0));
+
if (mask & CPViewMinXMargin)
- newFrame.origin.x += dX;
+ newFrame.origin.x += dX * (_frame.origin.x / flexibleX);
if (mask & CPViewWidthSizable)
- newFrame.size.width += dX;
+ newFrame.size.width += dX * (_frame.size.width / flexibleX);
if (mask & CPViewMinYMargin)
- newFrame.origin.y += dY;
+ newFrame.origin.y += dY * (_frame.origin.y / flexibleY);
if (mask & CPViewHeightSizable)
- newFrame.size.height += dY;
+ newFrame.size.height += dY * (_frame.size.height /
flexibleY);
[self setFrame:newFrame];