* Source/NSView.m: Applied patch from Banlu Kemiyatorn. Corrects

issue with detection of events in a rotated view.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23908 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-10-19 05:47:36 +00:00
parent 97f5dfaf39
commit 5b14579bdd
2 changed files with 69 additions and 21 deletions

View file

@ -1,3 +1,8 @@
2006-10-19 01:45-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSView.m: Applied patch from Banlu Kemiyatorn. Corrects
issue with detection of events in a rotated view.
2006-10-16 20:53-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSFont.m: Apply slightly modified version of patch

View file

@ -305,9 +305,25 @@ GSSetDragTypes(NSView* obj, NSArray *types)
NSRect superviewsVisibleRect;
BOOL wasFlipped = _super_view->_rFlags.flipped_view;
NSAffineTransform *pMatrix = [_super_view _matrixToWindow];
NSAffineTransform *tMatrix = nil;
[_matrixToWindow takeMatrixFromTransform: pMatrix];
(*preImp)(_matrixToWindow, preSel, _frameMatrix);
/* prepend translation */
tMatrix = _matrixToWindow;
tMatrix->matrix.tX = NSMinX(_frame) * tMatrix->matrix.m11 +
NSMinY(_frame) * tMatrix->matrix.m21 +
tMatrix->matrix.tX;
tMatrix->matrix.tY = NSMinX(_frame) * tMatrix->matrix.m12 +
NSMinY(_frame) * tMatrix->matrix.m22 +
tMatrix->matrix.tY;
/* prepend rotation */
if (_frameMatrix != nil)
{
(*preImp)(_matrixToWindow, preSel, _frameMatrix);
}
if (_rFlags.flipped_view != wasFlipped)
{
/*
@ -428,11 +444,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_bounds.origin = NSZeroPoint; // Set bounds rectangle
_bounds.size = _frame.size;
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
_matrixFromWindow = [NSAffineTransform new]; // Map from window coordinates
[_frameMatrix setFrameOrigin: _frame.origin];
_sub_views = [NSMutableArray new];
_tracking_rects = [NSMutableArray new];
@ -559,7 +573,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
RELEASE(_matrixToWindow);
RELEASE(_matrixFromWindow);
RELEASE(_frameMatrix);
TEST_RELEASE(_frameMatrix);
RELEASE(_boundsMatrix);
TEST_RELEASE(_sub_views);
if (_rFlags.has_tooltips != 0)
@ -1050,11 +1064,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_bounds.size = frameRect.size;
if (changedOrigin)
{
[_frameMatrix setFrameOrigin: _frame.origin];
}
if (changedSize && _is_rotated_or_scaled_from_base)
{
[self _updateBoundsMatrix];
@ -1082,7 +1091,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
(*invalidateImp)(self, invalidateSel);
}
_frame.origin = newOrigin;
[_frameMatrix setFrameOrigin: _frame.origin];
if (_post_frame_changes)
{
@ -1134,10 +1142,17 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (void) setFrameRotation: (float)angle
{
/* no frame matrix, create one since it is needed for rotation */
if (_frameMatrix == nil)
{
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
}
if (_coordinates_valid)
{
(*invalidateImp)(self, invalidateSel);
}
[_frameMatrix setFrameRotation: angle];
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
@ -2072,10 +2087,14 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
NSRect subviewFrame = subview->_frame;
BOOL intersectCalculated = NO;
if ([subview->_frameMatrix isRotated])
if (subview->_frameMatrix) // assume rotation
{
[subview->_frameMatrix boundingRectFor: subviewFrame
result: &subviewFrame];
NSRect r;
r.origin = NSZeroPoint;
r.size = subviewFrame.size;
[subview->_frameMatrix boundingRectFor: r
result: &r];
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
}
/*
@ -2201,9 +2220,15 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
NSRect isect;
BOOL intersectCalculated = NO;
if ([subview->_frameMatrix isRotated] == YES)
[subview->_frameMatrix boundingRectFor: subviewFrame
result: &subviewFrame];
if (subview->_frameMatrix != nil)
{
NSRect r;
r.origin = NSZeroPoint;
r.size = subviewFrame.size;
[subview->_frameMatrix boundingRectFor: r
result: &r];
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
}
/*
* Having drawn ourself into the rect, we must make sure that
@ -2835,10 +2860,23 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
As a special case, always assume that it's a hit if our _super_view is nil,
ie. if we're the top-level view in a window.
*/
if (_super_view && ![_super_view mouse: aPoint inRect: _frame])
return nil;
p = [self convertPoint: aPoint fromView: _super_view];
if (_is_rotated_or_scaled_from_base)
{
p = [self convertPoint: aPoint fromView: _super_view];
if (!NSPointInRect (p, _bounds))
{
return nil;
}
}
else if (_super_view && ![_super_view mouse: aPoint inRect: _frame])
{
return nil;
}
else
{
p = [self convertPoint: aPoint fromView: _super_view];
}
if (_rFlags.has_subviews)
{
@ -3999,7 +4037,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[super initWithCoder: aDecoder];
// initialize these here, since they're needed in either case.
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
//_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
_matrixFromWindow = [NSAffineTransform new];// Map from window coordinates
@ -4095,7 +4133,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
_bounds.origin = NSZeroPoint;
_bounds.size = _frame.size;
[_frameMatrix setFrameOrigin: _frame.origin];
// [_frameMatrix setFrameOrigin: _frame.origin];
rect = [aDecoder decodeRect];
[self setBounds: rect];
@ -4237,7 +4275,12 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
- (float) frameRotation
{
if (_frameMatrix != nil)
{
return [_frameMatrix rotationAngle];
}
return 0.0;
}
- (BOOL) postsFrameChangedNotifications