Implemented apple API extension allowing delegate to constrain divider

position to certain positions while dragging


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8850 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2001-01-28 17:43:13 +00:00
parent bf4bf3e589
commit dbbdfa3719

View file

@ -81,6 +81,9 @@
float divVertical, divHorizontal;
NSDate *farAway = [NSDate distantFuture];
unsigned int eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
/* YES if delegate implements splitView:constrainSplitPosition:ofSubviewAt:*/
BOOL delegateConstrains = NO;
/* if there are less the two subviews, there is nothing to do */
if (count < 2)
@ -164,6 +167,18 @@
prev = v;
}
}
/* Check if the delegate wants to constrain the spliview divider to
certain positions */
if (_delegate
&& [_delegate
respondsToSelector:
@selector(splitView:constrainSplitPosition:ofSubviewAt:)])
{
delegateConstrains = YES;
}
if (_isVertical == NO)
{
divVertical = _dividerWidth;
@ -239,6 +254,20 @@
while ([e type] != NSLeftMouseUp)
{
p = [self convertPoint: [e locationInWindow] fromView: nil];
if (delegateConstrains)
{
if (_isVertical)
{
p.x = [_delegate splitView: self constrainSplitPosition: p.x
ofSubviewAt: offset];
}
else
{
p.y = [_delegate splitView: self constrainSplitPosition: p.y
ofSubviewAt: offset];
}
}
if (_isVertical == NO)
{
if (p.y < minCoord)