Added Lots of Documentation
Added some nice to haves Improved and Unified General Code Layout
This commit is contained in:
@@ -9,14 +9,16 @@
|
||||
#import "MPSumFunctionLayout.h"
|
||||
|
||||
#import "MPSumFunction.h"
|
||||
|
||||
#import "NSIndexPath+MPAdditions.h"
|
||||
|
||||
|
||||
#define kSumFunctionStartExpressionOffset 0
|
||||
#define kSumFunctionTargetExpressionOffset 0
|
||||
#define kSumFunctionSumExpressionOffset 3
|
||||
#define kSumFunctionTrailingOffset 5
|
||||
|
||||
|
||||
|
||||
@implementation MPSumFunctionLayout
|
||||
|
||||
- (MPSumFunction *)sumFunction
|
||||
@@ -24,16 +26,19 @@
|
||||
return (MPSumFunction *)self.function;
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)indexOfLeadingChild
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)indexOfTrailingChild
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)indexOfChildAfterChildAtIndex:(NSUInteger)index
|
||||
{
|
||||
if (index != 2) {
|
||||
@@ -42,21 +47,25 @@
|
||||
return [super indexOfChildAfterChildAtIndex:index];
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)indexOfChildBelowChildAtIndex:(NSUInteger)index
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
- (NSUInteger)indexOfChildAboveChildAtIndex:(NSUInteger)index
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexSet *)indexesOfRemainingChildren
|
||||
{
|
||||
return [NSIndexSet indexSetWithIndex:2];
|
||||
}
|
||||
|
||||
|
||||
- (CTLineRef)line
|
||||
{
|
||||
CTLineRef line = [self lineForPrivateCacheIndex:0 generator:^CTLineRef{
|
||||
@@ -67,6 +76,7 @@
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
- (NSRect)localLineBounds
|
||||
{
|
||||
NSRect lineBounds = CTLineGetBoundsWithOptions(self.line, 0);
|
||||
@@ -77,6 +87,7 @@
|
||||
return NSMakeRect(xPosition, lineBounds.origin.y, lineBounds.size.width, lineBounds.size.height);
|
||||
}
|
||||
|
||||
|
||||
- (NSPoint)offsetOfChildLayoutAtIndex:(NSUInteger)index
|
||||
{
|
||||
NSRect childBounds = [self childLayoutAtIndex:index].bounds;
|
||||
@@ -101,11 +112,13 @@
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)childAtIndexUsesSmallSize:(NSUInteger)index
|
||||
{
|
||||
return (index == 0 || index == 1) ? YES : self.usesSmallSize;
|
||||
}
|
||||
|
||||
|
||||
- (NSIndexPath *)indexPathForLocalMousePoint:(NSPoint)point
|
||||
{
|
||||
if (point.x < CTLineGetBoundsWithOptions(self.line, 0).size.width / 2) {
|
||||
@@ -115,6 +128,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (NSRect)generateBounds
|
||||
{
|
||||
NSRect lineBounds = CTLineGetBoundsWithOptions(self.line, 0);
|
||||
@@ -139,6 +153,7 @@
|
||||
return bounds;
|
||||
}
|
||||
|
||||
|
||||
- (void)draw
|
||||
{
|
||||
// Get the current context
|
||||
|
||||
Reference in New Issue
Block a user