Skip to content

Commit

Permalink
mac osx support
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudkite committed Aug 19, 2013
1 parent cf2def3 commit e54dec5
Show file tree
Hide file tree
Showing 50 changed files with 702 additions and 223 deletions.
426 changes: 384 additions & 42 deletions Masonry.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions Masonry.xcodeproj/xcshareddata/xcschemes/Masonry Mac.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0460"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DDA4D6EA17C0253B0076BD87"
BuildableName = "Masonry Mac.framework"
BlueprintName = "Masonry Mac"
ReferencedContainer = "container:Masonry.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DDA4D70017C0253B0076BD87"
BuildableName = "Masonry Mac Tests.octest"
BlueprintName = "Masonry Mac Tests"
ReferencedContainer = "container:Masonry.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DD52F1A9179CA93B005CD195"
BuildableName = "libMasonry.a"
BlueprintName = "Masonry"
BuildableName = "libMasonry iOS.a"
BlueprintName = "Masonry iOS"
ReferencedContainer = "container:Masonry.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -47,8 +47,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DD52F1BA179CA93B005CD195"
BuildableName = "MasonryTests.octest"
BlueprintName = "MasonryTests"
BuildableName = "Masonry iOS Tests.octest"
BlueprintName = "Masonry iOS Tests"
ReferencedContainer = "container:Masonry.xcodeproj">
</BuildableReference>
</TestableReference>
Expand Down
2 changes: 1 addition & 1 deletion Masonry.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Masonry/MASCompositeConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright (c) 2013 cloudling. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MASConstraint.h"
#import "MASUtilities.h"

typedef NS_ENUM(NSInteger, MASCompositeConstraintType) {
MASCompositeConstraintTypeEdges, //top, left, bottom, right
Expand All @@ -25,7 +25,7 @@ typedef NS_ENUM(NSInteger, MASCompositeConstraintType) {
/**
* default first item for any child MASConstraints
*/
@property (nonatomic, weak, readonly) UIView *view;
@property (nonatomic, weak, readonly) MAS_VIEW *view;

/**
* type of Composite, used internally to generate child MASViewConstraits
Expand All @@ -41,7 +41,7 @@ typedef NS_ENUM(NSInteger, MASCompositeConstraintType) {
*
* @return a composite constraint
*/
- (id)initWithView:(UIView *)view type:(MASCompositeConstraintType)type;
- (id)initWithView:(MAS_VIEW *)view type:(MASCompositeConstraintType)type;

/**
* Creates a composite with a predefined array of children
Expand All @@ -51,6 +51,6 @@ typedef NS_ENUM(NSInteger, MASCompositeConstraintType) {
*
* @return a composite constraint
*/
- (id)initWithView:(UIView *)view children:(NSArray *)children;
- (id)initWithView:(MAS_VIEW *)view children:(NSArray *)children;

@end
12 changes: 6 additions & 6 deletions Masonry/MASCompositeConstraint.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "MASCompositeConstraint.h"
#import "UIView+MASAdditions.h"
#import "View+MASAdditions.h"
#import "MASViewConstraint.h"

@interface MASCompositeConstraint () <MASConstraintDelegate>
Expand All @@ -21,7 +21,7 @@ @implementation MASCompositeConstraint

@synthesize delegate = _delegate;

- (id)initWithView:(UIView *)view type:(MASCompositeConstraintType)type {
- (id)initWithView:(MAS_VIEW *)view type:(MASCompositeConstraintType)type {
self = [super init];
if (!self) return nil;

Expand All @@ -33,7 +33,7 @@ - (id)initWithView:(UIView *)view type:(MASCompositeConstraintType)type {
return self;
}

- (id)initWithView:(UIView *)view children:(NSArray *)children {
- (id)initWithView:(MAS_VIEW *)view children:(NSArray *)children {
self = [super init];
if (!self) return nil;

Expand Down Expand Up @@ -82,15 +82,15 @@ - (void)createChildren {
#pragma mark - MASConstraintDelegate

- (void)constraint:(id<MASConstraint>)constraint shouldBeReplacedWithConstraint:(id<MASConstraint>)replacementConstraint {
int index = [self.childConstraints indexOfObject:constraint];
NSUInteger index = [self.childConstraints indexOfObject:constraint];
NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
[self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint];
}

#pragma mark - NSLayoutConstraint constant proxies

- (id<MASConstraint> (^)(UIEdgeInsets))insets {
return ^id(UIEdgeInsets insets) {
- (id<MASConstraint> (^)(MASEdgeInsets))insets {
return ^id(MASEdgeInsets insets) {
for (id<MASConstraint> constraint in self.childConstraints) {
constraint.insets(insets);
}
Expand Down
13 changes: 2 additions & 11 deletions Masonry/MASConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@
// Copyright (c) 2013 cloudling. All rights reserved.
//

#import <UIKit/UIKit.h>

enum {
MASLayoutPriorityRequired = UILayoutPriorityRequired,
MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh,
MASLayoutPriorityDefaultMedium = 500,
MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow,
MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel,
};
typedef float MASLayoutPriority;
#import "MASUtilities.h"

@protocol MASConstraintDelegate;

Expand All @@ -36,7 +27,7 @@ typedef float MASLayoutPriority;
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
*/
@property (nonatomic, copy, readonly) id<MASConstraint> (^insets)(UIEdgeInsets insets);
@property (nonatomic, copy, readonly) id<MASConstraint> (^insets)(MASEdgeInsets insets);

/**
* Modifies the NSLayoutConstraint constant,
Expand Down
4 changes: 2 additions & 2 deletions Masonry/MASConstraintMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Copyright (c) 2013 cloudling. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MASConstraint.h"
#import "MASUtilities.h"

@interface MASConstraintMaker : NSObject

Expand Down Expand Up @@ -55,7 +55,7 @@
*
* @return a new MASConstraintMaker
*/
- (id)initWithView:(UIView *)view;
- (id)initWithView:(MAS_VIEW *)view;

/**
* Calls commit method on any MASConstraints which requested to be added view MASConstraintDelegate
Expand Down
6 changes: 3 additions & 3 deletions Masonry/MASConstraintMaker.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

@interface MASConstraintMaker () <MASConstraintDelegate>

@property (nonatomic, weak) UIView *view;
@property (nonatomic, weak) MAS_VIEW *view;
@property (nonatomic, strong) NSMutableArray *constraints;

@end

@implementation MASConstraintMaker

- (id)initWithView:(UIView *)view {
- (id)initWithView:(MAS_VIEW *)view {
self = [super init];
if (!self) return nil;

Expand All @@ -40,7 +40,7 @@ - (void)commit {
#pragma mark - MASConstraintDelegate

- (void)constraint:(id<MASConstraint>)constraint shouldBeReplacedWithConstraint:(id<MASConstraint>)replacementConstraint {
int index = [self.constraints indexOfObject:constraint];
NSUInteger index = [self.constraints indexOfObject:constraint];
NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
[self.constraints replaceObjectAtIndex:index withObject:replacementConstraint];
}
Expand Down
3 changes: 1 addition & 2 deletions Masonry/MASLayoutConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
// Copyright (c) 2013 Jonas Budelmann. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "MASUtilities.h"
/**
* When you are debugging or printing the constraints attached to a view this subclass
* makes it easier to identify which constraints have been created via Masonry
Expand Down
60 changes: 60 additions & 0 deletions Masonry/MASUtilities.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// MASUtilities.h
// Masonry
//
// Created by Jonas Budelmann on 19/08/13.
// Copyright (c) 2013 Jonas Budelmann. All rights reserved.
//

#if TARGET_OS_IPHONE

#import <UIKit/UIKit.h>
#define MAS_VIEW UIView
#define MASEdgeInsets UIEdgeInsets

enum {
MASLayoutPriorityRequired = UILayoutPriorityRequired,
MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh,
MASLayoutPriorityDefaultMedium = 500,
MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow,
MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel,
};
typedef float MASLayoutPriority;

#elif TARGET_OS_MAC

#import <AppKit/AppKit.h>
#define MAS_VIEW NSView
#define MASEdgeInsets NSEdgeInsets

enum {
MASLayoutPriorityRequired = NSLayoutPriorityRequired,
MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh,
MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow,
MASLayoutPriorityDefaultMedium = 501,
MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut,
MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow,
MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow,
MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression,
};
typedef float MASLayoutPriority;

#endif

/**
* Allows you to attach keys to objects matching the variable names passed.
*
* view1.mas_key = @"view1", view2.mas_key = @"view2";
*
* is equivalent to:
*
* MASAttachKeys(view1, view2);
*/
#define MASAttachKeys(...) \
NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \
for (id key in keyPairs.allKeys) { \
id obj = keyPairs[key]; \
NSAssert([obj respondsToSelector:@selector(setMas_key:)], \
@"Cannot attach mas_key to %@", obj); \
[obj setMas_key:key]; \
}
6 changes: 3 additions & 3 deletions Masonry/MASViewAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
// Copyright (c) 2013 cloudling. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MASUtilities.h"

@interface MASViewAttribute : NSObject

@property (nonatomic, weak, readonly) UIView *view;
@property (nonatomic, weak, readonly) MAS_VIEW *view;
@property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;

- (id)initWithView:(UIView *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
- (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;

/**
* Determine whether the layoutAttribute is a size attribute
Expand Down
2 changes: 1 addition & 1 deletion Masonry/MASViewAttribute.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@implementation MASViewAttribute

- (id)initWithView:(UIView *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
- (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
self = [super init];
if (!self) return nil;

Expand Down
Loading

0 comments on commit e54dec5

Please sign in to comment.