Revision: 12891
          http://sourceforge.net/p/skim-app/code/12891
Author:   hofman
Date:     2022-05-06 15:30:39 +0000 (Fri, 06 May 2022)
Log Message:
-----------
don't draw topbar background in presentation when not overlapping

Modified Paths:
--------------
    trunk/SKMainWindowController_FullScreen.m
    trunk/SKTopBarView.h
    trunk/SKTopBarView.m

Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m   2022-05-06 15:20:58 UTC (rev 
12890)
+++ trunk/SKMainWindowController_FullScreen.m   2022-05-06 15:30:39 UTC (rev 
12891)
@@ -113,10 +113,13 @@
         sideWindow = [[SKSideWindow alloc] 
initWithView:leftSideController.view];
     
     [leftSideController.topBar setHasSeparator:NO];
-    [leftSideController.topBar applyPresentationBackground];
-    if (mwcFlags.fullSizeContent)
+    if (mwcFlags.fullSizeContent) {
+        [leftSideController.topBar applyPresentationBackground];
         [leftSideController setTopInset:0.0];
-    
+    } else {
+        [leftSideController.topBar setDrawsBackground:NO];
+    }
+
     mwcFlags.savedLeftSidePaneState = [self leftSidePaneState];
     [self setLeftSidePaneState:SKSidePaneStateThumbnail];
     [sideWindow makeFirstResponder:leftSideController.thumbnailTableView];
@@ -130,9 +133,12 @@
         if ([[sideWindow firstResponder] 
isDescendantOf:leftSideController.view])
             [sideWindow makeFirstResponder:nil];
         [leftSideController.topBar setHasSeparator:YES];
-        [leftSideController.topBar applyDefaultBackground];
-        if (mwcFlags.fullSizeContent)
+        if (mwcFlags.fullSizeContent) {
+            [leftSideController.topBar applyDefaultBackground];
             [leftSideController setTopInset:titleBarHeight];
+        } else {
+            [leftSideController.topBar setDrawsBackground:YES];
+        }
         
         [leftSideController.view setFrame:[leftSideContentView bounds]];
         

Modified: trunk/SKTopBarView.h
===================================================================
--- trunk/SKTopBarView.h        2022-05-06 15:20:58 UTC (rev 12890)
+++ trunk/SKTopBarView.h        2022-05-06 15:30:39 UTC (rev 12891)
@@ -46,12 +46,13 @@
     NSArray *backgroundColors;
     NSArray *alternateBackgroundColors;
     BOOL hasSeparator;
+    BOOL drawsBackground;
     BOOL wantsSubviews;
 }
 
 @property (nonatomic, readonly) NSView *contentView;
 @property (nonatomic, copy) NSArray *backgroundColors, 
*alternateBackgroundColors;
-@property (nonatomic) BOOL hasSeparator;
+@property (nonatomic) BOOL hasSeparator, drawsBackground;
 
 - (void)applyDefaultBackground;
 - (void)applyPresentationBackground;

Modified: trunk/SKTopBarView.m
===================================================================
--- trunk/SKTopBarView.m        2022-05-06 15:20:58 UTC (rev 12890)
+++ trunk/SKTopBarView.m        2022-05-06 15:30:39 UTC (rev 12891)
@@ -47,7 +47,7 @@
 
 @implementation SKTopBarView
 
-@synthesize contentView, backgroundColors, alternateBackgroundColors, 
hasSeparator;
+@synthesize contentView, backgroundColors, alternateBackgroundColors, 
hasSeparator, drawsBackground;
 
 - (id)initWithFrame:(NSRect)frame {
     wantsSubviews = YES;
@@ -77,6 +77,7 @@
         backgroundColors = [[decoder decodeObjectForKey:@"backgroundColors"] 
retain];
         alternateBackgroundColors = [[decoder 
decodeObjectForKey:@"alternateBackgroundColors"] retain];
         hasSeparator = [decoder decodeBoolForKey:@"hasSeparator"];
+        drawsBackground = [decoder decodeBoolForKey:@"drawsBackground"];
         wantsSubviews = NO;
        }
        return self;
@@ -90,6 +91,7 @@
     [coder encodeObject:backgroundColors forKey:@"backgroundColors"];
     [coder encodeObject:alternateBackgroundColors 
forKey:@"alternateBackgroundColors"];
     [coder encodeBool:hasSeparator forKey:@"hasSeparator"];
+    [coder encodeBool:drawsBackground forKey:@"drawsBackground"];
 }
 
 - (void)dealloc {
@@ -133,6 +135,9 @@
 }
 
 - (void)drawRect:(NSRect)aRect {
+    if (drawsBackground == NO)
+        return;
+    
     NSArray *colors = backgroundColors;
     if (alternateBackgroundColors && [[self window] isMainWindow] == NO && 
[[self window] isKeyWindow] == NO)
         colors = alternateBackgroundColors;
@@ -221,6 +226,16 @@
        }
 }
 
+- (void)setDrawsBackground:(BOOL)flag {
+    if (drawsBackground != flag) {
+        drawsBackground = flag;
+        [backgroundView setHidden:drawsBackground == NO];
+        [separatorView setHidden:drawsBackground == NO];
+        if (RUNNING_BEFORE(10_14))
+            [self setNeedsDisplay:YES];
+    }
+}
+
 - (void)setAlternateBackgroundColors:(NSArray *)colors {
     if (colors != alternateBackgroundColors) {
         if ([self window]) {
@@ -256,7 +271,7 @@
 #pragma clang diagnostic pop
         [backgroundView 
setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
     } else {
-        [self setBackgroundColors:nil];
+        [self setBackgroundColors:[NSArray arrayWithObjects:[NSColor 
windowBackgroundColor], nil]];
         [self setAlternateBackgroundColors:nil];
     }
 }

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

Reply via email to