Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (NSRect)frameOfOutlineCellAtRow:(NSInteger)row {
- return NSZeroRect;
- }
- - (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
- NSRect superFrame = [super frameOfCellAtColumn:column row:row];
- if ((column == 0) /* && isGroupRow */) {
- return NSMakeRect(0, superFrame.origin.y, [self bounds].size.width, superFrame.size.height);
- }
- return superFrame;
- }
- -(BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item
- {
- // replace this with your logic to determine whether the
- // disclosure triangle should be hidden for a particular item
- return [item hidesDisclosureTriangle];
- }
- - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item {
- return NO;
- }
- @implementation ExpandedOutlineView
- #define kOutlineCellWidth 11
- #define kOutlineMinLeftMargin 6
- - (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
- NSRect superFrame = [super frameOfCellAtColumn:column row:row];
- if (column == 0) {
- // expand by kOutlineCellWidth to the left to cancel the indent
- CGFloat adjustment = kOutlineCellWidth;
- // ...but be extra defensive because we have no fucking clue what is going on here
- if (superFrame.origin.x - adjustment < kOutlineMinLeftMargin) {
- NSLog(@"%@ adjustment amount is incorrect: adjustment = %f, superFrame = %@, kOutlineMinLeftMargin = %f", NSStringFromClass([self class]), (float)adjustment, NSStringFromRect(superFrame), (float)kOutlineMinLeftMargin);
- adjustment = MAX(0, superFrame.origin.x - kOutlineMinLeftMargin);
- }
- return NSMakeRect(superFrame.origin.x - adjustment, superFrame.origin.y, superFrame.size.width + adjustment, superFrame.size.height);
- }
- return superFrame;
- }
- @end
- extension NSTableRowView {
- override open func layout() {
- super.layout()
- if let cell = subviews.first as? NSTableCellView, cell.objectValue is <YourHeaderCellClass> {
- subviews.first?.setFrameOrigin(NSZeroPoint)
- }
- }
- }
- func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any
Add Comment
Please, Sign In to add comment