//
//  YSMASConstraint+Private.h
//  Masonry
//
//  Created by Nick Tymchenko on 29/04/14.
//  Copyright (c) 2014 cloudling. All rights reserved.
//

#import "YSMASConstraint.h"

@protocol YSMASConstraintDelegate;


@interface YSMASConstraint ()

/**
 *  Whether or not to check for an existing constraint instead of adding constraint
 */
@property (nonatomic, assign) BOOL updateExisting;

/**
 *	Usually YSMASConstraintMaker but could be a parent YSMASConstraint
 */
@property (nonatomic, weak) id<YSMASConstraintDelegate> delegate;

/**
 *  Based on a provided value type, is equal to calling:
 *  NSNumber - setOffset:
 *  NSValue with CGPoint - setPointOffset:
 *  NSValue with CGSize - setSizeOffset:
 *  NSValue with YSMASEdgeInsets - setInsets:
 */
- (void)setLayoutConstantWithValue:(NSValue *)value;

@end


@interface YSMASConstraint (Abstract)

/**
 *	Sets the constraint relation to given NSLayoutRelation
 *  returns a block which accepts one of the following:
 *    YSMASViewAttribute, UIView, NSValue, NSArray
 *  see readme for more details.
 */
- (YSMASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;

/**
 *	Override to set a custom chaining behaviour
 */
- (YSMASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;

@end


@protocol YSMASConstraintDelegate <NSObject>

/**
 *	Notifies the delegate when the constraint needs to be replaced with another constraint. For example
 *  A YSMASViewConstraint may turn into a YSMASCompositeConstraint when an array is passed to one of the equality blocks
 */
- (void)constraint:(YSMASConstraint *)constraint shouldBeReplacedWithConstraint:(YSMASConstraint *)replacementConstraint;

- (YSMASConstraint *)constraint:(YSMASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;

@end
