Cleaned Code
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user