Skip to content

Commit

Permalink
Merge branch 'object_outline'
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Dec 29, 2024
2 parents 6c60a0e + 323e94d commit 9f208fe
Show file tree
Hide file tree
Showing 21 changed files with 517 additions and 42 deletions.
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2024-12-29 Gregory John Casamento <[email protected]>

* GormCore/English.lproj/GormObjectOutlineView.gorm/data.classes
* GormCore/GNUmakefile
* GormCore/GormDocument.h
* GormCore/GormDocument.m
* GormCore/GormGenericEditor.h
* GormCore/GormObjectEditor.h
* GormCore/GormObjectEditor.m
* GormCore/GormObjectMainView.h
* GormCore/GormObjectMainView.m
* GormCore/GormObjectOutlineView.h
* GormCore/GormObjectOutlineView.m
* GormCore/GormObjectViewController.h
* GormCore/GormObjectViewController.m: Add support for
outline view of objects.

2024-12-25 Gregory John Casamento <[email protected]>

* GormObjCHeaderParser/OCClass.m: Improve parsing
Expand Down
Binary file modified GormCore/English.lproj/GormDocument.gorm/data.info
Binary file not shown.
Binary file modified GormCore/English.lproj/GormDocument.gorm/objects.gorm
Binary file not shown.
22 changes: 22 additions & 0 deletions GormCore/English.lproj/GormObjectOutlineView.gorm/data.classes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"iconView:",
"outlineView:"
);
Super = NSObject;
};
GormObjectViewController = {
Actions = (
"iconView:",
"outlineView:"
);
Outlets = (
displayView,
iconButton,
outlineButton
);
Super = NSViewController;
};
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions GormCore/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ GormCore_HEADER_FILES = \
GormNSWindow.h \
GormObjectEditor.h \
GormObjectInspector.h \
GormObjectMainView.h \
GormObjectOutlineView.h \
GormObjectViewController.h \
GormOpenGLView.h \
GormOutlineView.h \
GormPalettesManager.h \
Expand Down Expand Up @@ -148,6 +151,9 @@ GormCore_OBJC_FILES = \
GormNSWindow.m \
GormObjectEditor.m \
GormObjectInspector.m \
GormObjectMainView.m \
GormObjectOutlineView.m \
GormObjectViewController.m \
GormOpenGLView.m \
GormOutlineView.m \
GormPalettesManager.m \
Expand Down Expand Up @@ -217,6 +223,7 @@ GormCore_RESOURCE_FILES = \
Images/GormWindow.tiff \
Images/browserView.tiff \
Images/outlineView.tiff \
Images/iconView.tiff \
Resources/VersionProfiles.plist \
Resources/ClassInformation.plist

Expand All @@ -237,6 +244,7 @@ GormCore_LOCALIZED_RESOURCE_FILES = \
GormInspectorPanel.gorm \
GormNSSplitViewInspector.gorm \
GormObjectInspector.gorm \
GormObjectOutlineView.gorm \
GormPalettePanel.gorm \
GormPrefColors.gorm \
GormPreferences.gorm \
Expand Down
5 changes: 4 additions & 1 deletion GormCore/GormDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <GNUstepGUI/GSNibContainer.h>

@class GormClassManager, GormClassEditor, GormObjectProxy, GormFilesOwner,
GormFilePrefsManager, GormDocumentWindow;
GormFilePrefsManager, GormDocumentWindow, GormObjectViewController;

/*
* Trivial classes for connections from objects to their editors, and from
Expand Down Expand Up @@ -99,6 +99,9 @@
NSMutableSet *topLevelObjects;
NSMutableSet *visibleWindows;
NSMutableSet *deferredWindows;

// Controllers...
GormObjectViewController *objectViewController;
}

/* Handle notifications */
Expand Down
210 changes: 183 additions & 27 deletions GormCore/GormDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#import "GormDocumentWindow.h"
#import "GormDocumentController.h"
#import "GormXLIFFDocument.h"
#import "GormObjectViewController.h"

@interface NSObject (GormNSCoding)
@end
Expand Down Expand Up @@ -326,7 +327,8 @@ - (void) awakeFromNib
NSMenu *mainMenu = nil;
NSEnumerator *en = nil;
id o = nil;

NSOutlineView *outlineView = [[NSOutlineView alloc] init];

// get the window and cache it...
window = (GormDocumentWindow *)[self _docWindow];
[IBResourceManager registerForAllPboardTypes:window
Expand Down Expand Up @@ -361,22 +363,72 @@ - (void) awakeFromNib
object: window];

// objects...
NSScrollView *outlineScrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
NSTableColumn *tbo = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"objects"]);
NSTableColumn *tbc = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"destination"]);
NSTableColumn *tbs = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"source"]);
NSTableColumn *tbcl = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"class"]);
NSTableColumn *tbv = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"version"]);

// Titles
[tbo setTitle: @"Objects"];
[tbc setTitle: @"Destination"];
[tbs setTitle: @"Source"];
[tbcl setTitle: @"Class"];
[tbv setTitle: @"Version"];

// Set up the outline view...
[outlineView setDrawsGrid: NO];
[outlineView setOutlineTableColumn: tbo];
[outlineView addTableColumn: tbo];
[outlineView addTableColumn: tbcl];
[outlineView addTableColumn: tbv];
[outlineView addTableColumn: tbc];
[outlineView addTableColumn: tbs];
[outlineScrollView setHasVerticalScroller: YES];
[outlineScrollView setHasHorizontalScroller: YES];
[outlineScrollView setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[outlineScrollView setBorderType: NSBezelBorder];

// Configure the scrollview...
mainRect.origin = NSMakePoint(0,0);
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
[scrollView setHasVerticalScroller: YES];
[scrollView setHasHorizontalScroller: YES];
[scrollView setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[scrollView setBorderType: NSBezelBorder];

objectViewController = [[GormObjectViewController alloc] initWithNibName: @"GormObjectOutlineView"
bundle: [NSBundle bundleForClass: [self class]]];
[objectViewController setDocument: self];
NSDebugLog(@"objectViewController = %@, view = %@", objectViewController, [objectViewController view]);

objectsView = [[GormObjectEditor alloc] initWithObject: nil
inDocument: self];
[objectsView setFrame: mainRect];
[objectsView setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[scrollView setDocumentView: objectsView];
RELEASE(objectsView);
RELEASE(objectsView);

[objectViewController setIconView: scrollView];
RELEASE(scrollView);

[outlineScrollView setDocumentView: outlineView];
[objectViewController setOutlineView: outlineScrollView];
[outlineView setDataSource: self];
[self deactivateEditors];
[outlineView reloadData];
[self reactivateEditors];

RELEASE(outlineView);

[[objectViewController view] setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
[objectViewController resetDisplayView: scrollView];

// images...
mainRect.origin = NSMakePoint(0,0);
imagesScrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
Expand Down Expand Up @@ -417,7 +469,7 @@ - (void) awakeFromNib
/*
* Set the objects view as the initial view the user's see on startup.
*/
[selectionBox setContentView: scrollView];
[selectionBox setContentView: [objectViewController view]]; //scrollView];

// add to the objects view...
[objectsView addObject: filesOwner];
Expand Down Expand Up @@ -952,7 +1004,7 @@ - (void) changeToViewWithTag: (int)tag
{
case 0: // objects
{
[selectionBox setContentView: scrollView];
[selectionBox setContentView: [objectViewController view]]; //scrollView];
[toolbar setSelectedItemIdentifier: @"ObjectsItem"];
if (![[NSApp delegate] isConnecting])
[self setSelectionFromEditor: objectsView];
Expand Down Expand Up @@ -2608,6 +2660,9 @@ - (void) setSelectionFromEditor: (id<IBEditors>)anEditor
*/
- (void) touch
{
[self deactivateEditors];
[[[objectViewController outlineView] documentView] reloadData];
[self reactivateEditors];
[self updateChangeCount: NSChangeDone];
}

Expand Down Expand Up @@ -3780,24 +3835,6 @@ - (NSArray *) validate
}
}

/*
NSLog(@"Checking connections..."); // %@", connections);
en = [connections objectEnumerator];
o = nil;
while ((o = [en nextObject]) != nil)
{
id src = [o source];
id dst = [o destination];
NSString *label = [o label];
if ([o isKindOfClass: [NSNibControlConnector class]])
{
}
else if ([o isKindOfClass: [NSNibOutletConnector class]])
{
}
}
*/
return results;
}

Expand Down Expand Up @@ -3917,26 +3954,145 @@ - (id) outlineView: (NSOutlineView *)ov
child: (NSInteger)index
ofItem: (id)item
{
return nil;
id result = nil;

[self deactivateEditors];
NSDebugLog(@"index = %ld, item = %@", index, item);
if (item == nil)
{
result = [[topLevelObjects allObjects] objectAtIndex: index];
}
else if ([item isKindOfClass: [NSWindow class]])
{
result = [item contentView];
}
else if ([item isKindOfClass: [NSView class]])
{
result = [[item subviews] objectAtIndex: index];
}
else if ([item isKindOfClass: [NSMenu class]])
{
result = [item itemAtIndex: index];
}
else if ([item isKindOfClass: [NSMenuItem class]])
{
result = [item submenu];
}
NSDebugLog(@"result = %@", result);
[self reactivateEditors];

return result;
}

- (BOOL) outlineView: (NSOutlineView *)ov
isItemExpandable: (id)item
{
return NO;
BOOL f = NO;

[self deactivateEditors];
if (item == nil)
{
f = [topLevelObjects count] > 0;
}
else if ([item isKindOfClass: [NSWindow class]])
{
f = [item contentView] != nil;
}
else if ([item isKindOfClass: [NSView class]])
{
f = [[item subviews] count] > 0;
}
else if ([item isKindOfClass: [NSMenu class]])
{
f = [item numberOfItems] > 0;
}
else if ([item isKindOfClass: [NSMenuItem class]])
{
f = [item hasSubmenu];
}
[self reactivateEditors];

NSDebugLog(@"f = %d",f);
return f;
}

- (NSInteger) outlineView: (NSOutlineView *)ov
numberOfChildrenOfItem: (id)item
{
return 0;
NSInteger c = 0;

[self deactivateEditors];
if (item == nil)
{
c = [topLevelObjects count];
}
else if ([item isKindOfClass: [NSWindow class]])
{
c = 1; // We are only counting the contentView...
}
else if ([item isKindOfClass: [NSView class]])
{
c = [[item subviews] count];
}
else if ([item isKindOfClass: [NSMenu class]])
{
c = [item numberOfItems];
}
else if ([item isKindOfClass: [NSMenuItem class]])
{
c = 1; // one submenu...
}
[self reactivateEditors];

NSDebugLog(@"c = %ld", c);
return c;
}

- (id) outlineView: (NSOutlineView *)ov
objectValueForTableColumn: (NSTableColumn *)tableColumn
byItem: (id)tem
byItem: (id)item
{
return nil;
id value = nil;
NSString *className = [classManager classNameForObject: item];
NSString *name = [self nameForObject: item];
NSUInteger version = 0;

[self deactivateEditors];
if ([[tableColumn identifier] isEqualToString: @"objects"])
{
NSString *title = @"";

if ([item respondsToSelector: @selector(title)])
{
title = [item title];
value = [NSString stringWithFormat: @"%@ : %@", title, (name != nil)?name:@"*Unnamed*"];
}
else
{
value = [NSString stringWithFormat: @"%@", (name != nil)?name:@"*Unnamed*"];
}
}
else if ([[tableColumn identifier] isEqualToString: @"class"])
{
value = className;
}
else if ([[tableColumn identifier] isEqualToString: @"version"])
{
value = [NSNumber numberWithInteger: version];
}
else if ([[tableColumn identifier] isEqualToString: @"destination"])
{
NSArray *c = [self connectorsForDestination: item];
value = [NSNumber numberWithInteger: [c count]];
}
else if ([[tableColumn identifier] isEqualToString: @"source"])
{
NSArray *c = [self connectorsForSource: item];
value = [NSNumber numberWithInteger: [c count]];
}
[self reactivateEditors];

return value;
}

// Other methods...
Expand Down
Loading

0 comments on commit 9f208fe

Please sign in to comment.