Revision: 14064
http://sourceforge.net/p/skim-app/code/14064
Author: hofman
Date: 2024-02-20 10:31:53 +0000 (Tue, 20 Feb 2024)
Log Message:
-----------
display line preview in text note pref line well in pixel units rather than
point units, as does PDFAnnotationFreeText
Modified Paths:
--------------
trunk/SKLineWell.h
trunk/SKLineWell.m
trunk/SKNotesPreferences.m
Modified: trunk/SKLineWell.h
===================================================================
--- trunk/SKLineWell.h 2024-02-20 10:06:56 UTC (rev 14063)
+++ trunk/SKLineWell.h 2024-02-20 10:31:53 UTC (rev 14064)
@@ -65,6 +65,7 @@
struct _lwFlags {
unsigned int displayStyle:2;
+ unsigned int usePixelUnit:1;
unsigned int active:1;
unsigned int canActivate:1;
unsigned int existsActiveLineWell:1;
@@ -77,6 +78,7 @@
@property (nonatomic, readonly, getter=isActive) BOOL active;
@property (nonatomic) BOOL canActivate;
+@property (nonatomic) BOOL usePixelUnit;
@property (nonatomic) SKLineWellDisplayStyle displayStyle;
@property (nonatomic) CGFloat lineWidth;
@property (nonatomic) PDFBorderStyle style;
Modified: trunk/SKLineWell.m
===================================================================
--- trunk/SKLineWell.m 2024-02-20 10:06:56 UTC (rev 14063)
+++ trunk/SKLineWell.m 2024-02-20 10:31:53 UTC (rev 14064)
@@ -60,7 +60,7 @@
@implementation SKLineWell
-@synthesize lineWidth, style, dashPattern, startLineStyle, endLineStyle;
+@synthesize lineWidth, style, usePixelUnit, dashPattern, startLineStyle,
endLineStyle;
@dynamic active, canActivate, displayStyle;
- (Class)valueClassForBinding:(NSString *)binding {
@@ -152,9 +152,12 @@
- (NSBezierPath *)path {
NSBezierPath *path = [NSBezierPath bezierPath];
NSRect bounds = [self bounds];
+ CGFloat lw = lineWidth;
+ if (lwFlags.usePixelUnit)
+ lw *= [self convertSizeFromBacking:NSMakeSize(1.0, 1.0)].width;
if ([self displayStyle] == SKLineWellDisplayStyleLine) {
- CGFloat offset = 0.5 * lineWidth - floor(0.5 * lineWidth);
+ CGFloat offset = 0.5 * lw - floor(0.5 * lw);
NSPoint startPoint = NSMakePoint(NSMinX(bounds) + ceil(0.5 *
NSHeight(bounds)), round(NSMidY(bounds)) - offset);
NSPoint endPoint = NSMakePoint(NSMaxX(bounds) - ceil(0.5 *
NSHeight(bounds)), round(NSMidY(bounds)) - offset);
@@ -162,27 +165,27 @@
case kPDFLineStyleNone:
break;
case kPDFLineStyleSquare:
- [path appendBezierPathWithRect:NSMakeRect(startPoint.x - 1.5 *
lineWidth, startPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
+ [path appendBezierPathWithRect:NSMakeRect(startPoint.x - 1.5 *
lw, startPoint.y - 1.5 * lw, 3 * lw, 3 * lw)];
break;
case kPDFLineStyleCircle:
- [path appendBezierPathWithOvalInRect:NSMakeRect(startPoint.x -
1.5 * lineWidth, startPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
+ [path appendBezierPathWithOvalInRect:NSMakeRect(startPoint.x -
1.5 * lw, startPoint.y - 1.5 * lw, 3 * lw, 3 * lw)];
break;
case kPDFLineStyleDiamond:
- [path moveToPoint:NSMakePoint(startPoint.x - 1.5 * lineWidth,
startPoint.y)];
- [path lineToPoint:NSMakePoint(startPoint.x, startPoint.y +
1.5 * lineWidth)];
- [path lineToPoint:NSMakePoint(startPoint.x + 1.5 * lineWidth,
startPoint.y)];
- [path lineToPoint:NSMakePoint(startPoint.x, startPoint.y -
1.5 * lineWidth)];
+ [path moveToPoint:NSMakePoint(startPoint.x - 1.5 * lw,
startPoint.y)];
+ [path lineToPoint:NSMakePoint(startPoint.x, startPoint.y +
1.5 * lw)];
+ [path lineToPoint:NSMakePoint(startPoint.x + 1.5 * lw,
startPoint.y)];
+ [path lineToPoint:NSMakePoint(startPoint.x, startPoint.y -
1.5 * lw)];
[path closePath];
break;
case kPDFLineStyleOpenArrow:
- [path moveToPoint:NSMakePoint(startPoint.x + 3.0 * lineWidth,
startPoint.y - 1.5 * lineWidth)];
+ [path moveToPoint:NSMakePoint(startPoint.x + 3.0 * lw,
startPoint.y - 1.5 * lw)];
[path lineToPoint:NSMakePoint(startPoint.x, startPoint.y)];
- [path lineToPoint:NSMakePoint(startPoint.x + 3.0 * lineWidth,
startPoint.y + 1.5 * lineWidth)];
+ [path lineToPoint:NSMakePoint(startPoint.x + 3.0 * lw,
startPoint.y + 1.5 * lw)];
break;
case kPDFLineStyleClosedArrow:
- [path moveToPoint:NSMakePoint(startPoint.x + 3.0 * lineWidth,
startPoint.y - 1.5 * lineWidth)];
+ [path moveToPoint:NSMakePoint(startPoint.x + 3.0 * lw,
startPoint.y - 1.5 * lw)];
[path lineToPoint:NSMakePoint(startPoint.x, startPoint.y)];
- [path lineToPoint:NSMakePoint(startPoint.x + 3.0 * lineWidth,
startPoint.y + 1.5 * lineWidth)];
+ [path lineToPoint:NSMakePoint(startPoint.x + 3.0 * lw,
startPoint.y + 1.5 * lw)];
[path closePath];
break;
}
@@ -194,43 +197,43 @@
case kPDFLineStyleNone:
break;
case kPDFLineStyleSquare:
- [path appendBezierPathWithRect:NSMakeRect(endPoint.x - 1.5 *
lineWidth, endPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
+ [path appendBezierPathWithRect:NSMakeRect(endPoint.x - 1.5 *
lw, endPoint.y - 1.5 * lw, 3 * lw, 3 * lw)];
break;
case kPDFLineStyleCircle:
- [path appendBezierPathWithOvalInRect:NSMakeRect(endPoint.x -
1.5 * lineWidth, endPoint.y - 1.5 * lineWidth, 3 * lineWidth, 3 * lineWidth)];
+ [path appendBezierPathWithOvalInRect:NSMakeRect(endPoint.x -
1.5 * lw, endPoint.y - 1.5 * lw, 3 * lw, 3 * lw)];
break;
case kPDFLineStyleDiamond:
- [path moveToPoint:NSMakePoint(endPoint.x + 1.5 * lineWidth,
endPoint.y)];
- [path lineToPoint:NSMakePoint(endPoint.x, endPoint.y + 1.5 *
lineWidth)];
- [path lineToPoint:NSMakePoint(endPoint.x - 1.5 * lineWidth,
endPoint.y)];
- [path lineToPoint:NSMakePoint(endPoint.x, endPoint.y - 1.5 *
lineWidth)];
+ [path moveToPoint:NSMakePoint(endPoint.x + 1.5 * lw,
endPoint.y)];
+ [path lineToPoint:NSMakePoint(endPoint.x, endPoint.y + 1.5 *
lw)];
+ [path lineToPoint:NSMakePoint(endPoint.x - 1.5 * lw,
endPoint.y)];
+ [path lineToPoint:NSMakePoint(endPoint.x, endPoint.y - 1.5 *
lw)];
[path closePath];
break;
case kPDFLineStyleOpenArrow:
- [path moveToPoint:NSMakePoint(endPoint.x - 3.0 * lineWidth,
endPoint.y + 1.5 * lineWidth)];
+ [path moveToPoint:NSMakePoint(endPoint.x - 3.0 * lw,
endPoint.y + 1.5 * lw)];
[path lineToPoint:NSMakePoint(endPoint.x, endPoint.y)];
- [path lineToPoint:NSMakePoint(endPoint.x - 3.0 * lineWidth,
endPoint.y - 1.5 * lineWidth)];
+ [path lineToPoint:NSMakePoint(endPoint.x - 3.0 * lw,
endPoint.y - 1.5 * lw)];
break;
case kPDFLineStyleClosedArrow:
- [path moveToPoint:NSMakePoint(endPoint.x - 3.0 * lineWidth,
endPoint.y + 1.5 * lineWidth)];
+ [path moveToPoint:NSMakePoint(endPoint.x - 3.0 * lw,
endPoint.y + 1.5 * lw)];
[path lineToPoint:NSMakePoint(endPoint.x, endPoint.y)];
- [path lineToPoint:NSMakePoint(endPoint.x - 3.0 * lineWidth,
endPoint.y - 1.5 * lineWidth)];
+ [path lineToPoint:NSMakePoint(endPoint.x - 3.0 * lw,
endPoint.y - 1.5 * lw)];
[path closePath];
break;
}
} else if ([self displayStyle] == SKLineWellDisplayStyleSimpleLine) {
- CGFloat offset = 0.5 * lineWidth - floor(0.5 * lineWidth);
+ CGFloat offset = 0.5 * lw - floor(0.5 * lw);
[path moveToPoint:NSMakePoint(NSMinX(bounds) + ceil(0.5 *
NSHeight(bounds)), round(NSMidY(bounds)) - offset)];
[path lineToPoint:NSMakePoint(NSMaxX(bounds) - ceil(0.5 *
NSHeight(bounds)), round(NSMidY(bounds)) - offset)];
} else if ([self displayStyle] == SKLineWellDisplayStyleRectangle) {
- CGFloat inset = 7.0 + 0.5 * lineWidth;
+ CGFloat inset = 7.0 + 0.5 * lw;
[path appendBezierPathWithRect:NSInsetRect(bounds, inset, inset)];
} else {
- CGFloat inset = 7.0 + 0.5 * lineWidth;
+ CGFloat inset = 7.0 + 0.5 * lw;
[path appendBezierPathWithOvalInRect:NSInsetRect(bounds, inset,
inset)];
}
- [path setLineWidth:lineWidth];
+ [path setLineWidth:lw];
if (style == kPDFBorderStyleDashed)
[path setDashPattern:dashPattern];
@@ -470,6 +473,17 @@
}
}
+- (BOOL)usePixelUnit {
+ return lwFlags.usePixelUnit;
+}
+
+- (void)setUsePixelUnit:(BOOL)flag {
+ if (lwFlags.usePixelUnit != flag) {
+ lwFlags.usePixelUnit = flag;
+ [self setNeedsDisplay:YES];
+ }
+}
+
- (void)setLineWidth:(CGFloat)width {
if (fabs(lineWidth - width) > 0.00001) {
lineWidth = width;
Modified: trunk/SKNotesPreferences.m
===================================================================
--- trunk/SKNotesPreferences.m 2024-02-20 10:06:56 UTC (rev 14063)
+++ trunk/SKNotesPreferences.m 2024-02-20 10:31:53 UTC (rev 14064)
@@ -68,6 +68,7 @@
NSUserDefaultsController *sudc = [NSUserDefaultsController
sharedUserDefaultsController];
BIND_LINE_WELL(textLineWell, FreeText, SKLineWellDisplayStyleRectangle);
+ [textLineWell setUsePixelUnit:YES];
BIND_LINE_WELL(circleLineWell, Circle, SKLineWellDisplayStyleOval);
BIND_LINE_WELL(squareLineWell, Square, SKLineWellDisplayStyleRectangle);
BIND_LINE_WELL(lineLineWell, Line, SKLineWellDisplayStyleLine);
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