mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 22:10:58 +00:00
* 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:
parent
96f859fd88
commit
a72332d295
2 changed files with 69 additions and 21 deletions
|
@ -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>
|
2006-10-16 20:53-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSFont.m: Apply slightly modified version of patch
|
* Source/NSFont.m: Apply slightly modified version of patch
|
||||||
|
|
|
@ -305,9 +305,25 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
NSRect superviewsVisibleRect;
|
NSRect superviewsVisibleRect;
|
||||||
BOOL wasFlipped = _super_view->_rFlags.flipped_view;
|
BOOL wasFlipped = _super_view->_rFlags.flipped_view;
|
||||||
NSAffineTransform *pMatrix = [_super_view _matrixToWindow];
|
NSAffineTransform *pMatrix = [_super_view _matrixToWindow];
|
||||||
|
NSAffineTransform *tMatrix = nil;
|
||||||
|
|
||||||
[_matrixToWindow takeMatrixFromTransform: pMatrix];
|
[_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)
|
if (_rFlags.flipped_view != wasFlipped)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -428,11 +444,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
_bounds.origin = NSZeroPoint; // Set bounds rectangle
|
_bounds.origin = NSZeroPoint; // Set bounds rectangle
|
||||||
_bounds.size = _frame.size;
|
_bounds.size = _frame.size;
|
||||||
|
|
||||||
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
|
|
||||||
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds
|
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds
|
||||||
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
|
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
|
||||||
_matrixFromWindow = [NSAffineTransform new]; // Map from window coordinates
|
_matrixFromWindow = [NSAffineTransform new]; // Map from window coordinates
|
||||||
[_frameMatrix setFrameOrigin: _frame.origin];
|
|
||||||
|
|
||||||
_sub_views = [NSMutableArray new];
|
_sub_views = [NSMutableArray new];
|
||||||
_tracking_rects = [NSMutableArray new];
|
_tracking_rects = [NSMutableArray new];
|
||||||
|
@ -559,7 +573,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
|
|
||||||
RELEASE(_matrixToWindow);
|
RELEASE(_matrixToWindow);
|
||||||
RELEASE(_matrixFromWindow);
|
RELEASE(_matrixFromWindow);
|
||||||
RELEASE(_frameMatrix);
|
TEST_RELEASE(_frameMatrix);
|
||||||
RELEASE(_boundsMatrix);
|
RELEASE(_boundsMatrix);
|
||||||
TEST_RELEASE(_sub_views);
|
TEST_RELEASE(_sub_views);
|
||||||
if (_rFlags.has_tooltips != 0)
|
if (_rFlags.has_tooltips != 0)
|
||||||
|
@ -1050,11 +1064,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
_bounds.size = frameRect.size;
|
_bounds.size = frameRect.size;
|
||||||
|
|
||||||
|
|
||||||
if (changedOrigin)
|
|
||||||
{
|
|
||||||
[_frameMatrix setFrameOrigin: _frame.origin];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changedSize && _is_rotated_or_scaled_from_base)
|
if (changedSize && _is_rotated_or_scaled_from_base)
|
||||||
{
|
{
|
||||||
[self _updateBoundsMatrix];
|
[self _updateBoundsMatrix];
|
||||||
|
@ -1082,7 +1091,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
(*invalidateImp)(self, invalidateSel);
|
(*invalidateImp)(self, invalidateSel);
|
||||||
}
|
}
|
||||||
_frame.origin = newOrigin;
|
_frame.origin = newOrigin;
|
||||||
[_frameMatrix setFrameOrigin: _frame.origin];
|
|
||||||
|
|
||||||
if (_post_frame_changes)
|
if (_post_frame_changes)
|
||||||
{
|
{
|
||||||
|
@ -1134,10 +1142,17 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
|
|
||||||
- (void) setFrameRotation: (float)angle
|
- (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)
|
if (_coordinates_valid)
|
||||||
{
|
{
|
||||||
(*invalidateImp)(self, invalidateSel);
|
(*invalidateImp)(self, invalidateSel);
|
||||||
}
|
}
|
||||||
|
|
||||||
[_frameMatrix setFrameRotation: angle];
|
[_frameMatrix setFrameRotation: angle];
|
||||||
_is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
|
_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;
|
NSRect subviewFrame = subview->_frame;
|
||||||
BOOL intersectCalculated = NO;
|
BOOL intersectCalculated = NO;
|
||||||
|
|
||||||
if ([subview->_frameMatrix isRotated])
|
if (subview->_frameMatrix) // assume rotation
|
||||||
{
|
{
|
||||||
[subview->_frameMatrix boundingRectFor: subviewFrame
|
NSRect r;
|
||||||
result: &subviewFrame];
|
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;
|
NSRect isect;
|
||||||
BOOL intersectCalculated = NO;
|
BOOL intersectCalculated = NO;
|
||||||
|
|
||||||
if ([subview->_frameMatrix isRotated] == YES)
|
if (subview->_frameMatrix != nil)
|
||||||
[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));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Having drawn ourself into the rect, we must make sure that
|
* 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,
|
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.
|
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)
|
if (_rFlags.has_subviews)
|
||||||
{
|
{
|
||||||
|
@ -3999,7 +4037,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
[super initWithCoder: aDecoder];
|
[super initWithCoder: aDecoder];
|
||||||
|
|
||||||
// initialize these here, since they're needed in either case.
|
// 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
|
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds
|
||||||
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
|
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
|
||||||
_matrixFromWindow = [NSAffineTransform new];// Map from 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.origin = NSZeroPoint;
|
||||||
_bounds.size = _frame.size;
|
_bounds.size = _frame.size;
|
||||||
[_frameMatrix setFrameOrigin: _frame.origin];
|
// [_frameMatrix setFrameOrigin: _frame.origin];
|
||||||
|
|
||||||
rect = [aDecoder decodeRect];
|
rect = [aDecoder decodeRect];
|
||||||
[self setBounds: rect];
|
[self setBounds: rect];
|
||||||
|
@ -4237,7 +4275,12 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
|
|
||||||
- (float) frameRotation
|
- (float) frameRotation
|
||||||
{
|
{
|
||||||
|
if (_frameMatrix != nil)
|
||||||
|
{
|
||||||
return [_frameMatrix rotationAngle];
|
return [_frameMatrix rotationAngle];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) postsFrameChangedNotifications
|
- (BOOL) postsFrameChangedNotifications
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue