From 7bfa54dec04bfad28341ca9c0bb6a8167f94a0d8 Mon Sep 17 00:00:00 2001 From: anthony Date: Tue, 2 Mar 2021 20:03:13 +0000 Subject: [PATCH] Fix initial tab view size causing 0 width plot views in new tabs --- frontends/gnustep/BrowserWindowController.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontends/gnustep/BrowserWindowController.m b/frontends/gnustep/BrowserWindowController.m index 8a473085c..9af310e1a 100644 --- a/frontends/gnustep/BrowserWindowController.m +++ b/frontends/gnustep/BrowserWindowController.m @@ -370,8 +370,19 @@ static id newTabTarget; NSLog(@"TabView: %@", tabItem); NSView *innerView = [tabItem view]; NSLog(@"Inner view: %@", innerView); - PlotView *newPlotView = [[PlotView alloc] initWithFrame: [innerView bounds]]; - NSScrollView *newScrollView = [[NSScrollView alloc] initWithFrame: [innerView bounds]]; + + // Come up with a good initial frame. + NSRect bounds; + NSTabViewItem *currentTabView = [tabView selectedTabViewItem]; + if (currentTabView != nil) { + bounds = [[currentTabView view] bounds]; + [innerView setFrame: bounds]; + } else { + bounds = [innerView bounds]; + } + + PlotView *newPlotView = [[PlotView alloc] initWithFrame: bounds]; + NSScrollView *newScrollView = [[NSScrollView alloc] initWithFrame: bounds]; [newScrollView setHasVerticalScroller: YES]; [newScrollView setHasHorizontalScroller: YES]; [newScrollView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];