Fix initial tab view size causing 0 width plot views in new tabs

This commit is contained in:
anthony 2021-03-02 20:03:13 +00:00
parent 21efa0c6ed
commit 7bfa54dec0
1 changed files with 13 additions and 2 deletions

View File

@ -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];