Fix implementation of tracking rectangles to use the coordinate system

of their views, as they do under Cocoa.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35645 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2012-10-06 19:42:56 +00:00
parent c29763d8cc
commit b0b86079ca
5 changed files with 24 additions and 55 deletions

View file

@ -1,3 +1,17 @@
2012-10-06 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSWindow.m (-_checkTrackingRectangles:forEvent:):
Tracking rectangles now use the coordinate system of their views,
as they do under Cocoa.
* Source/GSToolTips.h (-rebuild): Remove.
* Source/GSToolTips.m (-rebuild): Remove.
* Source/NSView.m (-_rebuildCoordinates): No need to recompute
tool tip tracking rectangles.
* Source/GSToolTips.m (GSTTProvider): Remove view rectangles from
GSTTProvider class. They are no longer used.
2012-10-04 Wolfgang Lux <wolfgang.lux@gmail.com>
Improve keyboard navigation by automatically computing a key view

View file

@ -80,11 +80,6 @@
*/
- (void) mouseMoved: (NSEvent *)theEvent;
/** Rebuild rectangles. Called by NSView whenever it has to rebuild its
* coordinate system because it has been resized, moved, or reparented.
*/
- (void) rebuild;
/** Support [NSView-removeAllToolTips]
*/
- (void) removeAllToolTips;

View file

@ -63,13 +63,11 @@
{
id object;
void *data;
NSRect viewRect;
}
- (void*) data;
- (id) initWithObject: (id)o userData: (void*)d rect: (NSRect)r;
- (id) initWithObject: (id)o userData: (void*)d;
- (id) object;
- (void) setObject: (id)o;
- (NSRect) viewRect;
@end
@implementation GSTTProvider
@ -82,10 +80,9 @@
[self setObject: nil];
[super dealloc];
}
- (id) initWithObject: (id)o userData: (void*)d rect: (NSRect)r
- (id) initWithObject: (id)o userData: (void*)d
{
data = d;
viewRect = r;
[self setObject: o];
return self;
}
@ -116,10 +113,6 @@
object = [[object description] copy];
}
}
- (NSRect) viewRect
{
return viewRect;
}
@end
@interface GSTTPanel : NSPanel
@ -233,8 +226,7 @@ static BOOL restoreMouseMoved;
}
provider = [[GSTTProvider alloc] initWithObject: anObject
userData: data
rect: aRect];
userData: data];
tag = [view addTrackingRect: aRect
owner: self
userData: provider
@ -350,35 +342,6 @@ static BOOL restoreMouseMoved;
[window setFrameOrigin: origin];
}
- (void) rebuild
{
NSEnumerator *enumerator;
GSTrackingRect *rect;
enumerator = [((NSViewPtr)view)->_tracking_rects objectEnumerator];
while ((rect = [enumerator nextObject]) != nil)
{
if (rect->owner == self)
{
GSTTProvider *provider = (GSTTProvider *)rect->user_data;
NSRect frame;
if (rect->tag == toolTipTag)
{
frame = [view bounds];
}
else
{
// FIXME is this the thing to do with tooltips other than
// the main one (which we know should cover the whole view)?
frame = [provider viewRect];
}
frame = [view convertRect: frame toView: nil];
[rect reset: frame inside: NO];
}
}
}
- (void) removeAllToolTips
{
NSEnumerator *enumerator;
@ -461,8 +424,7 @@ static BOOL restoreMouseMoved;
rect = [view bounds];
provider = [[GSTTProvider alloc] initWithObject: string
userData: nil
rect: rect];
userData: nil];
toolTipTag = [view addTrackingRect: rect
owner: self
userData: provider

View file

@ -360,12 +360,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_visibleRect = _bounds;
}
}
if (_rFlags.has_tooltips != 0)
{
GSToolTips *tt = [GSToolTips tipsForView: self];
[tt rebuild];
}
}
}

View file

@ -3448,6 +3448,7 @@ resetCursorRectsForView(NSView *theView)
return;
if (theView->_rFlags.has_trkrects)
{
BOOL isFlipped = [theView isFlipped];
NSArray *tr = theView->_tracking_rects;
unsigned count = [tr count];
@ -3458,8 +3459,11 @@ resetCursorRectsForView(NSView *theView)
{
GSTrackingRect *rects[count];
NSPoint loc = [theEvent locationInWindow];
NSPoint lastPoint = _lastPoint;
unsigned i;
lastPoint = [theView convertPoint: lastPoint fromView: nil];
loc = [theView convertPoint: loc fromView: nil];
[tr getObjects: rects];
for (i = 0; i < count; ++i)
@ -3471,9 +3475,9 @@ resetCursorRectsForView(NSView *theView)
if ([r isValid] == NO)
continue;
/* Check mouse at last point */
last = NSMouseInRect(_lastPoint, r->rectangle, NO);
last = NSMouseInRect(lastPoint, r->rectangle, isFlipped);
/* Check mouse at current point */
now = NSMouseInRect(loc, r->rectangle, NO);
now = NSMouseInRect(loc, r->rectangle, isFlipped);
if ((!last) && (now)) // Mouse entered event
{