Revision: 26193
          http://sourceforge.net/p/bibdesk/svn/26193
Author:   hofman
Date:     2021-06-10 09:43:30 +0000 (Thu, 10 Jun 2021)
Log Message:
-----------
Calculate frames more directly, use macros, fix complex string editor messaging

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

Modified: trunk/bibdesk/BDSKComplexStringEditor.m
===================================================================
--- trunk/bibdesk/BDSKComplexStringEditor.m     2021-06-10 09:20:18 UTC (rev 
26192)
+++ trunk/bibdesk/BDSKComplexStringEditor.m     2021-06-10 09:43:30 UTC (rev 
26193)
@@ -42,6 +42,10 @@
 #import "NSView_BDSKExtensions.h"
 #import "BDSKComplexStringFormatter.h"
 
+#define EDITOR_MARGIN 2.0
+#define WINDOW_MARGIN 4.0
+#define MIN_WINDOW_WIDTH 24.0
+
 @interface BDSKComplexStringEditor (Private)
 
 - (BOOL)getEnclosingView:(NSView **)view scrollingView:(NSView **)contentView;
@@ -206,11 +210,7 @@
     if (NO == [self getEnclosingView:&view scrollingView:&contentView])
         return;
     
-       NSRectEdge lowerEdge = [view isFlipped] ? NSMaxYEdge : NSMinYEdge;
-       NSRect lowerEdgeRect = NSInsetRect([view bounds], -2.0, -2.0);
-       NSRect winFrame = [[self window] frame];
-       
-    lowerEdgeRect = BDSKSliceRect(lowerEdgeRect, 1.0, lowerEdge);
+       NSRect lowerEdgeRect = BDSKSliceRect(NSInsetRect([view bounds], 
-EDITOR_MARGIN, -EDITOR_MARGIN), 1.0, [view isFlipped] ? NSMaxYEdge : 
NSMinYEdge);
     if (contentView)
         lowerEdgeRect = NSIntersectionRect(lowerEdgeRect, [view 
convertRect:[contentView visibleRect] fromView:contentView]);
        // see if the cell's lower edge is scrolled out of sight
@@ -221,12 +221,12 @@
         }
                return;
        }
-       
        lowerEdgeRect = [view convertRectToScreen:lowerEdgeRect]; // takes into 
account isFlipped
-    winFrame.origin = lowerEdgeRect.origin;
-       winFrame.origin.y -= NSHeight(winFrame);
-       winFrame.size.width = fmax(NSWidth(lowerEdgeRect), 16.0); // minimal 
width of the window without margins, so subviews won't get shifted
-       winFrame = NSInsetRect(winFrame, -4.0, 0.0); // for the shadow and 
focus ring
+    
+    NSRect winFrame = [[self window] frame];
+    winFrame.origin.x = NSMinX(lowerEdgeRect) - WINDOW_MARGIN;
+       winFrame.origin.y = NSMinY(lowerEdgeRect) - NSHeight(winFrame);
+       winFrame.size.width = fmax(NSWidth(lowerEdgeRect) + 2.0 * 
WINDOW_MARGIN, MIN_WINDOW_WIDTH);
        [[self window] setFrame:winFrame display:YES];
        
        if ([self isWindowVisible] == NO) {
@@ -264,12 +264,12 @@
     NSString *error = nil;
     if ([formatter getObjectValue:&string forString:string 
errorDescription:&error]) {
         [expandedValueTextField setObjectValue:string];
+        [expandedValueTextField setTextColor:[NSColor controlTextColor]];
+        [expandedValueTextField setToolTip:NSLocalizedString(@"This field 
contains macros and is being edited as it would appear in a BibTeX file. This 
is the expanded value.", @"Tool tip message")];
+    } else {
+        [expandedValueTextField setObjectValue:error];
         [expandedValueTextField setTextColor:[NSColor systemRedColor]];
         [expandedValueTextField setToolTip:[NSString 
stringWithFormat:NSLocalizedString(@"Invalid BibTeX string: %@. This change 
will not be recorded.", @"Tool tip message"), string]];
-    } else {
-        [expandedValueTextField setObjectValue:error];
-        [expandedValueTextField setTextColor:[NSColor controlTextColor]];
-        [expandedValueTextField setToolTip:NSLocalizedString(@"This field 
contains macros and is being edited as it would appear in a BibTeX file. This 
is the expanded value.", @"Tool tip message")];
     }
 }
 

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