1

Context

I have an NSSplitView in my app that has 3 panes. I've subclassed NSSplitView and it has a single override:

-(CGFloat) dividerThickness { return 1.0f; }

I have disabled ALL the delegate methods that constrain divider min/max points and resize subviews, etc.


The Problem

When I drag any divider on a retina screen, the divider's thickness fluctuates during the drag. See this video: http://incident57.com/divider.mp4

This happens no matter what divider thickness I use---the thickness always varies by about 1px during drag.

This DOES NOT HAPPEN on non-retina screens. It also DOES NOT HAPPEN when the window itself is resized. The divider width only fluctuates when the divider itself is dragged.

(If you look really closely, you can see that there's some blank, white space between the views where it looks like NSSplitView should be drawing the divider, but isn't. Look at the end of the brown selected table row in the video.)


What I Need

How do I fix this so that the divider width stays constant during drags on retina screens?

Community
  • 1
  • 1
Bryan
  • 4,628
  • 3
  • 36
  • 62

2 Answers2

3

I solved this problem by implementing this NSSplitViewDelegate method:

- (CGFloat) splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex
{
    return floor(proposedPosition);
}

It's also worth pointing out that this issue only manifests if the subviews within the panes of the NSSplitView are NSScrollViews. Normal NSViews inside the panes will not cause the divider-width fluctuation.

Bryan
  • 4,628
  • 3
  • 36
  • 62
  • 1
    This works, thanks. But resizing the window still brings up this problem. Any ideas? EDIT: One of the NSScrollViews had "Draw Background" activated. Deactivating did the job – Lupurus Apr 26 '15 at 21:08
0

Layer-backing the split view (i.e. [splitView setWantsLayer:YES]) should also fix this. Since scroll views will often auto-layerback themselves, their layer overlaps the drawn split view divider when non point aligned.

Taylor
  • 3,183
  • 17
  • 18