mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
Skeleton of NSLayoutConstraint
This commit is contained in:
parent
58f3d1527b
commit
86e4e58df3
2 changed files with 150 additions and 5 deletions
|
@ -29,7 +29,7 @@
|
|||
#import <Foundation/NSGeometry.h>
|
||||
#import <AppKit/NSLayoutAnchor.h>
|
||||
|
||||
@class NSControl, NSView, NSAnimation, NSArray, NSDictionary;
|
||||
@class NSControl, NSView, NSAnimation, NSArray, NSMutableArray, NSDictionary;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
|
@ -54,7 +54,6 @@ enum {
|
|||
};
|
||||
typedef NSInteger NSLayoutConstraintOrientation;
|
||||
|
||||
|
||||
// Attributes
|
||||
enum {
|
||||
NSLayoutAttributeLeft = 1,
|
||||
|
@ -96,15 +95,27 @@ enum {
|
|||
NSLayoutFormatAlignAllFirstBaseline = (1 << NSLayoutAttributeFirstBaseline),
|
||||
NSLayoutFormatAlignAllBaseline = NSLayoutFormatAlignAllLastBaseline,
|
||||
NSLayoutFormatAlignmentMask = 0xFFFF,
|
||||
NSLayoutFormatDirectionLeadingToTrailing = 0 << 16, // default
|
||||
NSLayoutFormatDirectionLeadingToTrailing = 0 << 16,
|
||||
NSLayoutFormatDirectionLeftToRight = 1 << 16,
|
||||
NSLayoutFormatDirectionRightToLeft = 2 << 16,
|
||||
NSLayoutFormatDirectionMask = 0x3 << 16,
|
||||
};
|
||||
typedef NSUInteger NSLayoutFormatOptions;
|
||||
|
||||
@interface NSLayoutConstraint : NSObject
|
||||
|
||||
@interface NSLayoutConstraint : NSObject
|
||||
{
|
||||
NSLayoutAnchor *_firstAnchor;
|
||||
NSLayoutAnchor *_secondAnchor;
|
||||
id _firstItem;
|
||||
id _secondItem;
|
||||
NSLayoutAttribute _firstAttribute;
|
||||
NSLayoutAttribute _secondAttribute;
|
||||
NSLayoutRelation _relation;
|
||||
CGFloat _multiplier;
|
||||
CGFloat _constant;
|
||||
NSLayoutPriority _priority;
|
||||
}
|
||||
|
||||
+ (NSArray *)constraintsWithVisualFormat: (NSString *)fmt
|
||||
options: (NSLayoutFormatOptions)opt
|
||||
metrics: (NSDictionary *)metrics
|
||||
|
@ -118,6 +129,33 @@ typedef NSUInteger NSLayoutFormatOptions;
|
|||
multiplier: (CGFloat)mult
|
||||
constant: (CGFloat)c;
|
||||
|
||||
// Active
|
||||
- (BOOL) isActive;
|
||||
- (void) setActive: (BOOL)flag;
|
||||
|
||||
+ (void) activateConstraints: (NSArray *)constraints;
|
||||
+ (void) deactivateConstraints: (NSArray *)constraints;
|
||||
|
||||
// Items
|
||||
- (id) firstItem;
|
||||
|
||||
- (NSLayoutAttribute) firstAttribute;
|
||||
|
||||
- (NSLayoutRelation) relation;
|
||||
|
||||
- (id) secondItem;
|
||||
|
||||
- (NSLayoutAttribute) secondAttribute;
|
||||
|
||||
- (CGFloat) multiplier;
|
||||
|
||||
- (CGFloat) constant;
|
||||
|
||||
- (NSLayoutAnchor *) firstAnchor;
|
||||
|
||||
- (NSLayoutAnchor *) secondAnchor;
|
||||
|
||||
- (NSLayoutPriority) priority;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -22,9 +22,116 @@
|
|||
Boston, MA 02110 USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
|
||||
#import "AppKit/NSControl.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSAnimation.h"
|
||||
#import "AppKit/NSLayoutConstraint.h"
|
||||
|
||||
// @class NSControl, NSView, NSAnimation, NSArray, NSMutableArray, NSDictionary;
|
||||
|
||||
static NSMutableArray *activeConstraints;
|
||||
|
||||
@implementation NSLayoutConstraint
|
||||
+ (NSArray *)constraintsWithVisualFormat: (NSString *)fmt
|
||||
options: (NSLayoutFormatOptions)opt
|
||||
metrics: (NSDictionary *)metrics
|
||||
views: (NSDictionary *)views
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (instancetype) constraintWithItem: (id)view1
|
||||
attribute: (NSLayoutAttribute)attr1
|
||||
relatedBy: (NSLayoutRelation)relation
|
||||
toItem: (id)view2
|
||||
attribute: (NSLayoutAttribute)attr2
|
||||
multiplier: (CGFloat)mult
|
||||
constant: (CGFloat)c
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Active
|
||||
- (BOOL) isActive
|
||||
{
|
||||
return [activeConstraints containsObject: self];
|
||||
}
|
||||
|
||||
- (void) setActive: (BOOL)flag
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
[activeConstraints addObject: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[activeConstraints removeObject: self];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) activateConstraints: (NSArray *)constraints
|
||||
{
|
||||
[activeConstraints addObjectsFromArray: constraints];
|
||||
}
|
||||
|
||||
+ (void) deactivateConstraints: (NSArray *)constraints
|
||||
{
|
||||
[activeConstraints removeObjectsInArray: constraints];
|
||||
}
|
||||
|
||||
// Items
|
||||
- (id) firstItem
|
||||
{
|
||||
return _firstItem;
|
||||
}
|
||||
|
||||
- (NSLayoutAttribute) firstAttribute
|
||||
{
|
||||
return _firstAttribute;
|
||||
}
|
||||
|
||||
- (NSLayoutRelation) relation
|
||||
{
|
||||
return _relation;
|
||||
}
|
||||
|
||||
- (id) secondItem
|
||||
{
|
||||
return _secondItem;
|
||||
}
|
||||
|
||||
- (NSLayoutAttribute) secondAttribute
|
||||
{
|
||||
return _secondAttribute;
|
||||
}
|
||||
|
||||
- (CGFloat) multiplier
|
||||
{
|
||||
return _multiplier;
|
||||
}
|
||||
|
||||
- (CGFloat) constant
|
||||
{
|
||||
return _constant;
|
||||
}
|
||||
|
||||
- (NSLayoutAnchor *) firstAnchor
|
||||
{
|
||||
return _firstAnchor;
|
||||
}
|
||||
|
||||
- (NSLayoutAnchor *) secondAnchor
|
||||
{
|
||||
return _secondAnchor;
|
||||
}
|
||||
|
||||
- (NSLayoutPriority) priority
|
||||
{
|
||||
return _priority;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue