mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Merge pull request #106 from gnustep/NSCollectionView_branch
This commit is contained in:
commit
2148c2ba92
23 changed files with 3918 additions and 384 deletions
|
@ -67,7 +67,10 @@
|
|||
#import <AppKit/NSCIImageRep.h>
|
||||
#import <AppKit/NSClipView.h>
|
||||
#import <AppKit/NSCollectionView.h>
|
||||
#import <AppKit/NSCollectionViewFlowLayout.h>
|
||||
#import <AppKit/NSCollectionViewGridLayout.h>
|
||||
#import <AppKit/NSCollectionViewItem.h>
|
||||
#import <AppKit/NSCollectionViewLayout.h>
|
||||
#import <AppKit/NSColor.h>
|
||||
#import <AppKit/NSColorList.h>
|
||||
#import <AppKit/NSColorPanel.h>
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
/* -*-objc-*-
|
||||
NSCollectionView.h
|
||||
|
||||
Copyright (C) 2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 2013,2021 Free Software Foundation, Inc.
|
||||
|
||||
Author: Doug Simons (doug.simons@testplant.com)
|
||||
Frank LeGrand (frank.legrand@testplant.com)
|
||||
Date: February 2013
|
||||
Gregory Casamento (greg.casamento@gmail.com)
|
||||
(Adding new delegate methods and support for layouts)
|
||||
|
||||
Date: February 2013, December 2021
|
||||
|
||||
This file is part of the GNUstep GUI Library.
|
||||
|
||||
|
@ -33,9 +36,20 @@
|
|||
#import <AppKit/NSDragging.h>
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <AppKit/NSView.h>
|
||||
#import <AppKit/NSUserInterfaceItemIdentification.h>
|
||||
|
||||
@class NSCollectionViewItem;
|
||||
@class NSCollectionView;
|
||||
@class NSCollectionViewLayout;
|
||||
@class NSCollectionViewLayoutAttributes;
|
||||
@class NSCollectionViewTransitionLayout;
|
||||
@class NSPasteboard;
|
||||
@class NSNib;
|
||||
@class NSMapTable;
|
||||
@class NSMutableDictionary;
|
||||
@class NSMutableSet;
|
||||
|
||||
@protocol NSPasteboardWriting;
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -44,47 +58,400 @@ enum
|
|||
};
|
||||
typedef NSInteger NSCollectionViewDropOperation;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
enum {
|
||||
NSCollectionViewItemHighlightNone = 0,
|
||||
NSCollectionViewItemHighlightForSelection = 1,
|
||||
NSCollectionViewItemHighlightForDeselection = 2,
|
||||
NSCollectionViewItemHighlightAsDropTarget = 3,
|
||||
};
|
||||
typedef NSInteger NSCollectionViewItemHighlightState;
|
||||
|
||||
enum {
|
||||
NSCollectionViewScrollPositionNone = 0,
|
||||
|
||||
/*
|
||||
* Vertical positions are mutually exclusive to each other, but are bitwise or-able with
|
||||
* the horizontal scroll positions. Combining positions from the same grouping
|
||||
* (horizontal or vertical) will result in an NSInvalidArgumentException.
|
||||
*/
|
||||
NSCollectionViewScrollPositionTop = 1 << 0,
|
||||
NSCollectionViewScrollPositionCenteredVertically = 1 << 1,
|
||||
NSCollectionViewScrollPositionBottom = 1 << 2,
|
||||
NSCollectionViewScrollPositionNearestHorizontalEdge = 1 << 9, /* Nearer of Top,Bottom */
|
||||
|
||||
/*
|
||||
* Likewise, the horizontal positions are mutually exclusive to each other.
|
||||
*/
|
||||
NSCollectionViewScrollPositionLeft = 1 << 3,
|
||||
NSCollectionViewScrollPositionCenteredHorizontally = 1 << 4,
|
||||
NSCollectionViewScrollPositionRight = 1 << 5,
|
||||
NSCollectionViewScrollPositionLeadingEdge = 1 << 6, /* Left if LTR, Right if RTL */
|
||||
NSCollectionViewScrollPositionTrailingEdge = 1 << 7, /* Right if LTR, Left, if RTL */
|
||||
NSCollectionViewScrollPositionNearestVerticalEdge = 1 << 8, /* Nearer of Leading,Trailing */
|
||||
};
|
||||
typedef NSUInteger NSCollectionViewScrollPosition;
|
||||
|
||||
#endif
|
||||
|
||||
typedef NSString *NSCollectionViewSupplementaryElementKind;
|
||||
typedef NSString *NSUserInterfaceItemIdentifier;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
@protocol NSCollectionViewElement <NSObject, NSUserInterfaceItemIdentification>
|
||||
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@optional
|
||||
#endif
|
||||
|
||||
- (void) prepareForReuse;
|
||||
|
||||
- (void) applyLayoutAttributes: (NSCollectionViewLayoutAttributes *)layoutAttributes;
|
||||
|
||||
- (void) willTransitionFromLayout: (NSCollectionViewLayout *)oldLayout toLayout: (NSCollectionViewLayout *)newLayout;
|
||||
|
||||
- (void) didTransitionFromLayout: (NSCollectionViewLayout *)oldLayout toLayout: (NSCollectionViewLayout *)newLayout;
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) preferredLayoutAttributesFittingAttributes: (NSCollectionViewLayoutAttributes *)layoutAttributes;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
@protocol NSCollectionViewDataSource <NSObject>
|
||||
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@required
|
||||
#endif
|
||||
- (NSInteger) collectionView: (NSCollectionView *)collectionView
|
||||
numberOfItemsInSection: (NSInteger)section;
|
||||
|
||||
- (NSCollectionViewItem *) collectionView: (NSCollectionView *)collectionView
|
||||
itemForRepresentedObjectAtIndexPath: (NSIndexPath *)indexPath;
|
||||
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@optional
|
||||
#endif
|
||||
- (NSInteger) numberOfSectionsInCollectionView: (NSCollectionView *)collectionView;
|
||||
|
||||
- (NSView *) collectionView: (NSCollectionView *)collectionView
|
||||
viewForSupplementaryElementOfKind: (NSCollectionViewSupplementaryElementKind)kind
|
||||
atIndexPath: (NSIndexPath *)indexPath;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
@protocol NSCollectionViewPrefetching <NSObject>
|
||||
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@required
|
||||
#endif
|
||||
/**
|
||||
* Load the items listed in indexPaths in collectionView before they are displayed
|
||||
*/
|
||||
- (void)collectionView: (NSCollectionView *)collectionView prefetchItemsAtIndexPaths: (NSArray *)indexPaths;
|
||||
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@optional
|
||||
#endif
|
||||
/**
|
||||
* Cancel the prefetch request for the listed indexPaths.
|
||||
*/
|
||||
- (void)collectionView: (NSCollectionView *)collectionView cancelPrefetchingForItemsAtIndexPaths: (NSArray *)indexPaths;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@protocol NSCollectionViewDelegate <NSObject>
|
||||
|
||||
- (NSImage *)collectionView:(NSCollectionView *)collectionView
|
||||
draggingImageForItemsAtIndexes:(NSIndexSet *)indexes
|
||||
withEvent:(NSEvent *)event
|
||||
offset:(NSPointPointer)dragImageOffset;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
writeItemsAtIndexes:(NSIndexSet *)indexes
|
||||
toPasteboard:(NSPasteboard *)pasteboard;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
canDragItemsAtIndexes:(NSIndexSet *)indexes
|
||||
withEvent:(NSEvent *)event;
|
||||
- (NSDragOperation)collectionView:(NSCollectionView *)collectionView
|
||||
validateDrop:(id < NSDraggingInfo >)draggingInfo
|
||||
proposedIndex:(NSInteger *)proposedDropIndex
|
||||
dropOperation:(NSCollectionViewDropOperation *)proposedDropOperation;
|
||||
- (BOOL)collectionView:(NSCollectionView *)collectionView
|
||||
acceptDrop:(id < NSDraggingInfo >)draggingInfo
|
||||
index:(NSInteger)index
|
||||
dropOperation:(NSCollectionViewDropOperation)dropOperation;
|
||||
- (NSArray *)collectionView:(NSCollectionView *)collectionView
|
||||
namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropURL
|
||||
forDraggedItemsAtIndexes:(NSIndexSet *)indexes;
|
||||
#if GS_PROTOCOLS_HAVE_OPTIONAL
|
||||
@optional
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Return a boolean indicating if the indexPaths on collectionView can be dragged with the passed in event.
|
||||
*/
|
||||
- (BOOL) collectionView: (NSCollectionView *)collectionView
|
||||
canDragItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
withEvent: (NSEvent *)event;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
/**
|
||||
* Return a boolean indicating if the indexes on collectionView can be dragged with the passed in event.
|
||||
*/
|
||||
- (BOOL) collectionView: (NSCollectionView *)collectionView
|
||||
canDragItemsAtIndexes: (NSIndexSet *)indexes
|
||||
withEvent: (NSEvent *)event;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Return a boolean if the items at indexPaths can be written to the pasteboard
|
||||
*/
|
||||
- (BOOL) collectionView: (NSCollectionView *)collectionView
|
||||
writeItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
toPasteboard: (NSPasteboard *)pasteboard;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
/**
|
||||
* Return a boolean if the items at indexes can be written to the pasteboard
|
||||
*/
|
||||
- (BOOL) collectionView: (NSCollectionView *)collectionView
|
||||
writeItemsAtIndexes: (NSIndexSet *)indexes
|
||||
toPasteboard: (NSPasteboard *)pasteboard;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Returns an array of filenames for files at indexPaths that will be dropped at the destination specified by NSURL.
|
||||
*/
|
||||
- (NSArray *) collectionView: (NSCollectionView *)collectionView
|
||||
namesOfPromisedFilesDroppedAtDestination: (NSURL *)dropURL
|
||||
forDraggedItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
/**
|
||||
* Returns an array of filenames for files at indexes that will be dropped at the destination specified by NSURL.
|
||||
*/
|
||||
- (NSArray *) collectionView: (NSCollectionView *)collectionView
|
||||
namesOfPromisedFilesDroppedAtDestination: (NSURL *)dropURL
|
||||
forDraggedItemsAtIndexes: (NSIndexSet *)indexes;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Returns an NSImage representing the items at indexPaths which are being dragged.
|
||||
*/
|
||||
- (NSImage *) collectionView: (NSCollectionView *)collectionView
|
||||
draggingImageForItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
withEvent: (NSEvent *)event
|
||||
offset: (NSPointPointer)dragImageOffset;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
/**
|
||||
* Returns an NSImage representing the items at indexes which are being dragged.
|
||||
*/
|
||||
- (NSImage *) collectionView: (NSCollectionView *)collectionView
|
||||
draggingImageForItemsAtIndexes: (NSIndexSet *)indexes
|
||||
withEvent: (NSEvent *)event
|
||||
offset: (NSPointPointer)dragImageOffset;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Return NSDragOperation when performing drag and drop on collectionView at proposedDropIndexPath.
|
||||
*/
|
||||
- (NSDragOperation) collectionView: (NSCollectionView *)collectionView
|
||||
validateDrop: (id < NSDraggingInfo >)draggingInfo
|
||||
proposedIndexPath: (NSIndexPath **)proposedDropIndexPath
|
||||
dropOperation: (NSCollectionViewDropOperation *)proposedDropOperation;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
/**
|
||||
* Return NSDragOperation when performing drag and drop on collectionView at proposedIndex.
|
||||
*/
|
||||
- (NSDragOperation) collectionView: (NSCollectionView *)collectionView
|
||||
validateDrop: (id < NSDraggingInfo >)draggingInfo
|
||||
proposedIndex: (NSInteger *)proposedDropIndex
|
||||
dropOperation: (NSCollectionViewDropOperation *)proposedDropOperation;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Returns a BOOL to indicate if the drop at indexPath was accepted
|
||||
*/
|
||||
- (BOOL) collectionView: (NSCollectionView *)collectionView
|
||||
acceptDrop: (id < NSDraggingInfo >)draggingInfo
|
||||
indexPath: (NSIndexPath *)indexPath
|
||||
dropOperation: (NSCollectionViewDropOperation)dropOperation;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
/**
|
||||
* Returns a BOOL to indicate if the drop at index was accepted
|
||||
*/
|
||||
- (BOOL) collectionView: (NSCollectionView *)collectionView
|
||||
acceptDrop: (id < NSDraggingInfo >)draggingInfo
|
||||
index: (NSInteger)index
|
||||
dropOperation: (NSCollectionViewDropOperation)dropOperation;
|
||||
#endif
|
||||
|
||||
/* Multi-image drag and drop */
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Return NSPasteboardWriting object for collectionView at indexPath
|
||||
*/
|
||||
- (id <NSPasteboardWriting>) collectionView: (NSCollectionView *)collectionView
|
||||
pasteboardWriterForItemAtIndexPath: (NSIndexPath *)indexPath;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return NSPasteboardWriting object for collectionView at index
|
||||
*/
|
||||
- (id <NSPasteboardWriting>) collectionView: (NSCollectionView *)collectionView
|
||||
pasteboardWriterForItemAtIndex: (NSUInteger)index;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Allows application to specify the screenPoint at which a dragging session will begin
|
||||
* for the given indexPaths
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
draggingSession: (NSDraggingSession *)session
|
||||
willBeginAtPoint: (NSPoint)screenPoint
|
||||
forItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allows application to specify the screenPoint at which a dragging session will begin
|
||||
* for the given indexes
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
draggingSession: (NSDraggingSession *)session
|
||||
willBeginAtPoint: (NSPoint)screenPoint
|
||||
forItemsAtIndexes: (NSIndexSet *)indexes;
|
||||
|
||||
/**
|
||||
* Allows application to specify the screenPoint at which a dragging session did end
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
draggingSession: (NSDraggingSession *)session
|
||||
endedAtPoint: (NSPoint)screenPoint
|
||||
dragOperation: (NSDragOperation)operation;
|
||||
/**
|
||||
* Update items include in the drag operation for collectionView.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
updateDraggingItemsForDrag: (id <NSDraggingInfo>)draggingInfo;
|
||||
|
||||
/* Selection and Highlighting */
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/**
|
||||
* Returns the set of indexPaths that should change their selection. This is sent to inform the delegate of
|
||||
* those items that the collectionView would like to change to highlightState.
|
||||
*/
|
||||
- (NSSet *) collectionView: (NSCollectionView *)collectionView
|
||||
shouldChangeItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
toHighlightState: (NSCollectionViewItemHighlightState)highlightState;
|
||||
|
||||
/**
|
||||
* This is sent to inform the delegate of those items that did change highlightState.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
didChangeItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
toHighlightState: (NSCollectionViewItemHighlightState)highlightState;
|
||||
|
||||
/**
|
||||
* Returns the set of indexPaths that should change.
|
||||
*/
|
||||
- (NSSet *) collectionView: (NSCollectionView *)collectionView
|
||||
shouldSelectItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
/**
|
||||
* Returns the set of NSIndexPath objects that should be deselected given the proposed indexPaths.
|
||||
*/
|
||||
- (NSSet *) collectionView: (NSCollectionView *)collectionView shouldDeselectItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
/**
|
||||
* Called to inform the delegate of those items that were selected.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView didSelectItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
/**
|
||||
* Called to inform the delegate of those items that were deselected.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView didDeselectItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
/* Display Notification */
|
||||
|
||||
/**
|
||||
* Called to inform the delegate that the item representing the object at indexPath will be displayed.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
willDisplayItem: (NSCollectionViewItem *)item
|
||||
forRepresentedObjectAtIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Called to inform the delegate that the supplementary view for the elementKind will be displayed
|
||||
* at indexPath.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
willDisplaySupplementaryView: (NSView *)view
|
||||
forElementKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Called to inform the delegate that the collectionView will end display of item for the object at indexPath.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
didEndDisplayingItem: (NSCollectionViewItem *)item
|
||||
forRepresentedObjectAtIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
/**
|
||||
* Called to inform the delegate that the collectionView will end display of supplementaryView for the
|
||||
* object at indexPath.
|
||||
*/
|
||||
- (void) collectionView: (NSCollectionView *)collectionView
|
||||
didEndDisplayingSupplementaryView: (NSView *)view
|
||||
forElementOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
/* Layout Transition Support */
|
||||
|
||||
/**
|
||||
* Called to inform the delegate that the collectionView is transitioning from the old to the new
|
||||
* layout indicated.
|
||||
*/
|
||||
- (NSCollectionViewTransitionLayout *) collectionView: (NSCollectionView *)collectionView
|
||||
transitionLayoutForOldLayout: (NSCollectionViewLayout *)fromLayout
|
||||
newLayout: (NSCollectionViewLayout *)toLayout;
|
||||
#endif
|
||||
@end
|
||||
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionView : NSView //<NSDraggingDestination, NSDraggingSource>
|
||||
{
|
||||
// Content
|
||||
NSArray *_content;
|
||||
IBOutlet NSCollectionViewItem *itemPrototype;
|
||||
NSMutableArray *_items;
|
||||
NSIndexSet *_selectionIndexes;
|
||||
NSSet *_selectionIndexPaths;
|
||||
NSArray *_backgroundColors;
|
||||
|
||||
// Delegate and datasource
|
||||
IBOutlet NSCollectionViewItem *itemPrototype;
|
||||
IBOutlet id <NSCollectionViewDelegate> _delegate;
|
||||
IBOutlet id <NSCollectionViewDataSource> _dataSource;
|
||||
IBOutlet NSView *_backgroundView;
|
||||
IBOutlet id <NSCollectionViewPrefetching> _prefetchDataSource;
|
||||
|
||||
// Layout
|
||||
NSCollectionViewLayout *_collectionViewLayout;
|
||||
|
||||
// Managing items
|
||||
NSMutableArray *_visibleItems;
|
||||
NSMutableDictionary *_visibleSupplementaryViews;
|
||||
NSMutableSet *_indexPathsForSupplementaryElementsOfKind;
|
||||
|
||||
// Private
|
||||
// Map items -> indexPath
|
||||
NSMapTable *_itemsToIndexPaths;
|
||||
NSMapTable *_indexPathsToItems;
|
||||
NSMapTable *_itemsToAttributes;
|
||||
|
||||
// Registered class/nib for item identifier
|
||||
NSMapTable *_registeredNibs;
|
||||
NSMapTable *_registeredClasses;
|
||||
|
||||
// Selection management...
|
||||
BOOL _allowsMultipleSelection;
|
||||
BOOL _isSelectable;
|
||||
NSIndexSet *_selectionIndexes;
|
||||
|
||||
NSArray *_backgroundColors;
|
||||
IBOutlet id <NSCollectionViewDelegate> delegate;
|
||||
|
||||
BOOL _allowsEmptySelection;
|
||||
BOOL _backgroundViewScrollsWithContent;
|
||||
BOOL _allowReload;
|
||||
|
||||
// Size
|
||||
NSSize _itemSize;
|
||||
NSSize _maxItemSize;
|
||||
NSSize _minItemSize;
|
||||
|
@ -95,10 +462,10 @@ APPKIT_EXPORT_CLASS
|
|||
NSUInteger _maxNumberOfColumns;
|
||||
NSUInteger _maxNumberOfRows;
|
||||
NSUInteger _numberOfColumns;
|
||||
|
||||
|
||||
// Drag & Drop
|
||||
NSDragOperation _draggingSourceOperationMaskForLocal;
|
||||
NSDragOperation _draggingSourceOperationMaskForRemote;
|
||||
|
||||
NSDragOperation _draggingSourceOperationMaskForRemote;
|
||||
NSUInteger _draggingOnRow;
|
||||
NSUInteger _draggingOnIndex;
|
||||
}
|
||||
|
@ -109,8 +476,8 @@ APPKIT_EXPORT_CLASS
|
|||
- (NSArray *) backgroundColors;
|
||||
- (void) setBackgroundColors: (NSArray *)colors;
|
||||
|
||||
- (NSArray *)content;
|
||||
- (void)setContent:(NSArray *)content;
|
||||
- (NSArray *) content;
|
||||
- (void) setContent: (NSArray *)content;
|
||||
|
||||
- (id < NSCollectionViewDelegate >) delegate;
|
||||
- (void) setDelegate: (id < NSCollectionViewDelegate >)aDelegate;
|
||||
|
@ -136,9 +503,18 @@ APPKIT_EXPORT_CLASS
|
|||
- (NSIndexSet *) selectionIndexes;
|
||||
- (void) setSelectionIndexes: (NSIndexSet *)indexes;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
- (NSSet *) selectionIndexPaths;
|
||||
- (void) setSelectionIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
|
||||
- (NSCollectionViewLayout *) collectionViewLayout;
|
||||
- (void) setCollectionViewLayout: (NSCollectionViewLayout *)layout;
|
||||
#endif
|
||||
|
||||
- (NSRect) frameForItemAtIndex: (NSUInteger)index;
|
||||
- (NSCollectionViewItem *) itemAtIndex: (NSUInteger)index;
|
||||
- (NSCollectionViewItem *) newItemForRepresentedObject:(id)object;
|
||||
- (NSCollectionViewItem *) newItemForRepresentedObject: (id)object;
|
||||
|
||||
- (void) tile;
|
||||
|
||||
|
@ -149,6 +525,142 @@ APPKIT_EXPORT_CLASS
|
|||
withEvent: (NSEvent *)event
|
||||
offset: (NSPointPointer)dragImageOffset;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
/* Locating Items and Views */
|
||||
|
||||
- (NSArray *) visibleItems;
|
||||
|
||||
- (NSSet *) indexPathsForVisibleItems;
|
||||
|
||||
- (NSArray *) visibleSupplementaryViewsOfKind: (NSCollectionViewSupplementaryElementKind)elementKind;
|
||||
|
||||
- (NSSet *) indexPathsForVisibleSupplementaryElementsOfKind: (NSCollectionViewSupplementaryElementKind)elementKind;
|
||||
|
||||
- (NSIndexPath *) indexPathForItem: (NSCollectionViewItem *)item;
|
||||
|
||||
- (NSIndexPath *) indexPathForItemAtPoint: (NSPoint)point;
|
||||
|
||||
- (NSCollectionViewItem *) itemAtIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (NSView *)supplementaryViewForElementKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (void) scrollToItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
scrollPosition: (NSCollectionViewScrollPosition)scrollPosition;
|
||||
|
||||
/* Creating Collection view Items */
|
||||
|
||||
- (NSCollectionViewItem *) makeItemWithIdentifier: (NSUserInterfaceItemIdentifier)identifier
|
||||
forIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (void) registerClass: (Class)itemClass
|
||||
forItemWithIdentifier: (NSUserInterfaceItemIdentifier)identifier;
|
||||
|
||||
- (void) registerNib: (NSNib *)nib
|
||||
forItemWithIdentifier: (NSUserInterfaceItemIdentifier)identifier;
|
||||
|
||||
- (NSView *) makeSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
withIdentifier: (NSUserInterfaceItemIdentifier)identifier
|
||||
forIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (void)registerClass: (Class)viewClass
|
||||
forSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)kind
|
||||
withIdentifier: (NSUserInterfaceItemIdentifier)identifier;
|
||||
|
||||
- (void) registerNib: (NSNib *)nib
|
||||
forSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)kind
|
||||
withIdentifier: (NSUserInterfaceItemIdentifier)identifier;
|
||||
|
||||
/* Providing the collection view's data */
|
||||
|
||||
- (id<NSCollectionViewDataSource>) dataSource;
|
||||
|
||||
- (void) setDataSource: (id<NSCollectionViewDataSource>)dataSource;
|
||||
|
||||
/* Configuring the Collection view */
|
||||
|
||||
- (NSView *) backgroundView;
|
||||
|
||||
- (void) setBackgroundView: (NSView *)backgroundView;
|
||||
|
||||
- (BOOL) backgroundViewScrollsWithContent;
|
||||
|
||||
- (void) setBackgroundViewScrollsWithContent: (BOOL)f;
|
||||
|
||||
/* Reloading Content */
|
||||
|
||||
- (void) reloadData;
|
||||
|
||||
- (void) reloadSections: (NSIndexSet *)sections;
|
||||
|
||||
- (void) reloadItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
/* Prefetching Collection View Cells and Data */
|
||||
|
||||
- (id<NSCollectionViewPrefetching>) prefetchDataSource;
|
||||
|
||||
- (void) setPrefetchDataSource: (id<NSCollectionViewPrefetching>)prefetchDataSource;
|
||||
|
||||
/* Getting the State of the Collection View */
|
||||
|
||||
- (NSInteger) numberOfSections;
|
||||
|
||||
- (NSInteger) numberOfItemsInSection: (NSInteger)section;
|
||||
|
||||
/* Inserting, Moving and Deleting Items */
|
||||
|
||||
- (void) insertItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
- (void) moveItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
toIndexPath: (NSIndexPath *)newIndexPath;
|
||||
|
||||
- (void) deleteItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
/* Inserting, Moving, Deleting and Collapsing Sections */
|
||||
|
||||
- (void) insertSections: (NSIndexSet *)sections;
|
||||
|
||||
- (void) moveSection: (NSInteger)section
|
||||
toSection: (NSInteger)newSection;
|
||||
|
||||
- (void) deleteSections: (NSIndexSet *)sections;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
|
||||
- (IBAction) toggleSectionCollapse: (id)sender;
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
- (BOOL) allowsEmptySelection;
|
||||
|
||||
- (void) setAllowsEmptySelection: (BOOL)flag;
|
||||
|
||||
- (NSSet *) selectionIndexPaths; // copy
|
||||
|
||||
- (IBAction) selectAll: (id)sender;
|
||||
|
||||
- (IBAction) deselectAll: (id)sender;
|
||||
|
||||
- (void) selectItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
scrollPosition: (NSCollectionViewScrollPosition)scrollPosition;
|
||||
|
||||
- (void) deselectItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
/* Getting Layout Information */
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForSupplementaryElementOfKind: (NSCollectionViewSupplementaryElementKind)kind
|
||||
atIndexPath: (NSIndexPath *)indexPath;
|
||||
/* Animating Multiple Changes */
|
||||
|
||||
DEFINE_BLOCK_TYPE_NO_ARGS(GSCollectionViewPerformBatchUpdatesBlock, void);
|
||||
DEFINE_BLOCK_TYPE(GSCollectionViewCompletionHandlerBlock, void, BOOL);
|
||||
|
||||
- (void) performBatchUpdates: (GSCollectionViewPerformBatchUpdatesBlock) updates
|
||||
completionHandler: (GSCollectionViewCompletionHandlerBlock) completionHandler;
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
|
48
Headers/AppKit/NSCollectionViewCompositionalLayout.h
Normal file
48
Headers/AppKit/NSCollectionViewCompositionalLayout.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Definition of class NSCollectionViewCompositionalLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 _NSCollectionViewCompositionalLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSCollectionViewCompositionalLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <AppKit/NSCollectionViewLayout.h>
|
||||
#import <AppKit/AppKitDefines.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewCompositionalLayout : NSCollectionViewLayout
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSCollectionViewCompositionalLayout_h_GNUSTEP_GUI_INCLUDE */
|
156
Headers/AppKit/NSCollectionViewFlowLayout.h
Normal file
156
Headers/AppKit/NSCollectionViewFlowLayout.h
Normal file
|
@ -0,0 +1,156 @@
|
|||
/* Definition of class NSCollectionViewFlowLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 _NSCollectionViewFlowLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSCollectionViewFlowLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <AppKit/NSCollectionViewLayout.h>
|
||||
#import <AppKit/AppKitDefines.h>
|
||||
|
||||
@class NSCollectionViewLayout, NSMutableIndexSet;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
NSCollectionViewScrollDirectionVertical,
|
||||
NSCollectionViewScrollDirectionHorizontal
|
||||
};
|
||||
typedef NSInteger NSCollectionViewScrollDirection;
|
||||
|
||||
APPKIT_EXPORT NSCollectionViewSupplementaryElementKind NSCollectionElementKindSectionHeader;
|
||||
APPKIT_EXPORT NSCollectionViewSupplementaryElementKind NSCollectionElementKindSectionFooter;
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewFlowLayoutInvalidationContext : NSCollectionViewLayoutInvalidationContext
|
||||
{
|
||||
BOOL _invalidateFlowLayoutDelegateMetrics;
|
||||
BOOL _invalidateFlowLayoutAttributes;
|
||||
}
|
||||
|
||||
- (void) setInvalidateFlowLayoutDelegateMetrics: (BOOL)flag;
|
||||
- (BOOL) invalidateFlowLayoutDelegateMetrics;
|
||||
|
||||
- (void) setInvalidateFlowLayoutAttributes: (BOOL)flag;
|
||||
- (BOOL) invalidateFlowLayoutAttributes;
|
||||
@end
|
||||
|
||||
@protocol NSCollectionViewDelegateFlowLayout <NSCollectionViewDelegate>
|
||||
|
||||
- (NSSize) collectionView: (NSCollectionView *)collectionView
|
||||
layout: (NSCollectionViewLayout*)collectionViewLayout
|
||||
sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
|
||||
|
||||
- (NSEdgeInsets)collectionView: (NSCollectionView *)collectionView
|
||||
layout: (NSCollectionViewLayout *)collectionViewLayout
|
||||
insetForSectionAtIndex: (NSInteger)section;
|
||||
|
||||
- (CGFloat) collectionView: (NSCollectionView *)collectionView
|
||||
layout: (NSCollectionViewLayout *)collectionViewLayout
|
||||
minimumLineSpacingForSectionAtIndex: (NSInteger)section;
|
||||
|
||||
- (CGFloat) collectionView: (NSCollectionView *)collectionView
|
||||
layout: (NSCollectionViewLayout *)collectionViewLayout
|
||||
minimumInteritemSpacingForSectionAtIndex: (NSInteger)section;
|
||||
|
||||
- (NSSize) collectionView: (NSCollectionView *)collectionView
|
||||
layout: (NSCollectionViewLayout *)collectionViewLayout
|
||||
referenceSizeForHeaderInSection: (NSInteger)section;
|
||||
|
||||
- (NSSize) collectionView: (NSCollectionView *)collectionView
|
||||
layout: (NSCollectionViewLayout *)collectionViewLayout
|
||||
referenceSizeForFooterInSection: (NSInteger)section;
|
||||
|
||||
@end
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewFlowLayout : NSCollectionViewLayout
|
||||
{
|
||||
CGFloat _minimumLineSpacing;
|
||||
CGFloat _minimumInteritemSpacing;
|
||||
NSSize _itemSize;
|
||||
NSSize _estimatedItemSize;
|
||||
NSCollectionViewScrollDirection _scrollDirection;
|
||||
NSSize _headerReferenceSize;
|
||||
NSSize _footerReferenceSize;
|
||||
NSEdgeInsets _sectionInset;
|
||||
BOOL _sectionHeadersPinToVisibleBounds;
|
||||
BOOL _sectionFootersPinToVisibleBounds;
|
||||
NSMutableIndexSet *_collapsedSections;
|
||||
|
||||
NSInteger _ds; // deltas for when overflow happens...
|
||||
NSInteger _dr;
|
||||
|
||||
}
|
||||
|
||||
- (CGFloat) minimumLineSpacing;
|
||||
- (void) setMinimumLineSpacing: (CGFloat)spacing;
|
||||
|
||||
- (CGFloat) minimumInteritemSpacing;
|
||||
- (void) setMinimumInteritemSpacing: (CGFloat)spacing;
|
||||
|
||||
- (NSSize) itemSize;
|
||||
- (void) setItemSize: (NSSize)itemSize;
|
||||
|
||||
- (NSSize) estimatedItemSize;
|
||||
- (void) setEstimatedItemSize: (NSSize)size;
|
||||
|
||||
- (NSCollectionViewScrollDirection) scrollDirection;
|
||||
- (void) setScrollDirection: (NSCollectionViewScrollDirection)direction;
|
||||
|
||||
- (NSSize) headerReferenceSize;
|
||||
- (void) setHeaderReferenceSize: (NSSize)size;
|
||||
|
||||
- (NSSize) footerReferenceSize;
|
||||
- (void) setFooterReferenceSize: (NSSize)size;
|
||||
|
||||
- (NSEdgeInsets) sectionInset;
|
||||
- (void) setSectionInset: (NSEdgeInsets)inset;
|
||||
|
||||
- (BOOL) sectionHeadersPinToVisibleBounds;
|
||||
- (void) setSectionHeadersPinToVisibleBounds: (BOOL)f;
|
||||
|
||||
- (BOOL) sectionFootersPinToVisibleBounds;
|
||||
- (void) setSectionFootersPinToVisibleBounds: (BOOL)f;
|
||||
|
||||
- (BOOL) sectionAtIndexIsCollapsed: (NSUInteger)sectionIndex;
|
||||
|
||||
- (void) collapseSectionAtIndex: (NSUInteger)sectionIndex;
|
||||
|
||||
- (void) expandSectionAtIndex: (NSUInteger)sectionIndex;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSCollectionViewFlowLayout_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
77
Headers/AppKit/NSCollectionViewGridLayout.h
Normal file
77
Headers/AppKit/NSCollectionViewGridLayout.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/* Definition of class NSCollectionViewGridLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 _NSCollectionViewGridLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSCollectionViewGridLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSGeometry.h>
|
||||
#import <AppKit/NSCollectionViewLayout.h>
|
||||
#import <AppKit/AppKitDefines.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewGridLayout : NSCollectionViewLayout
|
||||
{
|
||||
NSUInteger _maximumNumberOfRows;
|
||||
NSUInteger _maximumNumberOfColumns;
|
||||
NSSize _minimumItemSize;
|
||||
NSSize _maximumItemSize;
|
||||
NSEdgeInsets _margins;
|
||||
CGFloat _minimumInteritemSpacing;
|
||||
}
|
||||
|
||||
- (void) setMaximumNumberOfRows: (NSUInteger)maxRows;
|
||||
- (NSUInteger) maximumNumberOfRows;
|
||||
|
||||
- (void) setMaximumNumberOfColumns: (NSUInteger)maxCols;
|
||||
- (NSUInteger) maximumNumberOfColumns;
|
||||
|
||||
- (void) setMinimumItemSize: (NSSize)minSize;
|
||||
- (NSSize) minimumItemSize;
|
||||
|
||||
- (void) setMaximumItemSize: (NSSize)maxSize;
|
||||
- (NSSize) maximumItemSize;;
|
||||
|
||||
- (void) setMargins: (NSEdgeInsets)insets;
|
||||
- (NSEdgeInsets) margins;
|
||||
|
||||
- (void) setMinimumInteritemSpacing: (CGFloat)spacing;
|
||||
- (CGFloat) minimumInteritemSpacing;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSCollectionViewGridLayout_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
|
@ -31,18 +31,18 @@
|
|||
#import <AppKit/AppKitDefines.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
#import <AppKit/NSCollectionView.h>
|
||||
#import <AppKit/NSDragging.h>
|
||||
#import <AppKit/NSImageView.h>
|
||||
#import <AppKit/NSNibDeclarations.h>
|
||||
#import <AppKit/NSTextField.h>
|
||||
#import <AppKit/NSView.h>
|
||||
#import <AppKit/NSViewController.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@class NSImageView, NSTextField;
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewItem : NSViewController
|
||||
@interface NSCollectionViewItem : NSViewController <NSCopying>
|
||||
{
|
||||
IBOutlet NSTextField *textField;
|
||||
IBOutlet NSImageView *imageView;
|
||||
|
@ -63,4 +63,6 @@ APPKIT_EXPORT_CLASS
|
|||
|
||||
@end
|
||||
|
||||
#endif /* _GNUstep_H_NSCollectionView */
|
||||
#endif /* OS_API_MACOSX */
|
||||
|
||||
#endif /* _GNUstep_H_NSCollectionViewItem */
|
||||
|
|
267
Headers/AppKit/NSCollectionViewLayout.h
Normal file
267
Headers/AppKit/NSCollectionViewLayout.h
Normal file
|
@ -0,0 +1,267 @@
|
|||
/* Interface of class NSCollectionViewLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 _NSCollectionViewLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSCollectionViewLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSGeometry.h>
|
||||
|
||||
#import <AppKit/NSCollectionView.h>
|
||||
#import <AppKit/AppKitDefines.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
NSCollectionElementCategoryItem,
|
||||
NSCollectionElementCategorySupplementaryView,
|
||||
NSCollectionElementCategoryDecorationView,
|
||||
NSCollectionElementCategoryInterItemGap
|
||||
};
|
||||
typedef NSInteger NSCollectionElementCategory;
|
||||
|
||||
|
||||
typedef NSString *NSCollectionViewDecorationElementKind;
|
||||
APPKIT_EXPORT NSCollectionViewSupplementaryElementKind NSCollectionElementKindInterItemGapIndicator;
|
||||
|
||||
@class NSCollectionViewLayoutAttributes;
|
||||
@class NSCollectionView;
|
||||
@class NSDictionary;
|
||||
@class NSIndexPath;
|
||||
@class NSMutableDictionary;
|
||||
@class NSNib;
|
||||
@class NSSet;
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewLayoutAttributes : NSObject <NSCopying>
|
||||
{
|
||||
NSRect _frame;
|
||||
CGFloat _alpha;
|
||||
NSInteger _zIndex;
|
||||
BOOL _hidden;
|
||||
NSIndexPath *_indexPath;
|
||||
NSCollectionElementCategory _representedElementCategory;
|
||||
NSString *_representedElementKind;
|
||||
}
|
||||
|
||||
// Initializers
|
||||
+ (instancetype) layoutAttributesForItemWithIndexPath: (NSIndexPath *)indexPath;
|
||||
+ (instancetype) layoutAttributesForInterItemGapBeforeIndexPath: (NSIndexPath *)indexPath;
|
||||
+ (instancetype) layoutAttributesForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
withIndexPath: (NSIndexPath *)indexPath;
|
||||
+ (instancetype)layoutAttributesForDecorationViewOfKind:(NSCollectionViewDecorationElementKind)decorationViewKind
|
||||
withIndexPath: (NSIndexPath*)indexPath;
|
||||
|
||||
// Properties
|
||||
- (NSRect) frame;
|
||||
- (void) setFrame: (NSRect)frame;
|
||||
|
||||
- (NSSize) size;
|
||||
- (void) setSize: (NSSize)size;
|
||||
|
||||
- (CGFloat) alpha;
|
||||
- (void) setAlpha: (CGFloat)alpha;
|
||||
|
||||
- (BOOL) isHidden;
|
||||
- (void) setHidden: (BOOL)hidden;
|
||||
|
||||
- (NSIndexPath *) indexPath;
|
||||
- (void) setIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (NSCollectionElementCategory) representedElementCategory;
|
||||
- (NSString *) representedElementKind;
|
||||
|
||||
- (NSInteger) zIndex;
|
||||
- (void) setZIndex: (NSInteger)zIndex;
|
||||
|
||||
@end
|
||||
|
||||
enum
|
||||
{
|
||||
NSCollectionUpdateActionInsert,
|
||||
NSCollectionUpdateActionDelete,
|
||||
NSCollectionUpdateActionReload,
|
||||
NSCollectionUpdateActionMove,
|
||||
NSCollectionUpdateActionNone
|
||||
};
|
||||
typedef NSInteger NSCollectionUpdateAction;
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewUpdateItem : NSObject
|
||||
{
|
||||
NSIndexPath *_indexPathBeforeUpdate;
|
||||
NSIndexPath *_indexPathAfterUpdate;
|
||||
NSCollectionUpdateAction _updateAction;
|
||||
}
|
||||
|
||||
- (NSIndexPath *) indexPathBeforeUpdate;
|
||||
- (NSIndexPath *) indexPathAfterUpdate;
|
||||
- (NSCollectionUpdateAction) updateAction;
|
||||
|
||||
@end
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewLayoutInvalidationContext : NSObject
|
||||
{
|
||||
NSPoint _contentOffsetAdjustment;
|
||||
NSSize _contentSizeAdjustment;
|
||||
NSSet *_invalidatedItemIndexPaths;
|
||||
NSDictionary *_invalidatedSupplementaryIndexPaths;
|
||||
NSDictionary *_invalidatedDecorationIndexPaths;
|
||||
}
|
||||
|
||||
// Initializers
|
||||
- (void)invalidateItemsAtIndexPaths: (NSSet *)indexPaths;
|
||||
- (void)invalidateSupplementaryElementsOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPaths: (NSSet *)indexPaths;
|
||||
- (void)invalidateDecorationElementsOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPaths: (NSSet *)indexPaths;
|
||||
|
||||
// Properties
|
||||
- (BOOL) invalidateEverything;
|
||||
- (BOOL) invalidateDataSourceCounts;
|
||||
|
||||
- (NSSet *) invalidatedItemIndexPaths;
|
||||
|
||||
- (NSPoint) contentOffsetAdjustment;
|
||||
- (void) setContentOffsetAdjustment: (NSPoint)point;
|
||||
|
||||
- (NSSize) contentSizeAdjustment;
|
||||
- (void) setContentSizeAdjustment: (NSSize)size;
|
||||
|
||||
- (NSDictionary *) invalidatedSupplementaryIndexPaths;
|
||||
- (NSDictionary *) invalidatedDecorationIndexPaths;
|
||||
|
||||
@end
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewLayout : NSObject <NSCoding>
|
||||
{
|
||||
NSCollectionView *_collectionView; // weak
|
||||
BOOL _valid;
|
||||
|
||||
Class _layoutAttributesClass;
|
||||
Class _invalidationContextClass;
|
||||
NSSize _collectionViewContentSize;
|
||||
}
|
||||
|
||||
// Initializers
|
||||
- (void)invalidateLayout;
|
||||
- (void)invalidateLayoutWithContext: (NSCollectionViewLayoutInvalidationContext *)context;
|
||||
|
||||
- (void)registerClass: (Class)viewClass
|
||||
forDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind;
|
||||
- (void)registerNib: (NSNib *)nib
|
||||
forDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind;
|
||||
|
||||
// Properties
|
||||
- (NSCollectionView *) collectionView;
|
||||
- (void) setCollectionView: (NSCollectionView *)cv;
|
||||
|
||||
@end
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewLayout (NSSubclassingHooks)
|
||||
|
||||
// Methods to override for specific layouts...
|
||||
- (void) prepareLayout;
|
||||
- (NSArray *) layoutAttributesForElementsInRect: (NSRect)rect;
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath;
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForDropTargetAtPoint: (NSPoint)pointInCollectionView;
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForInterItemGapBeforeIndexPath: (NSIndexPath *)indexPath;
|
||||
|
||||
- (BOOL) shouldInvalidateLayoutForBoundsChange: (NSRect)newBounds;
|
||||
- (NSCollectionViewLayoutInvalidationContext *) invalidationContextForBoundsChange: (NSRect)newBounds;
|
||||
|
||||
- (BOOL) shouldInvalidateLayoutForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes;
|
||||
|
||||
- (NSCollectionViewLayoutInvalidationContext *)
|
||||
invalidationContextForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes;
|
||||
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset
|
||||
withScrollingVelocity: (NSPoint)velocity;
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset;
|
||||
|
||||
- (NSSize) collectionViewContentSize;
|
||||
|
||||
@end
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewLayout (NSUpdateSupportHooks)
|
||||
|
||||
// Update support
|
||||
- (void) prepareForCollectionViewUpdates: (NSArray *)updateItems;
|
||||
- (void) finalizeCollectionViewUpdates;
|
||||
- (void) prepareForAnimatedBoundsChange: (NSRect)oldBounds;
|
||||
- (void) finalizeAnimatedBoundsChange;
|
||||
|
||||
- (void) prepareForTransitionToLayout: (NSCollectionViewLayout *)newLayout;
|
||||
- (void) prepareForTransitionFromLayout: (NSCollectionViewLayout *)oldLayout;
|
||||
- (void) finalizeLayoutTransition;
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) initialLayoutAttributesForAppearingItemAtIndexPath: (NSIndexPath *)itemIndexPath;
|
||||
- (NSCollectionViewLayoutAttributes *) finalLayoutAttributesForDisappearingItemAtIndexPath: (NSIndexPath *)itemIndexPath;
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
initialLayoutAttributesForAppearingSupplementaryElementOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)elementIndexPath;
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
finalLayoutAttributesForDisappearingSupplementaryElementOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)elementIndexPath;
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
initialLayoutAttributesForAppearingDecorationElementOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)decorationIndexPath;
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
finalLayoutAttributesForDisappearingDecorationElementOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)decorationIndexPath;
|
||||
|
||||
- (NSSet *) indexPathsToDeleteForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind;
|
||||
- (NSSet *) indexPathsToDeleteForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind;
|
||||
- (NSSet *) indexPathsToInsertForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind;
|
||||
- (NSSet *) indexPathsToInsertForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSCollectionViewLayout_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
69
Headers/AppKit/NSCollectionViewTransitionLayout.h
Normal file
69
Headers/AppKit/NSCollectionViewTransitionLayout.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* Definition of class NSCollectionViewTransitionLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 _NSCollectionViewTransitionLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
#define _NSCollectionViewTransitionLayout_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#import <AppKit/NSCollectionViewLayout.h>
|
||||
#import <AppKit/AppKitDefines.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11, GS_API_LATEST)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef NSString* NSCollectionViewTransitionLayoutAnimatedKey;
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSCollectionViewTransitionLayout : NSCollectionViewLayout
|
||||
{
|
||||
CGFloat _transitionProgress;
|
||||
NSCollectionViewLayout *_currentLayout;
|
||||
NSCollectionViewLayout *_nextLayout;
|
||||
}
|
||||
|
||||
- (CGFloat) transitionProgress;
|
||||
- (void) setTransitionProgress: (CGFloat)transitionProgress;
|
||||
|
||||
- (NSCollectionViewLayout *) currentLayout;
|
||||
- (NSCollectionViewLayout *) nextLayout;
|
||||
|
||||
// Designated initializer
|
||||
- (instancetype) initWithCurrentLayout: (NSCollectionViewLayout *)currentLayout
|
||||
nextLayout: (NSCollectionViewLayout *)nextLayout;
|
||||
|
||||
- (void) updateValue: (CGFloat)value forAnimatedKey: (NSCollectionViewTransitionLayoutAnimatedKey)key;
|
||||
- (CGFloat) valueForAnimatedKey: (NSCollectionViewTransitionLayoutAnimatedKey)key;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSCollectionViewTransitionLayout_h_GNUSTEP_GUI_INCLUDE */
|
||||
|
|
@ -74,7 +74,7 @@ typedef enum _NSFontRenderingMode
|
|||
} NSFontRenderingMode;
|
||||
#endif
|
||||
|
||||
APPKIT_EXPORT const CGFloat *NSFontIdentityMatrix;
|
||||
APPKIT_EXPORT const CGFloat NSFontIdentityMatrix[6];
|
||||
|
||||
APPKIT_EXPORT_CLASS
|
||||
@interface NSFont : NSObject <NSCoding, NSCopying>
|
||||
|
|
|
@ -88,6 +88,9 @@ APPKIT_EXPORT_CLASS
|
|||
|
||||
- (NSString *)nibName;
|
||||
- (NSBundle *)nibBundle;
|
||||
|
||||
- (void) viewWillLoad;
|
||||
- (void) viewDidLoad;
|
||||
@end
|
||||
|
||||
#endif // OS_API_VERSION
|
||||
|
|
5
MISSING
5
MISSING
|
@ -1,11 +1,6 @@
|
|||
MISSING HEADERS ( * = difficult, - = quick, + = placeholder, x = won't do )
|
||||
---
|
||||
> NSATSTypesetter.h +
|
||||
> NSCollectionViewCompositionalLayout.h *
|
||||
> NSCollectionViewFlowLayout.h *
|
||||
> NSCollectionViewGridLayout.h *
|
||||
> NSCollectionViewLayout.h *
|
||||
> NSCollectionViewTransitionLayout.h *
|
||||
> NSDictionaryController.h -
|
||||
> NSDiffableDataSource.h *
|
||||
> NSDraggingItem.h -
|
||||
|
|
|
@ -76,6 +76,11 @@ NSClipView.m \
|
|||
NSClickGestureRecognizer.m \
|
||||
NSCollectionView.m \
|
||||
NSCollectionViewItem.m \
|
||||
NSCollectionViewLayout.m \
|
||||
NSCollectionViewCompositionalLayout.m \
|
||||
NSCollectionViewFlowLayout.m \
|
||||
NSCollectionViewGridLayout.m \
|
||||
NSCollectionViewTransitionLayout.m \
|
||||
NSColor.m \
|
||||
NSColorList.m \
|
||||
NSColorPanel.m \
|
||||
|
@ -402,6 +407,11 @@ NSClickGestureRecognizer.h \
|
|||
NSClipView.h \
|
||||
NSCollectionView.h \
|
||||
NSCollectionViewItem.h \
|
||||
NSCollectionViewLayout.h \
|
||||
NSCollectionViewCompositionalLayout.h \
|
||||
NSCollectionViewFlowLayout.h \
|
||||
NSCollectionViewGridLayout.h \
|
||||
NSCollectionViewTransitionLayout.h \
|
||||
NSColor.h \
|
||||
NSColorList.h \
|
||||
NSColorPanel.h \
|
||||
|
|
|
@ -47,10 +47,12 @@
|
|||
#import "AppKit/NSFormCell.h"
|
||||
#import "AppKit/NSGridView.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
#import "AppKit/NSLayoutConstraint.h"
|
||||
#import "AppKit/NSMatrix.h"
|
||||
#import "AppKit/NSMenu.h"
|
||||
#import "AppKit/NSMenuItem.h"
|
||||
#import "AppKit/NSNib.h"
|
||||
#import "AppKit/NSPageController.h"
|
||||
#import "AppKit/NSParagraphStyle.h"
|
||||
#import "AppKit/NSPathCell.h"
|
||||
#import "AppKit/NSPopUpButton.h"
|
||||
|
@ -66,8 +68,6 @@
|
|||
#import "AppKit/NSTabView.h"
|
||||
#import "AppKit/NSToolbarItem.h"
|
||||
#import "AppKit/NSView.h"
|
||||
#import "AppKit/NSLayoutConstraint.h"
|
||||
#import "AppKit/NSPageController.h"
|
||||
#import "GSCodingFlags.h"
|
||||
|
||||
#define DEBUG_XIB5 0
|
||||
|
@ -324,6 +324,7 @@ static NSArray *XmlBoolDefaultYes = nil;
|
|||
@"beginningViews", @"NSStackViewBeginningContainer", // NSStackView
|
||||
@"middleViews", @"NSStackViewMiddleContainer",
|
||||
@"endViews", @"NSStackViewEndContainer",
|
||||
@"collectionViewLayout", @"NSCollectionViewLayout",
|
||||
nil];
|
||||
RETAIN(XmlKeyMapTable);
|
||||
|
||||
|
@ -3318,6 +3319,10 @@ didStartElement: (NSString*)elementName
|
|||
// New xib stores values as attributes...
|
||||
object = [currentElement attributeForKey: key];
|
||||
}
|
||||
else if ([@"NSCollectionViewBackgroundColor" isEqualToString: key])
|
||||
{
|
||||
object = [self decodeObjectForKey: @"primaryBackgroundColor"];
|
||||
}
|
||||
else if (([@"NSSearchButtonCell" isEqualToString: key]) ||
|
||||
([@"NSCancelButtonCell" isEqualToString: key]))
|
||||
{
|
||||
|
@ -3539,6 +3544,10 @@ didStartElement: (NSString*)elementName
|
|||
{
|
||||
hasValue = [self containsValueForKey: [XmlKeyMapTable objectForKey: key]];
|
||||
}
|
||||
else if ([@"NSBackgroundColors" isEqualToString: key])
|
||||
{
|
||||
hasValue = [currentElement elementForKey: @"primaryBackgroundColor"] != nil;
|
||||
}
|
||||
else if (([@"NSIntercellSpacingHeight" isEqualToString: key]) ||
|
||||
([@"NSIntercellSpacingWidth" isEqualToString: key]))
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
30
Source/NSCollectionViewCompositionalLayout.m
Normal file
30
Source/NSCollectionViewCompositionalLayout.m
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Implementation of class NSCollectionViewCompositionalLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 "AppKit/NSCollectionViewCompositionalLayout.h"
|
||||
|
||||
@implementation NSCollectionViewCompositionalLayout
|
||||
|
||||
@end
|
||||
|
518
Source/NSCollectionViewFlowLayout.m
Normal file
518
Source/NSCollectionViewFlowLayout.m
Normal file
|
@ -0,0 +1,518 @@
|
|||
/* Implementation of class NSCollectionViewFlowLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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/NSIndexPath.h>
|
||||
|
||||
#import "AppKit/NSCollectionView.h"
|
||||
#import "AppKit/NSCollectionViewFlowLayout.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
|
||||
#import "GSGuiPrivate.h"
|
||||
|
||||
@implementation NSCollectionViewFlowLayoutInvalidationContext
|
||||
|
||||
- (instancetype) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_invalidateFlowLayoutAttributes = YES;
|
||||
_invalidateFlowLayoutDelegateMetrics = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) setInvalidateFlowLayoutDelegateMetrics: (BOOL)flag
|
||||
{
|
||||
_invalidateFlowLayoutDelegateMetrics = flag;
|
||||
}
|
||||
|
||||
- (BOOL) invalidateFlowLayoutDelegateMetrics
|
||||
{
|
||||
return _invalidateFlowLayoutDelegateMetrics;
|
||||
}
|
||||
|
||||
- (void) setInvalidateFlowLayoutAttributes: (BOOL)flag
|
||||
{
|
||||
_invalidateFlowLayoutAttributes = flag;
|
||||
}
|
||||
|
||||
- (BOOL) invalidateFlowLayoutAttributes
|
||||
{
|
||||
return _invalidateFlowLayoutAttributes;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewFlowLayout
|
||||
|
||||
- (instancetype) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_collapsedSections = [[NSMutableIndexSet alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_collapsedSections);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self)
|
||||
{
|
||||
_collapsedSections = [[NSMutableIndexSet alloc] init];
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSMinimumLineSpacing"])
|
||||
{
|
||||
_minimumLineSpacing = [coder decodeFloatForKey: @"NSMinimumLineSpacing"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSMinimumInteritemSpacing"])
|
||||
{
|
||||
_minimumInteritemSpacing = [coder decodeFloatForKey: @"NSMinimumInteritemSpacing"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSItemSize"])
|
||||
{
|
||||
_itemSize = [coder decodeSizeForKey: @"NSItemSize"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSEstimatedItemSize"])
|
||||
{
|
||||
_estimatedItemSize = [coder decodeSizeForKey: @"NSEstimatedItemSize"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSScrollDirection"])
|
||||
{
|
||||
_scrollDirection = [coder decodeIntForKey: @"NSScrollDirection"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSHeaderReferenceSize"])
|
||||
{
|
||||
_headerReferenceSize = [coder decodeSizeForKey: @"NSHeaderReferneceSize"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSFooterReferenceSize"])
|
||||
{
|
||||
_footerReferenceSize = [coder decodeSizeForKey: @"NSFooterReferenceSize"];
|
||||
}
|
||||
|
||||
// decode inset...
|
||||
if ([coder containsValueForKey: @"NSSectionInset.bottom"])
|
||||
{
|
||||
_sectionInset.bottom = [coder decodeFloatForKey: @"NSSectionInset.bottom"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSSectionInset.top"])
|
||||
{
|
||||
_sectionInset.top = [coder decodeFloatForKey: @"NSSectionInset.top"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSSectionInset.left"])
|
||||
{
|
||||
_sectionInset.left = [coder decodeFloatForKey: @"NSSectionInset.left"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSSectionInset.right"])
|
||||
{
|
||||
_sectionInset.right = [coder decodeFloatForKey: @"NSSectionInset.right"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSSectionHeadersPinToVisibleBounds"])
|
||||
{
|
||||
_sectionHeadersPinToVisibleBounds = [coder decodeBoolForKey: @"NSSectionHeadersPinToVisibleBounds"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSSectionFootersPinToVisibleBounds"])
|
||||
{
|
||||
_sectionFootersPinToVisibleBounds = [coder decodeBoolForKey: @"NSSectionFootersPinToVisibleBounds"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_minimumInteritemSpacing];
|
||||
_itemSize = [coder decodeSize];
|
||||
_estimatedItemSize = [coder decodeSize];
|
||||
decode_NSInteger(coder, &_scrollDirection);
|
||||
_headerReferenceSize = [coder decodeSize];
|
||||
_footerReferenceSize = [coder decodeSize];
|
||||
|
||||
// decode inset...
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.bottom];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.top];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.left];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.right];
|
||||
|
||||
|
||||
[coder decodeValueOfObjCType: @encode(BOOL)
|
||||
at: &_sectionHeadersPinToVisibleBounds];
|
||||
[coder decodeValueOfObjCType: @encode(BOOL)
|
||||
at: &_sectionFootersPinToVisibleBounds];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
[coder encodeFloat: _minimumLineSpacing
|
||||
forKey: @"NSMinimumLineSpacing"];
|
||||
[coder encodeFloat: _minimumInteritemSpacing
|
||||
forKey: @"NSMinimumInteritemSpacing"];
|
||||
[coder encodeSize: _itemSize
|
||||
forKey: @"NSItemSize"];
|
||||
[coder encodeSize: _estimatedItemSize
|
||||
forKey: @"NSEstimatedItemSize"];
|
||||
[coder encodeInt: _scrollDirection
|
||||
forKey: @"NSScrollDirection"];
|
||||
[coder encodeSize: _headerReferenceSize
|
||||
forKey: @"NSHeaderReferneceSize"];
|
||||
[coder encodeSize: _footerReferenceSize
|
||||
forKey: @"NSFooterReferenceSize"];
|
||||
|
||||
// decode inset...
|
||||
[coder encodeFloat: _sectionInset.bottom
|
||||
forKey: @"NSSectionInset.bottom"];
|
||||
[coder encodeFloat: _sectionInset.top
|
||||
forKey: @"NSSectionInset.top"];
|
||||
[coder encodeFloat: _sectionInset.left
|
||||
forKey: @"NSSectionInset.left"];
|
||||
[coder encodeFloat: _sectionInset.right
|
||||
forKey: @"NSSectionInset.right"];
|
||||
|
||||
[coder encodeBool: _sectionHeadersPinToVisibleBounds
|
||||
forKey: @"NSSectionHeadersPinToVisibleBounds"];
|
||||
[coder encodeBool: _sectionFootersPinToVisibleBounds
|
||||
forKey: @"NSSectionFootersPinToVisibleBounds"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_minimumInteritemSpacing];
|
||||
[coder encodeSize: _itemSize];
|
||||
[coder encodeSize: _estimatedItemSize];
|
||||
encode_NSInteger(coder, &_scrollDirection);
|
||||
[coder encodeSize: _headerReferenceSize];
|
||||
[coder encodeSize: _footerReferenceSize];
|
||||
|
||||
// decode inset...
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.bottom];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.top];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.left];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat)
|
||||
at: &_sectionInset.right];
|
||||
|
||||
|
||||
[coder encodeValueOfObjCType: @encode(BOOL)
|
||||
at: &_sectionHeadersPinToVisibleBounds];
|
||||
[coder encodeValueOfObjCType: @encode(BOOL)
|
||||
at: &_sectionFootersPinToVisibleBounds];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat) minimumLineSpacing
|
||||
{
|
||||
return _minimumLineSpacing;
|
||||
}
|
||||
|
||||
- (void) setMinimumLineSpacing: (CGFloat)spacing
|
||||
{
|
||||
_minimumLineSpacing = spacing;
|
||||
}
|
||||
|
||||
- (CGFloat) minimumInteritemSpacing
|
||||
{
|
||||
return _minimumInteritemSpacing;
|
||||
}
|
||||
|
||||
- (void) setMinimumInteritemSpacing: (CGFloat)spacing
|
||||
{
|
||||
_minimumInteritemSpacing = spacing;
|
||||
}
|
||||
|
||||
- (NSSize) itemSize
|
||||
{
|
||||
return _itemSize;
|
||||
}
|
||||
|
||||
- (void) setItemSize: (NSSize)itemSize
|
||||
{
|
||||
_itemSize = itemSize;
|
||||
}
|
||||
|
||||
- (NSSize) estimatedItemSize
|
||||
{
|
||||
return _estimatedItemSize;
|
||||
}
|
||||
|
||||
- (void) setEstimatedItemSize: (NSSize)size
|
||||
{
|
||||
_estimatedItemSize = size;
|
||||
}
|
||||
|
||||
- (NSCollectionViewScrollDirection) scrollDirection
|
||||
{
|
||||
return _scrollDirection;
|
||||
}
|
||||
|
||||
- (void) setScrollDirection: (NSCollectionViewScrollDirection)direction
|
||||
{
|
||||
_scrollDirection = direction;
|
||||
}
|
||||
|
||||
- (NSSize) headerReferenceSize
|
||||
{
|
||||
return _headerReferenceSize;
|
||||
}
|
||||
|
||||
- (void) setHeaderReferenceSize: (NSSize)size
|
||||
{
|
||||
_headerReferenceSize = size;
|
||||
}
|
||||
|
||||
- (NSSize) footerReferenceSize
|
||||
{
|
||||
return _footerReferenceSize;
|
||||
}
|
||||
|
||||
- (void) setFooterReferenceSize: (NSSize)size
|
||||
{
|
||||
_footerReferenceSize = size;
|
||||
}
|
||||
|
||||
- (NSEdgeInsets) sectionInset
|
||||
{
|
||||
return _sectionInset;
|
||||
}
|
||||
|
||||
- (void) setSectionInset: (NSEdgeInsets)inset
|
||||
{
|
||||
_sectionInset = inset;
|
||||
}
|
||||
|
||||
- (BOOL) sectionHeadersPinToVisibleBounds
|
||||
{
|
||||
return _sectionHeadersPinToVisibleBounds;
|
||||
}
|
||||
|
||||
- (void) setSectionHeadersPinToVisibleBounds: (BOOL)f
|
||||
{
|
||||
_sectionHeadersPinToVisibleBounds = f;
|
||||
}
|
||||
|
||||
- (BOOL) sectionFootersPinToVisibleBounds
|
||||
{
|
||||
return _sectionFootersPinToVisibleBounds;
|
||||
}
|
||||
|
||||
- (void) setSectionFootersPinToVisibleBounds: (BOOL)f
|
||||
{
|
||||
_sectionFootersPinToVisibleBounds = f;
|
||||
}
|
||||
|
||||
- (BOOL) sectionAtIndexIsCollapsed: (NSUInteger)sectionIndex
|
||||
{
|
||||
return [_collapsedSections containsIndex: sectionIndex];
|
||||
}
|
||||
|
||||
- (void) collapseSectionAtIndex: (NSUInteger)sectionIndex
|
||||
{
|
||||
[_collapsedSections addIndex: sectionIndex];
|
||||
}
|
||||
|
||||
- (void) expandSectionAtIndex: (NSUInteger)sectionIndex
|
||||
{
|
||||
[_collapsedSections removeIndex: sectionIndex];
|
||||
}
|
||||
|
||||
// Methods to override for specific layouts...
|
||||
- (void) prepareLayout
|
||||
{
|
||||
[super prepareLayout];
|
||||
_ds = 0;
|
||||
_dr = 0;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *attrs = AUTORELEASE([[NSCollectionViewLayoutAttributes alloc] init]);
|
||||
NSSize sz = NSZeroSize;
|
||||
id <NSCollectionViewDelegateFlowLayout> delegate = (id <NSCollectionViewDelegateFlowLayout>)[_collectionView delegate];
|
||||
NSInteger section = [indexPath section];
|
||||
NSInteger row = [indexPath item];
|
||||
NSEdgeInsets insets;
|
||||
CGFloat mls = 0.0;
|
||||
CGFloat mis = 0.0;
|
||||
CGFloat h = 0.0, w = 0.0, x = 0.0, y = 0.0;
|
||||
NSRect f = NSZeroRect;
|
||||
NSRect vf = [_collectionView frame]; // needed for reflow...
|
||||
|
||||
// Item size...
|
||||
if ([delegate respondsToSelector: @selector(collectionView:layout:sizeForItemAtIndexPath:)])
|
||||
{
|
||||
sz = [delegate collectionView: _collectionView
|
||||
layout: self
|
||||
sizeForItemAtIndexPath: indexPath];
|
||||
}
|
||||
else
|
||||
{
|
||||
sz = [self itemSize];
|
||||
}
|
||||
|
||||
// Inset
|
||||
if ([delegate respondsToSelector: @selector(collectionView:layout:insetForSectionAtIndex:)])
|
||||
{
|
||||
insets = [delegate collectionView: _collectionView
|
||||
layout: self
|
||||
insetForSectionAtIndex: section];
|
||||
}
|
||||
else
|
||||
{
|
||||
insets = [self sectionInset];
|
||||
}
|
||||
|
||||
// minimum line spacing
|
||||
if ([delegate respondsToSelector: @selector(collectionView:layout:minimimLineSpacingForSectionAtIndex:)])
|
||||
{
|
||||
mls = [delegate collectionView: _collectionView
|
||||
layout: self
|
||||
minimumLineSpacingForSectionAtIndex: section];
|
||||
}
|
||||
else
|
||||
{
|
||||
mls = [self minimumLineSpacing];
|
||||
}
|
||||
|
||||
// minimum interitem spacing
|
||||
if ([delegate respondsToSelector: @selector(collectionView:layout:minimimInteritemSpacingForSectionAtIndex:)])
|
||||
{
|
||||
mis = [delegate collectionView: _collectionView
|
||||
layout: self
|
||||
minimumInteritemSpacingForSectionAtIndex: section];
|
||||
}
|
||||
else
|
||||
{
|
||||
mis = [self minimumInteritemSpacing];
|
||||
}
|
||||
|
||||
// Calculations...
|
||||
h = sz.height;
|
||||
w = sz.width;
|
||||
x = (row * w) + insets.left + mis;
|
||||
y = (section * h) + insets.top + mls;
|
||||
f = NSMakeRect(x, y, w, h);
|
||||
|
||||
// Determine if it is needed to reflow the given element...
|
||||
if ((x + w) > vf.size.width)
|
||||
{
|
||||
_ds += 1;
|
||||
x = insets.left + mis;
|
||||
y = ((section + _ds) * h) + insets.top + mls;
|
||||
f = NSMakeRect(x, y, w, h);
|
||||
}
|
||||
|
||||
// Build attrs object...
|
||||
[attrs setFrame: f];
|
||||
[attrs setZIndex: 0];
|
||||
[attrs setSize: f.size];
|
||||
[attrs setHidden: NO];
|
||||
[attrs setAlpha: 1.0];
|
||||
|
||||
return attrs;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)layoutAttributesForDropTargetAtPoint: (NSPoint)pointInCollectionView
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)layoutAttributesForInterItemGapBeforeIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)shouldInvalidateLayoutForBoundsChange: (NSRect)newBounds
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange: (NSRect)newBounds
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)shouldInvalidateLayoutForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutInvalidationContext *)
|
||||
invalidationContextForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset
|
||||
withScrollingVelocity: (NSPoint)velocity
|
||||
{
|
||||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset
|
||||
{
|
||||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (NSSize) collectionViewContentSize
|
||||
{
|
||||
return [_collectionView frame].size;
|
||||
}
|
||||
// end subclassing hooks...
|
||||
|
||||
@end
|
||||
|
271
Source/NSCollectionViewGridLayout.m
Normal file
271
Source/NSCollectionViewGridLayout.m
Normal file
|
@ -0,0 +1,271 @@
|
|||
/* Implementation of class NSCollectionViewGridLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 "AppKit/NSCollectionViewGridLayout.h"
|
||||
|
||||
#import "GSGuiPrivate.h"
|
||||
|
||||
@implementation NSCollectionViewGridLayout
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder: coder];
|
||||
if (self)
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSMaximumNumberOfRows"])
|
||||
{
|
||||
_maximumNumberOfRows = [coder decodeIntegerForKey: @"NSMaximumNumberOfRows"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSMaximumNumberOfColumns"])
|
||||
{
|
||||
_maximumNumberOfColumns = [coder decodeIntegerForKey: @"NSMaximumNumberOfColumns"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSMaximumItemSize"])
|
||||
{
|
||||
_maximumItemSize = [coder decodeSizeForKey: @"NSMaximumItemSize"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSMinimumItemSize"])
|
||||
{
|
||||
_minimumItemSize = [coder decodeSizeForKey: @"NSMinimumItemSize"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSMinimumInteritemSpacing"])
|
||||
{
|
||||
_minimumInteritemSpacing = [coder decodeFloatForKey: @"NSMinimumInteritemSpacing"];
|
||||
}
|
||||
|
||||
// margins...
|
||||
if ([coder containsValueForKey: @"NSCollectionViewGridLayoutMargins.bottom"])
|
||||
{
|
||||
_margins.bottom = [coder decodeFloatForKey: @"NSCollectionViewGridLayoutMargins.bottom"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSCollectionViewGridLayoutMargins.top"])
|
||||
{
|
||||
_margins.top = [coder decodeFloatForKey: @"NSCollectionViewGridLayoutMargins.top"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSCollectionViewGridLayoutMargins.left"])
|
||||
{
|
||||
_margins.left = [coder decodeFloatForKey: @"NSCollectionViewGridLayoutMargins.left"];
|
||||
}
|
||||
|
||||
if ([coder containsValueForKey: @"NSCollectionViewGridLayoutMargins.right"])
|
||||
{
|
||||
_margins.right = [coder decodeFloatForKey: @"NSCollectionViewGridLayoutMargins.right"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
decode_NSUInteger(coder, &_maximumNumberOfRows);
|
||||
decode_NSUInteger(coder, &_maximumNumberOfColumns);
|
||||
|
||||
_maximumItemSize = [coder decodeSize];
|
||||
_minimumItemSize = [coder decodeSize];
|
||||
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat) at: &_minimumInteritemSpacing];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat) at: &_margins.bottom];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat) at: &_margins.top];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat) at: &_margins.left];
|
||||
[coder decodeValueOfObjCType: @encode(CGFloat) at: &_margins.right];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
[coder encodeInteger: _maximumNumberOfRows
|
||||
forKey: @"NSMaximumNumberOfRows"];
|
||||
[coder encodeInteger: _maximumNumberOfColumns
|
||||
forKey: @"NSMaximumNumberOfColumns"];
|
||||
|
||||
[coder encodeSize: _maximumItemSize
|
||||
forKey: @"NSMaximumItemSize"];
|
||||
[coder encodeSize: _minimumItemSize
|
||||
forKey: @"NSMinimumItemSize"];
|
||||
|
||||
[coder encodeFloat: _minimumInteritemSpacing
|
||||
forKey: @"NSMinimumInteritemSpacing"];
|
||||
|
||||
[coder encodeFloat: _margins.bottom
|
||||
forKey: @"NSCollectionViewGridLayoutMargins.bottom"];
|
||||
[coder encodeFloat: _margins.top
|
||||
forKey: @"NSCollectionViewGridLayoutMargins.top"];
|
||||
[coder encodeFloat: _margins.left
|
||||
forKey: @"NSCollectionViewGridLayoutMargins.left"];
|
||||
[coder encodeFloat: _margins.right
|
||||
forKey: @"NSCollectionViewGridLayoutMargins.right"];
|
||||
}
|
||||
else
|
||||
{
|
||||
encode_NSUInteger(coder, &_maximumNumberOfRows);
|
||||
encode_NSUInteger(coder, &_maximumNumberOfColumns);
|
||||
|
||||
[coder encodeSize: _maximumItemSize];
|
||||
[coder encodeSize: _minimumItemSize];
|
||||
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat) at: &_minimumInteritemSpacing];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat) at: &_margins.bottom];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat) at: &_margins.top];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat) at: &_margins.left];
|
||||
[coder encodeValueOfObjCType: @encode(CGFloat) at: &_margins.right];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setMaximumNumberOfRows: (NSUInteger)maxRows
|
||||
{
|
||||
_maximumNumberOfRows = maxRows;
|
||||
}
|
||||
|
||||
- (NSUInteger) maximumNumberOfRows;
|
||||
{
|
||||
return _maximumNumberOfRows;
|
||||
}
|
||||
|
||||
- (void) setMaximumNumberOfColumns: (NSUInteger)maxCols
|
||||
{
|
||||
_maximumNumberOfColumns = maxCols;
|
||||
}
|
||||
|
||||
- (NSUInteger) maximumNumberOfColumns
|
||||
{
|
||||
return _maximumNumberOfColumns;
|
||||
}
|
||||
|
||||
- (void) setMinimumItemSize: (NSSize)minSize
|
||||
{
|
||||
_minimumItemSize = minSize;
|
||||
}
|
||||
|
||||
- (NSSize) minimumItemSize
|
||||
{
|
||||
return _minimumItemSize;
|
||||
}
|
||||
|
||||
- (void) setMaximumItemSize: (NSSize)maxSize
|
||||
{
|
||||
_maximumItemSize = maxSize;
|
||||
}
|
||||
|
||||
- (NSSize) maximumItemSize
|
||||
{
|
||||
return _maximumItemSize;
|
||||
}
|
||||
|
||||
- (void) setMargins: (NSEdgeInsets)insets
|
||||
{
|
||||
_margins = insets;
|
||||
}
|
||||
|
||||
- (NSEdgeInsets) margins
|
||||
{
|
||||
return _margins;
|
||||
}
|
||||
|
||||
- (void) setMinimumInteritemSpacing: (CGFloat)spacing
|
||||
{
|
||||
_minimumInteritemSpacing = spacing;
|
||||
}
|
||||
|
||||
- (CGFloat) minimumInteritemSpacing
|
||||
{
|
||||
return _minimumInteritemSpacing;
|
||||
}
|
||||
|
||||
// Methods to override for specific layouts...
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *attrs = AUTORELEASE([[NSCollectionViewLayoutAttributes alloc] init]);
|
||||
NSSize sz = NSZeroSize;
|
||||
NSInteger s = [indexPath section];
|
||||
NSInteger r = [indexPath item];
|
||||
NSEdgeInsets si;
|
||||
CGFloat mls = 0.0;
|
||||
CGFloat mis = 0.0;
|
||||
CGFloat h = 0.0, w = 0.0, x = 0.0, y = 0.0;
|
||||
NSRect f = NSZeroRect;
|
||||
NSRect vf = [_collectionView frame];
|
||||
NSInteger ns = [_collectionView numberOfSections];
|
||||
NSInteger ni = [_collectionView numberOfItemsInSection: s];
|
||||
CGFloat ph = 0.0;
|
||||
CGFloat pw = 0.0;
|
||||
|
||||
sz = [self minimumItemSize];
|
||||
si = [self margins];
|
||||
mls = [self minimumInteritemSpacing];
|
||||
mis = [self minimumInteritemSpacing];
|
||||
|
||||
// Calculations...
|
||||
h = sz.height;
|
||||
ph = vf.size.height / ns;
|
||||
if (ph > sz.height)
|
||||
{
|
||||
NSSize mx = [self maximumItemSize];
|
||||
if (ph > mx.height)
|
||||
{
|
||||
ph = mx.height;
|
||||
}
|
||||
h = ph;
|
||||
}
|
||||
|
||||
w = sz.width;
|
||||
pw = vf.size.width / ni;
|
||||
if (pw > sz.width)
|
||||
{
|
||||
NSSize mx = [self maximumItemSize];
|
||||
if (pw > mx.width)
|
||||
{
|
||||
pw = mx.width;
|
||||
}
|
||||
w = pw;
|
||||
}
|
||||
|
||||
x = (r * w) + si.left + mis;
|
||||
y = (s * h) + si.top + mls;
|
||||
f = NSMakeRect(x, y, w, h);
|
||||
|
||||
// Build attrs object...
|
||||
[attrs setFrame: f];
|
||||
[attrs setZIndex: 0];
|
||||
[attrs setSize: f.size];
|
||||
[attrs setHidden: NO];
|
||||
[attrs setAlpha: 1.0];
|
||||
|
||||
return attrs;
|
||||
}
|
||||
|
||||
- (NSSize) collectionViewContentSize
|
||||
{
|
||||
return [_collectionView frame].size;
|
||||
}
|
||||
|
||||
@end
|
|
@ -34,6 +34,7 @@
|
|||
#import "AppKit/NSImageView.h"
|
||||
#import "AppKit/NSKeyValueBinding.h"
|
||||
#import "AppKit/NSTextField.h"
|
||||
#import "AppKit/NSDragging.h"
|
||||
|
||||
@implementation NSCollectionViewItem
|
||||
|
||||
|
@ -198,4 +199,9 @@
|
|||
return RETAIN(newItem);
|
||||
}
|
||||
|
||||
- (NSString *) description
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@ - selected = %@, representedObject = %@", [super description], _isSelected ? @"YES" : @"NO", [self representedObject]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
492
Source/NSCollectionViewLayout.m
Normal file
492
Source/NSCollectionViewLayout.m
Normal file
|
@ -0,0 +1,492 @@
|
|||
/* Implementation of class NSCollectionViewLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 "AppKit/NSCollectionViewLayout.h"
|
||||
#import "AppKit/NSCollectionViewItem.h"
|
||||
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
@interface NSCollectionView (__NSCollectionViewLayout__)
|
||||
- (NSMapTable *) itemsToAttributes;
|
||||
@end
|
||||
|
||||
@implementation NSCollectionView (__NSCollectionViewLayout__)
|
||||
- (NSMapTable *) itemsToAttributes
|
||||
{
|
||||
return _itemsToAttributes;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewLayoutAttributes
|
||||
|
||||
// Initializers
|
||||
+ (instancetype) layoutAttributesForItemWithIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (instancetype) layoutAttributesForInterItemGapBeforeIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (instancetype) layoutAttributesForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
withIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (instancetype)layoutAttributesForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)decorationViewKind
|
||||
withIndexPath: (NSIndexPath*)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Properties
|
||||
- (NSRect) frame
|
||||
{
|
||||
return _frame;
|
||||
}
|
||||
|
||||
- (void) setFrame: (NSRect)frame
|
||||
{
|
||||
_frame = frame;
|
||||
}
|
||||
|
||||
- (NSSize) size
|
||||
{
|
||||
return _frame.size;
|
||||
}
|
||||
|
||||
- (void) setSize: (NSSize)size
|
||||
{
|
||||
_frame.size = size;
|
||||
}
|
||||
|
||||
- (CGFloat) alpha
|
||||
{
|
||||
return _alpha;
|
||||
}
|
||||
|
||||
- (void) setAlpha: (CGFloat)alpha
|
||||
{
|
||||
_alpha = alpha;
|
||||
}
|
||||
|
||||
- (BOOL) isHidden
|
||||
{
|
||||
return _hidden;
|
||||
}
|
||||
|
||||
- (void) setHidden: (BOOL)hidden
|
||||
{
|
||||
_hidden = hidden;
|
||||
}
|
||||
|
||||
- (NSIndexPath *) indexPath
|
||||
{
|
||||
return _indexPath;
|
||||
}
|
||||
|
||||
- (void) setIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
_indexPath = indexPath;
|
||||
}
|
||||
|
||||
- (NSInteger) zIndex
|
||||
{
|
||||
return _zIndex;
|
||||
}
|
||||
|
||||
- (void) setZIndex: (NSInteger)zIndex
|
||||
{
|
||||
_zIndex = zIndex;
|
||||
}
|
||||
|
||||
- (NSCollectionElementCategory) representedElementCategory
|
||||
{
|
||||
return _representedElementCategory;
|
||||
}
|
||||
|
||||
- (NSString *) representedElementKind
|
||||
{
|
||||
return _representedElementKind;
|
||||
}
|
||||
|
||||
// Copying
|
||||
- (id) copyWithZone: (NSZone *)z
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *a = [[NSCollectionViewLayoutAttributes allocWithZone: z] init];
|
||||
|
||||
[a setFrame: [self frame]];
|
||||
[a setSize: [self size]];
|
||||
[a setAlpha: [self alpha]];
|
||||
[a setHidden: [self isHidden]];
|
||||
[a setIndexPath: [self indexPath]];
|
||||
[a setZIndex: [self zIndex]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *) description
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@ - f = %@, alpha = %f, z = %ld",
|
||||
[super description], NSStringFromRect(_frame),
|
||||
_alpha, _zIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSCollectionViewUpdateItem
|
||||
|
||||
- (NSIndexPath *) indexPathBeforeUpdate
|
||||
{
|
||||
return _indexPathBeforeUpdate;
|
||||
}
|
||||
|
||||
- (NSIndexPath *) indexPathAfterUpdate
|
||||
{
|
||||
return _indexPathAfterUpdate;
|
||||
}
|
||||
|
||||
- (NSCollectionUpdateAction) updateAction
|
||||
{
|
||||
return _updateAction;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSCollectionViewLayoutInvalidationContext
|
||||
|
||||
// Initializers
|
||||
- (void)invalidateItemsAtIndexPaths: (NSSet *)indexPaths
|
||||
{
|
||||
}
|
||||
|
||||
- (void)invalidateSupplementaryElementsOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPaths: (NSSet *)indexPaths
|
||||
{
|
||||
}
|
||||
|
||||
- (void)invalidateDecorationElementsOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPaths: (NSSet *)indexPaths
|
||||
{
|
||||
}
|
||||
|
||||
// Properties
|
||||
- (BOOL) invalidateEverything
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) invalidateDataSourceCounts
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSSet *) invalidatedItemIndexPaths
|
||||
{
|
||||
return _invalidatedItemIndexPaths;
|
||||
}
|
||||
|
||||
- (NSPoint) contentOffsetAdjustment
|
||||
{
|
||||
return _contentOffsetAdjustment;
|
||||
}
|
||||
|
||||
- (void) setContentOffsetAdjustment: (NSPoint)point
|
||||
{
|
||||
_contentOffsetAdjustment = point;
|
||||
}
|
||||
|
||||
- (NSSize) contentSizeAdjustment
|
||||
{
|
||||
return _contentSizeAdjustment;
|
||||
}
|
||||
|
||||
- (void) setContentSizeAdjustment: (NSSize)size
|
||||
{
|
||||
_contentSizeAdjustment = size;
|
||||
}
|
||||
|
||||
- (NSDictionary *) invalidatedSupplementaryIndexPaths
|
||||
{
|
||||
return _invalidatedSupplementaryIndexPaths;
|
||||
}
|
||||
|
||||
- (NSDictionary *) invalidatedDecorationIndexPaths
|
||||
{
|
||||
return _invalidatedDecorationIndexPaths;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewLayout
|
||||
|
||||
// Initializers
|
||||
- (void) _initDefaults
|
||||
{
|
||||
// _itemsToAttributes = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
- (void)invalidateLayout
|
||||
{
|
||||
_valid = NO;
|
||||
[_collectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)invalidateLayoutWithContext:(NSCollectionViewLayoutInvalidationContext *)context
|
||||
{
|
||||
}
|
||||
|
||||
- (void)registerClass: (Class)viewClass
|
||||
forDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
{
|
||||
}
|
||||
|
||||
- (void)registerNib: (NSNib *)nib
|
||||
forDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
{
|
||||
}
|
||||
|
||||
// Properties
|
||||
- (NSCollectionView *) collectionView
|
||||
{
|
||||
return _collectionView;
|
||||
}
|
||||
|
||||
- (void) setCollectionView: (NSCollectionView *)cv
|
||||
{
|
||||
_collectionView = cv;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
[self _initDefaults];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewLayout (NSSubclassingHooks)
|
||||
|
||||
// Methods to override for specific layouts...
|
||||
- (void) prepareLayout
|
||||
{
|
||||
_valid = YES;
|
||||
}
|
||||
|
||||
- (NSArray *) layoutAttributesForElementsInRect: (NSRect)rect
|
||||
{
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
NSArray *items = [_collectionView visibleItems];
|
||||
NSMapTable *itemsToAttributes = [_collectionView itemsToAttributes];
|
||||
|
||||
FOR_IN(NSCollectionViewItem*, i, items)
|
||||
{
|
||||
NSView *v = [i view];
|
||||
NSRect f = [v frame];
|
||||
BOOL intersects = NSIntersectsRect(f, rect);
|
||||
|
||||
if (intersects)
|
||||
{
|
||||
NSCollectionViewLayoutAttributes *a = [itemsToAttributes objectForKey: i];
|
||||
[result addObject: a]; // add item since it intersects
|
||||
}
|
||||
}
|
||||
END_FOR_IN(items);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) layoutAttributesForItemAtIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
layoutAttributesForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)layoutAttributesForDropTargetAtPoint: (NSPoint)pointInCollectionView
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)layoutAttributesForInterItemGapBeforeIndexPath: (NSIndexPath *)indexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) shouldInvalidateLayoutForBoundsChange: (NSRect)newBounds
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange: (NSRect)newBounds
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)shouldInvalidateLayoutForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutInvalidationContext *)
|
||||
invalidationContextForPreferredLayoutAttributes: (NSCollectionViewLayoutAttributes *)preferredAttributes
|
||||
withOriginalAttributes: (NSCollectionViewLayoutAttributes *)originalAttributes
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset
|
||||
withScrollingVelocity: (NSPoint)velocity
|
||||
{
|
||||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (NSPoint) targetContentOffsetForProposedContentOffset: (NSPoint)proposedContentOffset
|
||||
{
|
||||
return NSZeroPoint;
|
||||
}
|
||||
|
||||
- (NSSize) collectionViewContentSize
|
||||
{
|
||||
return [_collectionView frame].size;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSCollectionViewLayout (NSUpdateSupportHooks)
|
||||
|
||||
// Update support
|
||||
- (void) prepareForCollectionViewUpdates: (NSArray *)updateItems
|
||||
{
|
||||
}
|
||||
|
||||
- (void) finalizeCollectionViewUpdates
|
||||
{
|
||||
}
|
||||
|
||||
- (void) prepareForAnimatedBoundsChange: (NSRect)oldBounds
|
||||
{
|
||||
}
|
||||
|
||||
- (void) finalizeAnimatedBoundsChange
|
||||
{
|
||||
}
|
||||
|
||||
- (void) prepareForTransitionToLayout: (NSCollectionViewLayout *)newLayout
|
||||
{
|
||||
}
|
||||
|
||||
- (void) prepareForTransitionFromLayout: (NSCollectionViewLayout *)oldLayout
|
||||
{
|
||||
}
|
||||
|
||||
- (void) finalizeLayoutTransition
|
||||
{
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) initialLayoutAttributesForAppearingItemAtIndexPath: (NSIndexPath *)itemIndexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *) finalLayoutAttributesForDisappearingItemAtIndexPath: (NSIndexPath *)itemIndexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
initialLayoutAttributesForAppearingSupplementaryElementOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)elementIndexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
finalLayoutAttributesForDisappearingSupplementaryElementOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)elementIndexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
initialLayoutAttributesForAppearingDecorationElementOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)decorationIndexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayoutAttributes *)
|
||||
finalLayoutAttributesForDisappearingDecorationElementOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
atIndexPath: (NSIndexPath *)decorationIndexPath
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSSet *)indexPathsToDeleteForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSSet *)indexPathsToDeleteForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSSet *)indexPathsToInsertForSupplementaryViewOfKind: (NSCollectionViewSupplementaryElementKind)elementKind
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSSet *)indexPathsToInsertForDecorationViewOfKind: (NSCollectionViewDecorationElementKind)elementKind
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
79
Source/NSCollectionViewTransitionLayout.m
Normal file
79
Source/NSCollectionViewTransitionLayout.m
Normal file
|
@ -0,0 +1,79 @@
|
|||
/* Implementation of class NSCollectionViewTransitionLayout
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory John Casamento
|
||||
Date: 30-05-2021
|
||||
|
||||
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 "AppKit/NSCollectionViewTransitionLayout.h"
|
||||
|
||||
@implementation NSCollectionViewTransitionLayout
|
||||
|
||||
- (CGFloat) transitionProgress
|
||||
{
|
||||
return _transitionProgress;
|
||||
}
|
||||
|
||||
- (void) setTransitionProgress: (CGFloat)transitionProgress
|
||||
{
|
||||
_transitionProgress = transitionProgress;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayout *) currentLayout
|
||||
{
|
||||
return _currentLayout;
|
||||
}
|
||||
|
||||
- (NSCollectionViewLayout *) nextLayout
|
||||
{
|
||||
return _nextLayout;
|
||||
}
|
||||
|
||||
// Designated initializer
|
||||
- (instancetype) initWithCurrentLayout: (NSCollectionViewLayout *)currentLayout
|
||||
nextLayout: (NSCollectionViewLayout *)nextLayout
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
ASSIGN(_currentLayout, currentLayout);
|
||||
ASSIGN(_nextLayout, nextLayout);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_currentLayout);
|
||||
RELEASE(_nextLayout);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) updateValue: (CGFloat)value forAnimatedKey: (NSCollectionViewTransitionLayoutAnimatedKey)key
|
||||
{
|
||||
// not implemented...
|
||||
}
|
||||
|
||||
- (CGFloat) valueForAnimatedKey: (NSCollectionViewTransitionLayoutAnimatedKey)key
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@end
|
|
@ -776,7 +776,6 @@ static Class textFieldCellClass;
|
|||
self = [super initWithCoder: aDecoder];
|
||||
if ([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
// do nothing for now...
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -73,6 +73,14 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)viewWillLoad
|
||||
{
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setRepresentedObject:(id)representedObject
|
||||
{
|
||||
ASSIGN(_representedObject, representedObject);
|
||||
|
@ -124,6 +132,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
[self viewWillLoad];
|
||||
nib = [[NSNib alloc] initWithNibNamed: [self nibName]
|
||||
bundle: [self nibBundle]];
|
||||
if ((nib != nil) && [nib instantiateNibWithOwner: self
|
||||
|
@ -131,6 +140,7 @@
|
|||
{
|
||||
_vcFlags.nib_is_loaded = YES;
|
||||
// FIXME: Need to resolve possible retain cycles here
|
||||
[self viewDidLoad];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -214,6 +224,11 @@
|
|||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSString *) description
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@ - view = %@", [super description], view];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSViewController (NSEditorRegistration)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#import "AppKit/NSAppearance.h"
|
||||
#import "AppKit/NSFontCollection.h"
|
||||
#import "AppKit/NSTextFinder.h"
|
||||
#import "AppKit/NSCollectionView.h"
|
||||
|
||||
// Global strings
|
||||
APPKIT_DECLARE APPKIT_DECLARE NSString *NSModalPanelRunLoopMode = @"NSModalPanelRunLoopMode";
|
||||
|
@ -778,6 +779,11 @@ APPKIT_DECLARE NSPasteboardTypeTextFinderOptionKey const NSTextFinderMatchingTyp
|
|||
|
||||
APPKIT_DECLARE CGFloat const NSGridViewSizeForContent = 0.0;
|
||||
|
||||
// NSCollectionView constants
|
||||
APPKIT_DECLARE NSCollectionViewSupplementaryElementKind const NSCollectionElementKindInterItemGapIndicator = @"NSCollectionElementKindInterItemGapIndicator";
|
||||
APPKIT_DECLARE NSCollectionViewSupplementaryElementKind const NSCollectionElementKindSectionHeader = @"UICollectionElementKindSectionHeader";
|
||||
APPKIT_DECLARE NSCollectionViewSupplementaryElementKind const NSCollectionElementKindSectionFooter = @"UICollectionElementKindSectionFooter";
|
||||
|
||||
extern void __objc_gui_force_linking (void);
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue