scrolling state of group outline gets updated

This commit is contained in:
michael starke
2016-02-29 16:14:21 +01:00
parent 627d48a74e
commit 15ffde7f0f

View File

@@ -84,6 +84,13 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
name:MPDidActivateViewNotification name:MPDidActivateViewNotification
object:self.outlineView]; object:self.outlineView];
NSView *clipView = self.outlineView.enclosingScrollView.contentView;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_outlineDidScroll:)
name:NSViewBoundsDidChangeNotification
object:clipView];
} }
- (NSResponder *)reconmendedFirstResponder { - (NSResponder *)reconmendedFirstResponder {
@@ -107,6 +114,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
} }
- (void)_expandItems:(NSTreeNode *)node { - (void)_expandItems:(NSTreeNode *)node {
KPKTree *tree = self.treeController.content;
id nodeItem = [node representedObject]; id nodeItem = [node representedObject];
if([nodeItem isKindOfClass:[KPKTree class]]) { if([nodeItem isKindOfClass:[KPKTree class]]) {
[self.outlineView expandItem:node expandChildren:NO]; [self.outlineView expandItem:node expandChildren:NO];
@@ -168,6 +177,20 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
document.selectedItem = document.selectedGroup; document.selectedItem = document.selectedGroup;
} }
- (void)_outlineDidScroll:(NSNotification *)notification {
NSView *clipView = notification.object;
if(nil == clipView || self.outlineView.enclosingScrollView.contentView != clipView) {
return; // Wrong view
}
NSInteger topRow = [self.outlineView rowAtPoint:clipView.bounds.origin];
id item = [[self.outlineView itemAtRow:topRow] representedObject];
if([item isKindOfClass:[KPKGroup class]]) {
KPKGroup *group = item;
KPKTree *tree = self.treeController.content;
tree.metaData.lastTopVisibleGroup = group.uuid;
}
}
# pragma mark MPDocument Notifications # pragma mark MPDocument Notifications
- (void)_didAddGroup:(NSNotification *)notification { - (void)_didAddGroup:(NSNotification *)notification {
NSDictionary *userInfo = [notification userInfo]; NSDictionary *userInfo = [notification userInfo];
@@ -181,8 +204,8 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
} }
- (id)itemUnderMouse { - (id)itemUnderMouse {
NSPoint mouseLocation = [[self.outlineView window] mouseLocationOutsideOfEventStream]; NSPoint mouseLocation = [self.outlineView.window mouseLocationOutsideOfEventStream];
NSPoint localPoint = [self.outlineView convertPoint:mouseLocation fromView:[[self.outlineView window] contentView]]; NSPoint localPoint = [self.outlineView convertPoint:mouseLocation fromView:self.outlineView.window.contentView];
NSInteger row = [self.outlineView rowAtPoint:localPoint]; NSInteger row = [self.outlineView rowAtPoint:localPoint];
if(row == -1) { if(row == -1) {
return nil; // No row was hit return nil; // No row was hit