forked from Tricertops/KeepLayout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeepTypes.h
58 lines (40 loc) · 1.66 KB
/
KeepTypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// KeepTypes.h
// Keep Layout
//
// Created by Martin Kiss on 28.1.13.
// Copyright (c) 2013 Triceratops. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKit.h>
#define KeepAssert(CONDITION, DESCRIPTION...) NSAssert((CONDITION), @"Keep Layout: " DESCRIPTION)
#define KeepParameterAssert(CONDITION) NSAssert((CONDITION), @"Keep Layout: " @"Invalid parameter not satisfying: %s", #CONDITION)
#pragma mark Priority
/// Use custom names.
typedef enum : NSInteger {
KeepPriorityRequired = UILayoutPriorityRequired,
KeepPriorityHigh = UILayoutPriorityDefaultHigh,
KeepPriorityLow = UILayoutPriorityDefaultLow,
KeepPriorityFitting = UILayoutPriorityFittingSizeLevel,
} KeepPriority;
extern NSString *KeepPriorityDescription(KeepPriority);
#pragma mark Value
/// Represents a value with associated priority. Used as values for attributes and underlaying constraints.
typedef struct {
CGFloat value;
KeepPriority priority;
} KeepValue;
/// Value, that represents no value. KeepValueIsNone will return YES.
extern const KeepValue KeepNone;
/// Returns YES for any value that has real value of CGFLOAT_MIN or priority 0.
extern BOOL KeepValueIsNone(KeepValue);
/// Constructor with arbitrary priority
extern KeepValue KeepValueMake(CGFloat, KeepPriority);
/// Constructors for 4 basic priorities
extern KeepValue KeepRequired(CGFloat);
extern KeepValue KeepHigh(CGFloat);
extern KeepValue KeepLow(CGFloat);
extern KeepValue KeepFitting(CGFloat);
/// Debug description (example “42@750”, or just “42” if priority is Required)
extern NSString *KeepValueDescription(KeepValue);