Skip to content

Commit

Permalink
cocoaui: fix playlist redraw issues when moving cursor with keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Feb 8, 2019
1 parent 9098090 commit 2d75901
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions plugins/cocoaui/DdbListview.m
Original file line number Diff line number Diff line change
Expand Up @@ -1652,32 +1652,27 @@ - (void)setCursor:(int)cursor noscroll:(BOOL)noscroll {
[_delegate unrefRow:row];
}

BOOL need_redraw = YES;
if (!noscroll) {
if ([self setScrollForPos:[self getRowPos:cursor]]) {
need_redraw = NO;
}
}
if (need_redraw) {
[contentView setNeedsDisplay:YES];
[self setScrollForPos:[self getRowPos:cursor]];
}
[contentView setNeedsDisplay:YES];
}

// returns YES if scroll has occured as result of changing the cursor position
- (BOOL)setScrollForPos:(int)pos {
NSScrollView *sv = [contentView enclosingScrollView];
NSRect vis = [sv documentVisibleRect];
int scrollpos = vis.origin.y;
int cursor_scroll = pos;
int newscroll = scrollpos;

if (![_delegate pinGroups] && cursor_scroll < scrollpos) {
newscroll = cursor_scroll;
if (![_delegate pinGroups] && pos < scrollpos) {
newscroll = pos;
}
else if ([_delegate pinGroups] && cursor_scroll < scrollpos + _grouptitle_height) {
newscroll = cursor_scroll - _grouptitle_height;
else if ([_delegate pinGroups] && pos < scrollpos + _grouptitle_height) {
newscroll = pos - _grouptitle_height;
}
else if (cursor_scroll + rowheight >= scrollpos + vis.size.height) {
newscroll = cursor_scroll + rowheight - vis.size.height + 1;
else if (pos + rowheight >= scrollpos + vis.size.height) {
newscroll = pos + rowheight - vis.size.height;
if (newscroll < 0) {
newscroll = 0;
}
Expand Down

0 comments on commit 2d75901

Please sign in to comment.