Revision: 16095
          http://sourceforge.net/p/skim-app/code/16095
Author:   hofman
Date:     2026-03-24 16:53:05 +0000 (Tue, 24 Mar 2026)
Log Message:
-----------
observe collapsed of side pane items, to redirect the first responder and 
update the toolbar items

Modified Paths:
--------------
    trunk/SKMainToolbarController.h
    trunk/SKMainToolbarController.m
    trunk/SKMainWindowController.h
    trunk/SKMainWindowController.m
    trunk/SKMainWindowController_Actions.m

Modified: trunk/SKMainToolbarController.h
===================================================================
--- trunk/SKMainToolbarController.h     2026-03-24 15:54:07 UTC (rev 16094)
+++ trunk/SKMainToolbarController.h     2026-03-24 16:53:05 UTC (rev 16095)
@@ -108,8 +108,10 @@
 - (void)handleChangedHistoryNotification:(nullable NSNotification 
*)notification;
 - (void)handlePageChangedNotification:(nullable NSNotification *)notification;
 
-- (void)noteToolbarDidShowOrHide;
-- (void)splitPDFDidShowOrHide;
+- (void)leftSidePaneDidShowOrHide:(BOOL)show;
+- (void)rightSidePaneDidShowOrHide:(BOOL)show;
+- (void)noteToolbarDidShowOrHide:(BOOL)show;
+- (void)splitPDFDidShowOrHide:(BOOL)show;
 
 #pragma mark Actions
 

Modified: trunk/SKMainToolbarController.m
===================================================================
--- trunk/SKMainToolbarController.m     2026-03-24 15:54:07 UTC (rev 16094)
+++ trunk/SKMainToolbarController.m     2026-03-24 16:53:05 UTC (rev 16095)
@@ -585,7 +585,7 @@
             [item setView:notesButton];
             [item setMenuFormRepresentation:menuItem];
             
-            [self noteToolbarDidShowOrHide];
+            [self noteToolbarDidShowOrHide:[mainController hasNoteToolbar]];
             
         } else if ([identifier 
isEqualToString:SKDocumentToolbarToolModeItemIdentifier]) {
             
@@ -1128,25 +1128,25 @@
     }
 }
 
-- (void)noteToolbarDidShowOrHide {
-    [notesButton setSelected:[mainController hasNoteToolbar] forSegment:0];
+- (void)noteToolbarDidShowOrHide:(BOOL)show {
+    [notesButton setSelected:show forSegment:0];
     NSToolbarItem *item = [toolbarItems 
objectForKey:SKDocumentToolbarNotesItemIdentifier];
-    [item setToolTip:[mainController hasNoteToolbar] ? 
NSLocalizedString(@"Hide Note Toolbar", @"Tool tip message") : 
NSLocalizedString(@"Show Note Toolbar", @"Tool tip message")];
+    [item setToolTip:show ? NSLocalizedString(@"Hide Note Toolbar", @"Tool tip 
message") : NSLocalizedString(@"Show Note Toolbar", @"Tool tip message")];
 }
 
-- (void)leftSidePaneDidShowOrHide {
+- (void)leftSidePaneDidShowOrHide:(BOOL)show {
     NSToolbarItem *item = [toolbarItems 
objectForKey:SKDocumentToolbarContentsPaneItemIdentifier];
-    [item setToolTip:[leftPaneButton tag] ? NSLocalizedString(@"Show Contents 
Pane", @"Tool tip message") : NSLocalizedString(@"Hide Contents Pane", @"Tool 
tip message")];
+    [item setToolTip:show ? NSLocalizedString(@"Hide Contents Pane", @"Tool 
tip message") : NSLocalizedString(@"Show Contents Pane", @"Tool tip message")];
 }
 
-- (void)rightSidePaneDidShowOrHide {
+- (void)rightSidePaneDidShowOrHide:(BOOL)show {
     NSToolbarItem *item = [toolbarItems 
objectForKey:SKDocumentToolbarNotesPaneItemIdentifier];
-    [item setToolTip:[rightPaneButton tag] ? NSLocalizedString(@"Show Notes 
Pane", @"Tool tip message") : NSLocalizedString(@"Hide Notes Pane", @"Tool tip 
message")];
+    [item setToolTip:show ? NSLocalizedString(@"Hide Notes Pane", @"Tool tip 
message") : NSLocalizedString(@"Show Notes Pane", @"Tool tip message")];
 }
 
-- (void)splitPDFDidShowOrHide {
+- (void)splitPDFDidShowOrHide:(BOOL)show {
     NSToolbarItem *item = [toolbarItems 
objectForKey:SKDocumentToolbarSplitPDFItemIdentifier];
-    [item setToolTip:[(NSView *)mainController.secondaryPdfView window] ? 
NSLocalizedString(@"Hide Split PDF", @"Tool tip message") : 
NSLocalizedString(@"Show Split PDF", @"Tool tip message")];
+    [item setToolTip:show ? NSLocalizedString(@"Hide Split PDF", @"Tool tip 
message") : NSLocalizedString(@"Show Split PDF", @"Tool tip message")];
 }
 
 - (IBAction)goToPreviousNextFirstLastPage:(id)sender {
@@ -1515,20 +1515,6 @@
     [pacerButton setImage:[NSImage imageNamed:name] forSegment:0];
 }
 
-- (void)handleSplitViewDidResizeSubviewsNotification:(NSNotification 
*)notification {
-    NSSplitView *splitView = [notification object];
-    NSInteger isLeftSideViewCollapsed = [splitView 
isSubviewCollapsed:[[splitView subviews] firstObject]];
-    NSInteger isRightSideViewCollapsed = [splitView 
isSubviewCollapsed:[[splitView subviews] objectAtIndex:2]];
-    if (isLeftSideViewCollapsed != [leftPaneButton tag]) {
-        [leftPaneButton setTag:isLeftSideViewCollapsed];
-        [self leftSidePaneDidShowOrHide];
-    }
-    if (isRightSideViewCollapsed != [rightPaneButton tag]) {
-        [rightPaneButton setTag:isRightSideViewCollapsed];
-        [self rightSidePaneDidShowOrHide];
-    }
-}
-
 - (void)registerForNotifications {
     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
     
@@ -1560,8 +1546,6 @@
                              name:PDFViewDisplayBoxChangedNotification 
object:mainController.pdfView];
     [nc addObserver:self selector:@selector(handleChangedHistoryNotification:)
                              name:PDFViewChangedHistoryNotification 
object:mainController.pdfView];
-    [nc addObserver:self 
selector:@selector(handleSplitViewDidResizeSubviewsNotification:)
-                             name:NSSplitViewDidResizeSubviewsNotification 
object:mainController.splitView];
     
     [self handleChangedHistoryNotification:nil];
     [self handlePageChangedNotification:nil];

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2026-03-24 15:54:07 UTC (rev 16094)
+++ trunk/SKMainWindowController.h      2026-03-24 16:53:05 UTC (rev 16095)
@@ -197,8 +197,6 @@
 
 @property (nonatomic, nullable, strong) IBOutlet SKStatusBar *statusBar;
 
-@property (nonatomic, nullable, readonly) NSSplitView *splitView;
-
 @property (nonatomic, nullable, strong) NSString *searchString;
 
 - (SKTransitionController *)transitionControllerCreating:(BOOL)create;

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2026-03-24 15:54:07 UTC (rev 16094)
+++ trunk/SKMainWindowController.m      2026-03-24 16:53:05 UTC (rev 16095)
@@ -174,6 +174,8 @@
 
 static char SKMainWindowTransitionsObservationContext;
 
+static char SKMainWindowSplitViewItemObservationContext;
+
 #define SKLeftSidePaneWidthKey @"SKLeftSidePaneWidth"
 #define SKRightSidePaneWidthKey @"SKRightSidePaneWidth"
 
@@ -225,7 +227,7 @@
 @implementation SKMainWindowController
 
 @synthesize statusBar, pdfView, secondaryPdfView, presentationNotesDocument, 
presentationNotesOffset, notes, thumbnails, snapshots, searchResults, 
groupedSearchResults, tags, rating, pageLabel, interactionMode, 
placeholderPdfDocument;
-@dynamic splitView, pdfDocument, selectedNotes, hasNotes, widgetProperties, 
currentPage, leftSidePaneState, rightSidePaneState, findPaneState, 
displaysFindPane, leftSidePaneIsOpen, rightSidePaneIsOpen, searchString, 
hasNoteToolbar, hasOverview, notesMenu;
+@dynamic pdfDocument, selectedNotes, hasNotes, widgetProperties, currentPage, 
leftSidePaneState, rightSidePaneState, findPaneState, displaysFindPane, 
leftSidePaneIsOpen, rightSidePaneIsOpen, searchString, hasNoteToolbar, 
hasOverview, notesMenu;
 
 + (BOOL)automaticallyNotifiesObserversOfPageLabel { return NO; }
 
@@ -1264,10 +1266,6 @@
 
 #pragma mark Accessors
 
-- (NSSplitView *)splitView {
-    return [splitViewController splitView];
-}
-
 - (PDFDocument *)pdfDocument{
     return [pdfView document];
 }
@@ -2567,6 +2565,8 @@
         [NSApp addObserver:self forKeyPath:@"effectiveAppearance" options:0 
context:&SKMainWindowAppObservationContext];
     if (mwcFlags.fullSizeContent)
         [[self window] addObserver:self forKeyPath:@"contentLayoutRect" 
options:0 context:&SKMainWindowContentLayoutObservationContext];
+    [[[splitViewController splitViewItems] firstObject] addObserver:self 
forKeyPath:@"collapsed" options:NSKeyValueObservingOptionPrior 
context:&SKMainWindowSplitViewItemObservationContext];
+    [[[splitViewController splitViewItems] lastObject] addObserver:self 
forKeyPath:@"collapsed" options:NSKeyValueObservingOptionPrior 
context:&SKMainWindowSplitViewItemObservationContext];
 }
 
 - (void)unregisterAsObserver {
@@ -2597,6 +2597,10 @@
         @try { [[presentationView transitionController] removeObserver:self 
forKeyPath:PAGETRANSITIONS_KEY 
context:&SKMainWindowTransitionsObservationContext]; }
         @catch (id e) {}
     }
+    @try { [[[splitViewController splitViewItems] firstObject] 
removeObserver:self forKeyPath:@"collapsed" 
context:&SKMainWindowSplitViewItemObservationContext]; }
+    @catch (id e) {}
+    @try { [[[splitViewController splitViewItems] lastObject] 
removeObserver:self forKeyPath:@"collapsed" 
context:&SKMainWindowSplitViewItemObservationContext]; }
+    @catch (id e) {}
 }
 
 #pragma mark Undo
@@ -2740,8 +2744,20 @@
             mwcFlags.updatingThumbnailSelection = 0;
         }
         
+    } else if (context == &SKMainWindowSplitViewItemObservationContext) {
+        
+        NSSplitViewItem *item = object;
+        if ([[change objectForKey:NSKeyValueChangeNotificationIsPriorKey] 
boolValue]) {
+            if ([item isCollapsed] == NO && [[self window] 
firstResponderIsDescendantOf:[[item viewController] view]])
+                [[self window] makeFirstResponder:pdfView];
+        } else if ([item viewController] == leftSideController) {
+            [toolbarController leftSidePaneDidShowOrHide:[item isCollapsed] == 
NO];
+        } else if ([item viewController] == rightSideController) {
+            [toolbarController rightSidePaneDidShowOrHide:[item isCollapsed] 
== NO];
+        }
+        
     } else if (context == &SKPDFAnnotationPropertiesObservationContext) {
-        
+
         // The value of some note's property has changed
         PDFAnnotation *note = (PDFAnnotation *)object;
         // Ignore changes that aren't really changes.

Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m      2026-03-24 15:54:07 UTC (rev 
16094)
+++ trunk/SKMainWindowController_Actions.m      2026-03-24 16:53:05 UTC (rev 
16095)
@@ -1031,8 +1031,6 @@
     } else {
         NSSplitViewItem *item = [[splitViewController splitViewItems] 
firstObject];
         BOOL collapse = [item isCollapsed] == NO;
-        if (collapse && [[self window] firstResponderIsDescendantOf:[[item 
viewController] view]])
-            [[self window] makeFirstResponder:pdfView];
         if ([NSView shouldShowSlideAnimation])
             [[item animator] setCollapsed:collapse];
         else
@@ -1047,8 +1045,6 @@
     } else {
         NSSplitViewItem *item = [[splitViewController splitViewItems] 
lastObject];
         BOOL collapse = [item isCollapsed] == NO;
-        if (collapse && [[self window] firstResponderIsDescendantOf:[[item 
viewController] view]])
-            [[self window] makeFirstResponder:pdfView];
         if ([NSView shouldShowSlideAnimation])
             [[item animator] setCollapsed:collapse];
         else
@@ -1103,6 +1099,8 @@
                 }];
         }
         
+        [toolbarController splitPDFDidShowOrHide:NO];
+        
     } else {
         
         NSRect frame = [pdfView bounds];
@@ -1163,11 +1161,11 @@
         } else {
             [item setCollapsed:NO];
         }
+        
+        [toolbarController splitPDFDidShowOrHide:YES];
     }
     
     [[self window] recalculateKeyViewLoop];
-    
-    [toolbarController splitPDFDidShowOrHide];
 }
 
 - (IBAction)toggleNoteToolbar:(id)sender {
@@ -1186,7 +1184,7 @@
         }
         [[self window] 
addTitlebarAccessoryViewController:noteToolbarController];
     }
-    [toolbarController noteToolbarDidShowOrHide];
+    [toolbarController noteToolbarDidShowOrHide:[noteToolbarController 
isVisible]];
 }
 
 - (IBAction)toggleFullscreen:(id)sender {

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