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

Store the preferred width of the left tab bar separately from its actual...

Store the preferred width of the left tab bar separately from its actual width, which is constrained by the width of the window. The preferred width is set by a manual drag and is persisted in user defaults. When the window is wide enough to accommodate the preferred width, the tab bar will grow up to but not beyond that size. Issue 5833
parent cb97a71a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -30,6 +30,8 @@ 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
@@ -47,7 +49,9 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
_delegate = delegate;
 
self.autoresizesSubviews = YES;
_leftTabBarWidth = [iTermPreferences doubleForKey:kPreferenceKeyLeftTabBarWidth];
_leftTabBarPreferredWidth = [iTermPreferences doubleForKey:kPreferenceKeyLeftTabBarWidth];
[self setLeftTabBarWidthFromPreferredWidth];
// Create the tab view.
self.tabView = [[[PTYTabView alloc] initWithFrame:self.bounds] autorelease];
_tabView.autoresizingMask = (NSViewWidthSizable | NSViewHeightSizable);
Loading
Loading
@@ -352,7 +356,7 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
}
 
case PSMTab_LeftTab: {
[self constrainLeftTabBarWidth];
[self setLeftTabBarWidthFromPreferredWidth];
CGFloat heightAdjustment = 0;
if (_delegate.haveBottomBorder) {
heightAdjustment += 1;
Loading
Loading
@@ -434,14 +438,14 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
DLog(@"repositionWidgets - return.");
}
 
- (void)constrainLeftTabBarWidth {
if (_leftTabBarWidth < 50) {
_leftTabBarWidth = 50;
}
const CGFloat maxWidth = self.bounds.size.width / 3;
if (_leftTabBarWidth > maxWidth) {
_leftTabBarWidth = maxWidth;
}
- (CGFloat)leftTabBarWidthForPreferredWidth:(CGFloat)preferredWidth {
const CGFloat minimumWidth = 50;
const CGFloat maximumWidth = self.bounds.size.width / 3;
return MAX(MIN(maximumWidth, preferredWidth), minimumWidth);
}
- (void)setLeftTabBarWidthFromPreferredWidth {
_leftTabBarWidth = [self leftTabBarWidthForPreferredWidth:_leftTabBarPreferredWidth];
}
 
#pragma mark - iTermTabBarControlViewDelegate
Loading
Loading
@@ -462,12 +466,12 @@ static const CGFloat kMaximumToolbeltSizeAsFractionOfWindow = 0.5;
 
// For the left-side tab bar.
- (CGFloat)dragHandleView:(iTermDragHandleView *)dragHandle didMoveBy:(CGFloat)delta {
CGFloat originalValue = _leftTabBarWidth;
_leftTabBarWidth += delta;
CGFloat originalValue = _leftTabBarPreferredWidth;
_leftTabBarPreferredWidth = [self leftTabBarWidthForPreferredWidth:_leftTabBarPreferredWidth + delta];
[self layoutSubviews]; // This may modify _leftTabBarWidth if it's too big or too small.
[[NSUserDefaults standardUserDefaults] setDouble:_leftTabBarWidth
[[NSUserDefaults standardUserDefaults] setDouble:_leftTabBarPreferredWidth
forKey:kPreferenceKeyLeftTabBarWidth];
return _leftTabBarWidth - originalValue;
return _leftTabBarPreferredWidth - originalValue;
}
 
- (void)dragHandleViewDidFinishMoving:(iTermDragHandleView *)dragHandle {
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