mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-11 02:50:57 +00:00
Source/NSSplitView.m
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12843 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8d42ee0bd4
commit
c7c63a3dc4
2 changed files with 224 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2002-02-27 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||||
|
|
||||||
|
* Source/NSSplitView.m ([NSSplitView -mouseDown:]):
|
||||||
|
Tweaked the drawing code and the event code, so that everything
|
||||||
|
is displayed more smoothly and faster.
|
||||||
|
|
||||||
2002-02-27 Fred Kiefer <FredKiefer@gmx.de>
|
2002-02-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSTextView.m
|
* Source/NSTextView.m
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include <AppKit/NSEvent.h>
|
#include <AppKit/NSEvent.h>
|
||||||
#include <AppKit/NSSplitView.h>
|
#include <AppKit/NSSplitView.h>
|
||||||
|
|
||||||
|
#include "AppKit/DPSOperators.h"
|
||||||
|
|
||||||
@implementation NSSplitView
|
@implementation NSSplitView
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -95,10 +97,14 @@
|
||||||
int offset = 0, i, count = [subs count];
|
int offset = 0, i, count = [subs count];
|
||||||
float divVertical, divHorizontal;
|
float divVertical, divHorizontal;
|
||||||
NSDate *farAway = [NSDate distantFuture];
|
NSDate *farAway = [NSDate distantFuture];
|
||||||
|
NSDate *longTimeAgo = [NSDate distantPast];
|
||||||
unsigned int eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
unsigned int eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
|
||||||
/* YES if delegate implements splitView:constrainSplitPosition:ofSubviewAt:*/
|
/* YES if delegate implements splitView:constrainSplitPosition:ofSubviewAt:*/
|
||||||
BOOL delegateConstrains = NO;
|
BOOL delegateConstrains = NO;
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
SEL constrainSel =
|
||||||
|
@selector(splitView:constrainSplitPosition:ofSubviewAt:);
|
||||||
|
IMP constrainImp;
|
||||||
|
|
||||||
|
|
||||||
/* if there are less the two subviews, there is nothing to do */
|
/* if there are less the two subviews, there is nothing to do */
|
||||||
|
@ -267,6 +273,11 @@
|
||||||
inMode: NSEventTrackingRunLoopMode
|
inMode: NSEventTrackingRunLoopMode
|
||||||
dequeue: YES];
|
dequeue: YES];
|
||||||
|
|
||||||
|
if (delegateConstrains)
|
||||||
|
{
|
||||||
|
constrainImp = [_delegate methodForSelector: constrainSel];
|
||||||
|
}
|
||||||
|
|
||||||
// user is moving the knob loop until left mouse up
|
// user is moving the knob loop until left mouse up
|
||||||
while ([e type] != NSLeftMouseUp)
|
while ([e type] != NSLeftMouseUp)
|
||||||
{
|
{
|
||||||
|
@ -275,13 +286,21 @@
|
||||||
{
|
{
|
||||||
if (_isVertical)
|
if (_isVertical)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
p.x = [_delegate splitView: self constrainSplitPosition: p.x
|
p.x = [_delegate splitView: self constrainSplitPosition: p.x
|
||||||
ofSubviewAt: offset];
|
ofSubviewAt: offset];
|
||||||
|
*/
|
||||||
|
(*constrainImp)(_delegate, constrainSel, self,
|
||||||
|
p.x, offset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
p.y = [_delegate splitView: self constrainSplitPosition: p.y
|
p.y = [_delegate splitView: self constrainSplitPosition: p.y
|
||||||
ofSubviewAt: offset];
|
ofSubviewAt: offset];
|
||||||
|
*/
|
||||||
|
(*constrainImp)(_delegate, constrainSel, self,
|
||||||
|
p.y, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,19 +335,212 @@
|
||||||
NSDebugLog(@"drawing divider at x: %d, y: %d, w: %d, h: %d\n",
|
NSDebugLog(@"drawing divider at x: %d, y: %d, w: %d, h: %d\n",
|
||||||
(int)NSMinX(r), (int)NSMinY(r), (int)NSWidth(r), (int)NSHeight(r));
|
(int)NSMinX(r), (int)NSMinY(r), (int)NSWidth(r), (int)NSHeight(r));
|
||||||
[_dividerColor set];
|
[_dividerColor set];
|
||||||
|
|
||||||
|
|
||||||
|
if (lit == YES)
|
||||||
|
{
|
||||||
|
if (_isVertical == NO)
|
||||||
|
{
|
||||||
|
if ((NSMinY(r) > NSMaxY(oldRect))
|
||||||
|
|| (NSMaxY(r) < NSMinY(oldRect)))
|
||||||
|
// the two rects don't intersect
|
||||||
|
{
|
||||||
|
DPScompositerect(GSCurrentContext(),
|
||||||
|
NSMinX(oldRect),
|
||||||
|
NSMinY(oldRect),
|
||||||
|
NSWidth(oldRect),
|
||||||
|
NSHeight(oldRect),
|
||||||
|
NSCompositeHighlight);
|
||||||
|
// NSHighlightRect(oldRect);
|
||||||
|
NSHighlightRect(r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// the two rects intersect
|
||||||
|
{
|
||||||
|
if (NSMinY(r) > NSMinY(oldRect))
|
||||||
|
{
|
||||||
|
NSRect onRect, offRect;
|
||||||
|
onRect.size.width = r.size.width;
|
||||||
|
onRect.origin.x = r.origin.x;
|
||||||
|
offRect.size.width = r.size.width;
|
||||||
|
offRect.origin.x = r.origin.x;
|
||||||
|
|
||||||
|
offRect.origin.y = NSMinY(oldRect);
|
||||||
|
offRect.size.height =
|
||||||
|
NSMinY(r) - NSMinY(oldRect);
|
||||||
|
|
||||||
|
onRect.origin.y = NSMaxY(oldRect);
|
||||||
|
onRect.size.height =
|
||||||
|
NSMaxY(r) - NSMaxY(oldRect);
|
||||||
|
|
||||||
|
// NSHighlightRect(onRect);
|
||||||
|
DPScompositerect(GSCurrentContext(),
|
||||||
|
NSMinX(onRect),
|
||||||
|
NSMinY(onRect),
|
||||||
|
NSWidth(onRect),
|
||||||
|
NSHeight(onRect),
|
||||||
|
NSCompositeHighlight);
|
||||||
|
|
||||||
|
NSHighlightRect(offRect);
|
||||||
|
|
||||||
|
//NSLog(@"on : %@", NSStringFromRect(onRect));
|
||||||
|
//NSLog(@"off : %@", NSStringFromRect(offRect));
|
||||||
|
//NSLog(@"old : %@", NSStringFromRect(oldRect));
|
||||||
|
//NSLog(@"r : %@", NSStringFromRect(r));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSRect onRect, offRect;
|
||||||
|
onRect.size.width = r.size.width;
|
||||||
|
onRect.origin.x = r.origin.x;
|
||||||
|
offRect.size.width = r.size.width;
|
||||||
|
offRect.origin.x = r.origin.x;
|
||||||
|
|
||||||
|
offRect.origin.y = NSMaxY(r);
|
||||||
|
offRect.size.height =
|
||||||
|
NSMaxY(oldRect) - NSMaxY(r);
|
||||||
|
|
||||||
|
onRect.origin.y = NSMinY(r);
|
||||||
|
onRect.size.height =
|
||||||
|
NSMinY(oldRect) - NSMinY(r);
|
||||||
|
|
||||||
|
// NSHighlightRect(onRect);
|
||||||
|
DPScompositerect(GSCurrentContext(),
|
||||||
|
NSMinX(onRect),
|
||||||
|
NSMinY(onRect),
|
||||||
|
NSWidth(onRect),
|
||||||
|
NSHeight(onRect),
|
||||||
|
NSCompositeHighlight);
|
||||||
|
|
||||||
|
NSHighlightRect(offRect);
|
||||||
|
|
||||||
|
//NSLog(@"on : %@", NSStringFromRect(onRect));
|
||||||
|
//NSLog(@"off : %@", NSStringFromRect(offRect));
|
||||||
|
//NSLog(@"old : %@", NSStringFromRect(oldRect));
|
||||||
|
//NSLog(@"r : %@", NSStringFromRect(r));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((NSMinX(r) > NSMaxX(oldRect))
|
||||||
|
|| (NSMaxX(r) < NSMinX(oldRect)))
|
||||||
|
// the two rects don't intersect
|
||||||
|
{
|
||||||
|
DPScompositerect(GSCurrentContext(),
|
||||||
|
NSMinX(oldRect),
|
||||||
|
NSMinY(oldRect),
|
||||||
|
NSWidth(oldRect),
|
||||||
|
NSHeight(oldRect),
|
||||||
|
NSCompositeHighlight);
|
||||||
|
NSHighlightRect(r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// the two rects intersect
|
||||||
|
{
|
||||||
|
if (NSMinX(r) > NSMinX(oldRect))
|
||||||
|
{
|
||||||
|
NSRect onRect, offRect;
|
||||||
|
onRect.size.height = r.size.height;
|
||||||
|
onRect.origin.y = r.origin.y;
|
||||||
|
offRect.size.height = r.size.height;
|
||||||
|
offRect.origin.y = r.origin.y;
|
||||||
|
|
||||||
|
offRect.origin.x = NSMinX(oldRect);
|
||||||
|
offRect.size.width =
|
||||||
|
NSMinX(r) - NSMinX(oldRect);
|
||||||
|
|
||||||
|
onRect.origin.x = NSMaxX(oldRect);
|
||||||
|
onRect.size.width =
|
||||||
|
NSMaxX(r) - NSMaxX(oldRect);
|
||||||
|
|
||||||
|
DPScompositerect(GSCurrentContext(),
|
||||||
|
NSMinX(onRect),
|
||||||
|
NSMinY(onRect),
|
||||||
|
NSWidth(onRect),
|
||||||
|
NSHeight(onRect),
|
||||||
|
NSCompositeHighlight);
|
||||||
|
// NSHighlightRect(onRect);
|
||||||
|
NSHighlightRect(offRect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSRect onRect, offRect;
|
||||||
|
onRect.size.height = r.size.height;
|
||||||
|
onRect.origin.y = r.origin.y;
|
||||||
|
offRect.size.height = r.size.height;
|
||||||
|
offRect.origin.y = r.origin.y;
|
||||||
|
|
||||||
|
offRect.origin.x = NSMaxX(r);
|
||||||
|
offRect.size.width =
|
||||||
|
NSMaxX(oldRect) - NSMaxX(r);
|
||||||
|
|
||||||
|
onRect.origin.x = NSMinX(r);
|
||||||
|
onRect.size.width =
|
||||||
|
NSMinX(oldRect) - NSMinX(r);
|
||||||
|
|
||||||
|
DPScompositerect(GSCurrentContext(),
|
||||||
|
NSMinX(onRect),
|
||||||
|
NSMinY(onRect),
|
||||||
|
NSWidth(onRect),
|
||||||
|
NSHeight(onRect),
|
||||||
|
NSCompositeHighlight);
|
||||||
|
|
||||||
|
// NSHighlightRect(onRect);
|
||||||
|
NSHighlightRect(offRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSHighlightRect(r);
|
||||||
|
}
|
||||||
|
/*
|
||||||
if (lit == YES)
|
if (lit == YES)
|
||||||
{
|
{
|
||||||
NSHighlightRect(oldRect);
|
NSHighlightRect(oldRect);
|
||||||
lit = NO;
|
lit = NO;
|
||||||
}
|
}
|
||||||
NSHighlightRect(r);
|
NSHighlightRect(r);
|
||||||
|
*/
|
||||||
lit = YES;
|
lit = YES;
|
||||||
oldRect = r;
|
oldRect = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
NSEvent *ee;
|
||||||
|
|
||||||
e = [app nextEventMatchingMask: eventMask
|
e = [app nextEventMatchingMask: eventMask
|
||||||
untilDate: farAway
|
untilDate: farAway
|
||||||
inMode: NSEventTrackingRunLoopMode
|
inMode: NSEventTrackingRunLoopMode
|
||||||
dequeue: YES];
|
dequeue: YES];
|
||||||
|
|
||||||
|
if ((ee = [app nextEventMatchingMask: NSLeftMouseUpMask
|
||||||
|
untilDate: longTimeAgo
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES]) != nil)
|
||||||
|
{
|
||||||
|
[app discardEventsMatchingMask:NSLeftMouseDraggedMask
|
||||||
|
beforeEvent:ee];
|
||||||
|
e = ee;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ee = e;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
e = ee;
|
||||||
|
ee = [app nextEventMatchingMask: NSLeftMouseDraggedMask
|
||||||
|
untilDate: longTimeAgo
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
|
}
|
||||||
|
while(ee != nil);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lit == YES)
|
if (lit == YES)
|
||||||
|
@ -405,7 +617,7 @@
|
||||||
|
|
||||||
[self setNeedsDisplay: YES];
|
[self setNeedsDisplay: YES];
|
||||||
|
|
||||||
[self display];
|
//[self display];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _adjustSubviews: (NSSize)oldSize
|
- (void) _adjustSubviews: (NSSize)oldSize
|
||||||
|
|
Loading…
Reference in a new issue