Revision: 14687
          http://sourceforge.net/p/skim-app/code/14687
Author:   hofman
Date:     2024-11-15 16:06:53 +0000 (Fri, 15 Nov 2024)
Log Message:
-----------
set tooltip window as ivar of navigation window instead of a singleton window

Modified Paths:
--------------
    trunk/SKNavigationWindow.h
    trunk/SKNavigationWindow.m

Modified: trunk/SKNavigationWindow.h
===================================================================
--- trunk/SKNavigationWindow.h  2024-11-14 15:38:27 UTC (rev 14686)
+++ trunk/SKNavigationWindow.h  2024-11-15 16:06:53 UTC (rev 14687)
@@ -50,6 +50,8 @@
 @end
     
 
+@class SKNavigationToolTipWindow;
+
 @interface SKNavigationWindow : SKHUDWindow {
     SKNavigationButton *previousButton;
     SKNavigationButton *nextButton;
@@ -56,9 +58,11 @@
     SKNavigationButton *zoomButton;
     SKNavigationButton *cursorButton;
     SKNavigationButton *closeButton;
+    SKNavigationToolTipWindow *toolTipWindow;
 }
 - (void)handleAutoScalesChangedNotification:(NSNotification *)notification;
 - (void)handlePageChangedNotification:(NSNotification *)notification;
+- (SKNavigationToolTipWindow *)toolTipWindowCreating:(BOOL)create;
 @end
 
 
@@ -76,7 +80,6 @@
 @interface SKNavigationToolTipWindow : NSPanel {
     NSView *view;
 }
-@property (class, nonatomic, readonly) SKNavigationToolTipWindow 
*sharedToolTipWindow;
 - (void)showToolTip:(NSString *)toolTip forView:(NSView *)aView;
 @property (nonatomic, nullable, readonly) NSView *view;
 @end

Modified: trunk/SKNavigationWindow.m
===================================================================
--- trunk/SKNavigationWindow.m  2024-11-14 15:38:27 UTC (rev 14686)
+++ trunk/SKNavigationWindow.m  2024-11-15 16:06:53 UTC (rev 14687)
@@ -228,7 +228,7 @@
 }
 
 - (void)orderOut:(id)sender {
-    [[SKNavigationToolTipWindow sharedToolTipWindow] orderOut:nil];
+    [toolTipWindow orderOut:nil];
     [super orderOut:sender];
 }
 
@@ -241,6 +241,12 @@
     [nextButton setEnabled:[[notification object] canGoToNextPage]];
 }
 
+- (SKNavigationToolTipWindow *)toolTipWindowCreating:(BOOL)create {
+    if (toolTipWindow == nil && create)
+        toolTipWindow = [[SKNavigationToolTipWindow alloc] init];
+    return toolTipWindow;
+}
+
 @end
 
 #pragma mark -
@@ -409,13 +415,6 @@
 
 @synthesize view;
 
-+ (SKNavigationToolTipWindow *)sharedToolTipWindow {
-    static SKNavigationToolTipWindow *sharedToolTipWindow = nil;
-    if (sharedToolTipWindow == nil)
-        sharedToolTipWindow = [[self alloc] init];
-    return sharedToolTipWindow;
-}
-
 - (instancetype)init {
     self = [super initWithContentRect:NSZeroRect 
styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES];
     if (self) {
@@ -600,15 +599,24 @@
     [([self state] == NSControlStateValueOn && [self alternatePath] ? [self 
alternatePath] : [self path]) fill];
 }
 
+- (BOOL)showsToolTip {
+    NSView *controlView = [self controlView];
+    return [[[(SKNavigationWindow *)[controlView window] 
toolTipWindowCreating:NO] view] isEqual:controlView];
+}
+
+- (SKNavigationToolTipWindow *)toolTipWindow {
+    return [(SKNavigationWindow *)[[self controlView] window] 
toolTipWindowCreating:YES];
+}
+
 - (void)mouseEntered:(NSEvent *)theEvent {
     NSString *currentToolTip = [self state] == NSControlStateValueOn && 
alternateToolTip ? alternateToolTip : toolTip;
-    [[SKNavigationToolTipWindow sharedToolTipWindow] 
showToolTip:currentToolTip forView:[self controlView]];
+    [[self toolTipWindow] showToolTip:currentToolTip forView:[self 
controlView]];
     [super mouseEntered:theEvent];
 }
 
 - (void)mouseExited:(NSEvent *)theEvent {
-    if ([[[SKNavigationToolTipWindow sharedToolTipWindow] view] isEqual:[self 
controlView]])
-        [[SKNavigationToolTipWindow sharedToolTipWindow] orderOut:nil];
+    if ([self showsToolTip])
+        [[self toolTipWindow] orderOut:nil];
     [super mouseExited:theEvent];
 }
 
@@ -619,9 +627,9 @@
     if (oldState != state && [[button window] isVisible]) {
         if (alternatePath)
             [button setNeedsDisplay:YES];
-        if (alternateToolTip && [[[SKNavigationToolTipWindow 
sharedToolTipWindow] view] isEqual:button]) {
+        if (alternateToolTip && [self showsToolTip]) {
             NSString *currentToolTip = [self state] == NSControlStateValueOn 
&& alternateToolTip ? alternateToolTip : toolTip;
-            [[SKNavigationToolTipWindow sharedToolTipWindow] 
showToolTip:currentToolTip forView:button];
+            [[self toolTipWindow] showToolTip:currentToolTip forView:button];
         }
     }
     [self setAccessibilityLabel:state == NSControlStateValueOn && 
alternateToolTip ? alternateToolTip : toolTip];

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

Reply via email to