mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:10:48 +00:00
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:
parent
e87db4cf8f
commit
0526fde72e
1 changed files with 29 additions and 0 deletions
|
@ -81,6 +81,9 @@
|
||||||
float divVertical, divHorizontal;
|
float divVertical, divHorizontal;
|
||||||
NSDate *farAway = [NSDate distantFuture];
|
NSDate *farAway = [NSDate distantFuture];
|
||||||
unsigned int eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
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 there are less the two subviews, there is nothing to do */
|
||||||
if (count < 2)
|
if (count < 2)
|
||||||
|
@ -164,6 +167,18 @@
|
||||||
prev = v;
|
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)
|
if (_isVertical == NO)
|
||||||
{
|
{
|
||||||
divVertical = _dividerWidth;
|
divVertical = _dividerWidth;
|
||||||
|
@ -239,6 +254,20 @@
|
||||||
while ([e type] != NSLeftMouseUp)
|
while ([e type] != NSLeftMouseUp)
|
||||||
{
|
{
|
||||||
p = [self convertPoint: [e locationInWindow] fromView: nil];
|
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 (_isVertical == NO)
|
||||||
{
|
{
|
||||||
if (p.y < minCoord)
|
if (p.y < minCoord)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue