Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added a property to allow listview items to opt out of the listview's…

… padding
  • Loading branch information...
commit 6cf375d0c7b9d7ad1c1aaa55c1aed10cf4ccc0f6 1 parent 9931433
@joshaber authored
Showing with 9 additions and 2 deletions.
  1. +7 −2 JAListView.m
  2. +1 −0  JAListViewItem.h
  3. +1 −0  JAListViewItem.m
View
9 JAListView.m
@@ -105,6 +105,10 @@ - (void)viewWillMoveToSuperview:(NSView *)newSuperview {
- (void)viewDidMoveToSuperview {
if(self.superview == nil) return;
+ if(self.scrollView == nil) {
+ NSLog(@"%@ is not in a scroll view. Unless you know what you're doing, this is a mistake.", self);
+ }
+
[self.scrollView.contentView setPostsBoundsChangedNotifications:YES];
[self.scrollView.contentView setPostsFrameChangedNotifications:YES];
@@ -776,7 +780,8 @@ - (void)standardLayoutAnimated:(BOOL)animated removeViews:(NSArray *)viewsToRemo
for(JAListViewItem *view in viewsToAdd) {
CGFloat y = self.cachedLocations[[self.cachedViews indexOfObject:view]];
- view.frame = NSIntegralRect(NSMakeRect(self.padding.left, y, self.bounds.size.width - (self.padding.left + self.padding.right), view.bounds.size.height));
+ NSRect viewFrame = NSMakeRect(view.ignoresListViewPadding ? 0.0f : self.padding.left, y, view.ignoresListViewPadding ? self.bounds.size.width : self.bounds.size.width - (self.padding.left + self.padding.right), view.bounds.size.height);
+ view.frame = NSIntegralRect(viewFrame);
id viewOrProxy = animated ? [self animator] : self;
[viewOrProxy addSubview:view];
@@ -790,7 +795,7 @@ - (void)standardLayoutAnimated:(BOOL)animated removeViews:(NSArray *)viewsToRemo
CGFloat y = self.cachedLocations[indexOfView]; //!!!: boom - bad access
id viewOrProxy = animated ? [view animator] : view;
- [viewOrProxy setFrame:NSMakeRect(self.padding.left, y, view.bounds.size.width, view.bounds.size.height)];
+ [viewOrProxy setFrame:NSMakeRect(view.ignoresListViewPadding ? 0.0f : self.padding.left, y, view.bounds.size.width, view.bounds.size.height)];
}
}
View
1  JAListViewItem.h
@@ -26,5 +26,6 @@ typedef enum {
@property (nonatomic, assign, getter=isSelected) BOOL selected;
@property (nonatomic, assign, getter=isHighlighted) BOOL highlighted;
@property (nonatomic, readonly) JAListViewPosition listViewPosition;
+@property (nonatomic, assign) BOOL ignoresListViewPadding;
@end
View
1  JAListViewItem.m
@@ -35,6 +35,7 @@ - (BOOL)acceptsFirstResponder {
@synthesize selected;
@synthesize highlighted;
@synthesize listViewPosition;
+@synthesize ignoresListViewPadding;
- (NSImage *)draggingImage {
NSBitmapImageRep *bitmap = [self bitmapImageRepForCachingDisplayInRect:self.bounds];
Please sign in to comment.
Something went wrong with that request. Please try again.