Revision: 12884 http://sourceforge.net/p/skim-app/code/12884 Author: hofman Date: 2022-05-05 16:21:00 +0000 (Thu, 05 May 2022) Log Message: ----------- Let content in main window move behind title and tool bar. Offset search/find top bars by its height, and add it to the content insets of the ascroll views.
Modified Paths: -------------- trunk/SKFindController.m trunk/SKLeftSideViewController.m trunk/SKMainWindowController.h trunk/SKMainWindowController.m trunk/SKMainWindowController_FullScreen.m trunk/SKMainWindowController_UI.m trunk/SKRightSideViewController.m trunk/SKSideViewController.h trunk/SKSideViewController.m Modified: trunk/SKFindController.m =================================================================== --- trunk/SKFindController.m 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKFindController.m 2022-05-05 16:21:00 UTC (rev 12884) @@ -117,7 +117,7 @@ if (view == nil) { NSArray *subviews = [[findBar superview] subviews]; for (view in subviews) { - if (view != findBar && fabs(NSMaxY([view frame]) - NSMaxY([findBar frame])) <= 0.0) + if (view != findBar && NSMaxY([view frame]) >= NSMaxY([findBar frame])) break; } } @@ -128,6 +128,9 @@ CGFloat barHeight = NSHeight([findBar frame]); NSArray *constraints; NSScrollView *scrollView = [view descendantOfClass:[NSScrollView class]]; + CGFloat inset = 0.0; + if (RUNNING_AFTER(10_13)) + inset += NSHeight([[contentView window] frame]) - NSHeight([[contentView window] contentLayoutRect]); if (visible) { [contentView addSubview:findBar]; @@ -134,7 +137,7 @@ constraints = [NSArray arrayWithObjects: [NSLayoutConstraint constraintWithItem:findBar attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:findBar attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0.0], - [NSLayoutConstraint constraintWithItem:findBar attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:animate ? -barHeight : 0.0], nil]; + [NSLayoutConstraint constraintWithItem:findBar attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:animate ? inset - barHeight : inset], nil]; [NSLayoutConstraint activateConstraints:constraints]; [contentView layoutSubtreeIfNeeded]; topConstraint = [constraints lastObject]; @@ -154,13 +157,13 @@ [messageField setHidden:YES]; [scrollView setAutomaticallyAdjustsContentInsets:visible == NO]; - [scrollView setContentInsets:NSEdgeInsetsMake(visible ? barHeight : 0.0, 0.0, 0.0, 0.0)]; + [scrollView setContentInsets:NSEdgeInsetsMake(visible ? barHeight + inset : inset, 0.0, 0.0, 0.0)]; if (animate) { animating = YES; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ [context setDuration:0.5 * [context duration]]; - [[topConstraint animator] setConstant:visible ? 0.0 : -barHeight]; + [[topConstraint animator] setConstant:visible ? inset : inset - barHeight]; } completionHandler:^{ if (visible == NO) Modified: trunk/SKLeftSideViewController.m =================================================================== --- trunk/SKLeftSideViewController.m 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKLeftSideViewController.m 2022-05-05 16:21:00 UTC (rev 12884) @@ -169,6 +169,10 @@ [super setMainController:newMainController]; } +- (NSArray *)tableViews { + return [NSArray arrayWithObjects:thumbnailTableView, tocOutlineView, findTableView, groupedFindTableView, nil]; +} + - (BOOL)requiresAlternateButtonForView:(NSView *)aView { return [findTableView isDescendantOf:aView] || [groupedFindTableView isDescendantOf:aView]; } Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKMainWindowController.h 2022-05-05 16:21:00 UTC (rev 12884) @@ -160,6 +160,8 @@ CGFloat lastRightSidePaneWidth; CGFloat lastSplitPDFHeight; + CGFloat titleBarHeight; + CGFloat thumbnailCacheSize; CGFloat snapshotCacheSize; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKMainWindowController.m 2022-05-05 16:21:00 UTC (rev 12884) @@ -175,6 +175,8 @@ static char SKMainWindowThumbnailSelectionObservationContext; +static char SKMainWindowContentLayoutObservationContext; + #define SKLeftSidePaneWidthKey @"SKLeftSidePaneWidth" #define SKRightSidePaneWidthKey @"SKRightSidePaneWidth" @@ -391,12 +393,6 @@ // Set up the window [window setCollectionBehavior:[window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary]; - 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]; - } - [window setStyleMask:[window styleMask] | NSFullSizeContentViewWindowMask]; if ([window respondsToSelector:@selector(setToolbarStyle:)]) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpartial-availability" @@ -403,6 +399,19 @@ [window setToolbarStyle:NSWindowToolbarStyleExpanded]; #pragma clang diagnostic pop + [window setStyleMask:[window styleMask] | NSFullSizeContentViewWindowMask]; + if (RUNNING_AFTER(10_13)) { + 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]; + } + } + [self setWindowFrameAutosaveNameOrCascade:SKMainWindowFrameAutosaveName]; [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; @@ -1645,7 +1654,7 @@ NSArray *constraints = [NSArray arrayWithObjects: [NSLayoutConstraint constraintWithItem:overviewContentView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:overviewContentView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0.0], - [NSLayoutConstraint constraintWithItem:overviewContentView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:isPresentation ? contentView : [[self window] contentLayoutGuide] attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], + [NSLayoutConstraint constraintWithItem:overviewContentView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:RUNNING_AFTER(10_13) || isPresentation ? contentView : [[self window] contentLayoutGuide] attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:hasStatus ? statusBar : contentView attribute:hasStatus ? NSLayoutAttributeTop : NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:overviewContentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], nil]; [overviewContentView setFrame:[oldView frame]]; @@ -1711,7 +1720,7 @@ NSArray *constraints = [NSArray arrayWithObjects: [NSLayoutConstraint constraintWithItem:newView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:newView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:0.0], - [NSLayoutConstraint constraintWithItem:newView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:isMainWindow ? [mainWindow contentLayoutGuide] : contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], + [NSLayoutConstraint constraintWithItem:newView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:RUNNING_AFTER(10_13) || isMainWindow == NO ? contentView : [mainWindow contentLayoutGuide] attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:hasStatus ? statusBar : contentView attribute:hasStatus ? NSLayoutAttributeTop : NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:newView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], nil]; if (animate) { @@ -2318,8 +2327,10 @@ SKShouldAntiAliasKey, SKInterpolationQualityKey, SKGreekingThresholdKey, SKTableFontSizeKey, nil] context:&SKMainWindowDefaultsObservationContext]; - if (RUNNING_AFTER(10_13)) + if (RUNNING_AFTER(10_13)) { [NSApp addObserver:self forKeyPath:@"effectiveAppearance" options:0 context:&SKMainWindowAppObservationContext]; + [[self window] addObserver:self forKeyPath:@"contentLayoutRect" options:0 context:&SKMainWindowContentLayoutObservationContext]; + } } - (void)unregisterAsObserver { @@ -2335,6 +2346,8 @@ if (RUNNING_AFTER(10_13)) { @try { [NSApp removeObserver:self forKeyPath:@"effectiveAppearance" context:&SKMainWindowAppObservationContext]; } @catch (id e) {} + @try { [mainWindow removeObserver:self forKeyPath:@"contentLayoutRect" context:&SKMainWindowContentLayoutObservationContext]; } + @catch (id e) {} } } @@ -2448,6 +2461,21 @@ [pdfView setBackgroundColor:backgroundColor]; [secondaryPdfView setBackgroundColor:backgroundColor]; + } else if (context == &SKMainWindowContentLayoutObservationContext) { + + CGFloat titleHeight = NSHeight([mainWindow frame]) - NSHeight([mainWindow contentLayoutRect]); + if (fabs(titleHeight - titleBarHeight) > 0.0) { + titleBarHeight = titleHeight; + [rightSideController setTopInset:titleBarHeight]; + if ([self interactionMode] != SKPresentationMode || [self leftSidePaneIsOpen] == NO) + [leftSideController setTopInset:titleBarHeight]; + if ([[findController view] window]) { + [[[[findController view] superview] constraintWithFirstItem:[findController view] firstAttribute:NSLayoutAttributeTop] setConstant:titleBarHeight]; + if ([self interactionMode] != SKPresentationMode) + [[pdfView scrollView] setContentInsets:NSEdgeInsetsMake(NSHeight([[findController view] frame]) + titleBarHeight, 0.0, 0.0, 0.0)]; + } + } + } else if (context == &SKMainWindowThumbnailSelectionObservationContext) { NSIndexSet *indexes = [overviewView selectionIndexes]; Modified: trunk/SKMainWindowController_FullScreen.m =================================================================== --- trunk/SKMainWindowController_FullScreen.m 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKMainWindowController_FullScreen.m 2022-05-05 16:21:00 UTC (rev 12884) @@ -114,6 +114,8 @@ [leftSideController.topBar setHasSeparator:NO]; [leftSideController.topBar applyPresentationBackground]; + if (RUNNING_AFTER(10_13)) + [leftSideController setTopInset:0.0]; mwcFlags.savedLeftSidePaneState = [self leftSidePaneState]; [self setLeftSidePaneState:SKSidePaneStateThumbnail]; @@ -129,6 +131,9 @@ [sideWindow makeFirstResponder:nil]; [leftSideController.topBar setHasSeparator:YES]; [leftSideController.topBar applyDefaultBackground]; + if (RUNNING_AFTER(10_13)) + [leftSideController setTopInset:titleBarHeight]; + [leftSideController.view setFrame:[leftSideContentView bounds]]; [leftSideContentView addSubview:leftSideController.view]; @@ -276,7 +281,7 @@ [scrollView setDrawsBackground:[[savedNormalSetup objectForKey:DRAWSBACKGROUND_KEY] boolValue]]; if ([[findController view] window]) { [scrollView setAutomaticallyAdjustsContentInsets:NO]; - [scrollView setContentInsets:NSEdgeInsetsMake(NSHeight([[findController view] frame]), 0.0, 0.0, 0.0)]; + [scrollView setContentInsets:NSEdgeInsetsMake(NSHeight([[findController view] frame]) + titleBarHeight, 0.0, 0.0, 0.0)]; } } Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKMainWindowController_UI.m 2022-05-05 16:21:00 UTC (rev 12884) @@ -112,6 +112,7 @@ #define MIN_SIDE_PANE_WIDTH 100.0 #define DEFAULT_SPLIT_PANE_HEIGHT 200.0 #define MIN_SPLIT_PANE_HEIGHT 50.0 +#define MIN_PDF_PANE_HEIGHT 50.0 #define SNAPSHOT_HEIGHT 200.0 @@ -1564,7 +1565,7 @@ else if ([sender isEqual:splitView] && dividerIndex == 0) return proposedMin + MIN_SIDE_PANE_WIDTH; else if ([sender isEqual:pdfSplitView]) - return proposedMin + MIN_SPLIT_PANE_HEIGHT; + return proposedMin + titleBarHeight + MIN_PDF_PANE_HEIGHT; return proposedMin; } @@ -1614,7 +1615,7 @@ NSSize bottomSize = [bottomView frame].size; CGFloat contentHeight = NSHeight([sender frame]) - [sender dividerThickness]; - if (bottomSize.height <= 0.0 || contentHeight < 2.0 * MIN_SPLIT_PANE_HEIGHT) { + if (bottomSize.height <= 0.0 || contentHeight < titleBarHeight + MIN_PDF_PANE_HEIGHT + MIN_SPLIT_PANE_HEIGHT) { topSize.height = contentHeight; bottomSize.height = 0.0; } else { @@ -1628,9 +1629,9 @@ if (bottomSize.height < MIN_SPLIT_PANE_HEIGHT) { bottomSize.height = MIN_SPLIT_PANE_HEIGHT; topSize.height = contentHeight - MIN_SPLIT_PANE_HEIGHT; - } else if (topSize.height < MIN_SPLIT_PANE_HEIGHT) { - topSize.height = MIN_SPLIT_PANE_HEIGHT; - bottomSize.height = contentHeight - MIN_SPLIT_PANE_HEIGHT; + } else if (topSize.height < titleBarHeight + MIN_PDF_PANE_HEIGHT) { + topSize.height = titleBarHeight - MIN_PDF_PANE_HEIGHT; + bottomSize.height = contentHeight - titleBarHeight - MIN_PDF_PANE_HEIGHT; } } topSize.width = bottomSize.width = NSWidth([sender frame]); Modified: trunk/SKRightSideViewController.m =================================================================== --- trunk/SKRightSideViewController.m 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKRightSideViewController.m 2022-05-05 16:21:00 UTC (rev 12884) @@ -133,4 +133,8 @@ [super setMainController:newMainController]; } +- (NSArray *)tableViews { + return [NSArray arrayWithObjects:noteOutlineView, snapshotTableView, nil]; +} + @end Modified: trunk/SKSideViewController.h =================================================================== --- trunk/SKSideViewController.h 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKSideViewController.h 2022-05-05 16:21:00 UTC (rev 12884) @@ -56,6 +56,9 @@ @property (nonatomic, retain) IBOutlet NSSearchField *searchField; @property (nonatomic, retain) IBOutlet NSView *currentView; +@property (nonatomic) CGFloat topInset; +@property (nonatomic, readonly) NSArray *tableViews; + - (BOOL)requiresAlternateButtonForView:(NSView *)aView; - (void)replaceSideView:(NSView *)newView animate:(BOOL)animate; Modified: trunk/SKSideViewController.m =================================================================== --- trunk/SKSideViewController.m 2022-05-04 17:31:50 UTC (rev 12883) +++ trunk/SKSideViewController.m 2022-05-05 16:21:00 UTC (rev 12884) @@ -42,6 +42,7 @@ #import "SKImageToolTipWindow.h" #import "NSGeometry_SKExtensions.h" #import "SKStringConstants.h" +#import "NSView_SKExtensions.h" #define DURATION 0.7 @@ -48,6 +49,7 @@ @implementation SKSideViewController @synthesize mainController, topBar, button, alternateButton, searchField, currentView; +@dynamic topInset, tableViews; - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -66,6 +68,24 @@ [topBar setHasSeparator:YES]; } +#pragma mark Accessors + +- (NSArray *)tableViews { return nil; } + +- (CGFloat)topInset { + return [[[topBar superview] constraintWithFirstItem:topBar firstAttribute:NSLayoutAttributeTop] constant]; +} + +- (void)setTopInset:(CGFloat)topInset { + [[[topBar superview] constraintWithFirstItem:topBar firstAttribute:NSLayoutAttributeTop] 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]; + [scrollView setAutomaticallyAdjustsContentInsets:NO]; + [scrollView setContentInsets:insets]; + } +} + #pragma mark View animation - (BOOL)requiresAlternateButtonForView:(NSView *)aView { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit