Cleaned Code
This commit is contained in:
@@ -9,12 +9,12 @@
|
||||
#import "MPFractionFunctionLayout.h"
|
||||
#import "MPExpressionLayout.h"
|
||||
|
||||
#define kFractionFunctionLineWidth 2
|
||||
#define kFractionFunctionHorizontalInset 2
|
||||
#define kFractionFunctionLineWidth 1.0
|
||||
#define kFractionFunctionHorizontalInset 2.0
|
||||
#define kFractionFunctionNominatorOffset 0
|
||||
#define kFractionFunctionDenominatorOffset 0
|
||||
|
||||
#define MPFractionMiddle (CTFontGetAscent((CTFontRef)self.font) / 2)
|
||||
#define MPFractionMiddle (CTFontGetCapHeight((CTFontRef)self.font) / 2)
|
||||
|
||||
@implementation MPFractionFunctionLayout
|
||||
|
||||
@@ -41,13 +41,14 @@
|
||||
- (NSPoint)offsetOfChildLayoutAtIndex:(NSUInteger)index
|
||||
{
|
||||
if (index == 0) {
|
||||
CGFloat y = MPFractionMiddle + kFractionFunctionLineWidth / 2;
|
||||
return NSMakePoint(0, y);
|
||||
NSRect nominatorBounds = [self childLayoutAtIndex:0].bounds;
|
||||
CGFloat y = MPFractionMiddle + kFractionFunctionLineWidth / 2 - nominatorBounds.origin.y;
|
||||
return NSMakePoint(kFractionFunctionHorizontalInset, y);
|
||||
} else {
|
||||
NSRect denominatorBounds = [self childLayoutAtIndex:1].bounds;
|
||||
CGFloat y = CTFontGetAscent((CTFontRef)self.font) / 2 - kFractionFunctionLineWidth / 2;
|
||||
y -= denominatorBounds.size.height - denominatorBounds.origin.y;
|
||||
return NSMakePoint(0, y);
|
||||
CGFloat y = MPFractionMiddle - kFractionFunctionLineWidth / 2;
|
||||
y -= denominatorBounds.size.height + denominatorBounds.origin.y;
|
||||
return NSMakePoint(kFractionFunctionHorizontalInset, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,16 +72,15 @@
|
||||
NSRect denominatorBounds = [self childLayoutAtIndex:1].bounds;
|
||||
NSRect bounds;
|
||||
bounds.origin.x = 0;
|
||||
CGFloat y = CTFontGetAscent((CTFontRef)self.font) / 2 - kFractionFunctionLineWidth / 2;
|
||||
y -= denominatorBounds.size.height;
|
||||
bounds.size.width = MAX(nominatorBounds.size.width, denominatorBounds.size.width);
|
||||
bounds.origin.y = MPFractionMiddle - kFractionFunctionLineWidth / 2 - denominatorBounds.size.height;
|
||||
bounds.size.width = MAX(nominatorBounds.size.width, denominatorBounds.size.width) + 2 * kFractionFunctionHorizontalInset;
|
||||
bounds.size.height = nominatorBounds.size.height + denominatorBounds.size.height + kFractionFunctionLineWidth;
|
||||
return bounds;
|
||||
}
|
||||
|
||||
- (void)draw
|
||||
{
|
||||
CGFloat y = CTFontGetAscent((CTFontRef)self.font) / 2 - kFractionFunctionLineWidth / 2;
|
||||
CGFloat y = MPFractionMiddle - kFractionFunctionLineWidth / 2;
|
||||
NSRectFill(NSMakeRect(0, y, self.bounds.size.width, kFractionFunctionLineWidth));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user