mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
Changes in GSXib5KeyedUnarchiver to decode constraints.
This commit is contained in:
commit
474e87d2ad
5 changed files with 115 additions and 45 deletions
|
@ -1,3 +1,4 @@
|
|||
<<<<<<< HEAD
|
||||
2020-05-31 Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Headers/AppKit/AppKit.h: Add to .h file
|
||||
|
@ -10,6 +11,13 @@
|
|||
* Source/NSLayoutConstraint.m: Layout constraint.
|
||||
* Source/NSLayoutGuide.m: Constraints guide implementation.
|
||||
|
||||
=======
|
||||
2020-06-12 Yavor Doganov <yavor@gnu.org>
|
||||
|
||||
* Headers/AppKit/NSApplication.h: Remove semicolons from the
|
||||
NSAppKitVersionNumber* definitions.
|
||||
|
||||
>>>>>>> 488f7096fb586422be13c41a474339161802dd1f
|
||||
2020-05-29 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* TextConverters/RTF/rtfGrammar.y: Correct encoding handling.
|
||||
|
|
|
@ -125,34 +125,34 @@ typedef NSUInteger NSRequestUserAttentionType;
|
|||
#define NSAppKitVersionNumber10_5_3 949.33
|
||||
#define NSAppKitVersionNumber10_6 1038
|
||||
#define NSAppKitVersionNumber10_7 1138
|
||||
#define NSAppKitVersionNumber10_7_2 1138.23;
|
||||
#define NSAppKitVersionNumber10_7_3 1138.32;
|
||||
#define NSAppKitVersionNumber10_7_4 1138.47;
|
||||
#define NSAppKitVersionNumber10_8 1187;
|
||||
#define NSAppKitVersionNumber10_9 1265;
|
||||
#define NSAppKitVersionNumber10_10 1343;
|
||||
#define NSAppKitVersionNumber10_10_2 1344;
|
||||
#define NSAppKitVersionNumber10_10_3 1347;
|
||||
#define NSAppKitVersionNumber10_10_4 1348;
|
||||
#define NSAppKitVersionNumber10_10_5 1348;
|
||||
#define NSAppKitVersionNumber10_10_Max 1349;
|
||||
#define NSAppKitVersionNumber10_11 1404;
|
||||
#define NSAppKitVersionNumber10_11_1 1404.13;
|
||||
#define NSAppKitVersionNumber10_11_2 1404.34;
|
||||
#define NSAppKitVersionNumber10_11_3 1404.34;
|
||||
#define NSAppKitVersionNumber10_12 1504;
|
||||
#define NSAppKitVersionNumber10_12_1 1504.60;
|
||||
#define NSAppKitVersionNumber10_12_2 1504.76;
|
||||
#define NSAppKitVersionNumber10_13 1561;
|
||||
#define NSAppKitVersionNumber10_13_1 1561.1;
|
||||
#define NSAppKitVersionNumber10_13_2 1561.2;
|
||||
#define NSAppKitVersionNumber10_13_4 1561.4;
|
||||
#define NSAppKitVersionNumber10_14 1671;
|
||||
#define NSAppKitVersionNumber10_14_1 1671.1;
|
||||
#define NSAppKitVersionNumber10_14_2 1671.2;
|
||||
#define NSAppKitVersionNumber10_14_3 1671.3;
|
||||
#define NSAppKitVersionNumber10_14_4 1671.4;
|
||||
#define NSAppKitVersionNumber10_14_5 1671.5;
|
||||
#define NSAppKitVersionNumber10_7_2 1138.23
|
||||
#define NSAppKitVersionNumber10_7_3 1138.32
|
||||
#define NSAppKitVersionNumber10_7_4 1138.47
|
||||
#define NSAppKitVersionNumber10_8 1187
|
||||
#define NSAppKitVersionNumber10_9 1265
|
||||
#define NSAppKitVersionNumber10_10 1343
|
||||
#define NSAppKitVersionNumber10_10_2 1344
|
||||
#define NSAppKitVersionNumber10_10_3 1347
|
||||
#define NSAppKitVersionNumber10_10_4 1348
|
||||
#define NSAppKitVersionNumber10_10_5 1348
|
||||
#define NSAppKitVersionNumber10_10_Max 1349
|
||||
#define NSAppKitVersionNumber10_11 1404
|
||||
#define NSAppKitVersionNumber10_11_1 1404.13
|
||||
#define NSAppKitVersionNumber10_11_2 1404.34
|
||||
#define NSAppKitVersionNumber10_11_3 1404.34
|
||||
#define NSAppKitVersionNumber10_12 1504
|
||||
#define NSAppKitVersionNumber10_12_1 1504.60
|
||||
#define NSAppKitVersionNumber10_12_2 1504.76
|
||||
#define NSAppKitVersionNumber10_13 1561
|
||||
#define NSAppKitVersionNumber10_13_1 1561.1
|
||||
#define NSAppKitVersionNumber10_13_2 1561.2
|
||||
#define NSAppKitVersionNumber10_13_4 1561.4
|
||||
#define NSAppKitVersionNumber10_14 1671
|
||||
#define NSAppKitVersionNumber10_14_1 1671.1
|
||||
#define NSAppKitVersionNumber10_14_2 1671.2
|
||||
#define NSAppKitVersionNumber10_14_3 1671.3
|
||||
#define NSAppKitVersionNumber10_14_4 1671.4
|
||||
#define NSAppKitVersionNumber10_14_5 1671.5
|
||||
|
||||
APPKIT_EXPORT const double NSAppKitVersionNumber;
|
||||
#endif
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
{
|
||||
GSXibElement *_IBObjectContainer;
|
||||
GSXibElement *_connectionRecords;
|
||||
GSXibElement *_constraints;
|
||||
GSXibElement *_objectRecords;
|
||||
GSXibElement *_orderedObjects;
|
||||
GSXibElement *_flattenedProperties;
|
||||
|
|
|
@ -169,6 +169,7 @@ static NSDictionary *XmlKeyToDecoderSelectorMap = nil;
|
|||
static NSArray *XmlKeysDefined = nil;
|
||||
static NSArray *XmlReferenceAttributes = nil;
|
||||
static NSArray *XmlConnectionRecordTags = nil;
|
||||
static NSArray *XmlConstraintRecordTags = nil;
|
||||
static NSArray *XmlBoolDefaultYes = nil;
|
||||
|
||||
+ (void) initialize
|
||||
|
@ -230,6 +231,9 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
XmlConnectionRecordTags = [NSArray arrayWithObjects: @"action", @"outlet", @"binding", nil];
|
||||
RETAIN(XmlConnectionRecordTags);
|
||||
|
||||
XmlConstraintRecordTags = [NSArray arrayWithObject: @"constraint"];
|
||||
RETAIN(XmlConstraintRecordTags);
|
||||
|
||||
// These cross-reference from the OLD key to the NEW key that can be referenced and its value
|
||||
// or object returned verbatim. If an OLD XIB key does not exist and contains the 'NS' prefix
|
||||
// the key processing will strip the 'NS' prefix, make the first letter lowercase then check
|
||||
|
@ -509,7 +513,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
forKey: @"destination"];
|
||||
}
|
||||
|
||||
// Build a connection recort
|
||||
// Build a connection record
|
||||
connectionRecord = [[GSXibElement alloc] initWithType: @"object"
|
||||
andAttributes:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
|
@ -666,6 +670,10 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
andAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"connectionRecords", @"key",
|
||||
nil]];
|
||||
_constraints = [[GSXibElement alloc] initWithType: @"array"
|
||||
andAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"constraints", @"key",
|
||||
nil]];
|
||||
_flattenedProperties = [[GSXibElement alloc] initWithType: @"dictionary"
|
||||
andAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"NSMutableDictionary", @"class",
|
||||
|
@ -691,6 +699,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
// Create the linked set of XIB elements...
|
||||
[_IBObjectContainer setElement: _connectionRecords forKey: @"connectionRecords"];
|
||||
[_IBObjectContainer setElement: _objectRecords forKey: @"objectRecords"];
|
||||
[_IBObjectContainer setElement: _constraints forKey: @"constraints"];
|
||||
[_IBObjectContainer setElement: _flattenedProperties forKey: @"flattenedProperties"];
|
||||
}
|
||||
|
||||
|
@ -698,6 +707,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
{
|
||||
RELEASE(_IBObjectContainer);
|
||||
RELEASE(_connectionRecords);
|
||||
RELEASE(_constraints);
|
||||
RELEASE(_objectRecords);
|
||||
RELEASE(_flattenedProperties);
|
||||
RELEASE(_runtimeAttributes);
|
||||
|
@ -791,6 +801,10 @@ didStartElement: (NSString*)elementName
|
|||
// Need to store element for making the connections...
|
||||
[self addConnection: element];
|
||||
}
|
||||
else if ([XmlConstraintRecordTags containsObject: elementName])
|
||||
{
|
||||
[self objectForXib: element]; // decode the constraint...
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2777,12 +2791,6 @@ didStartElement: (NSString*)elementName
|
|||
return num;
|
||||
}
|
||||
|
||||
- (id) decodeConstraintItem: (GSXibElement *)element
|
||||
{
|
||||
NSLog(@"%@", element);
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) objectForXib: (GSXibElement*)element
|
||||
{
|
||||
id object = [super objectForXib: element];
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#import "AppKit/NSLayoutConstraint.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
|
||||
static NSMutableArray *activeConstraints;
|
||||
static NSMutableArray *activeConstraints = nil;
|
||||
|
||||
@implementation NSLayoutConstraint
|
||||
|
||||
|
@ -41,7 +41,10 @@ static NSMutableArray *activeConstraints;
|
|||
if (self == [NSLayoutConstraint class])
|
||||
{
|
||||
[self setVersion: 1];
|
||||
activeConstraints = [NSMutableArray arrayWithCapacity: 10];
|
||||
if (nil == activeConstraints)
|
||||
{
|
||||
activeConstraints = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,6 +205,28 @@ static NSMutableArray *activeConstraints;
|
|||
return r;
|
||||
}
|
||||
|
||||
+ (void) _addActiveConstraint: (NSLayoutConstraint *)constraint
|
||||
{
|
||||
NSUInteger idx = 0;
|
||||
NSEnumerator *en = [activeConstraints objectEnumerator];
|
||||
NSLayoutConstraint *c = nil;
|
||||
NSLog(@"Adding %@", constraint);
|
||||
while ((c = [en nextObject]) != nil)
|
||||
{
|
||||
if ([c priority] < [constraint priority])
|
||||
{
|
||||
idx++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[activeConstraints insertObject: constraint
|
||||
atIndex: idx];
|
||||
}
|
||||
|
||||
+ (NSArray *) constraintsWithVisualFormat: (NSString *)fmt
|
||||
options: (NSLayoutFormatOptions)opt
|
||||
metrics: (NSDictionary *)metrics
|
||||
|
@ -234,8 +259,9 @@ static NSMutableArray *activeConstraints;
|
|||
selector: @selector(_handleWindowResize:)
|
||||
name: NSWindowDidResizeNotification
|
||||
object: [_firstItem window]];
|
||||
|
||||
[activeConstraints addObject: self];
|
||||
|
||||
NSLog(@"init");
|
||||
[NSLayoutConstraint _addActiveConstraint: self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -272,7 +298,7 @@ static NSMutableArray *activeConstraints;
|
|||
{
|
||||
if (flag)
|
||||
{
|
||||
[activeConstraints addObject: self];
|
||||
[NSLayoutConstraint _addActiveConstraint: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -282,7 +308,7 @@ static NSMutableArray *activeConstraints;
|
|||
|
||||
+ (void) activateConstraints: (NSArray *)constraints
|
||||
{
|
||||
[activeConstraints addObjectsFromArray: constraints];
|
||||
[activeConstraints addObjectsFromArray: [constraints sortedArrayUsingSelector: @selector(_compare:)]];
|
||||
}
|
||||
|
||||
+ (void) deactivateConstraints: (NSArray *)constraints
|
||||
|
@ -290,6 +316,20 @@ static NSMutableArray *activeConstraints;
|
|||
[activeConstraints removeObjectsInArray: constraints];
|
||||
}
|
||||
|
||||
- (NSComparisonResult) _compare: (NSLayoutConstraint *)constraint
|
||||
{
|
||||
if ([self priority] < [constraint priority])
|
||||
{
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
else if ([self priority] > [constraint priority])
|
||||
{
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
|
||||
return NSOrderedSame;
|
||||
}
|
||||
|
||||
// Items
|
||||
- (id) firstItem
|
||||
{
|
||||
|
@ -407,7 +447,8 @@ static NSMutableArray *activeConstraints;
|
|||
selector: @selector(_handleWindowResize:)
|
||||
name: NSWindowDidResizeNotification
|
||||
object: [_firstItem window]];
|
||||
[activeConstraints addObject: self];
|
||||
NSLog(@"Decoding");
|
||||
[NSLayoutConstraint _addActiveConstraint: self];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -468,7 +509,7 @@ static NSMutableArray *activeConstraints;
|
|||
- (NSString *) description
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@ <firstItem = %@, firstAttribute = %ld, relation = %ld, secondItem = %@, "
|
||||
"secondAttribute = %ld, multiplier = %f, constant = %f>",
|
||||
"secondAttribute = %ld, multiplier = %f, constant = %f, priority = %f>",
|
||||
[super description],
|
||||
_firstItem,
|
||||
_firstAttribute,
|
||||
|
@ -476,12 +517,24 @@ static NSMutableArray *activeConstraints;
|
|||
_secondItem,
|
||||
_secondAttribute,
|
||||
_multiplier,
|
||||
_constant];
|
||||
_constant,
|
||||
_priority];
|
||||
}
|
||||
|
||||
- (void) _applyConstraint
|
||||
{
|
||||
NSLog(@"activeConstraints = %@", activeConstraints);
|
||||
}
|
||||
|
||||
- (void) _handleWindowResize: (NSNotification *)notification
|
||||
{
|
||||
NSLog(@"Resized");
|
||||
NSLayoutConstraint *c = nil;
|
||||
NSEnumerator *en = [activeConstraints objectEnumerator];
|
||||
|
||||
while ((c = [en nextObject]) != nil)
|
||||
{
|
||||
[c _applyConstraint];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue