From 003dcb8149f99b77e5ada1d0ac5c15258ceb1378 Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Mon, 31 Dec 2012 18:55:36 +0000 Subject: [PATCH] * Source/NSView.m (-_rebuildCoordinates): Check if the flipped state of the view has changed. Call this method all the times instead of checking _coordinates_valid. This change allows views to dynamically change their flipped state. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35928 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Headers/AppKit/NSView.h | 2 +- Source/NSView.m | 34 +++++++++++++++------------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1ff87639..36f56ff6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-12-31 Fred Kiefer + + * Source/NSView.m (-_rebuildCoordinates): Check if the flipped + state of the view has changed. Call this method all the times + instead of checking _coordinates_valid. + This change allows views to dynamically change their flipped state. + 2012-12-31 Fred Kiefer * Source/NSFont.m (-setInContext:): Remove usage of diff --git a/Headers/AppKit/NSView.h b/Headers/AppKit/NSView.h index 5d8cc8725..b9829f4c8 100644 --- a/Headers/AppKit/NSView.h +++ b/Headers/AppKit/NSView.h @@ -124,7 +124,7 @@ PACKAGE_SCOPE * Flags for internal use by NSView and it's subclasses. */ struct _rFlagsType { - unsigned flipped_view:1; /* Deprecated and unused. */ + unsigned flipped_view:1; /* Flipped state the last time we checked. */ unsigned has_subviews:1; /* The view has subviews. */ unsigned has_currects:1; /* The view has cursor rects. */ unsigned has_trkrects:1; /* The view has tracking rects. */ diff --git a/Source/NSView.m b/Source/NSView.m index 20a325523..4e3110da4 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -258,10 +258,7 @@ GSSetDragTypes(NSView* obj, NSArray *types) */ - (NSAffineTransform*) _matrixFromWindow { - if (_coordinates_valid == NO) - { - [self _rebuildCoordinates]; - } + [self _rebuildCoordinates]; return _matrixFromWindow; } @@ -274,10 +271,7 @@ GSSetDragTypes(NSView* obj, NSArray *types) */ - (NSAffineTransform*) _matrixToWindow { - if (_coordinates_valid == NO) - { - [self _rebuildCoordinates]; - } + [self _rebuildCoordinates]; return _matrixToWindow; } @@ -288,9 +282,14 @@ GSSetDragTypes(NSView* obj, NSArray *types) */ - (void) _rebuildCoordinates { - if (_coordinates_valid == NO) + BOOL isFlipped = [self isFlipped]; + BOOL lastFlipped = _rFlags.flipped_view; + + if ((_coordinates_valid == NO) || (isFlipped != lastFlipped)) { _coordinates_valid = YES; + _rFlags.flipped_view = isFlipped; + if (!_window) { _visibleRect = NSZeroRect; @@ -300,18 +299,18 @@ GSSetDragTypes(NSView* obj, NSArray *types) else { NSRect superviewsVisibleRect; - BOOL wasFlipped; + BOOL superFlipped; NSAffineTransform *pMatrix; NSAffineTransformStruct ts; if (_super_view != nil) { - wasFlipped = [_super_view isFlipped]; + superFlipped = [_super_view isFlipped]; pMatrix = [_super_view _matrixToWindow]; } else { - wasFlipped = NO; + superFlipped = NO; pMatrix = [NSAffineTransform transform]; } @@ -328,7 +327,7 @@ GSSetDragTypes(NSView* obj, NSArray *types) (*preImp)(_matrixToWindow, preSel, _frameMatrix); } - if ([self isFlipped] != wasFlipped) + if (isFlipped != superFlipped) { /* * The flipping process must result in a coordinate system that @@ -2540,15 +2539,12 @@ static void autoresize(CGFloat oldContainerSize, if (context == wContext) { NSRect neededRect; + NSRect visibleRect = [self visibleRect]; flush = YES; [_window disableFlushWindow]; - if (_coordinates_valid == NO) - { - [self _rebuildCoordinates]; - } - aRect = NSIntersectionRect(aRect, _visibleRect); - neededRect = NSIntersectionRect(_invalidRect, _visibleRect); + aRect = NSIntersectionRect(aRect, visibleRect); + neededRect = NSIntersectionRect(_invalidRect, visibleRect); /* * If the rect we are going to display contains the _invalidRect