Skip to content

NSStoryboard refactoring #274

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Headers/Additions/GNUstepGUI/GSXibKeyedUnarchiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ APPKIT_EXPORT_CLASS

+ (BOOL) checkXib5: (NSData *)data;

+ (BOOL) checkStoryboard: (NSData *)data;

+ (NSKeyedUnarchiver *) unarchiverForReadingWithData: (NSData *)data;

- (void) _initCommon;
Expand Down
22 changes: 22 additions & 0 deletions Headers/Additions/GNUstepGUI/GSXibLoading.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#import <Foundation/NSObject.h>
#import <Foundation/NSKeyedArchiver.h>

#import "GNUstepGUI/GSXibKeyedUnarchiver.h"

@class NSString, NSDictionary, NSArray, NSMutableDictionary, NSMutableArray;
Expand All @@ -42,18 +43,21 @@

// Hack: This allows the class name FirstResponder in NSCustomObject and
// correctly returns nil as the corresponding object.
APPKIT_EXPORT_CLASS
@interface FirstResponder: NSObject
{
}
@end

APPKIT_EXPORT_CLASS
@interface IBClassDescriptionSource: NSObject
{
NSString *majorKey;
NSString *minorKey;
}
@end

APPKIT_EXPORT_CLASS
@interface IBPartialClassDescription: NSObject
{
NSString *className;
Expand All @@ -64,12 +68,14 @@
}
@end

APPKIT_EXPORT_CLASS
@interface IBClassDescriber: NSObject
{
NSMutableArray *referencedPartialClassDescriptions;
}
@end

APPKIT_EXPORT_CLASS
@interface IBConnection: NSObject <NSCoding>
{
NSString *label;
Expand All @@ -84,23 +90,27 @@
- (void) establishConnection;
@end

APPKIT_EXPORT_CLASS
@interface IBActionConnection: IBConnection
{
NSString *trigger;
}
@end

APPKIT_EXPORT_CLASS
@interface IBOutletConnection: IBConnection
{
}
@end

APPKIT_EXPORT_CLASS
@interface IBBindingConnection: IBConnection
{
NSNibBindingConnector *connector;
}
@end

APPKIT_EXPORT_CLASS
@interface IBConnectionRecord: NSObject
{
IBConnection *connection;
Expand All @@ -109,6 +119,7 @@
- (IBConnection *) connection;
@end

APPKIT_EXPORT_CLASS
@interface IBToolTipAttribute: NSObject
{
NSString *name;
Expand All @@ -117,6 +128,7 @@
}
@end

APPKIT_EXPORT_CLASS
@interface IBInitialTabViewItemAttribute: NSObject
{
NSString *name;
Expand All @@ -125,6 +137,7 @@
}
@end

APPKIT_EXPORT_CLASS
@interface IBObjectRecord: NSObject
{
id objectID;
Expand All @@ -137,6 +150,7 @@
- (id) objectID;
@end

APPKIT_EXPORT_CLASS
@interface IBMutableOrderedSet: NSObject
{
NSArray *orderedObjects;
Expand All @@ -145,6 +159,7 @@
- (id) objectWithObjectID: (id)objID;
@end

APPKIT_EXPORT_CLASS
@interface IBObjectContainer: NSObject <NSCoding>
{
NSMutableArray *connectionRecords;
Expand Down Expand Up @@ -196,4 +211,11 @@ APPKIT_EXPORT_CLASS

@end

APPKIT_EXPORT_CLASS
@interface IBScenesContaienr : NSObject <NSCoding>
{
IBMutableOrderedSet *_sceneRecords;
}
@end

#endif
8 changes: 6 additions & 2 deletions Headers/AppKit/NSStoryboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
extern "C" {
#endif

@class NSString, NSBundle, NSMutableDictionary;
@class NSBundle;
@class NSData;
@class NSMutableDictionary;
@class NSString;

typedef NSString *NSStoryboardName;
typedef NSString *NSStoryboardSceneIdentifier;
Expand All @@ -43,7 +46,8 @@ DEFINE_BLOCK_TYPE(NSStoryboardControllerCreator, NSCoder*, id);
APPKIT_EXPORT_CLASS
@interface NSStoryboard : NSObject
{
id _transform;
NSData *_data;
NSMutableDictionary *_scenes;
}

#if OS_API_VERSION(MAC_OS_X_VERSION_10_13, GS_API_LATEST)
Expand Down
5 changes: 4 additions & 1 deletion Source/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ GSDisplayServer.m \
GSHelpManagerPanel.m \
GSInfoPanel.m \
GSMemoryPanel.m \
GSScene.m \
GSSlideView.m \
GSStoryboardLoader.m \
GSTextStorage.m \
GSTrackingRect.m \
GSServicesManager.m \
Expand All @@ -332,6 +334,7 @@ GSGormLoading.m \
GSIconManager.m \
GSImageMagickImageRep.m \
GSNibLoading.m \
GSScenes.m \
GSTheme.m \
GSThemeDrawing.m \
GSThemeInspector.m \
Expand All @@ -346,7 +349,7 @@ GSToolTips.m \
GSToolbarView.m \
GSToolbarCustomizationPalette.m \
GSStandardWindowDecorationView.m \
GSStoryboardTransform.m \
GSStoryboardKeyedUnarchiver.m \
GSWindowDecorationView.m \
GSPrinting.m \
GSPrintOperation.m \
Expand Down
2 changes: 1 addition & 1 deletion Source/GSModelLoaderFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ + (NSString *) type

+ (float) priority
{
return 0.0;
return FLT_MAX;
}

- (BOOL) loadModelData: (NSData *)data
Expand Down
60 changes: 60 additions & 0 deletions Source/GSScene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* Interface of class GSScene
Copyright (C) 2024 Free Software Foundation, Inc.

By: Gregory John Casamento
Date: 12-05-2024

This file is part of the GNUstep Library.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/

#ifndef _GSScene_h_GNUSTEP_GUI_INCLUDE
#define _GSScene_h_GNUSTEP_GUI_INCLUDE

#import <Foundation/NSObject.h>
#import <Foundation/NSGeometry.h>

#if defined(__cplusplus)
extern "C" {
#endif

@class NSMutableArray;
@class NSString;

@interface GSScene : NSObject <NSCoding, NSCopying>
{
NSString *_sceneID;
NSMutableArray *_objects;
NSPoint _canvasLocation;
}

- (NSString *) sceneID;
- (void) setSceneID: (NSString *)sceneID;

- (NSMutableArray *) objects;
- (void) setObjects: (NSMutableArray *)objects;

- (NSPoint) canvasLocation;
- (void) setCanvasLocation: (NSPoint)point;

@end

#if defined(__cplusplus)
}
#endif

#endif /* _GSScene_h_GNUSTEP_GUI_INCLUDE */
123 changes: 123 additions & 0 deletions Source/GSScene.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* Implementation of class GSScene
Copyright (C) 2024 Free Software Foundation, Inc.

By: Gregory John Casamento
Date: 12-05-2024

This file is part of the GNUstep Library.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/

#import <Foundation/NSKeyedArchiver.h>

#import "GSScene.h"

@implementation GSScene

- (instancetype) init
{
self = [super init];
if (self != nil)
{
_sceneID = nil;
_objects = nil;
_canvasLocation = NSMakePoint(0.0, 0.0);
}
return self;
}

- (void) dealloc
{
RELEASE(_sceneID);
RELEASE(_objects);
[super dealloc];
}

- (NSString *) sceneID
{
return _sceneID;
}

- (void) setSceneID: (NSString *)sceneID
{
ASSIGN(_sceneID, sceneID);
}

- (NSMutableArray *) objects
{
return _objects;
}

- (void) setObjects: (NSMutableArray *)objects
{
ASSIGN(_objects, objects);
}

- (NSPoint) canvasLocation
{
return _canvasLocation;
}

- (void) setCanvasLocation: (NSPoint)point
{
_canvasLocation = point;
}

// NSCoding

- (instancetype) initWithCoder: (NSCoder *)coder
{
NSLog(@"Decoding GSScene");
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"NSSceneID"])
{
[self setSceneID: [coder decodeObjectForKey: @"NSSceneID"]];
}

if ([coder containsValueForKey: @"NSObjects"])
{
[self setObjects: [coder decodeObjectForKey: @"NSObjects"]];
}

if ([coder containsValueForKey: @"NSCanvasLocation"])
{
[self setCanvasLocation: [coder decodePointForKey: @"NSCanvasLocation"]];
}
}
return self;
}

- (void) encodeWithCoder: (NSCoder *)coder
{
}

// NSCopying

- (id) copyWithZone: (NSZone *)zone
{
GSScene *scene = [[GSScene allocWithZone: zone] init];

[scene setSceneID: [self sceneID]];
[scene setObjects: [self objects]];
[scene setCanvasLocation: [self canvasLocation]];

return scene;
}

@end

Loading
Loading