Skip to content

Commit

Permalink
avoid losing the splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
NattyNarwhal committed Dec 23, 2023
1 parent af34d80 commit 4ccd4d0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Submariner/SBMusicController.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ - (void)awakeFromNib {
[super awakeFromNib];
self->compensatedSplitView = self->rightSplitView;
// so it doesn't resize unless the user does so
rightSplitView.delegate = self;
artistSplitView.delegate = self;
}

Expand Down Expand Up @@ -774,6 +775,21 @@ - (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)v
return YES;
}

- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview {
if (splitView == rightSplitView && subview == splitView.subviews.firstObject) {
return NO;
}
return YES;
}

- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex {
if (splitView == rightSplitView && dividerIndex == 0) {
// Prevent the splitter from going above the toolbar
return MAX(self.view.safeAreaInsets.top, 0);
}
return proposedMinimumPosition;
}


#pragma mark -
#pragma mark UI Validator
Expand Down
16 changes: 16 additions & 0 deletions Submariner/SBServerLibraryController.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ - (void)awakeFromNib {

self->compensatedSplitView = self->rightSplitView;
// so it doesn't resize unless the user does so
rightSplitView.delegate = self;
artistSplitView.delegate = self;
}

Expand Down Expand Up @@ -643,6 +644,21 @@ - (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview:(NSView *)v
return YES;
}

- (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview {
if (splitView == rightSplitView && subview == splitView.subviews.firstObject) {
return NO;
}
return YES;
}

- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex {
if (splitView == rightSplitView && dividerIndex == 0) {
// Prevent the splitter from going above the toolbar
return MAX(self.view.safeAreaInsets.top, 0);
}
return proposedMinimumPosition;
}


#pragma mark -
#pragma mark UI Validator
Expand Down

0 comments on commit 4ccd4d0

Please sign in to comment.