From c673a0697023a6bdb0e06f16f8a74d645d365a43 Mon Sep 17 00:00:00 2001 From: ericwa Date: Tue, 15 Oct 2013 06:17:36 +0000 Subject: [PATCH] * Source/NSTabView.m (-initWithCoder:): Make non-keyed archives call -selectTabViewItem: to select the current tab at unarchiving time (keyed archives were already doing this.) Comment: "N.B.: As a side effect, this discards the subview frame and sets it to [self contentRect]. This is desirable because the subview frame will be different depending on whether the arcive is from Cocoa or GNUstep, and which GNUstep theme was active at save time. However, it does mean that the tab view contents should be prepared to resize slightly." The immediate need for this is tab views were changed to use flipped coordinates, so the subview frames stored in existing archives are now in the wrong coordinate system. This is essentially the same idea as NSScrollView calling -tile at the end of -initWithCoder: so I hope it makes sense for tab views too. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37232 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 23 +++++++++++++++++++++++ Source/NSTabView.m | 15 ++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce5bb8e1f..c747e94c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2013-10-15 Eric Wasylishen + + * Source/NSTabView.m (-initWithCoder:): Make non-keyed archives + call -selectTabViewItem: to select the current tab at unarchiving + time (keyed archives were already doing this.) + + Comment: "N.B.: As a side effect, this discards the subview frame + and sets it to [self contentRect]. + + This is desirable because the subview frame will be different + depending on whether the arcive is from Cocoa or GNUstep, + and which GNUstep theme was active at save time. + + However, it does mean that the tab view contents should be + prepared to resize slightly." + + The immediate need for this is tab views were changed to use + flipped coordinates, so the subview frames stored in existing + archives are now in the wrong coordinate system. + + This is essentially the same idea as NSScrollView calling -tile at the + end of -initWithCoder: so I hope it makes sense for tab views too. + 2013-10-14 Eric Wasylishen * Source/GSThemeDrawing.m (-tabHeightForType:): Check for nil diff --git a/Source/NSTabView.m b/Source/NSTabView.m index ced578387..2fd1df61b 100644 --- a/Source/NSTabView.m +++ b/Source/NSTabView.m @@ -605,6 +605,15 @@ } if ([aDecoder containsValueForKey: @"NSSelectedTabViewItem"]) { + // N.B.: As a side effect, this discards the subview frame + // and sets it to [self contentRect]. + // + // This is desirable because the subview frame will be different + // depending on whether the arcive is from Cocoa or GNUstep, + // and which GNUstep theme was active at save time. + // + // However, it does mean that the tab view contents should be + // prepared to resize slightly. [self selectTabViewItem: [aDecoder decodeObjectForKey: @"NSSelectedTabViewItem"]]; } @@ -660,9 +669,9 @@ { [aDecoder decodeValueOfObjCType: @encode(NSUInteger) at: &selected_item]; } - - if (selected_item != NSNotFound) - _selected = [_items objectAtIndex: selected_item]; + + // N.B. Recalculates subview frame; see comment above. + [self selectTabViewItemAtIndex: selected_item]; } return self; }