Archived
1

Slightly Improved Size Calculation of MPExpressionLayout.

This commit is contained in:
Kim Wittenburg
2015-01-08 22:26:01 +01:00
parent 524238dc2f
commit 49cb03082e

View File

@@ -129,14 +129,13 @@
if (self.expression.countElements == 0) { if (self.expression.countElements == 0) {
return NSMakeRect(0, kMPEmptyBoxYOrigin, kMPEmptyBoxWidth, kMPEmptyBoxHeight); return NSMakeRect(0, kMPEmptyBoxYOrigin, kMPEmptyBoxWidth, kMPEmptyBoxHeight);
} }
CGFloat x = 0, y = 0, width = 0, height = 0; CGRect bounds = NSMakeRect(0, 0, 0, 0);
for (NSUInteger index = 0; index < self.expression.countElements; index++) { for (NSUInteger index = 0; index < self.expression.countElements; index++) {
NSRect elementBounds = [self boundsOfElementAtIndex:index]; NSRect elementBounds = [self boundsOfElementAtIndex:index];
width += elementBounds.size.width; elementBounds.origin.x = bounds.size.width;
height = MAX(height, elementBounds.size.height); bounds = NSUnionRect(bounds, elementBounds);
y = MIN(y, elementBounds.origin.y);
} }
return NSMakeRect(x, y, width, height); return bounds;
} }