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
@@ -4427,10 +4427,12 @@ ITERM_WEAKLY_REFERENCEABLE
Loading
@@ -4427,10 +4427,12 @@ ITERM_WEAKLY_REFERENCEABLE
[session setIgnoreResizeNotifications:NO]; [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 // 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 if (([_contentView.tabView numberOfTabViewItems] == 1) || // just decreased to 1 or increased above 1 and is hidden
([iTermPreferences boolForKey:kPreferenceKeyHideTabBar] && willShowTabBar) {
([_contentView.tabView numberOfTabViewItems] > 1 && [_contentView.tabBarControl isHidden]))) {
// Need to change the visibility status of the tab bar control. // Need to change the visibility status of the tab bar control.
PtyLog(@"tabViewDidChangeNumberOfTabViewItems - calling fitWindowToTab"); PtyLog(@"tabViewDidChangeNumberOfTabViewItems - calling fitWindowToTab");
   
Loading
@@ -4449,6 +4451,9 @@ ITERM_WEAKLY_REFERENCEABLE
Loading
@@ -4449,6 +4451,9 @@ ITERM_WEAKLY_REFERENCEABLE
PTYSession *session = firstTab.sessions.firstObject; PTYSession *session = firstTab.sessions.firstObject;
[[session view] setShowTitle:NO adjustScrollView:YES]; [[session view] setShowTitle:NO adjustScrollView:YES];
} }
if (willShowTabBar && [iTermPreferences intForKey:kPreferenceKeyTabPosition] == PSMTab_LeftTab) {
[_contentView willShowTabBar];
}
[self fitWindowToTabs]; [self fitWindowToTabs];
[self repositionWidgets]; [self repositionWidgets];
if (wasDraggedFromAnotherWindow_) { if (wasDraggedFromAnotherWindow_) {
Loading
Loading
Loading
@@ -69,6 +69,7 @@ extern const CGFloat kHorizontalTabBarHeight;
Loading
@@ -69,6 +69,7 @@ extern const CGFloat kHorizontalTabBarHeight;
@property(nonatomic, readonly) CGFloat tabviewWidth; @property(nonatomic, readonly) CGFloat tabviewWidth;
   
@property(nonatomic, readonly) CGFloat leftTabBarWidth; @property(nonatomic, readonly) CGFloat leftTabBarWidth;
@property(nonatomic, readonly) CGFloat leftTabBarPreferredWidth;
   
- (instancetype)initWithFrame:(NSRect)frame - (instancetype)initWithFrame:(NSRect)frame
color:(NSColor *)color color:(NSColor *)color
Loading
@@ -93,4 +94,6 @@ extern const CGFloat kHorizontalTabBarHeight;
Loading
@@ -93,4 +94,6 @@ extern const CGFloat kHorizontalTabBarHeight;
   
- (BOOL)tabBarShouldBeVisibleWithAdditionalTabs:(int)numberOfAdditionalTabs; - (BOOL)tabBarShouldBeVisibleWithAdditionalTabs:(int)numberOfAdditionalTabs;
   
- (void)willShowTabBar;
@end @end
Loading
@@ -30,7 +30,6 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
Loading
@@ -30,7 +30,6 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
@property(nonatomic, retain) SolidColorView *divisionView; @property(nonatomic, retain) SolidColorView *divisionView;
@property(nonatomic, retain) iTermToolbeltView *toolbelt; @property(nonatomic, retain) iTermToolbeltView *toolbelt;
@property(nonatomic, retain) iTermDragHandleView *leftTabBarDragHandle; @property(nonatomic, retain) iTermDragHandleView *leftTabBarDragHandle;
@property(nonatomic, readonly) CGFloat leftTabBarPreferredWidth;
   
@end @end
   
Loading
@@ -293,6 +292,10 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
Loading
@@ -293,6 +292,10 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
DLog(@"repositionWidgets - Set tab view frame to %@", NSStringFromRect(tabViewFrame)); DLog(@"repositionWidgets - Set tab view frame to %@", NSStringFromRect(tabViewFrame));
[self.tabView setFrame:tabViewFrame]; [self.tabView setFrame:tabViewFrame];
[self updateDivisionView]; [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 { } else {
// The tabBar control is visible. // The tabBar control is visible.
DLog(@"repositionWidgets - tabs are visible. Adjusting window size..."); DLog(@"repositionWidgets - tabs are visible. Adjusting window size...");
Loading
@@ -451,16 +454,33 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
Loading
@@ -451,16 +454,33 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
DLog(@"repositionWidgets - return."); DLog(@"repositionWidgets - return.");
} }
   
- (CGFloat)leftTabBarWidthForPreferredWidth:(CGFloat)preferredWidth { - (CGFloat)leftTabBarWidthForPreferredWidth:(CGFloat)preferredWidth contentWidth:(CGFloat)contentWidth {
const CGFloat minimumWidth = 50; const CGFloat minimumWidth = 50;
const CGFloat maximumWidth = self.bounds.size.width / 3; const CGFloat maximumWidth = contentWidth / 3;
return MAX(MIN(maximumWidth, preferredWidth), minimumWidth); return MAX(MIN(maximumWidth, preferredWidth), minimumWidth);
}
- (CGFloat)leftTabBarWidthForPreferredWidth:(CGFloat)preferredWidth {
return [self leftTabBarWidthForPreferredWidth:preferredWidth contentWidth:self.bounds.size.width];
} }
   
- (void)setLeftTabBarWidthFromPreferredWidth { - (void)setLeftTabBarWidthFromPreferredWidth {
_leftTabBarWidth = [self leftTabBarWidthForPreferredWidth:_leftTabBarPreferredWidth]; _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 #pragma mark - iTermTabBarControlViewDelegate
   
- (BOOL)iTermTabBarShouldFlashAutomatically { - (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