Revision: 14145
http://sourceforge.net/p/skim-app/code/14145
Author: hofman
Date: 2024-03-25 17:40:32 +0000 (Mon, 25 Mar 2024)
Log Message:
-----------
combine adding subview and constraints with zero margins
Modified Paths:
--------------
trunk/NSView_SKExtensions.h
trunk/NSView_SKExtensions.m
trunk/SKMainWindowController.m
trunk/SKMainWindowController_FullScreen.m
trunk/SKSideWindow.m
Modified: trunk/NSView_SKExtensions.h
===================================================================
--- trunk/NSView_SKExtensions.h 2024-03-25 17:16:25 UTC (rev 14144)
+++ trunk/NSView_SKExtensions.h 2024-03-25 17:40:32 UTC (rev 14145)
@@ -58,7 +58,7 @@
- (NSBitmapImageRep *)bitmapImageRepCachingDisplay;
-- (void)activateConstraintsToSuperview;
+- (void)addSubviewWithConstraints:(NSView *)view;
@property (class, nonatomic, readonly) BOOL shouldShowSlideAnimation;
@property (class, nonatomic, readonly) BOOL shouldShowFadeAnimation;
Modified: trunk/NSView_SKExtensions.m
===================================================================
--- trunk/NSView_SKExtensions.m 2024-03-25 17:16:25 UTC (rev 14144)
+++ trunk/NSView_SKExtensions.m 2024-03-25 17:40:32 UTC (rev 14145)
@@ -100,13 +100,13 @@
return imageRep;
}
-- (void)activateConstraintsToSuperview {
- NSView *superview = [self superview];
+- (void)addSubviewWithConstraints:(NSView *)view {
+ [self addSubview:view];
NSArray *constraints = @[
- [[self leadingAnchor] constraintEqualToAnchor:[superview
leadingAnchor]],
- [[superview trailingAnchor] constraintEqualToAnchor:[self
trailingAnchor]],
- [[self topAnchor] constraintEqualToAnchor:[superview topAnchor]],
- [[superview bottomAnchor] constraintEqualToAnchor:[self
bottomAnchor]]];
+ [[view leadingAnchor] constraintEqualToAnchor:[self leadingAnchor]],
+ [[self trailingAnchor] constraintEqualToAnchor:[view trailingAnchor]],
+ [[view topAnchor] constraintEqualToAnchor:[self topAnchor]],
+ [[self bottomAnchor] constraintEqualToAnchor:[view bottomAnchor]]];
[NSLayoutConstraint activateConstraints:constraints];
}
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2024-03-25 17:16:25 UTC (rev 14144)
+++ trunk/SKMainWindowController.m 2024-03-25 17:40:32 UTC (rev 14145)
@@ -308,10 +308,8 @@
// Set up the panes and subviews, needs to be done before we resize them
// make sure the first thing we call on the side view controllers is its
view so their nib is loaded
- [leftSideContentView addSubview:leftSideController.view];
- [leftSideController.view activateConstraintsToSuperview];
- [rightSideContentView addSubview:rightSideController.view];
- [rightSideController.view activateConstraintsToSuperview];
+ [leftSideContentView addSubviewWithConstraints:leftSideController.view];
+ [rightSideContentView addSubviewWithConstraints:rightSideController.view];
[leftSideContentView setAccessibilityLabel:NSLocalizedString(@"contents
pane", @"Accessibility description")];
[rightSideContentView setAccessibilityLabel:NSLocalizedString(@"notes
pane", @"Accessibility description")];
@@ -406,8 +404,7 @@
[leftSideController.button setEnabled:NO
forSegment:SKSidePaneStateOutline];
// Due to a bug in Leopard we should only resize and swap in the PDFView
after loading the PDFDocument
- [pdfContentView addSubview:pdfView];
- [pdfView activateConstraintsToSuperview];
+ [pdfContentView addSubviewWithConstraints:pdfView];
// get the initial display mode from the PDF if present and not overridden
by an explicit setup
if (hasWindowSetup == NO && [[NSUserDefaults standardUserDefaults]
boolForKey:SKUseSettingsFromPDFKey]) {
Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m 2024-03-25 17:16:25 UTC (rev
14144)
+++ trunk/SKMainWindowController_FullScreen.m 2024-03-25 17:40:32 UTC (rev
14145)
@@ -146,8 +146,7 @@
[leftSideController.view setFrame:[leftSideContentView bounds]];
- [leftSideContentView addSubview:leftSideController.view];
- [leftSideController.view activateConstraintsToSuperview];
+ [leftSideContentView
addSubviewWithConstraints:leftSideController.view];
[self setLeftSidePaneState:mwcFlags.savedLeftSidePaneState];
@@ -426,8 +425,7 @@
NSWindow *fullScreenWindow = [self window];
- [[fullScreenWindow contentView] addSubview:pdfView];
- [pdfView activateConstraintsToSuperview];
+ [[fullScreenWindow contentView] addSubviewWithConstraints:pdfView];
[pdfView layoutDocumentView];
[pdfView requiresDisplay];
[fullScreenWindow makeFirstResponder:pdfView];
@@ -496,7 +494,11 @@
// this should be done before exitPresentationMode to get a smooth
transition
[pdfContentView addSubview:pdfView positioned:NSWindowBelow
relativeTo:nil];
- [pdfView activateConstraintsToSuperview];
+ [NSLayoutConstraint activateConstraints:@[
+ [[pdfView leadingAnchor] constraintEqualToAnchor:[pdfContentView
leadingAnchor]],
+ [[pdfContentView trailingAnchor] constraintEqualToAnchor:[pdfView
trailingAnchor]],
+ [[pdfView topAnchor] constraintEqualToAnchor:[pdfContentView
topAnchor]],
+ [[pdfContentView bottomAnchor] constraintEqualToAnchor:[pdfView
bottomAnchor]]]];
[pdfView setBackgroundColor:backgroundColor];
[secondaryPdfView setBackgroundColor:backgroundColor];
if ([self hasOverview])
Modified: trunk/SKSideWindow.m
===================================================================
--- trunk/SKSideWindow.m 2024-03-25 17:16:25 UTC (rev 14144)
+++ trunk/SKSideWindow.m 2024-03-25 17:40:32 UTC (rev 14145)
@@ -104,8 +104,7 @@
mainContentView = [[NSView alloc] initWithFrame:contentRect];
[mainContentView setAutoresizingMask:NSViewMinXMargin |
NSViewHeightSizable];
[backgroundView addSubview:mainContentView];
- [mainContentView addSubview:view];
- [view activateConstraintsToSuperview];
+ [mainContentView addSubviewWithConstraints:view];
}
return self;
}
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