Permalink
Browse files

Renamed methods to not conflict with methods in AppKit. Officially st…

…opping active development.
  • Loading branch information...
1 parent 3b68651 commit d65ffa0c7d48b647ac26a87947dd53cc109fe2f0 @davedelong committed Apr 27, 2011
Showing with 49 additions and 45 deletions.
  1. +4 −4 CHLayoutManager.h
  2. +19 −19 CHLayoutManager.m
  3. +11 −11 CHLayoutManagerAppDelegate.m
  4. +3 −3 NSView+CHLayout.h
  5. +6 −6 NSView+CHLayout.m
  6. +6 −2 README.markdown
View
@@ -38,11 +38,11 @@
+ (id) sharedLayoutManager;
-- (void) removeAllConstraints;
+- (void) removeAllLayoutConstraints;
-- (void) addConstraint:(CHLayoutConstraint *)constraint toView:(NSView *)view;
-- (void) removeConstraintsFromView:(NSView *)view;
-- (NSArray *) constraintsOnView:(NSView *)view;
+- (void) addLayoutConstraint:(CHLayoutConstraint *)constraint toView:(NSView *)view;
+- (void) removeLayoutConstraintsFromView:(NSView *)view;
+- (NSArray *) layoutConstraintsOnView:(NSView *)view;
- (NSString *) layoutNameForView:(NSView *)view;
- (void) setLayoutName:(NSString *)name forView:(NSView *)view;
View
@@ -31,16 +31,16 @@ of this software and associated documentation files (the "Software"), to deal
@interface CHLayoutContainer : NSObject
{
NSString * layoutName;
- NSMutableArray * constraints;
+ NSMutableArray * layoutConstraints;
}
@property (nonatomic, copy) NSString * layoutName;
-@property (readonly) NSMutableArray * constraints;
+@property (readonly) NSMutableArray * layoutConstraints;
@end
@implementation CHLayoutContainer
-@synthesize layoutName, constraints;
+@synthesize layoutName, layoutConstraints;
+ (id) container {
return [[[self alloc] init] autorelease];
@@ -49,13 +49,13 @@ + (id) container {
- (id) init {
self = [super init];
if (self) {
- constraints = [[NSMutableArray alloc] init];
+ layoutConstraints = [[NSMutableArray alloc] init];
}
return self;
}
- (void) dealloc {
- [constraints release];
+ [layoutConstraints release];
[layoutName release];
[super dealloc];
}
@@ -138,15 +138,15 @@ - (id) init {
- (void) dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
- [self removeAllConstraints];
+ [self removeAllLayoutConstraints];
[viewsToProcess release];
[processedViews release];
[constraints release];
[super dealloc];
}
-- (void) removeAllConstraints {
+- (void) removeAllLayoutConstraints {
[constraints removeAllObjects];
}
@@ -157,7 +157,7 @@ - (void) processView:(NSView *)aView {
}
[processedViews addObject:aView];
- NSArray * viewConstraints = [self constraintsOnView:aView];
+ NSArray * viewConstraints = [self layoutConstraintsOnView:aView];
for (CHLayoutConstraint * constraint in viewConstraints) {
[constraint applyToTargetView:aView];
}
@@ -175,7 +175,7 @@ - (void) processView:(NSView *)aView {
for (NSView * subview in superSubviews) {
if (subview == aView) { continue; }
- NSArray * subviewConstraints = [self constraintsOnView:subview];
+ NSArray * subviewConstraints = [self layoutConstraintsOnView:subview];
for (CHLayoutConstraint * subviewConstraint in subviewConstraints) {
NSView * sourceView = [subview relativeViewForName:[subviewConstraint sourceName]];
if (sourceView == aView) {
@@ -188,7 +188,7 @@ - (void) processView:(NSView *)aView {
//subviews constrained to this view
NSArray * subviews = [aView subviews];
for (NSView * subview in subviews) {
- NSArray * subviewConstraints = [self constraintsOnView:subview];
+ NSArray * subviewConstraints = [self layoutConstraintsOnView:subview];
for (CHLayoutConstraint * subviewConstraint in subviewConstraints) {
NSView * sourceView = [subview relativeViewForName:[subviewConstraint sourceName]];
if (sourceView == aView) {
@@ -265,38 +265,38 @@ and all is (hopefully) well in the world.
- (void) chlayoutautoremove_dynamicDealloc {
if ([self isKindOfClass:[NSView class]]) { //to prevent people from being stupid
- [[CHLayoutManager sharedLayoutManager] removeConstraintsFromView:(NSView *)self];
+ [[CHLayoutManager sharedLayoutManager] removeLayoutConstraintsFromView:(NSView *)self];
[[CHLayoutManager sharedLayoutManager] setLayoutName:nil forView:(NSView *)self];
//THIS IS NOT A RECURSIVE CALL
//see the big comment above for why
[self chlayoutautoremove_dynamicDealloc];
}
}
-- (void) addConstraint:(CHLayoutConstraint *)constraint toView:(NSView *)view {
+- (void) addLayoutConstraint:(CHLayoutConstraint *)constraint toView:(NSView *)view {
CHLayoutContainer * viewContainer = [constraints objectForKey:view];
if (viewContainer == nil) {
viewContainer = [CHLayoutContainer container];
[constraints setObject:viewContainer forKey:view];
}
- [[viewContainer constraints] addObject:constraint];
+ [[viewContainer layoutConstraints] addObject:constraint];
[self beginProcessingView:view];
}
-- (void) removeConstraintsFromView:(NSView *)view {
+- (void) removeLayoutConstraintsFromView:(NSView *)view {
CHLayoutContainer * viewContainer = [constraints objectForKey:view];
- [[viewContainer constraints] removeAllObjects];
+ [[viewContainer layoutConstraints] removeAllObjects];
- if ([[viewContainer constraints] count] == 0 && [viewContainer layoutName] == nil) {
+ if ([[viewContainer layoutConstraints] count] == 0 && [viewContainer layoutName] == nil) {
[constraints removeObjectForKey:view];
}
}
-- (NSArray *) constraintsOnView:(NSView *)view {
+- (NSArray *) layoutConstraintsOnView:(NSView *)view {
CHLayoutContainer * container = [constraints objectForKey:view];
if (container == nil) { return [NSArray array]; }
- return [[[container constraints] copy] autorelease];
+ return [[[container layoutConstraints] copy] autorelease];
}
- (NSString *) layoutNameForView:(NSView *)view {
@@ -307,7 +307,7 @@ - (NSString *) layoutNameForView:(NSView *)view {
- (void) setLayoutName:(NSString *)name forView:(NSView *)view {
CHLayoutContainer * viewContainer = [constraints objectForKey:view];
- if (name == nil && [[viewContainer constraints] count] == 0) {
+ if (name == nil && [[viewContainer layoutConstraints] count] == 0) {
[constraints removeObjectForKey:view];
} else {
if (viewContainer == nil) {
@@ -36,36 +36,36 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[button1 setLayoutName:@"button1"];
- [button2 addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinX relativeTo:@"button1" attribute:CHLayoutConstraintAttributeMaxX]];
- [button2 addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMaxY relativeTo:@"button1" attribute:CHLayoutConstraintAttributeMaxY]];
- [button2 addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeWidth relativeTo:@"button1" attribute:CHLayoutConstraintAttributeWidth]];
+ [button2 addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinX relativeTo:@"button1" attribute:CHLayoutConstraintAttributeMaxX]];
+ [button2 addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMaxY relativeTo:@"button1" attribute:CHLayoutConstraintAttributeMaxY]];
+ [button2 addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeWidth relativeTo:@"button1" attribute:CHLayoutConstraintAttributeWidth]];
[progress startAnimation:nil];
CHLayoutConstraint * centerHorizontal = [CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMidX relativeTo:@"superview" attribute:CHLayoutConstraintAttributeMidX];
CHLayoutConstraint * centerVertical = [CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMidY relativeTo:@"superview" attribute:CHLayoutConstraintAttributeMidY];
- [progress addConstraint:centerHorizontal];
- [progress addConstraint:centerVertical];
+ [progress addLayoutConstraint:centerHorizontal];
+ [progress addLayoutConstraint:centerVertical];
- [progress addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMidXMidY relativeTo:@"superview" attribute:CHLayoutConstraintAttributeBoundsCenter]];
+ [progress addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMidXMidY relativeTo:@"superview" attribute:CHLayoutConstraintAttributeBoundsCenter]];
[leftVerticalButton setLayoutName:@"leftVertical"];
- [leftVerticalButton addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinX relativeTo:@"superview" attribute:CHLayoutConstraintAttributeMinX offset:37]];
- [rightVerticalButton addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMaxX relativeTo:@"superview" attribute:CHLayoutConstraintAttributeMaxX offset:-13]];
- [rightVerticalButton addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinY relativeTo:@"leftVertical" attribute:CHLayoutConstraintAttributeMinY]];
+ [leftVerticalButton addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinX relativeTo:@"superview" attribute:CHLayoutConstraintAttributeMinX offset:37]];
+ [rightVerticalButton addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMaxX relativeTo:@"superview" attribute:CHLayoutConstraintAttributeMaxX offset:-13]];
+ [rightVerticalButton addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinY relativeTo:@"leftVertical" attribute:CHLayoutConstraintAttributeMinY]];
#if NS_BLOCKS_AVAILABLE
CHLayoutTransformer transformer = ^(CGFloat source) {
CGFloat superViewHeight = [[rightVerticalButton superview] frame].size.height;
return (superViewHeight - source);
};
- [rightVerticalButton addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMaxY relativeTo:@"leftVertical" attribute:CHLayoutConstraintAttributeMinY blockTransformer:transformer]];
+ [rightVerticalButton addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMaxY relativeTo:@"leftVertical" attribute:CHLayoutConstraintAttributeMinY blockTransformer:transformer]];
#endif
// [helpButton addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinX relativeTo:@"leftVertical" attribute:CHLayoutConstraintAttributeMinY scale:2.0 offset:0.0]];
- [helpButton addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMidXMidY relativeTo:@"button1" attribute:CHLayoutConstraintAttributeBoundsCenter]];
+ [helpButton addLayoutConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMidXMidY relativeTo:@"button1" attribute:CHLayoutConstraintAttributeBoundsCenter]];
SinTransformer * sinTransformer = [[SinTransformer alloc] init];
// [helpButton addConstraint:[CHLayoutConstraint constraintWithAttribute:CHLayoutConstraintAttributeMinY relativeTo:@"button1" attribute:CHLayoutConstraintAttributeMinY valueTransformer:sinTransformer]];
View
@@ -31,9 +31,9 @@
- (void) setLayoutName:(NSString *)newLayoutName;
- (NSString *) layoutName;
-- (void) addConstraint:(CHLayoutConstraint *)constraint;
-- (NSArray *) constraints;
-- (void) removeAllConstraints;
+- (void) addLayoutConstraint:(CHLayoutConstraint *)constraint;
+- (NSArray *) layoutConstraints;
+- (void) removeAllLayoutConstraints;
- (NSRect) valueForLayoutAttribute:(CHLayoutConstraintAttribute)attribute;
- (void) setValue:(NSRect)newValue forLayoutAttribute:(CHLayoutConstraintAttribute)attribute;
View
@@ -49,16 +49,16 @@ - (NSString *) layoutName {
return [[CHLayoutManager sharedLayoutManager] layoutNameForView:self];
}
-- (void) addConstraint:(CHLayoutConstraint *)constraint {
- [[CHLayoutManager sharedLayoutManager] addConstraint:constraint toView:self];
+- (void) addLayoutConstraint:(CHLayoutConstraint *)constraint {
+ [[CHLayoutManager sharedLayoutManager] addLayoutConstraint:constraint toView:self];
}
-- (NSArray *) constraints {
- return [[CHLayoutManager sharedLayoutManager] constraintsOnView:self];
+- (NSArray *) layoutConstraints {
+ return [[CHLayoutManager sharedLayoutManager] layoutConstraintsOnView:self];
}
-- (void) removeAllConstraints {
- [[CHLayoutManager sharedLayoutManager] removeConstraintsFromView:self];
+- (void) removeAllLayoutConstraints {
+ [[CHLayoutManager sharedLayoutManager] removeLayoutConstraintsFromView:self];
}
- (NSRect) valueForLayoutAttribute:(CHLayoutConstraintAttribute)attribute {
View
@@ -1,3 +1,5 @@
+**This project is no longer considered under active development, and has been deprecated in favor of built-in API. Please see the "Supported Platforms" section for more information.**
+
#CHLayoutManager
CHLayoutManager is a way to add positioning and sizing constraints on views. The easiest way to understand this is with an example:
@@ -35,7 +37,9 @@ Then `#import "CHLayout.h"` in any .m file that needs to apply constraints to vi
##Supported Platforms
-- Mac OS X 10.5+
+- Mac OS X 10.5 - 10.6.
+
+`CHLayoutManager` will not be supported beyond 10.6. `CHLayoutManager` will work on 10.7, but it is recommended that you use the layout system in 10.7 as opposed to this. While they are compatible, the mechanism in 10.7 is far more flexible.
##Special Considerations
@@ -51,7 +55,7 @@ Then `#import "CHLayout.h"` in any .m file that needs to apply constraints to vi
CHLayoutManager is licensed under the MIT license, which is reproduced in its entirety here:
->Copyright (c) 2010 Dave DeLong
+>Copyright (c) 2011 Dave DeLong
>
>Permission is hereby granted, free of charge, to any person obtaining a copy
>of this software and associated documentation files (the "Software"), to deal

0 comments on commit d65ffa0

Please sign in to comment.