Revision: 14054
          http://sourceforge.net/p/skim-app/code/14054
Author:   hofman
Date:     2024-02-18 18:23:56 +0000 (Sun, 18 Feb 2024)
Log Message:
-----------
Add some layout containts as ivars and outlets to change so we don't havee to 
search for them

Modified Paths:
--------------
    trunk/LeftSideView.xib
    trunk/MainWindow.xib
    trunk/SKMainWindowController.h
    trunk/SKMainWindowController.m
    trunk/SKSideViewController.h
    trunk/SKSideViewController.m
    trunk/SKStatusBar.h
    trunk/SKStatusBar.m

Modified: trunk/LeftSideView.xib
===================================================================
--- trunk/LeftSideView.xib      2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/LeftSideView.xib      2024-02-18 18:23:56 UTC (rev 14054)
@@ -20,6 +20,7 @@
                 <outlet property="thumbnailTableView" destination="101" 
id="180"/>
                 <outlet property="tocOutlineView" destination="119" id="189"/>
                 <outlet property="topBar" destination="134" id="194"/>
+                <outlet property="topConstraint" destination="whT-Z9-oOB" 
id="93r-ij-GdN"/>
                 <outlet property="view" destination="85" id="172"/>
             </connections>
         </customObject>

Modified: trunk/MainWindow.xib
===================================================================
--- trunk/MainWindow.xib        2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/MainWindow.xib        2024-02-18 18:23:56 UTC (rev 14054)
@@ -18,6 +18,7 @@
                 <outlet property="rightSideController" destination="1544" 
id="1546"/>
                 <outlet property="splitView" destination="1385" id="1448"/>
                 <outlet property="statusBar" destination="2Zw-iS-Qai" 
id="5oD-6z-7iD"/>
+                <outlet property="topConstraint" destination="kue-s7-oZq" 
id="Tun-Zg-UFY"/>
                 <outlet property="window" destination="5" id="18"/>
             </connections>
         </customObject>

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/SKMainWindowController.h      2024-02-18 18:23:56 UTC (rev 14054)
@@ -73,6 +73,7 @@
 
 @interface SKMainWindowController : NSWindowController 
<SKSnapshotWindowControllerDelegate, SKThumbnailDelegate, 
SKFindControllerDelegate, SKPDFViewDelegate, SKPDFDocumentDelegate, 
NSTouchBarDelegate> {
     SKSplitView                         *splitView;
+    NSLayoutConstraint                  *topConstraint;
     
     NSView                              *centerContentView;
     SKSplitView                         *pdfSplitView;
@@ -97,6 +98,7 @@
     SKStatusBar                         *statusBar;
     
     SKFindController                    *findController;
+    NSLayoutConstraint                  *findBarTopConstraint;
     
     SKFieldEditor                       *fieldEditor;
     
@@ -206,7 +208,8 @@
 @property (nonatomic, nullable, strong) IBOutlet NSWindow *mainWindow;
 
 @property (nonatomic, nullable, strong) IBOutlet SKSplitView *splitView;
-    
+@property (nonatomic, nullable, strong) IBOutlet NSLayoutConstraint 
*topConstraint;
+
 @property (nonatomic, nullable, strong) IBOutlet NSView *centerContentView;
 @property (nonatomic, nullable, strong) IBOutlet SKSplitView *pdfSplitView;
 @property (nonatomic, nullable, strong) IBOutlet NSView *pdfContentView;

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/SKMainWindowController.m      2024-02-18 18:23:56 UTC (rev 14054)
@@ -215,7 +215,7 @@
 
 @implementation SKMainWindowController
 
-@synthesize mainWindow, splitView, centerContentView, pdfSplitView, 
pdfContentView, statusBar, pdfView, secondaryPdfView, leftSideController, 
rightSideController, leftSideContentView, rightSideContentView, 
presentationNotesDocument, presentationNotesOffset, notes, thumbnails, 
snapshots, searchResults, groupedSearchResults, tags, rating, pageLabel, 
interactionMode, placeholderPdfDocument;
+@synthesize mainWindow, splitView, topConstraint, centerContentView, 
pdfSplitView, pdfContentView, statusBar, pdfView, secondaryPdfView, 
leftSideController, rightSideController, leftSideContentView, 
rightSideContentView, presentationNotesDocument, presentationNotesOffset, 
notes, thumbnails, snapshots, searchResults, groupedSearchResults, tags, 
rating, pageLabel, interactionMode, placeholderPdfDocument;
 @dynamic pdfDocument, presentationOptions, presentationUndoManager, 
selectedNotes, hasNotes, widgetProperties, autoScales, leftSidePaneState, 
rightSidePaneState, findPaneState, leftSidePaneIsOpen, rightSidePaneIsOpen, 
recentInfoNeedsUpdate, searchString, hasOverview, notesMenu;
 
 + (void)initialize {
@@ -350,12 +350,10 @@
         titleBarHeight = NSHeight([window frame]) - NSHeight([window 
contentLayoutRect]);
         [leftSideController setTopInset:titleBarHeight];
         [rightSideController setTopInset:titleBarHeight];
-    } else {
-        NSLayoutConstraint *constraint = [[window contentView] 
constraintWithFirstItem:splitView firstAttribute:NSLayoutAttributeTop];
-        if (constraint) {
-            [constraint setActive:NO];
-            [[NSLayoutConstraint constraintWithItem:splitView 
attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:[window 
contentLayoutGuide] attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0] 
setActive:YES];
-        }
+    } else if (topConstraint) {
+        [topConstraint setActive:NO];
+        topConstraint = [NSLayoutConstraint constraintWithItem:splitView 
attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:[window 
contentLayoutGuide] attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0];
+        [topConstraint setActive:YES];
     }
     
     [self setWindowFrameAutosaveNameOrCascade:SKMainWindowFrameAutosaveName];
@@ -1746,15 +1744,15 @@
     }
     
     if (animate) {
-        NSLayoutConstraint *topConstraint = [contentView 
constraintWithFirstItem:findBar firstAttribute:NSLayoutAttributeTop];
         mwcFlags.isAnimatingFindBar = YES;
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
                 [context setDuration:0.5 * [context duration]];
-                [[topConstraint animator] setConstant:titleBarHeight - 
barHeight];
+                [[findBarTopConstraint animator] setConstant:titleBarHeight - 
barHeight];
             }
             completionHandler:^{
                 [findBar removeFromSuperview];
                 [newTopConstraint setActive:YES];
+                findBarTopConstraint = newTopConstraint;
                 [mainWindow recalculateKeyViewLoop];
                 
                 mwcFlags.isAnimatingFindBar = NO;
@@ -1762,6 +1760,7 @@
     } else {
         [findBar removeFromSuperview];
         [newTopConstraint setActive:YES];
+        findBarTopConstraint = newTopConstraint;
         [contentView layoutSubtreeIfNeeded];
         [mainWindow recalculateKeyViewLoop];
     }
@@ -1792,9 +1791,10 @@
             [NSLayoutConstraint constraintWithItem:findBar 
attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual 
toItem:contentView attribute:NSLayoutAttributeTop multiplier:1.0 
constant:animate ? titleBarHeight - barHeight : titleBarHeight]];
         [NSLayoutConstraint activateConstraints:constraints];
         if (mwcFlags.fullSizeContent == NO) {
-            [[contentView constraintWithFirstItem:pdfSplitView 
firstAttribute:NSLayoutAttributeTop] setActive:NO];
+            [findBarTopConstraint setActive:NO];
             [[NSLayoutConstraint constraintWithItem:pdfSplitView 
attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:findBar 
attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0] setActive:YES];
         }
+        findBarTopConstraint = [constraints objectAtIndex:2];
         [contentView layoutSubtreeIfNeeded];
         
         [findController didAddFindBar];
@@ -2573,7 +2573,7 @@
             if ([self interactionMode] != SKPresentationMode || [self 
leftSidePaneIsOpen] == NO)
                 [leftSideController setTopInset:titleBarHeight];
             if ([[findController view] window]) {
-                [[[[findController view] superview] 
constraintWithFirstItem:[findController view] 
firstAttribute:NSLayoutAttributeTop] setConstant:titleBarHeight];
+                [findBarTopConstraint setConstant:titleBarHeight];
                 if ([self interactionMode] != SKPresentationMode)
                     [[pdfView scrollView] 
setContentInsets:NSEdgeInsetsMake(NSHeight([[findController view] frame]) + 
titleBarHeight, 0.0, 0.0, 0.0)];
             }

Modified: trunk/SKSideViewController.h
===================================================================
--- trunk/SKSideViewController.h        2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/SKSideViewController.h        2024-02-18 18:23:56 UTC (rev 14054)
@@ -44,6 +44,7 @@
 
 @interface SKSideViewController : NSViewController {
     SKTopBarView *topBar;
+    NSLayoutConstraint *topConstraint;
     NSSegmentedControl *button;
     NSSegmentedControl *alternateButton;
     NSSearchField *searchField;
@@ -54,6 +55,7 @@
 
 @property (nonatomic, nullable, weak) IBOutlet SKMainWindowController 
*mainController;
 @property (nonatomic, nullable, strong) IBOutlet SKTopBarView *topBar;
+@property (nonatomic, nullable, strong) IBOutlet NSLayoutConstraint 
*topConstraint;
 @property (nonatomic, nullable, strong) IBOutlet NSSegmentedControl *button, 
*alternateButton;
 @property (nonatomic, nullable, strong) IBOutlet NSSearchField *searchField;
 @property (nonatomic, nullable, strong) IBOutlet NSView *currentView;

Modified: trunk/SKSideViewController.m
===================================================================
--- trunk/SKSideViewController.m        2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/SKSideViewController.m        2024-02-18 18:23:56 UTC (rev 14054)
@@ -48,7 +48,7 @@
 
 @implementation SKSideViewController
 
-@synthesize mainController, topBar, button, alternateButton, searchField, 
currentView;
+@synthesize mainController, topBar, topConstraint, button, alternateButton, 
searchField, currentView;
 @dynamic topInset, tableViews;
 
 - (void)viewDidLoad {
@@ -61,11 +61,11 @@
 - (NSArray *)tableViews { return nil; }
 
 - (CGFloat)topInset {
-    return [[[topBar superview] constraintWithFirstItem:topBar 
firstAttribute:NSLayoutAttributeTop] constant];
+    return [topConstraint constant];
 }
 
 - (void)setTopInset:(CGFloat)topInset {
-    [[[topBar superview] constraintWithFirstItem:topBar 
firstAttribute:NSLayoutAttributeTop] setConstant:topInset];
+    [topConstraint setConstant:topInset];
     NSEdgeInsets insets = NSEdgeInsetsMake(topInset + NSHeight([topBar frame]) 
+ 1.0, 1.0, 1.0, 1.0);
     for (NSTableView *view in [self tableViews]) {
         NSScrollView *scrollView = [view enclosingScrollView];

Modified: trunk/SKStatusBar.h
===================================================================
--- trunk/SKStatusBar.h 2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/SKStatusBar.h 2024-02-18 18:23:56 UTC (rev 14054)
@@ -52,6 +52,8 @@
     NSTextField *rightField;
     NSImageView *iconView;
        NSProgressIndicator *progressIndicator;
+    NSLayoutConstraint *leftLeadingConstraint;
+    NSLayoutConstraint *rightTrailingConstraint;
     BOOL animating;
 }
 

Modified: trunk/SKStatusBar.m
===================================================================
--- trunk/SKStatusBar.m 2024-02-18 17:29:40 UTC (rev 14053)
+++ trunk/SKStatusBar.m 2024-02-18 18:23:56 UTC (rev 14054)
@@ -88,11 +88,14 @@
         [rightField setTranslatesAutoresizingMaskIntoConstraints:NO];
         [self addSubview:rightField];
         
-        [NSLayoutConstraint activateConstraints:@[
-             [NSLayoutConstraint constraintWithItem:leftField 
attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeLeading multiplier:1.0 constant:LEFT_MARGIN],
-             [NSLayoutConstraint constraintWithItem:leftField 
attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0],
-             [NSLayoutConstraint constraintWithItem:self 
attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual 
toItem:rightField attribute:NSLayoutAttributeTrailing multiplier:1.0 
constant:RIGHT_MARGIN],
-            [NSLayoutConstraint constraintWithItem:rightField 
attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0]]];
+        NSArray *constraints = @[
+            [NSLayoutConstraint constraintWithItem:leftField 
attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeLeading multiplier:1.0 constant:LEFT_MARGIN],
+            [NSLayoutConstraint constraintWithItem:leftField 
attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0],
+            [NSLayoutConstraint constraintWithItem:self 
attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual 
toItem:rightField attribute:NSLayoutAttributeTrailing multiplier:1.0 
constant:RIGHT_MARGIN],
+           [NSLayoutConstraint constraintWithItem:rightField 
attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0]];
+        leftLeadingConstraint = [constraints objectAtIndex:0];
+        rightTrailingConstraint = [constraints objectAtIndex:2];
+        [NSLayoutConstraint activateConstraints:constraints];
         
         iconView = nil;
                progressIndicator = nil;
@@ -273,18 +276,21 @@
             iconView = [[NSImageView alloc] init];
             [iconView setTranslatesAutoresizingMaskIntoConstraints:NO];
             [self addSubview:iconView];
-            [[self constraintWithFirstItem:leftField 
firstAttribute:NSLayoutAttributeLeading] setActive:NO];
-            [NSLayoutConstraint activateConstraints:@[
+            [leftLeadingConstraint setActive:NO];
+            NSArray *constraints = @[
                  [NSLayoutConstraint constraintWithItem:iconView 
attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeLeading multiplier:1.0 constant:LEFT_MARGIN],
                  [NSLayoutConstraint constraintWithItem:leftField 
attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual 
toItem:iconView attribute:NSLayoutAttributeTrailing multiplier:1.0 
constant:SEPARATION],
                  [NSLayoutConstraint constraintWithItem:iconView 
attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeTop multiplier:1.0 constant:1.0],
-                 [NSLayoutConstraint constraintWithItem:iconView 
attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual 
toItem:iconView attribute:NSLayoutAttributeHeight multiplier:1.0 
constant:0.0]]];
+                 [NSLayoutConstraint constraintWithItem:iconView 
attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual 
toItem:iconView attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0.0]];
+            leftLeadingConstraint = [constraints objectAtIndex:1];
+            [NSLayoutConstraint activateConstraints:constraints];
         }
         [iconView setImage:icon];
     } else if (iconView) {
         [iconView removeFromSuperview];
         iconView = nil;
-        [[NSLayoutConstraint constraintWithItem:leftField 
attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeLeading multiplier:1.0 constant:LEFT_MARGIN] 
setActive:YES];
+        leftLeadingConstraint = [NSLayoutConstraint 
constraintWithItem:leftField attribute:NSLayoutAttributeLeading 
relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeading 
multiplier:1.0 constant:LEFT_MARGIN];
+        [leftLeadingConstraint setActive:YES];
     }
 }
 
@@ -303,7 +309,8 @@
                        return;
                [progressIndicator removeFromSuperview];
                progressIndicator = nil;
-        [[NSLayoutConstraint constraintWithItem:self 
attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual 
toItem:rightField attribute:NSLayoutAttributeTrailing multiplier:1.0 
constant:RIGHT_MARGIN] setActive:YES];
+        rightTrailingConstraint = [NSLayoutConstraint constraintWithItem:self 
attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual 
toItem:rightField attribute:NSLayoutAttributeTrailing multiplier:1.0 
constant:RIGHT_MARGIN];
+        [rightTrailingConstraint setActive:YES];
        } else {
                if (progressIndicator && (NSInteger)[progressIndicator style] 
== style)
                        return;
@@ -315,11 +322,13 @@
             [progressIndicator setStyle:NSProgressIndicatorSpinningStyle];
             [progressIndicator 
setTranslatesAutoresizingMaskIntoConstraints:NO];
             [self addSubview:progressIndicator];
-            [[self constraintWithSecondItem:rightField 
secondAttribute:NSLayoutAttributeTrailing] setActive:NO];
-            [NSLayoutConstraint activateConstraints:@[
+            [rightTrailingConstraint setActive:NO];
+            NSArray *constraints = @[
                  [NSLayoutConstraint constraintWithItem:self 
attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual 
toItem:progressIndicator attribute:NSLayoutAttributeTrailing multiplier:1.0 
constant:RIGHT_MARGIN],
                  [NSLayoutConstraint constraintWithItem:progressIndicator 
attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual 
toItem:rightField attribute:NSLayoutAttributeTrailing multiplier:1.0 
constant:SEPARATION],
-                 [NSLayoutConstraint constraintWithItem:progressIndicator 
attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0]]];
+                 [NSLayoutConstraint constraintWithItem:progressIndicator 
attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self 
attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0]];
+            rightTrailingConstraint = [constraints objectAtIndex:1];
+            [NSLayoutConstraint activateConstraints:constraints];
                }
                [progressIndicator setIndeterminate:style == 
SKProgressIndicatorStyleIndeterminate];
        }

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