Revision: 28648
http://sourceforge.net/p/bibdesk/svn/28648
Author: hofman
Date: 2024-01-22 15:43:23 +0000 (Mon, 22 Jan 2024)
Log Message:
-----------
Use core animation for arrow fade effects
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2024-01-22
15:42:55 UTC (rev 28647)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2024-01-22
15:43:23 UTC (rev 28648)
@@ -253,7 +253,6 @@
NSRect _leftArrowFrame;
NSRect _rightArrowFrame;
CGFloat _arrowAlpha;
- NSAnimation *_arrowAnimation;
FVSliderWindow *_sliderWindow;
NSTrackingArea *_topSliderArea;
NSTrackingArea *_bottomSliderArea;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-22
15:42:55 UTC (rev 28647)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-22
15:43:23 UTC (rev 28648)
@@ -150,14 +150,9 @@
#import <Quartz/Quartz.h>
-@interface FVFileView (FVDelegateDeclarations) <FVAnimationDelegate,
FVDownloadDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate>
+@interface FVFileView (FVDelegateDeclarations) <FVDownloadDelegate,
QLPreviewPanelDataSource, QLPreviewPanelDelegate>
@end
-@interface FVAnimation : NSAnimation
-- (id <FVAnimationDelegate>)delegate;
-- (void)setDelegate:(id <FVAnimationDelegate>)newDelegate;
-@end
-
#if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED <
MAC_OS_X_VERSION_10_7
enum {
@@ -225,6 +220,8 @@
@property (nonatomic, copy) NSArray *iconURLs;
+@property (nonatomic) CGFloat arrowAlpha;
+
// only declare methods here to shut the compiler up if we can't rearrange
- (FVIcon *)iconAtIndex:(NSUInteger)anIndex;
- (FVIcon *)_cachedIconForURL:(NSURL *)aURL;
@@ -273,6 +270,7 @@
@synthesize dataSource;
@synthesize delegate;
@dynamic numberOfIcons;
+@synthesize arrowAlpha=_arrowAlpha;
+ (void)initialize
{
@@ -319,6 +317,12 @@
+ (BOOL)accessInstanceVariablesDirectly { return NO; }
++ (id)defaultAnimationForKey:(NSAnimatablePropertyKey)key {
+ if ([key isEqualToString:@"arrowAlpha"])
+ return [CABasicAnimation animation];
+ return [super defaultAnimationForKey:key];
+}
+
- (void)_commonInit {
// Icons keyed by URL; may contain icons that are no longer displayed.
Keeping this as primary storage means that
// rearranging/reloading is relatively cheap, since we don't recreate all
FVIcon instances every time -reload is called.
@@ -407,7 +411,6 @@
_leftArrowFrame = NSZeroRect;
_rightArrowFrame = NSZeroRect;
_arrowAlpha = 0.0;
- _arrowAnimation = nil;
_fvFlags.hasArrows = NO;
_minScale = 0.5;
@@ -2596,7 +2599,7 @@
if (isDrawingToScreen) {
- if (_fvFlags.hasArrows || _arrowAnimation) {
+ if (_fvFlags.hasArrows || _arrowAlpha > 0.0) {
if (NSIntersectsRect(rect, _leftArrowFrame))
[(FVArrowButtonCell *)_leftArrow drawWithFrame:_leftArrowFrame
inView:self alpha:_arrowAlpha];
if (NSIntersectsRect(rect, _rightArrowFrame))
@@ -3061,35 +3064,11 @@
[self _redisplayIconAfterPageChanged:anIcon];
}
-- (void)animationDidStop:(NSAnimation *)animation
-{
- _arrowAnimation = nil;
- _arrowAlpha = _fvFlags.hasArrows ? 1.0 : 0.0;
+- (void)setArrowAlpha:(CGFloat)arrowAlpha {
+ _arrowAlpha = arrowAlpha;
[self setNeedsDisplayInRect:NSUnionRect(_leftArrowFrame,
_rightArrowFrame)];
}
-- (void)animationDidEnd:(NSAnimation *)animation
-{
- _arrowAnimation = nil;
- _arrowAlpha = _fvFlags.hasArrows ? 1.0 : 0.0;
- [self setNeedsDisplayInRect:NSUnionRect(_leftArrowFrame,
_rightArrowFrame)];
-}
-
-- (void)animation:(NSAnimation *)animation
didReachProgress:(NSAnimationProgress)progress
-{
- _arrowAlpha = _fvFlags.hasArrows ? progress : (1 - progress);
- [self setNeedsDisplayInRect:NSUnionRect(_leftArrowFrame,
_rightArrowFrame)];
-}
-
-- (void)_startArrowAlphaTimer
-{
- // animate ~30 fps for 0.3 seconds, using NSAnimation to get the alpha
curve
- _arrowAnimation = [[FVAnimation alloc] initWithDuration:0.3
animationCurve:NSAnimationEaseInOut];
- [_arrowAnimation setAnimationBlockingMode:NSAnimationNonblocking];
- [_arrowAnimation setDelegate:self];
- [_arrowAnimation startAnimation];
-}
-
- (void)_showArrowsForIconAtIndex:(NSUInteger)anIndex
{
NSUInteger r, c;
@@ -3103,8 +3082,8 @@
if ([anIcon pageCount] > 1) {
- if (_arrowAnimation) {
- [_arrowAnimation stopAnimation];
+ if (_arrowAlpha > 0.0) {
+ _arrowAlpha = 0.0;
// make sure we redraw whatever area previously had the arrows
[self setNeedsDisplayInRect:NSUnionRect(_leftArrowFrame,
_rightArrowFrame)];
}
@@ -3128,8 +3107,11 @@
[self _updateButtonsForIcon:anIcon];
[self _setNeedsDisplayForIconInRow:r column:c];
- if (nil == _arrowAnimation)
- [self _startArrowAlphaTimer];
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext
*context){
+ [context setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
+ [context setDuration:0.3];
+ [[self animator] setArrowAlpha:1.0];
+ } completionHandler:^{}];
}
}
}
@@ -3140,8 +3122,11 @@
_fvFlags.hasArrows = NO;
[_leftArrow setRepresentedObject:nil];
[_rightArrow setRepresentedObject:nil];
- if (nil == _arrowAnimation)
- [self _startArrowAlphaTimer];
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
+ [context setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
+ [context setDuration:0.3];
+ [[self animator] setArrowAlpha:0.0];
+ } completionHandler:^{}];
}
}
@@ -4968,21 +4953,6 @@
#pragma mark -
-@implementation FVAnimation
-
-- (void)setCurrentProgress:(NSAnimationProgress)progress {
- [super setCurrentProgress:progress];
- if ([[self delegate]
respondsToSelector:@selector(animation:didReachProgress:)])
- [[self delegate] animation:self didReachProgress:progress];
-}
-
-- (id <FVAnimationDelegate>)delegate { return (id <FVAnimationDelegate>)[super
delegate]; }
-- (void)setDelegate:(id <FVAnimationDelegate>)newDelegate { [super
setDelegate:newDelegate]; }
-
-@end
-
-#pragma mark -
-
@implementation FVBackgroundView
@synthesize backgroundColor=_backgroundColor;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit