Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tabs -> spaces

  • Loading branch information...
commit dcd056f4bee195579aff92cd2a85d8188443a6b1 1 parent b198b31
@jspahrsummers jspahrsummers authored
View
14 lib/UIKit/TUILayoutConstraint.m
@@ -53,7 +53,7 @@ + (id)constraintWithAttribute:(TUILayoutConstraintAttribute)attr
attribute:(TUILayoutConstraintAttribute)srcAttr
scale:(CGFloat)scale
offset:(CGFloat)offset {
- return [[self alloc] initWithAttribute:attr relativeTo:source attribute:srcAttr scale:scale offset:offset];
+ return [[self alloc] initWithAttribute:attr relativeTo:source attribute:srcAttr scale:scale offset:offset];
}
+ (id)constraintWithAttribute:(TUILayoutConstraintAttribute)attr
@@ -79,7 +79,7 @@ - (id)initWithAttribute:(TUILayoutConstraintAttribute)attr
double attributeRange = floor(log10(attr));
double sourceAttributeRange = floor(log10(srcAttr));
- NSAssert(fabs(attributeRange - sourceAttributeRange) < 0.001, @"Invalid source and target attributes: %f, %f", sourceAttributeRange, attributeRange);
+ NSAssert(fabs(attributeRange - sourceAttributeRange) < 0.001, @"Invalid source and target attributes: %f, %f", sourceAttributeRange, attributeRange);
if((self = [super init])) {
_attribute = attr;
@@ -88,7 +88,7 @@ - (id)initWithAttribute:(TUILayoutConstraintAttribute)attr
_sourceName = [srcLayer copy];
_valueTransformer = transformer;
}
- return self;
+ return self;
}
- (CGFloat)transformValue:(CGFloat)original {
@@ -108,7 +108,7 @@ - (void)applyToTargetView:(TUIView *)target sourceView:(TUIView *)source {
NSRect sourceValue = [source valueForLayoutAttribute:[self sourceAttribute]];
NSRect targetValue = sourceValue;
-
+
if(self.attribute >= TUILayoutConstraintAttributeMinY && self.attribute <= TUILayoutConstraintAttributeMidX)
targetValue.origin.x = [self transformValue:sourceValue.origin.x];
@@ -129,14 +129,14 @@ - (id)initWithBlock:(TUILayoutTransformer)block {
if((self = [super init])) {
_transformer = [block copy];
}
- return self;
+ return self;
}
- (id)transformedValue:(id)value {
- if(!self.transformer) return nil;
+ if(!self.transformer) return nil;
CGFloat source = [value floatValue];
CGFloat transformed = self.transformer(source);
return [NSNumber numberWithFloat:transformed];
}
-@end
+@end
View
88 lib/UIKit/TUILayoutManager.m
@@ -32,7 +32,7 @@ - (id)init {
if((self = [super init])) {
_layoutConstraints = [[NSMutableArray alloc] init];
}
- return self;
+ return self;
}
@end
@@ -56,29 +56,29 @@ @implementation TUILayoutManager
@synthesize processedViews = _processedViews;
+ (id)sharedLayoutManager {
- static TUILayoutManager *_sharedLayoutManager = nil;
- static dispatch_once_t onceToken;
-
- dispatch_once(&onceToken, ^{
- _sharedLayoutManager = [[TUILayoutManager alloc] init];
- });
-
+ static TUILayoutManager *_sharedLayoutManager = nil;
+ static dispatch_once_t onceToken;
+
+ dispatch_once(&onceToken, ^{
+ _sharedLayoutManager = [[TUILayoutManager alloc] init];
+ });
+
return _sharedLayoutManager;
}
- (id)init {
- if((self = [super init])) {
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(frameChanged:)
- name:TUIViewFrameDidChangeNotification
- object:nil];
- _isProcessingChanges = NO;
-
- _constraints = [NSMapTable mapTableWithWeakToStrongObjects];
- _viewsToProcess = [[NSMutableArray alloc] init];
- _processedViews = [[NSMutableSet alloc] init];
- }
- return self;
+ if((self = [super init])) {
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(frameChanged:)
+ name:TUIViewFrameDidChangeNotification
+ object:nil];
+ _isProcessingChanges = NO;
+
+ _constraints = [NSMapTable mapTableWithWeakToStrongObjects];
+ _viewsToProcess = [[NSMutableArray alloc] init];
+ _processedViews = [[NSMutableSet alloc] init];
+ }
+ return self;
}
- (void)dealloc {
@@ -92,13 +92,13 @@ - (void)removeAllLayoutConstraints {
- (void)processView:(TUIView *)aView {
[self.processedViews addObject:aView];
- NSArray *viewConstraints = [self layoutConstraintsOnView:aView];
- for(TUILayoutConstraint * constraint in viewConstraints)
- [constraint applyToTargetView:aView];
+ NSArray *viewConstraints = [self layoutConstraintsOnView:aView];
+ for(TUILayoutConstraint * constraint in viewConstraints)
+ [constraint applyToTargetView:aView];
- // Order of Operations:
- // 1. Siblings with constraints to this view.
- // 2. Children with constraints to superview.
+ // Order of Operations:
+ // 1. Siblings with constraints to this view.
+ // 2. Children with constraints to superview.
if([self layoutNameForView:aView] != nil) {
NSArray *siblings = [[aView superview] subviews];
@@ -126,23 +126,23 @@ - (void)processView:(TUIView *)aView {
}
- (void)beginProcessingView:(TUIView *)view {
- if(self.isProcessingChanges == NO) {
- self.isProcessingChanges = YES;
+ if(self.isProcessingChanges == NO) {
+ self.isProcessingChanges = YES;
+
+ @autoreleasepool {
+ [self.viewsToProcess addObject:view];
+
+ while([self.viewsToProcess count] > 0) {
+ TUIView *currentView = [self.viewsToProcess objectAtIndex:0];
+ [self.viewsToProcess removeObjectAtIndex:0];
+ if([self.viewsToProcess containsObject:currentView] == NO)
+ [self processView:currentView];
+ }
+
+ [self.viewsToProcess removeAllObjects];
+ [self.processedViews removeAllObjects];
+ }
- @autoreleasepool {
- [self.viewsToProcess addObject:view];
-
- while([self.viewsToProcess count] > 0) {
- TUIView *currentView = [self.viewsToProcess objectAtIndex:0];
- [self.viewsToProcess removeObjectAtIndex:0];
- if([self.viewsToProcess containsObject:currentView] == NO)
- [self processView:currentView];
- }
-
- [self.viewsToProcess removeAllObjects];
- [self.processedViews removeAllObjects];
- }
-
self.isProcessingChanges = NO;
} else {
if([self.processedViews containsObject:view] == NO)
@@ -175,7 +175,7 @@ - (void)removeLayoutConstraintsFromView:(TUIView *)view {
- (NSArray *)layoutConstraintsOnView:(TUIView *)view {
TUILayoutContainer *container = [self.constraints objectForKey:view];
- if(!container) return nil;
+ if(!container) return nil;
else return [[container layoutConstraints] copy];
}
@@ -194,7 +194,7 @@ - (void)setLayoutName:(NSString *)name forView:(TUIView *)view {
viewContainer = [TUILayoutContainer container];
[self.constraints setObject:viewContainer forKey:view];
}
- [viewContainer setLayoutName:name];
+ [viewContainer setLayoutName:name];
}
}
View
18 lib/UIKit/TUIView+Layout.m
@@ -46,7 +46,7 @@ - (void)removeAllLayoutConstraints {
- (CGRect)valueForLayoutAttribute:(TUILayoutConstraintAttribute)attribute {
CGRect frame = self.frame;
CGRect bounds = self.bounds;
-
+
switch(attribute) {
case TUILayoutConstraintAttributeMinY:
return TUIScalarRect(NSMinY(frame));
@@ -89,7 +89,7 @@ - (CGRect)valueForLayoutAttribute:(TUILayoutConstraintAttribute)attribute {
case TUILayoutConstraintAttributeBounds:
return bounds;
default:
- NSAssert(NO, @"Invalid constraint attribute.");
+ NSAssert(NO, @"Invalid constraint attribute.");
return NSZeroRect;
}
}
@@ -150,7 +150,7 @@ - (void)setValue:(CGRect)newValue forLayoutAttribute:(TUILayoutConstraintAttribu
case TUILayoutConstraintAttributeBoundsCenter:
TUISetMidX(bounds, pointValue.x);
TUISetMidY(bounds, pointValue.y);
- [self setBounds:bounds];
+ [self setBounds:bounds];
break;
case TUILayoutConstraintAttributeMidXMaxY:
TUISetMidX(frame, pointValue.x);
@@ -173,14 +173,14 @@ - (void)setValue:(CGRect)newValue forLayoutAttribute:(TUILayoutConstraintAttribu
break;
case TUILayoutConstraintAttributeBounds:
bounds = rectValue;
- [self setBounds:bounds];
+ [self setBounds:bounds];
+ break;
+ default:
+ NSAssert(NO, @"Invalid constraint attribute.");
break;
- default:
- NSAssert(NO, @"Invalid constraint attribute.");
- break;
}
-
- [self setFrame:frame];
+
+ [self setFrame:frame];
}
- (TUIView *)relativeViewForName:(NSString *)name {

0 comments on commit dcd056f

Please sign in to comment.
Something went wrong with that request. Please try again.