Revision: 14960
          http://sourceforge.net/p/skim-app/code/14960
Author:   hofman
Date:     2025-03-11 10:09:31 +0000 (Tue, 11 Mar 2025)
Log Message:
-----------
Support toolbar placement also for 10.15-, as this can be supported. 
NSLayoutAttributeTop is also supported on 10.13+ according to the header, and 
the toolbar is moved into the title bar when the title is hidden. A toolbar 
beside the title and compact toolbar styles will not be supported on early 
versions.

Modified Paths:
--------------
    trunk/SKMainWindow.m
    trunk/SKMainWindowController.m

Modified: trunk/SKMainWindow.m
===================================================================
--- trunk/SKMainWindow.m        2025-03-10 17:21:21 UTC (rev 14959)
+++ trunk/SKMainWindow.m        2025-03-11 10:09:31 UTC (rev 14960)
@@ -146,38 +146,34 @@
 }
 
 - (void)toggleToolbarShown:(id)sender {
-    if (@available(macOS 11.0, *)) {
-        if (autoTitleVisibility == SKWindowTitleHiddenForTabBar) {
-            NSLayoutAttribute layoutAttribute = [[self toolbar] isVisible] ? 
NSLayoutAttributeTop : NSLayoutAttributeBottom;
-            NSString *identifier = [[self toolbar] identifier];
-            for (NSWindow *window in [NSApp windows]) {
-                if ([[[window toolbar] identifier] isEqualToString:identifier] 
&& [window isKindOfClass:[SKMainWindow class]] && [(SKMainWindow *)window 
autoTitleVisibility] == autoTitleVisibility)
-                    [(SKMainWindow *)window 
setTabBarLayoutAttribute:layoutAttribute];
-            }
-        } else if (autoTitleVisibility == SKWindowTitleHiddenForToolbar) {
-            NSWindowTitleVisibility visibility = [[self toolbar] isVisible] ? 
NSWindowTitleVisible : NSWindowTitleHidden;
-            NSString *identifier = [[self toolbar] identifier];
-            for (NSWindow *window in [NSApp windows]) {
-                if ([[[window toolbar] identifier] isEqualToString:identifier] 
&& [window isKindOfClass:[SKMainWindow class]] && [(SKMainWindow *)window 
autoTitleVisibility] == autoTitleVisibility)
-                    [window setTitleVisibility:visibility];
-            }
+    if (autoTitleVisibility == SKWindowTitleHiddenForTabBar) {
+        NSLayoutAttribute layoutAttribute = [[self toolbar] isVisible] ? 
NSLayoutAttributeTop : NSLayoutAttributeBottom;
+        NSString *identifier = [[self toolbar] identifier];
+        for (NSWindow *window in [NSApp windows]) {
+            if ([[[window toolbar] identifier] isEqualToString:identifier] && 
[window isKindOfClass:[SKMainWindow class]] && [(SKMainWindow *)window 
autoTitleVisibility] == autoTitleVisibility)
+                [(SKMainWindow *)window 
setTabBarLayoutAttribute:layoutAttribute];
         }
+    } else if (autoTitleVisibility == SKWindowTitleHiddenForToolbar) {
+        NSWindowTitleVisibility visibility = [[self toolbar] isVisible] ? 
NSWindowTitleVisible : NSWindowTitleHidden;
+        NSString *identifier = [[self toolbar] identifier];
+        for (NSWindow *window in [NSApp windows]) {
+            if ([[[window toolbar] identifier] isEqualToString:identifier] && 
[window isKindOfClass:[SKMainWindow class]] && [(SKMainWindow *)window 
autoTitleVisibility] == autoTitleVisibility)
+                [window setTitleVisibility:visibility];
+        }
     }
     [super toggleToolbarShown:sender];
 }
 
 - (void)addTitlebarAccessoryViewController:(NSTitlebarAccessoryViewController 
*)childViewController {
-    if (@available(macOS 11.0, *)) {
-        if ([self autoTitleVisibility] == SKWindowTitleHiddenForTabBar) {
-            [self setTitleVisibility:NSWindowTitleHidden];
-            if ([[self toolbar] isVisible] == NO) {
-                [childViewController setLayoutAttribute:NSLayoutAttributeTop];
-                NSURL *url = [self representedURL];
-                [self setRepresentedURL:nil];
-                [self setRepresentedURL:url];
-            } else {
-                [childViewController 
setLayoutAttribute:NSLayoutAttributeBottom];
-            }
+    if ([self autoTitleVisibility] == SKWindowTitleHiddenForTabBar) {
+        [self setTitleVisibility:NSWindowTitleHidden];
+        if ([[self toolbar] isVisible] == NO) {
+            [childViewController setLayoutAttribute:NSLayoutAttributeTop];
+            NSURL *url = [self representedURL];
+            [self setRepresentedURL:nil];
+            [self setRepresentedURL:url];
+        } else {
+            [childViewController setLayoutAttribute:NSLayoutAttributeBottom];
         }
     }
     [super addTitlebarAccessoryViewController:childViewController];
@@ -185,14 +181,12 @@
 
 - (void)removeTitlebarAccessoryViewControllerAtIndex:(NSInteger)index {
     [super removeTitlebarAccessoryViewControllerAtIndex:index];
-    if (@available(macOS 11.0, *)) {
-        if ([self autoTitleVisibility] == SKWindowTitleHiddenForTabBar) {
-            [self setTitleVisibility:NSWindowTitleVisible];
-            if ([[self toolbar] isVisible] == NO) {
-                NSURL *url = [self representedURL];
-                [self setRepresentedURL:nil];
-                [self setRepresentedURL:url];
-            }
+    if ([self autoTitleVisibility] == SKWindowTitleHiddenForTabBar) {
+        [self setTitleVisibility:NSWindowTitleVisible];
+        if ([[self toolbar] isVisible] == NO) {
+            NSURL *url = [self representedURL];
+            [self setRepresentedURL:nil];
+            [self setRepresentedURL:url];
         }
     }
 }

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2025-03-10 17:21:21 UTC (rev 14959)
+++ trunk/SKMainWindowController.m      2025-03-11 10:09:31 UTC (rev 14960)
@@ -330,16 +330,16 @@
     
     // Set up the window
     
+    // hidden pref for toolbar position relative to title:
+    // 0 = below, 1 = compact, 2 = beside, 3 = beside compact, 4 = replacing, 
5 = replacing compact
+    NSInteger placement = [[NSUserDefaults standardUserDefaults] 
integerForKey:SKToolbarPlacementKey];
     if (@available(macOS 11.0, *)) {
-        // hidden pref for toolbar position relative to title:
-        // 0 = below, 1 = compact, 2 = beside, 3 = beside compact, 4 = 
replacing, 5 = replacing compact
-        NSInteger placement = [[NSUserDefaults standardUserDefaults] 
integerForKey:SKToolbarPlacementKey];
         [window setToolbarStyle:placement == 0 ? NSWindowToolbarStyleExpanded 
: (placement & 1) ? NSWindowToolbarStyleUnifiedCompact : 
NSWindowToolbarStyleUnified];
-        if (placement == 1)
-            [(SKMainWindow *)window 
setAutoTitleVisibility:SKWindowTitleHiddenForTabBar];
-        else if (placement > 3)
-            [(SKMainWindow *)window 
setAutoTitleVisibility:SKWindowTitleHiddenForToolbar];
     }
+    if (placement == 1)
+        [(SKMainWindow *)window 
setAutoTitleVisibility:SKWindowTitleHiddenForTabBar];
+    else if (placement > 3)
+        [(SKMainWindow *)window 
setAutoTitleVisibility:SKWindowTitleHiddenForToolbar];
     
     // for animations
     [[window contentView] setWantsLayer:YES];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to