• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOutlineView indentation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView indentation


  • Subject: Re: NSOutlineView indentation
  • From: Bill Monk <email@hidden>
  • Date: Wed, 07 Jan 2009 22:49:46 -0600


On Jan 7, 2009, James Walker wrote:

Having the indentation affect the top level may be technically
consistent, but I don't know why anyone would want it to work that way.


Yes, I agree. Top-level items should stay near the left margin, and setting the indent to 0 should not cause top-level disclosure controls to impinge on neighboring columns. The following fixed it for my purposes.


// Add to a subclass of NSOutlineView

#define kApplyNSOutlineViewIndentationFix 1

// Changing the indentation of NSOutlineView causes the 0-level items
// to indent possibly large amounts as well, which looks bad.
// Similarly, if the indent is set to small values, disclosure triangles of
// top level items draw to far to the side and appear in the neighboring column.


#if kApplyNSOutlineViewIndentationFix
#define kMaxFirstLevelIndentation 16
#define kMinFirstLevelIndentation 10


// corrects text and icons (if using ImageAndTextCell) - (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row { NSRect frame = [super frameOfCellAtColumn:column row:row]; if ( column == 1 ) { CGFloat indent = [self indentationPerLevel]; if ( indent > kMaxFirstLevelIndentation ) { frame.origin.x -= (indent - kMaxFirstLevelIndentation); frame.size.width += (indent - kMaxFirstLevelIndentation); } else if ( indent < kMinFirstLevelIndentation ) { frame.origin.x += (kMinFirstLevelIndentation - indent); frame.size.width -= (kMinFirstLevelIndentation - indent); } } return frame; }

// corrects disclosure control icon
- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row;
{
	NSRect frame = [super frameOfOutlineCellAtRow:row];

	CGFloat indent = [self indentationPerLevel];
	if ( indent > kMaxFirstLevelIndentation )
		frame.origin.x -= (indent - kMaxFirstLevelIndentation);
	else if ( indent < kMinFirstLevelIndentation )
		frame.origin.x += (kMinFirstLevelIndentation - indent);

return frame;
}

#endif // kApplyNSOutlineViewIndentationFix
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSOutlineView indentation
      • From: James Walker <email@hidden>
  • Prev by Date: Re: -[NSView window] returns nil if its NSTabView not selected
  • Next by Date: Re: How to obtain icon displayed by Finder for a file
  • Previous by thread: Re: NSOutlineView indentation
  • Next by thread: Re: NSOutlineView indentation
  • Index(es):
    • Date
    • Thread