malcommac / DMSplitView

New NSSplitView class with multiple subviews resize behaviors and animated transitions
116 stars 24 forks source link

Alignment bug with centre aligned subviews when toggling panels #7

Open brendand opened 11 years ago

brendand commented 11 years ago

If you have a subview within a panel that is supposed to be aligned centred (either no strut is selected or the top strut is the only one selected for Autosizing in Interface Builder), then when you toggle any of the panels, the subview will end up being right-aligned instead of maintaining its centre position.

For example, the initial view with the icons properly centred:

Screen Shot 2013-02-16 at 6 35 46 PM

Then after clicking on the Toggle buttons (left and right), it looks like this:

Screen Shot 2013-02-16 at 6 35 58 PM

It's happening in the example app and in my app that's using DMSplitView too.

I'm not sure what's causing this problem. It doesn't happen if you drag the left pane so it's fully closed, but it does with the right most pane. It also doesn't happen on the left pane if you double-click on the divider bar to collapse or expand the view.

Also, after this happens, no amount of dragging the divider bar will correct it. The subview (the icon in this case) is stuck to the right edge of its superview.

And it doesn't matter if you use animated transitions or not. Same problem.

Any workaround for this that you know of?

brendand commented 11 years ago

Any ideas on this issue?

brendand commented 11 years ago

Do you have any idea if there's a workaround for this problem?

CodaFi commented 11 years ago

It happens when the constraints on two views happen to be ambiguous with respect to each other. For example, given a window that's 500 px wide, a splitview with two views that set their min-sizes to, say, 260 px, leaves a 20 px overlap that the splitview compensates for by shifting everything to the right. It's not a bug in the splitview, it's a mathematical error on someone's part.