Skip to content
Snippets Groups Projects
Commit 1ef1952b authored by George Nachman's avatar George Nachman
Browse files

Fix a problem where second and later tabs in a window with a left-side tab bar...

Fix a problem where second and later tabs in a window with a left-side tab bar that's limited by the 1/3 * content size bound will have fewer columns than it should. Issue 6371.
parent c71a6a68
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4427,10 +4427,12 @@ ITERM_WEAKLY_REFERENCEABLE
[session setIgnoreResizeNotifications:NO];
}
 
const BOOL willShowTabBar = ([iTermPreferences boolForKey:kPreferenceKeyHideTabBar] &&
[_contentView.tabView numberOfTabViewItems] > 1 &&
[_contentView.tabBarControl isHidden]);
// check window size in case tabs have to be hidden or shown
if (([_contentView.tabView numberOfTabViewItems] == 1) || // just decreased to 1 or increased above 1 and is hidden
([iTermPreferences boolForKey:kPreferenceKeyHideTabBar] &&
([_contentView.tabView numberOfTabViewItems] > 1 && [_contentView.tabBarControl isHidden]))) {
willShowTabBar) {
// Need to change the visibility status of the tab bar control.
PtyLog(@"tabViewDidChangeNumberOfTabViewItems - calling fitWindowToTab");
 
Loading
Loading
@@ -4449,6 +4451,9 @@ ITERM_WEAKLY_REFERENCEABLE
PTYSession *session = firstTab.sessions.firstObject;
[[session view] setShowTitle:NO adjustScrollView:YES];
}
if (willShowTabBar && [iTermPreferences intForKey:kPreferenceKeyTabPosition] == PSMTab_LeftTab) {
[_contentView willShowTabBar];
}
[self fitWindowToTabs];
[self repositionWidgets];
if (wasDraggedFromAnotherWindow_) {
Loading
Loading
Loading
Loading
@@ -69,6 +69,7 @@ extern const CGFloat kHorizontalTabBarHeight;
@property(nonatomic, readonly) CGFloat tabviewWidth;
 
@property(nonatomic, readonly) CGFloat leftTabBarWidth;
@property(nonatomic, readonly) CGFloat leftTabBarPreferredWidth;
 
- (instancetype)initWithFrame:(NSRect)frame
color:(NSColor *)color
Loading
Loading
@@ -93,4 +94,6 @@ extern const CGFloat kHorizontalTabBarHeight;
 
- (BOOL)tabBarShouldBeVisibleWithAdditionalTabs:(int)numberOfAdditionalTabs;
 
- (void)willShowTabBar;
@end
Loading
Loading
@@ -30,7 +30,6 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
@property(nonatomic, retain) SolidColorView *divisionView;
@property(nonatomic, retain) iTermToolbeltView *toolbelt;
@property(nonatomic, retain) iTermDragHandleView *leftTabBarDragHandle;
@property(nonatomic, readonly) CGFloat leftTabBarPreferredWidth;
 
@end
 
Loading
Loading
@@ -293,6 +292,10 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
DLog(@"repositionWidgets - Set tab view frame to %@", NSStringFromRect(tabViewFrame));
[self.tabView setFrame:tabViewFrame];
[self updateDivisionView];
// Even though it's not visible it needs an accurate number so we can compute the proper
// window size when it appears.
[self setLeftTabBarWidthFromPreferredWidth];
} else {
// The tabBar control is visible.
DLog(@"repositionWidgets - tabs are visible. Adjusting window size...");
Loading
Loading
@@ -451,16 +454,33 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
DLog(@"repositionWidgets - return.");
}
 
- (CGFloat)leftTabBarWidthForPreferredWidth:(CGFloat)preferredWidth {
- (CGFloat)leftTabBarWidthForPreferredWidth:(CGFloat)preferredWidth contentWidth:(CGFloat)contentWidth {
const CGFloat minimumWidth = 50;
const CGFloat maximumWidth = self.bounds.size.width / 3;
return MAX(MIN(maximumWidth, preferredWidth), minimumWidth);
const CGFloat maximumWidth = contentWidth / 3;
return MAX(MIN(maximumWidth, preferredWidth), minimumWidth);
}
- (CGFloat)leftTabBarWidthForPreferredWidth:(CGFloat)preferredWidth {
return [self leftTabBarWidthForPreferredWidth:preferredWidth contentWidth:self.bounds.size.width];
}
 
- (void)setLeftTabBarWidthFromPreferredWidth {
_leftTabBarWidth = [self leftTabBarWidthForPreferredWidth:_leftTabBarPreferredWidth];
}
 
- (void)willShowTabBar {
const CGFloat minimumWidth = 50;
// Given that the New window width (N) = Tab bar width (T) + Content Size (C)
// Given that T < N/3 (by leftTabBarWidthForPreferredWidth):
// T <= N / 3
// T <= 1/3(T+C)
// T <= T/3 + C/3
// 2/3T <= C/3
// T <= C/2
const CGFloat maximumWidth = self.bounds.size.width / 2;
_leftTabBarWidth = MAX(MIN(maximumWidth, _leftTabBarPreferredWidth), minimumWidth);
}
#pragma mark - iTermTabBarControlViewDelegate
 
- (BOOL)iTermTabBarShouldFlashAutomatically {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment