SubmarinerApp / Submariner

A Subsonic client for macOS
https://submarinerapp.com
BSD 3-Clause "New" or "Revised" License
140 stars 4 forks source link

constraints for sidebar are weird on macOS 12 #215

Open NattyNarwhal opened 3 months ago

NattyNarwhal commented 3 months ago

macOS 12 seems to have an issue with the autoresizing constraint translation where it adds to the initial width of the sidebar NSOutlineView that doesn't seem needed on macOS 14. Can be worked around with some hacks I'm not entirely comfortable with:

diff --git a/Submariner/SBDatabaseController.m b/Submariner/SBDatabaseController.m
index da15a5e..85967a5 100644
--- a/Submariner/SBDatabaseController.m
+++ b/Submariner/SBDatabaseController.m
@@ -330,6 +330,8 @@ - (void)windowDidLoad {
         [self toggleInspector: self];
     }

+    NSLog(@"Constraint fuckery: %@\nSource list/superview frame, %@/%@", sourceList.constraints, NSStringFromRect(sourceList.frame), NSStringFromRect(sourceList.superview.frame));
+    
     [resourcesController addObserver:self
                           forKeyPath:@"content"
                              options:NSKeyValueObservingOptionNew
@@ -391,6 +393,14 @@ - (void)awakeFromNib {
     [splitVC.view.leftAnchor constraintEqualToAnchor:((NSLayoutGuide*)self.window.contentLayoutGuide).leftAnchor].active=YES;
     [splitVC.view.rightAnchor constraintEqualToAnchor:((NSLayoutGuide*)self.window.contentLayoutGuide).rightAnchor].active=YES;

+    //sourceList.frame.size = sourceList.superview.frame.size;
+    NSLayoutConstraint *sourceListWidth = [sourceList.widthAnchor constraintEqualToAnchor: sourceList.superview.widthAnchor];
+    sourceListWidth.active = YES;
+    NSLayoutConstraint *sourceListHeight = [sourceList.heightAnchor constraintEqualToAnchor: sourceList.superview.heightAnchor];
+    sourceListWidth.active = YES;
+    //sourceList.superview.translatesAutoresizingMaskIntoConstraints = NO;
+    NSLog(@"SV Constraint fuckery: %@\nSource list/superview frame, %@/%@", sourceList.superview.constraints, NSStringFromRect(sourceList.frame), NSStringFromRect(sourceList.superview.frame));
+    
     // Need to set both for some reason? And after assignment to the parent?
     splitVC.splitView.autosaveName = @"DatabaseWindowSplitViewController";
     splitVC.splitView.identifier = @"SBDatabaseWindowSplitViewController";
@@ -746,6 +757,7 @@ - (IBAction)stop:(id)sender {
 }

 - (IBAction)nextTrack:(id)sender {
+    NSLog(@"SV Constraint fuckery: %@\nSource list/superview frame, %@/%@", sourceList.superview.constraints, NSStringFromRect(sourceList.frame), NSStringFromRect(sourceList.superview.frame));
     [[SBPlayer sharedInstance] next];
 }

Where it basically just removes the automatically made constraints and makes up its own.