Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ios
/
Masonry
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Nikolay Tymchenko
11 years ago
Commit
664a0727e3833aaa7066adac7b90bba0e6c08659
1 parent
db4657d1
Added back public MASConstraint constant setters, cleanup
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
89 deletions
Masonry/MASCompositeConstraint.m
Masonry/MASConstraint.h
Masonry/MASConstraint.m
Masonry/MASViewConstraint.m
Masonry/MASCompositeConstraint.m
View file @
664a072
...
...
@@ -107,15 +107,27 @@
#pragma mark - NSLayoutConstraint constant setters
-
(
void
)
set
ValueOffset
:
(
id
)
offset
{
-
(
void
)
set
Insets
:
(
MASEdgeInsets
)
insets
{
for
(
MASConstraint
*
constraint
in
self
.
childConstraints
)
{
constraint
.
valueOffset
=
offset
;
constraint
.
insets
=
insets
;
}
}
-
(
void
)
set
Insets
:
(
MASEdgeInsets
)
insets
{
-
(
void
)
set
Offset
:
(
CGFloat
)
offset
{
for
(
MASConstraint
*
constraint
in
self
.
childConstraints
)
{
constraint
.
insets
=
insets
;
constraint
.
offset
=
offset
;
}
}
-
(
void
)
setSizeOffset
:
(
CGSize
)
sizeOffset
{
for
(
MASConstraint
*
constraint
in
self
.
childConstraints
)
{
constraint
.
sizeOffset
=
sizeOffset
;
}
}
-
(
void
)
setCenterOffset
:
(
CGPoint
)
centerOffset
{
for
(
MASConstraint
*
constraint
in
self
.
childConstraints
)
{
constraint
.
centerOffset
=
centerOffset
;
}
}
...
...
Masonry/MASConstraint.h
View file @
664a072
...
...
@@ -22,6 +22,13 @@
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
*/
-
(
MASConstraint
*
(
^
)(
MASEdgeInsets
insets
))
insets
;
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeWidth, NSLayoutAttributeHeight
*/
-
(
MASConstraint
*
(
^
)(
CGSize
offset
))
sizeOffset
;
...
...
@@ -38,16 +45,6 @@
*/
-
(
MASConstraint
*
(
^
)(
CGFloat
offset
))
offset
;
// TODO: describe
-
(
MASConstraint
*
(
^
)(
id
value
))
_valueOffset
;
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
*/
-
(
MASConstraint
*
(
^
)(
MASEdgeInsets
insets
))
insets
;
/**
* Sets the NSLayoutConstraint multiplier property
*/
...
...
@@ -102,12 +99,8 @@
*/
-
(
MASConstraint
*
(
^
)(
id
attr
))
lessThanOrEqualTo
;
// TODO: description
// TODO: update docs for the methods above
-
(
MASConstraint
*
(
^
)(
id
attr
,
NSLayoutRelation
relation
))
_equalToWithRelation
;
/**
*
o
ptional semantic property which has no effect but improves the readability of constraint
*
O
ptional semantic property which has no effect but improves the readability of constraint
*/
-
(
MASConstraint
*
)
with
;
...
...
@@ -120,9 +113,6 @@
// NSLayoutConstraint constant Setters
// for use outside of mas_updateConstraints/mas_makeConstraints blocks
// TODO: describe
-
(
void
)
setValueOffset
:(
id
)
offset
;
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
...
...
@@ -130,6 +120,26 @@
*/
-
(
void
)
setInsets
:(
MASEdgeInsets
)
insets
;
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeWidth, NSLayoutAttributeHeight
*/
-
(
void
)
setSizeOffset
:(
CGSize
)
sizeOffset
;
/**
* Modifies the NSLayoutConstraint constant,
* only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
* NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
*/
-
(
void
)
setCenterOffset
:(
CGPoint
)
centerOffset
;
/**
* Modifies the NSLayoutConstraint constant
*/
-
(
void
)
setOffset
:(
CGFloat
)
offset
;
// NSLayoutConstraint Installation support
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
...
...
@@ -161,6 +171,22 @@
@end
@interface
MASConstraint
(
Private
)
// TODO: describe
-
(
MASConstraint
*
(
^
)(
id
))
_valueOffset
;
// TODO: describe
-
(
void
)
_setLayoutConstantWithValue
:(
NSValue
*
)
value
;
// TODO: description
// TODO: update docs for the methods above
-
(
MASConstraint
*
(
^
)(
id
attr
,
NSLayoutRelation
relation
))
_equalToWithRelation
;
@end
@protocol
MASConstraintDelegate
<
NSObject
>
/**
...
...
Masonry/MASConstraint.m
View file @
664a072
...
...
@@ -66,39 +66,62 @@
#pragma mark - NSLayoutConstraint constant proxies
-
(
MASConstraint
*
(
^
)(
MASEdgeInsets
))
insets
{
return
^
id
(
MASEdgeInsets
insets
){
self
.
insets
=
insets
;
return
self
;
};
}
-
(
MASConstraint
*
(
^
)(
CGSize
))
sizeOffset
{
return
^
id
(
CGSize
offset
)
{
self
.
valueOffset
=
MASBoxValue
(
offset
)
;
self
.
sizeOffset
=
offset
;
return
self
;
};
}
-
(
MASConstraint
*
(
^
)(
CGPoint
))
centerOffset
{
return
^
id
(
CGPoint
offset
)
{
self
.
valueOffset
=
MASBoxValue
(
offset
)
;
self
.
centerOffset
=
offset
;
return
self
;
};
}
-
(
MASConstraint
*
(
^
)(
CGFloat
))
offset
{
return
^
id
(
CGFloat
offset
){
self
.
valueOffset
=
MASBoxValue
(
offset
)
;
self
.
offset
=
offset
;
return
self
;
};
}
-
(
MASConstraint
*
(
^
)(
id
))
_valueOffset
{
return
^
id
(
id
offset
)
{
self
.
valueOffset
=
offset
;
NSAssert
([
offset
isKindOfClass
:
NSValue
.
class
],
@"expected an NSValue offset, got: %@"
,
offset
);
[
self
_setLayoutConstantWithValue
:
offset
];
return
self
;
};
}
-
(
MASConstraint
*
(
^
)(
MASEdgeInsets
))
insets
{
return
^
id
(
MASEdgeInsets
insets
){
#pragma mark - NSLayoutConstraint constant setter
-
(
void
)
_setLayoutConstantWithValue
:
(
NSValue
*
)
value
{
if
([
value
isKindOfClass
:
NSNumber
.
class
])
{
self
.
offset
=
[(
NSNumber
*
)
value
doubleValue
];
}
else
if
(
strcmp
(
value
.
objCType
,
@encode
(
CGPoint
))
==
0
)
{
CGPoint
point
;
[
value
getValue
:
&
point
];
self
.
centerOffset
=
point
;
}
else
if
(
strcmp
(
value
.
objCType
,
@encode
(
CGSize
))
==
0
)
{
CGSize
size
;
[
value
getValue
:
&
size
];
self
.
sizeOffset
=
size
;
}
else
if
(
strcmp
(
value
.
objCType
,
@encode
(
MASEdgeInsets
))
==
0
)
{
MASEdgeInsets
insets
;
[
value
getValue
:
&
insets
];
self
.
insets
=
insets
;
return
self
;
};
}
else
{
NSAssert
(
NO
,
@"attempting to set layout constant with unsupported value: %@"
,
value
);
}
}
#pragma mark - Semantic properties
...
...
@@ -129,10 +152,14 @@
-
(
MASConstraint
*
(
^
)(
id
key
))
key
{
methodNotImplemented
();
}
-
(
void
)
setValueOffset
:
(
id
)
offset
{
methodNotImplemented
();
}
-
(
void
)
setInsets
:
(
MASEdgeInsets
)
insets
{
methodNotImplemented
();
}
-
(
void
)
setSizeOffset
:
(
CGSize
)
sizeOffset
{
methodNotImplemented
();
}
-
(
void
)
setCenterOffset
:
(
CGPoint
)
centerOffset
{
methodNotImplemented
();
}
-
(
void
)
setOffset
:
(
CGFloat
)
offset
{
methodNotImplemented
();
}
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
-
(
MASConstraint
*
)
animator
{
methodNotImplemented
();
}
...
...
Masonry/MASViewConstraint.m
View file @
664a072
...
...
@@ -67,58 +67,6 @@
#endif
}
-
(
void
)
setLayoutConstantWithValue
:(
NSValue
*
)
value
{
if
([
value
isKindOfClass
:
NSNumber
.
class
])
{
self
.
offset
=
[(
NSNumber
*
)
value
doubleValue
];
}
else
if
(
strcmp
(
value
.
objCType
,
@encode
(
CGPoint
))
==
0
)
{
CGPoint
point
;
[
value
getValue
:
&
point
];
self
.
centerOffset
=
point
;
}
else
if
(
strcmp
(
value
.
objCType
,
@encode
(
CGSize
))
==
0
)
{
CGSize
size
;
[
value
getValue
:
&
size
];
self
.
sizeOffset
=
size
;
}
else
if
(
strcmp
(
value
.
objCType
,
@encode
(
MASEdgeInsets
))
==
0
)
{
MASEdgeInsets
insets
;
[
value
getValue
:
&
insets
];
self
.
insets
=
insets
;
}
else
{
NSAssert
(
NO
,
@"attempting to set layout constant with unsupported value: %@"
,
value
);
}
}
-
(
void
)
setOffset
:(
CGFloat
)
offset
{
self
.
layoutConstant
=
offset
;
}
-
(
void
)
setSizeOffset
:(
CGSize
)
sizeOffset
{
NSLayoutAttribute
layoutAttribute
=
self
.
firstViewAttribute
.
layoutAttribute
;
switch
(
layoutAttribute
)
{
case
NSLayoutAttributeWidth
:
self
.
layoutConstant
=
sizeOffset
.
width
;
break
;
case
NSLayoutAttributeHeight
:
self
.
layoutConstant
=
sizeOffset
.
height
;
break
;
default:
break
;
}
}
-
(
void
)
setCenterOffset
:(
CGPoint
)
centerOffset
{
NSLayoutAttribute
layoutAttribute
=
self
.
firstViewAttribute
.
layoutAttribute
;
switch
(
layoutAttribute
)
{
case
NSLayoutAttributeCenterX
:
self
.
layoutConstant
=
centerOffset
.
x
;
break
;
case
NSLayoutAttributeCenterY
:
self
.
layoutConstant
=
centerOffset
.
y
;
break
;
default:
break
;
}
}
-
(
void
)
setLayoutRelation
:(
NSLayoutRelation
)
layoutRelation
{
_layoutRelation
=
layoutRelation
;
self
.
hasLayoutRelation
=
YES
;
...
...
@@ -130,7 +78,7 @@
-
(
void
)
setSecondViewAttribute
:
(
id
)
secondViewAttribute
{
if
([
secondViewAttribute
isKindOfClass
:
NSValue
.
class
])
{
[
self
setLayoutConstantWithValue
:
secondViewAttribute
];
[
self
_
setLayoutConstantWithValue
:
secondViewAttribute
];
}
else
if
([
secondViewAttribute
isKindOfClass
:
MAS_VIEW
.
class
])
{
_secondViewAttribute
=
[[
MASViewAttribute
alloc
]
initWithView
:
secondViewAttribute
layoutAttribute
:
self
.
firstViewAttribute
.
layoutAttribute
];
}
else
if
([
secondViewAttribute
isKindOfClass
:
MASViewAttribute
.
class
])
{
...
...
@@ -222,10 +170,6 @@
#pragma mark - NSLayoutConstraint constant setters
-
(
void
)
setValueOffset
:
(
id
)
offset
{
[
self
setLayoutConstantWithValue
:
offset
];
}
-
(
void
)
setInsets
:
(
MASEdgeInsets
)
insets
{
NSLayoutAttribute
layoutAttribute
=
self
.
firstViewAttribute
.
layoutAttribute
;
switch
(
layoutAttribute
)
{
...
...
@@ -246,6 +190,38 @@
}
}
-
(
void
)
setOffset
:
(
CGFloat
)
offset
{
self
.
layoutConstant
=
offset
;
}
-
(
void
)
setSizeOffset
:
(
CGSize
)
sizeOffset
{
NSLayoutAttribute
layoutAttribute
=
self
.
firstViewAttribute
.
layoutAttribute
;
switch
(
layoutAttribute
)
{
case
NSLayoutAttributeWidth
:
self
.
layoutConstant
=
sizeOffset
.
width
;
break
;
case
NSLayoutAttributeHeight
:
self
.
layoutConstant
=
sizeOffset
.
height
;
break
;
default
:
break
;
}
}
-
(
void
)
setCenterOffset
:
(
CGPoint
)
centerOffset
{
NSLayoutAttribute
layoutAttribute
=
self
.
firstViewAttribute
.
layoutAttribute
;
switch
(
layoutAttribute
)
{
case
NSLayoutAttributeCenterX
:
self
.
layoutConstant
=
centerOffset
.
x
;
break
;
case
NSLayoutAttributeCenterY
:
self
.
layoutConstant
=
centerOffset
.
y
;
break
;
default
:
break
;
}
}
#pragma mark - MASConstraint
-
(
void
)
install
{
...
...
Please
register
or
login
to post a comment