Guest User

Untitled

a guest
Dec 13th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. - (NSRect)frameOfOutlineCellAtRow:(NSInteger)row {
  2. return NSZeroRect;
  3. }
  4.  
  5. - (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
  6. NSRect superFrame = [super frameOfCellAtColumn:column row:row];
  7.  
  8.  
  9. if ((column == 0) /* && isGroupRow */) {
  10. return NSMakeRect(0, superFrame.origin.y, [self bounds].size.width, superFrame.size.height);
  11. }
  12. return superFrame;
  13. }
  14.  
  15. -(BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item
  16. {
  17. // replace this with your logic to determine whether the
  18. // disclosure triangle should be hidden for a particular item
  19. return [item hidesDisclosureTriangle];
  20. }
  21.  
  22. - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item {
  23. return NO;
  24. }
  25.  
  26. @implementation ExpandedOutlineView
  27.  
  28. #define kOutlineCellWidth 11
  29. #define kOutlineMinLeftMargin 6
  30.  
  31. - (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
  32. NSRect superFrame = [super frameOfCellAtColumn:column row:row];
  33. if (column == 0) {
  34. // expand by kOutlineCellWidth to the left to cancel the indent
  35. CGFloat adjustment = kOutlineCellWidth;
  36.  
  37. // ...but be extra defensive because we have no fucking clue what is going on here
  38. if (superFrame.origin.x - adjustment < kOutlineMinLeftMargin) {
  39. NSLog(@"%@ adjustment amount is incorrect: adjustment = %f, superFrame = %@, kOutlineMinLeftMargin = %f", NSStringFromClass([self class]), (float)adjustment, NSStringFromRect(superFrame), (float)kOutlineMinLeftMargin);
  40. adjustment = MAX(0, superFrame.origin.x - kOutlineMinLeftMargin);
  41. }
  42.  
  43. return NSMakeRect(superFrame.origin.x - adjustment, superFrame.origin.y, superFrame.size.width + adjustment, superFrame.size.height);
  44. }
  45. return superFrame;
  46. }
  47.  
  48. @end
  49.  
  50. extension NSTableRowView {
  51. override open func layout() {
  52. super.layout()
  53. if let cell = subviews.first as? NSTableCellView, cell.objectValue is <YourHeaderCellClass> {
  54. subviews.first?.setFrameOrigin(NSZeroPoint)
  55. }
  56. }
  57. }
  58.  
  59. func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any
Add Comment
Please, Sign In to add comment