Authored by Paulo F. Andrade

Adding support for the animator proxy on OS X

@@ -165,6 +165,22 @@ @@ -165,6 +165,22 @@
165 return self; 165 return self;
166 } 166 }
167 167
  168 +#pragma mark - Animator proxy
  169 +
  170 +#if TARGET_OS_MAC && !TARGET_OS_IPHONE
  171 +
  172 +- (id<MASConstraint>)animator
  173 +{
  174 + for (id<MASConstraint> constraint in self.childConstraints) {
  175 +#pragma clang diagnostic push
  176 +#pragma clang diagnostic ignored "-Wunused-value"
  177 + constraint.animator;
  178 +#pragma clang diagnostic pop
  179 + }
  180 + return self;
  181 +}
  182 +#endif
  183 +
168 #pragma mark - debug helpers 184 #pragma mark - debug helpers
169 185
170 - (id<MASConstraint> (^)(id))key { 186 - (id<MASConstraint> (^)(id))key {
@@ -113,6 +113,13 @@ @@ -113,6 +113,13 @@
113 */ 113 */
114 @property (nonatomic, copy, readonly) id<MASConstraint> (^key)(id key); 114 @property (nonatomic, copy, readonly) id<MASConstraint> (^key)(id key);
115 115
  116 +#if TARGET_OS_MAC && !TARGET_OS_IPHONE
  117 +/**
  118 + * Whether or not to go through the animator proxy when modifying the constraint
  119 + */
  120 +@property (nonatomic, copy, readonly) id<MASConstraint> animator;
  121 +#endif
  122 +
116 /** 123 /**
117 * Whether or not to check for an existing constraint instead of adding constraint 124 * Whether or not to check for an existing constraint instead of adding constraint
118 */ 125 */
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 @property (nonatomic, assign) CGFloat layoutConstant; 22 @property (nonatomic, assign) CGFloat layoutConstant;
23 @property (nonatomic, assign) BOOL hasLayoutRelation; 23 @property (nonatomic, assign) BOOL hasLayoutRelation;
24 @property (nonatomic, strong) id mas_key; 24 @property (nonatomic, strong) id mas_key;
  25 +@property (nonatomic, assign) BOOL useAnimator;
25 26
26 @end 27 @end
27 28
@@ -57,7 +58,16 @@ @@ -57,7 +58,16 @@
57 58
58 - (void)setLayoutConstant:(CGFloat)layoutConstant { 59 - (void)setLayoutConstant:(CGFloat)layoutConstant {
59 _layoutConstant = layoutConstant; 60 _layoutConstant = layoutConstant;
  61 +
  62 +#if TARGET_OS_MAC && !TARGET_OS_IPHONE
  63 + if(self.useAnimator) {
  64 + self.layoutConstraint.animator.constant = layoutConstant;
  65 + } else {
60 self.layoutConstraint.constant = layoutConstant; 66 self.layoutConstraint.constant = layoutConstant;
  67 + }
  68 +#else
  69 + self.layoutConstraint.constant = layoutConstant;
  70 +#endif
61 } 71 }
62 72
63 - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation { 73 - (void)setLayoutRelation:(NSLayoutRelation)layoutRelation {
@@ -247,6 +257,18 @@ @@ -247,6 +257,18 @@
247 return self; 257 return self;
248 } 258 }
249 259
  260 +#pragma mark - Animator proxy
  261 +
  262 +#if TARGET_OS_MAC && !TARGET_OS_IPHONE
  263 +
  264 +- (id<MASConstraint>)animator
  265 +{
  266 + self.useAnimator = YES;
  267 + return self;
  268 +}
  269 +
  270 +#endif
  271 +
250 #pragma mark - debug helpers 272 #pragma mark - debug helpers
251 273
252 - (id<MASConstraint> (^)(id))key { 274 - (id<MASConstraint> (^)(id))key {