Added Lots of Documentation
Added some nice to haves Improved and Unified General Code Layout
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
#import "MPFractionFunction.h"
|
||||
|
||||
|
||||
#define kFractionFunctionLineWidth 1.0
|
||||
#define kFractionFunctionHorizontalInset 2.0
|
||||
#define kFractionFunctionNominatorOffset 0
|
||||
@@ -17,6 +18,8 @@
|
||||
|
||||
#define MPFractionMiddle (CTFontGetCapHeight((CTFontRef)self.font) / 2)
|
||||
|
||||
|
||||
|
||||
@implementation MPFractionFunctionLayout
|
||||
|
||||
- (MPFractionFunction *)fractionFunction
|
||||
@@ -24,21 +27,25 @@
|
||||
return (MPFractionFunction *)self.function;
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)indexOfChildBelowChildAtIndex:(NSUInteger)index
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)indexOfChildAboveChildAtIndex:(NSUInteger)index
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexSet *)indexesOfRemainingChildren
|
||||
{
|
||||
return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)];
|
||||
}
|
||||
|
||||
|
||||
- (NSPoint)offsetOfChildLayoutAtIndex:(NSUInteger)index
|
||||
{
|
||||
NSRect bounds = self.bounds;
|
||||
@@ -54,11 +61,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)childAtIndexUsesSmallSize:(NSUInteger)index
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexPath *)indexPathForLocalMousePoint:(NSPoint)point
|
||||
{
|
||||
if (point.x < self.bounds.size.width / 2) {
|
||||
@@ -68,6 +77,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (NSRect)generateBounds
|
||||
{
|
||||
NSRect nominatorBounds = [self childLayoutAtIndex:0].bounds;
|
||||
@@ -80,6 +90,7 @@
|
||||
return bounds;
|
||||
}
|
||||
|
||||
|
||||
- (void)draw
|
||||
{
|
||||
CGFloat y = MPFractionMiddle - kFractionFunctionLineWidth / 2;
|
||||
|
||||
Reference in New Issue
Block a user