Revision: 28844
          http://sourceforge.net/p/bibdesk/svn/28844
Author:   hofman
Date:     2024-03-12 19:07:01 +0000 (Tue, 12 Mar 2024)
Log Message:
-----------
animate content border thickness wwith shifting status bar

Modified Paths:
--------------
    trunk/bibdesk/BDSKStatusBar.m

Modified: trunk/bibdesk/BDSKStatusBar.m
===================================================================
--- trunk/bibdesk/BDSKStatusBar.m       2024-03-12 18:02:38 UTC (rev 28843)
+++ trunk/bibdesk/BDSKStatusBar.m       2024-03-12 19:07:01 UTC (rev 28844)
@@ -41,6 +41,7 @@
 #import "NSGeometry_BDSKExtensions.h"
 #import "NSAnimationContext_BDSKExtensions.h"
 #import "NSView_BDSKExtensions.h"
+#import <Quartz/Quartz.h>
 
 #define LEFT_MARGIN                            5.0
 #define RIGHT_MARGIN            15.0
@@ -67,6 +68,12 @@
 @synthesize leftMargin, rightMargin, progressIndicator, delegate, 
bottomConstraint;
 @dynamic visible, stringValue, font, progressIndicatorStyle, 
progressIndicatorValue, iconIdentifiers;
 
++ (id)defaultAnimationForKey:(NSAnimatablePropertyKey)key {
+    if ([key isEqualToString:@"offset"])
+        return [CABasicAnimation animation];
+    return [super defaultAnimationForKey:key];
+}
+
 - (instancetype)initWithFrame:(NSRect)frame {
     self = [super initWithFrame:frame];
     if (self) {
@@ -154,6 +161,15 @@
        return [self superview]  && [self isHidden] == NO;
 }
 
+- (CGFloat)offset {
+    return [bottomConstraint constant];
+}
+
+- (void)setOffset:(CGFloat)offset {
+    [bottomConstraint setConstant:offset];
+    [[self window] setContentBorderThickness:NSHeight([self frame]) + offset 
forEdge:NSMinYEdge];
+}
+
 - (void)toggleBelowView:(NSView *)view animate:(BOOL)animate {
     if (animating)
         return;
@@ -166,7 +182,6 @@
     NSMutableArray *constraints = [NSMutableArray array];
     
     if (visible) {
-        [[view window] setContentBorderThickness:statusHeight 
forEdge:NSMinYEdge];
         [contentView addSubview:self];
         [constraints addObject:[[self leadingAnchor] 
constraintEqualToAnchor:[contentView leadingAnchor]]];
         [constraints addObject:[[contentView trailingAnchor] 
constraintEqualToAnchor:[self trailingAnchor]]];
@@ -182,14 +197,12 @@
     
     if (duration > 0.0) {
         animating = YES;
-        CGFloat target = visible ? 0.0 : -statusHeight;
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
                 [context setDuration:duration];
-                [[bottomConstraint animator] setConstant:target];
+                [[self animator] setOffset:visible ? 0.0 : -statusHeight];
             }
             completionHandler:^{
                 if (visible == NO) {
-                    [[self window] setContentBorderThickness:0.0 
forEdge:NSMinYEdge];
                     [self removeFromSuperview];
                     [NSLayoutConstraint activateConstraints:constraints];
                     bottomConstraint = [constraints lastObject];
@@ -206,6 +219,8 @@
         [NSLayoutConstraint activateConstraints:constraints];
         [contentView layoutSubtreeIfNeeded];
         bottomConstraint = [constraints lastObject];
+    } else {
+        [[self window] setContentBorderThickness:statusHeight 
forEdge:NSMinYEdge];
     }
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to