mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:50:48 +00:00
Coordinate conversion code plus bugfix in redisplay stuff.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3768 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e7df4d454a
commit
db6480b4df
5 changed files with 97 additions and 21 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sun Feb 21 20:36:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* Headers/gnustep/gui/NSCell.h: tidyup
|
||||||
|
* Headers/gnustep/gui/NSView.h: Added matrix for coordinate conversion
|
||||||
|
* Source/NSView.m: Bugfix in update, plus partial code for improved
|
||||||
|
coordinate handling.
|
||||||
|
|
||||||
Fri Feb 19 20:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Fri Feb 19 20:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSClipView.m: coordinate fixes.
|
* Source/NSClipView.m: coordinate fixes.
|
||||||
|
|
|
@ -343,5 +343,15 @@ enum {
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
//
|
||||||
|
// Methods that are private GNUstep extensions
|
||||||
|
//
|
||||||
|
@interface NSCell (PrivateMethods)
|
||||||
|
|
||||||
|
- (void) _drawImage: (NSImage*)anImage inFrame: (NSRect)aRect;
|
||||||
|
- (void) _drawText: (NSString*)aString inFrame: (NSRect)aRect;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
#endif // _GNUstep_H_NSCell
|
#endif // _GNUstep_H_NSCell
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ enum {
|
||||||
NSRect bounds;
|
NSRect bounds;
|
||||||
id frameMatrix;
|
id frameMatrix;
|
||||||
id boundsMatrix;
|
id boundsMatrix;
|
||||||
|
id windowMatrix;
|
||||||
|
|
||||||
NSView* super_view;
|
NSView* super_view;
|
||||||
NSMutableArray *sub_views;
|
NSMutableArray *sub_views;
|
||||||
|
@ -371,10 +372,11 @@ enum {
|
||||||
* forcing recalculation of cached values next time they are needed.
|
* forcing recalculation of cached values next time they are needed.
|
||||||
*/
|
*/
|
||||||
- (void) _invalidateCoordinates;
|
- (void) _invalidateCoordinates;
|
||||||
|
- (void) _rebuildCoordinates;
|
||||||
|
|
||||||
- (PSMatrix*)_frameMatrix;
|
- (PSMatrix*)_frameMatrix;
|
||||||
- (PSMatrix*)_boundsMatrix;
|
- (PSMatrix*)_boundsMatrix;
|
||||||
|
- (PSMatrix*)_windowMatrix;
|
||||||
- (PSMatrix*) _concatenateBoundsMatricesInReverseOrderFromPath: (NSArray*)p;
|
- (PSMatrix*) _concatenateBoundsMatricesInReverseOrderFromPath: (NSArray*)p;
|
||||||
- (PSMatrix*) _concatenateMatricesInReverseOrderFromPath: (NSArray*)p;
|
- (PSMatrix*) _concatenateMatricesInReverseOrderFromPath: (NSArray*)p;
|
||||||
- (NSMutableArray*) _pathBetweenSubview: (NSView*)subview
|
- (NSMutableArray*) _pathBetweenSubview: (NSView*)subview
|
||||||
|
|
|
@ -176,6 +176,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||||
|
|
||||||
frameMatrix = [PSMatrix new]; // init PS matrix for
|
frameMatrix = [PSMatrix new]; // init PS matrix for
|
||||||
boundsMatrix = [PSMatrix new]; // frame and bounds
|
boundsMatrix = [PSMatrix new]; // frame and bounds
|
||||||
|
windowMatrix = [PSMatrix new]; // map to window coordinates
|
||||||
[frameMatrix setFrameOrigin: frame.origin];
|
[frameMatrix setFrameOrigin: frame.origin];
|
||||||
|
|
||||||
sub_views = [NSMutableArray new];
|
sub_views = [NSMutableArray new];
|
||||||
|
@ -191,12 +192,14 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||||
post_frame_changes = NO;
|
post_frame_changes = NO;
|
||||||
autoresize_subviews = YES;
|
autoresize_subviews = YES;
|
||||||
autoresizingMask = NSViewNotSizable;
|
autoresizingMask = NSViewNotSizable;
|
||||||
|
coordinates_valid = NO;
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
[windowMatrix release];
|
||||||
[frameMatrix release];
|
[frameMatrix release];
|
||||||
[boundsMatrix release];
|
[boundsMatrix release];
|
||||||
[sub_views release];
|
[sub_views release];
|
||||||
|
@ -626,10 +629,17 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||||
{
|
{
|
||||||
NSPoint new;
|
NSPoint new;
|
||||||
PSMatrix *matrix;
|
PSMatrix *matrix;
|
||||||
|
NSPoint yyy;
|
||||||
|
PSMatrix *xxx;
|
||||||
|
|
||||||
if (!aView)
|
if (!aView)
|
||||||
aView = [window contentView];
|
aView = [window contentView];
|
||||||
|
|
||||||
|
xxx = [[aView _windowMatrix] copy];
|
||||||
|
[xxx inverse];
|
||||||
|
(*concatImp)(xxx, concatSel, [self _windowMatrix]);
|
||||||
|
yyy = [xxx pointInMatrixSpace: aPoint];
|
||||||
|
|
||||||
if ([self isDescendantOf: aView])
|
if ([self isDescendantOf: aView])
|
||||||
{
|
{
|
||||||
NSMutableArray *path;
|
NSMutableArray *path;
|
||||||
|
@ -655,6 +665,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||||
new = [self convertPoint: new fromView: nil];
|
new = [self convertPoint: new fromView: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NSAssert(NSEqualPoints(new, yyy), NSInternalInconsistencyException);
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1004,7 +1015,7 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||||
* Having drawn ourself into the rect, we must unconditionally
|
* Having drawn ourself into the rect, we must unconditionally
|
||||||
* draw any subviews that are also in that rectangle.
|
* draw any subviews that are also in that rectangle.
|
||||||
*/
|
*/
|
||||||
isect = NSIntersectionRect(rect, subviewFrame);
|
isect = NSIntersectionRect(aRect, subviewFrame);
|
||||||
if (NSIsEmptyRect(isect) == NO)
|
if (NSIsEmptyRect(isect) == NO)
|
||||||
{
|
{
|
||||||
isect = [subview convertRect: isect
|
isect = [subview convertRect: isect
|
||||||
|
@ -1170,24 +1181,10 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||||
|
|
||||||
- (NSRect) visibleRect
|
- (NSRect) visibleRect
|
||||||
{
|
{
|
||||||
if (coordinates_valid)
|
if (coordinates_valid == NO)
|
||||||
return visibleRect;
|
[self _rebuildCoordinates];
|
||||||
if (!window)
|
if (needs_display)
|
||||||
visibleRect = NSZeroRect;
|
invalidRect = NSIntersectionRect(invalidRect, visibleRect);
|
||||||
else if (!super_view)
|
|
||||||
visibleRect = bounds;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NSRect superviewsVisibleRect;
|
|
||||||
|
|
||||||
superviewsVisibleRect = [self convertRect: [super_view visibleRect]
|
|
||||||
fromView: super_view];
|
|
||||||
|
|
||||||
visibleRect = NSIntersectionRect(superviewsVisibleRect, bounds);
|
|
||||||
if (needs_display)
|
|
||||||
invalidRect = NSIntersectionRect(invalidRect, visibleRect);
|
|
||||||
}
|
|
||||||
coordinates_valid = YES;
|
|
||||||
return visibleRect;
|
return visibleRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1865,11 +1862,58 @@ static SEL invalidateSel = @selector(_invalidateCoordinates);
|
||||||
while (view && view != _superview)
|
while (view && view != _superview)
|
||||||
{
|
{
|
||||||
[array addObject: view];
|
[array addObject: view];
|
||||||
view = view->super_view;
|
view = view->super_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) _rebuildCoordinates
|
||||||
|
{
|
||||||
|
if (coordinates_valid == NO)
|
||||||
|
{
|
||||||
|
coordinates_valid = YES;
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
visibleRect = NSZeroRect;
|
||||||
|
[windowMatrix makeIdentityMatrix];
|
||||||
|
}
|
||||||
|
if (!super_view)
|
||||||
|
{
|
||||||
|
visibleRect = bounds;
|
||||||
|
[windowMatrix makeIdentityMatrix];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSRect superviewsVisibleRect;
|
||||||
|
BOOL wasFlipped = [super_view isFlipped];
|
||||||
|
float vals[6];
|
||||||
|
PSMatrix *pMatrix = [super_view _windowMatrix];
|
||||||
|
|
||||||
|
[pMatrix getMatrix: vals];
|
||||||
|
[windowMatrix setMatrix: vals];
|
||||||
|
(*concatImp)(windowMatrix, concatSel, frameMatrix);
|
||||||
|
if ([self isFlipped] != wasFlipped)
|
||||||
|
{
|
||||||
|
flip->matrix[5] = bounds.size.height;
|
||||||
|
(*concatImp)(windowMatrix, concatSel, flip);
|
||||||
|
}
|
||||||
|
(*concatImp)(windowMatrix, concatSel, boundsMatrix);
|
||||||
|
|
||||||
|
superviewsVisibleRect = [self convertRect: [super_view visibleRect]
|
||||||
|
fromView: super_view];
|
||||||
|
|
||||||
|
visibleRect = NSIntersectionRect(superviewsVisibleRect, bounds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (PSMatrix*) _windowMatrix
|
||||||
|
{
|
||||||
|
if (coordinates_valid == NO)
|
||||||
|
[self _rebuildCoordinates];
|
||||||
|
return windowMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,19 @@ static const float pi = 3.1415926535897932384626433;
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isEqual: (id)anObject
|
||||||
|
{
|
||||||
|
if ([anObject class] == [PSMatrix class])
|
||||||
|
{
|
||||||
|
PSMatrix *o = anObject;
|
||||||
|
|
||||||
|
if (A == o->A && B == o->B && C == o->C
|
||||||
|
&& D == o->D && TX == o->TX && TY == o->TY)
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)scaleBy:(float)sx :(float)sy
|
- (void)scaleBy:(float)sx :(float)sy
|
||||||
{
|
{
|
||||||
A *= sx; B *= sx;
|
A *= sx; B *= sx;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue