Archived
1

Cleaned Code

This commit is contained in:
Kim Wittenburg
2014-10-21 15:06:57 +02:00
parent 5592128926
commit 91e7dbe9f2
20 changed files with 126 additions and 92 deletions

View File

@@ -101,17 +101,23 @@
}
- (NSAffineTransform *)parenthesisTransform
{
NSAffineTransform *transform = [NSAffineTransform transform];
[transform scaleXBy:1
yBy:self.scaleFactor];
return transform;
}
- (CGFloat)scaleFactor
{
NSRect parensBounds = self.openingParens.bounds;
NSRect expressionBounds = [self childLayoutAtIndex:0].bounds;
NSAffineTransform *transform = [NSAffineTransform transform];
if (expressionBounds.size.height >= parensBounds.size.height) {
return transform;
CGFloat parensHeight = parensBounds.size.height;
CGFloat expressionHeight = expressionBounds.size.height;
if (expressionHeight <= parensHeight) {
return 1.0;
}
CGFloat scaleFactor = expressionBounds.size.height / parensBounds.size.height;
[transform scaleXBy:1
yBy:scaleFactor];
return transform;
return expressionHeight / parensHeight;
}
- (NSPoint)offsetOfChildLayoutAtIndex:(NSUInteger)index
@@ -154,24 +160,18 @@
return bounds;
}
#warning Let the children be drawn automatically
- (BOOL)drawsChildrenManually
{
return YES;
}
- (void)draw
{
NSBezierPath *openingParens = self.transformedOpeningParens;
MPLayout *expressionLayout = [self childLayoutAtIndex:0];
NSBezierPath *closingParens = self.transformedClosingParens;
CGFloat x = 0;
[openingParens fill];
x += openingParens.bounds.size.width;
x += MPParenthesisFunctionOpeningParensOffset;
[expressionLayout drawAtPoint:NSMakePoint(x, 0)];
x += expressionLayout.bounds.size.width;
x += MPParenthesisFunctionClosingParensOffset;