Revision: 15157
http://sourceforge.net/p/skim-app/code/15157
Author: hofman
Date: 2025-05-04 21:25:51 +0000 (Sun, 04 May 2025)
Log Message:
-----------
enerate image for tool tip with a slight delay, so itdoesnot happen when just
moving over a link
Modified Paths:
--------------
trunk/SKImageToolTipWindow.h
trunk/SKImageToolTipWindow.m
Modified: trunk/SKImageToolTipWindow.h
===================================================================
--- trunk/SKImageToolTipWindow.h 2025-05-04 16:39:51 UTC (rev 15156)
+++ trunk/SKImageToolTipWindow.h 2025-05-04 21:25:51 UTC (rev 15157)
@@ -45,6 +45,7 @@
@interface SKImageToolTipWindow : SKAnimatedBorderlessWindow {
id <SKImageToolTipContext> context;
NSPoint point;
+ CGFloat scale;
NSImageView *imageView;
NSImage *image;
BOOL shouldShow;
Modified: trunk/SKImageToolTipWindow.m
===================================================================
--- trunk/SKImageToolTipWindow.m 2025-05-04 16:39:51 UTC (rev 15156)
+++ trunk/SKImageToolTipWindow.m 2025-05-04 21:25:51 UTC (rev 15157)
@@ -50,6 +50,7 @@
#define AUTO_HIDE_TIME_INTERVAL 10.0
#define DEFAULT_SHOW_DELAY 1.5
#define ALT_SHOW_DELAY 0.2
+#define GENERATE_DELAY 0.1
#define WINDOW_LEVEL ((NSWindowLevel)104)
#define DEFAULT_SCALE -2.0
@@ -159,22 +160,40 @@
[self show];
}
+- (void)generateImage {
+ id <SKImageToolTipContext> aContext = context;
+ CGFloat backingScale = [[NSScreen mainScreen] backingScaleFactor];
+ NSNumber *usedScaleNumber = [[NSUserDefaults standardUserDefaults]
objectForKey:SKToolTipScaleKey];
+ CGFloat usedScale = [usedScaleNumber
respondsToSelector:@selector(doubleValue)] ? [usedScaleNumber doubleValue] :
DEFAULT_SCALE;
+ if (usedScale <= 0.0)
+ usedScale = usedScale < 0.0 ? fmin(scale, -usedScale) : scale;
+
+ dispatch_async([[self class] imageQueue], ^{
+
+ NSImage *anImage = [aContext toolTipImageWithScale:usedScale
backingScale:backingScale];
+
+ dispatch_async(dispatch_get_main_queue(), ^{
+
+ // check if another image is enerated or we are fading out
+ if (aContext == context) {
+ image = anImage;
+ if (image == nil)
+ [self fadeOut];
+ else if (shouldShow)
+ [self show];
+ }
+
+ });
+
+ });
+}
+
- (void)stopAnimation {
[super stopAnimation];
+ [[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(generateImage) object:nil];
[[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(showDelayed) object:nil];
}
-static inline CGFloat toolTipScale(CGFloat scale) {
- NSNumber *usedScaleNumber = [[NSUserDefaults standardUserDefaults]
objectForKey:SKToolTipScaleKey];
- CGFloat usedScale = [usedScaleNumber
respondsToSelector:@selector(doubleValue)] ? [usedScaleNumber doubleValue] :
DEFAULT_SCALE;
- if (usedScale > 0.0)
- return usedScale;
- else if (usedScale < 0.0)
- return fmin(scale, -usedScale);
- else
- return scale;
-}
-
- (void)showForImageContext:(id <SKImageToolTipContext>)aContext
scale:(CGFloat)aScale atPoint:(NSPoint)aPoint {
point = aPoint;
@@ -182,30 +201,11 @@
[self stopAnimation];
context = aContext;
+ scale = aScale;
image = nil;
shouldShow = NO;
- CGFloat backingScale = [[NSScreen mainScreen] backingScaleFactor];
-
- dispatch_async([[self class] imageQueue], ^{
-
- NSImage *anImage = [aContext
toolTipImageWithScale:toolTipScale(aScale) backingScale:backingScale];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- // check if another image is enerated or we are fading out
- if (aContext == context) {
- image = anImage;
- if (image == nil)
- [self fadeOut];
- else if (shouldShow)
- [self show];
- }
-
- });
-
- });
-
+ [self performSelector:@selector(generateImage) withObject:nil
afterDelay:GENERATE_DELAY];
[self performSelector:@selector(showDelayed) withObject:nil
afterDelay:[self isVisible] ? ALT_SHOW_DELAY : DEFAULT_SHOW_DELAY];
}
}
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