Revision: 13572
http://sourceforge.net/p/skim-app/code/13572
Author: hofman
Date: 2023-08-13 09:20:46 +0000 (Sun, 13 Aug 2023)
Log Message:
-----------
Add sticky setting to draw temporary ink note in presentation. Add temporary
undoManager in presentation, so temporary drawing does not affect the document.
Add button in cursor window to change drawing option. Use segmented controls in
cusor window.
Modified Paths:
--------------
trunk/SKMainWindowController_UI.m
trunk/SKNavigationWindow.h
trunk/SKNavigationWindow.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2023-08-12 10:09:39 UTC (rev 13571)
+++ trunk/SKMainWindowController_UI.m 2023-08-13 09:20:46 UTC (rev 13572)
@@ -312,6 +312,12 @@
return fieldEditor;
}
+- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)sender {
+ if ([self interactionMode] == SKPresentationMode)
+ return [pdfView undoManager];
+ return nil;
+}
+
- (void)window:(NSWindow *)sender willSendEvent:(NSEvent *)event {
[[SKImageToolTipWindow sharedToolTipWindow] orderOut:nil];
Modified: trunk/SKNavigationWindow.h
===================================================================
--- trunk/SKNavigationWindow.h 2023-08-12 10:09:39 UTC (rev 13571)
+++ trunk/SKNavigationWindow.h 2023-08-13 09:20:46 UTC (rev 13572)
@@ -62,7 +62,8 @@
@interface SKCursorStyleWindow : SKHUDWindow {
NSSegmentedControl *styleButton;
- NSButton *removeShadowButton;
+ NSSegmentedControl *removeShadowButton;
+ NSSegmentedControl *drawButton;
NSButton *closeButton;
}
- (void)selectCursorStyle:(NSInteger)style;
@@ -113,9 +114,9 @@
@end
-@interface SKStyleSegmentedControl : NSSegmentedControl
+@interface SKHUDSegmentedControl : NSSegmentedControl
@end
-@interface SKStyleSegmentedCell : NSSegmentedCell
+@interface SKHUDSegmentedCell : NSSegmentedCell
@end
Modified: trunk/SKNavigationWindow.m
===================================================================
--- trunk/SKNavigationWindow.m 2023-08-12 10:09:39 UTC (rev 13571)
+++ trunk/SKNavigationWindow.m 2023-08-13 09:20:46 UTC (rev 13572)
@@ -52,6 +52,7 @@
#define BUTTON_HEIGHT 50.0
#define SLIDER_WIDTH 100.0
#define SEP_WIDTH 21.0
+#define SMALL_SEP_WIDTH 7.0
#define BUTTON_MARGIN 7.0
#define WINDOW_OFFSET 20.0
#define LABEL_OFFSET 10.0
@@ -88,7 +89,6 @@
[contentView setMaterial:RUNNING_BEFORE(10_14) ?
NSVisualEffectMaterialDark : NSVisualEffectMaterialFullScreenUI];
#pragma clang diagnostic pop
[contentView setState:NSVisualEffectStateActive];
- [contentView setMaskImage:[NSImage maskImageWithSize:contentRect.size
cornerRadius:CORNER_RADIUS]];
[self setContentView:contentView];
[contentView release];
@@ -203,6 +203,15 @@
[closeButton setToolTip:NSLocalizedString(@"Close", @"Tool tip
message")];
[closeButton setPath:closeButtonPath(rect.size)];
[[self contentView] addSubview:closeButton];
+
+ NSScreen *screen = [[pdfView window] screen] ?: [NSScreen mainScreen];
+ NSRect frame;
+ frame.size.width = 5 * BUTTON_WIDTH + 3 * SEP_WIDTH + 2 *
BUTTON_MARGIN;
+ frame.size.height = BUTTON_HEIGHT + 2.0 * BUTTON_MARGIN;
+ frame.origin.x = NSMidX([screen frame]) - 0.5 * NSWidth(frame);
+ frame.origin.y = NSMinY([screen frame]) + WINDOW_OFFSET;
+ [self setFrame:frame display:NO];
+ [(NSVisualEffectView *)[self contentView] setMaskImage:[NSImage
maskImageWithSize:frame.size cornerRadius:CORNER_RADIUS]];
}
return self;
}
@@ -251,7 +260,7 @@
NSRect rect;
- styleButton = [[SKStyleSegmentedControl alloc] init];
+ styleButton = [[SKHUDSegmentedControl alloc] init];
[styleButton setSegmentCount:8];
[styleButton setTrackingMode:NSSegmentSwitchTrackingSelectOne];
NSInteger i;
@@ -281,15 +290,12 @@
[[self contentView] addSubview:styleButton];
rect.origin.x = NSMaxX(rect);
- rect.size.width = SEP_WIDTH;
- [[self contentView] addSubview:[[[SKNavigationSeparator alloc]
initWithFrame:rect] autorelease]];
-
- rect.origin.x = NSMaxX(rect);
rect.size.width = NSHeight(rect);
- removeShadowButton = [[NSButton alloc] initWithFrame:rect];
- [removeShadowButton setButtonType:NSSwitchButton];
- [removeShadowButton setTitle:NSLocalizedString(@"Remove shadow",
@"Button title")];
- [removeShadowButton setState:[pdfView removeCursorShadow] ? NSOnState
: NSOffState];
+ removeShadowButton = [[SKHUDSegmentedControl alloc]
initWithFrame:rect];
+ [removeShadowButton setSegmentCount:1];
+ [removeShadowButton setTrackingMode:NSSegmentSwitchTrackingSelectAny];
+ [removeShadowButton setLabel:NSLocalizedString(@"Remove shadow",
@"Button title") forSegment:0];
+ [removeShadowButton setSelected:[pdfView removeCursorShadow]
forSegment:0];
[removeShadowButton setTarget:pdfView];
[removeShadowButton setAction:@selector(toggleRemoveCursorShadow:)];
if (RUNNING_BEFORE(10_14))
@@ -296,14 +302,33 @@
[[removeShadowButton cell]
setBackgroundStyle:NSBackgroundStyleDark];
[removeShadowButton sizeToFit];
rect.size.width = NSWidth([removeShadowButton frame]);
- [removeShadowButton setFrameOrigin:NSMakePoint(NSMinX(rect),
NSMidY(rect) - 0.5 * NSHeight([removeShadowButton frame]))];
[[self contentView] addSubview:removeShadowButton];
+ rect.origin.x = NSMaxX(rect) - SMALL_SEP_WIDTH;
+ rect.size.width = SMALL_SEP_WIDTH;
+ [[self contentView] addSubview:[[[SKNavigationSeparator alloc]
initWithFrame:rect] autorelease]];
+
+ rect.origin.x = NSMaxX(rect) + SMALL_SEP_WIDTH;
+ rect.size.width = NSHeight(rect);
+ drawButton = [[SKHUDSegmentedControl alloc] initWithFrame:rect];
+ [drawButton setSegmentCount:1];
+ [drawButton setTrackingMode:NSSegmentSwitchTrackingSelectAny];
+ [drawButton setWidth:24.0 forSegment:0];
+ [drawButton setImage:[NSImage imageNamed:SKImageNameInkNote]
forSegment:0];
+ [drawButton setSelected:[pdfView drawInPresentation] forSegment:0];
+ [drawButton setTarget:pdfView];
+ [drawButton setAction:@selector(toggleDrawInPresentation:)];
+ if (RUNNING_BEFORE(10_14))
+ [[drawButton cell] setBackgroundStyle:NSBackgroundStyleDark];
+ [drawButton sizeToFit];
+ rect.size.width = NSWidth([drawButton frame]);
+ [[self contentView] addSubview:drawButton];
+
rect.origin.x = NSMaxX(rect);
- rect.size.width = SEP_WIDTH;
+ rect.size.width = SMALL_SEP_WIDTH;
[[self contentView] addSubview:[[[SKNavigationSeparator alloc]
initWithFrame:rect] autorelease]];
- rect.origin.x = NSMaxX(rect);
+ rect.origin.x = NSMaxX(rect) + SMALL_SEP_WIDTH;
rect.size.width = NSHeight(rect);
closeButton = [[NSButton alloc] initWithFrame:rect];
[closeButton setBordered:NO];
@@ -317,7 +342,7 @@
NSScreen *screen = [[pdfView window] screen] ?: [NSScreen mainScreen];
NSRect frame;
- frame.size.width = NSWidth([styleButton frame]) +
NSWidth([removeShadowButton frame]) + NSHeight(rect) + 2.0 * BUTTON_MARGIN +
2.0 * SEP_WIDTH;
+ frame.size.width = NSWidth([styleButton frame]) +
NSWidth([removeShadowButton frame]) + NSWidth([drawButton frame]) +
NSHeight(rect) + 2.0 * BUTTON_MARGIN + 3.0 * SMALL_SEP_WIDTH;
frame.size.height = NSHeight(rect) + 2.0 * BUTTON_MARGIN;
frame.origin.x = NSMidX([screen frame]) - 0.5 * NSWidth(frame);
frame.origin.y = NSMinY([screen frame]) + WINDOW_OFFSET;
@@ -330,6 +355,7 @@
- (void)dealloc {
SKDESTROY(styleButton);
SKDESTROY(removeShadowButton);
+ SKDESTROY(drawButton);
SKDESTROY(closeButton);
[super dealloc];
}
@@ -339,7 +365,7 @@
}
- (void)removeShadow:(BOOL)removeShadow {
- [removeShadowButton setState:removeShadow ? NSOnState : NSOffState];
+ [removeShadowButton setSelected:removeShadow forSegment:0];
}
@end
@@ -630,9 +656,9 @@
#pragma mark -
-@implementation SKStyleSegmentedControl
+@implementation SKHUDSegmentedControl
-+ (Class)cellClass { return [SKStyleSegmentedCell class]; }
++ (Class)cellClass { return [SKHUDSegmentedCell class]; }
- (BOOL)allowsVibrancy { return NO; }
@@ -640,7 +666,7 @@
#pragma mark -
-@implementation SKStyleSegmentedCell
+@implementation SKHUDSegmentedCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
[self drawInteriorWithFrame:cellFrame inView:controlView];
@@ -647,7 +673,7 @@
}
- (void)drawSegment:(NSInteger)segment inFrame:(NSRect)frame withView:(NSView
*)controlView {
- if ([(NSSegmentedControl *)[self controlView] selectedSegment] == segment)
{
+ if ([self isSelectedForSegment:segment]) {
NSRect rect = frame;
rect.size.width -= 1.0;
rect.size.height -= 1.0;
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2023-08-12 10:09:39 UTC (rev 13571)
+++ trunk/SKPDFView.h 2023-08-13 09:20:46 UTC (rev 13572)
@@ -143,6 +143,7 @@
PDFAnnotation *highlightAnnotation;
NSMutableArray *temporaryAnnotations;
+ NSUndoManager *temporaryUndoManager;
SKTextNoteEditor *editor;
@@ -175,6 +176,7 @@
unsigned int cursorHidden:1;
unsigned int useArrowCursorInPresentation:1;
unsigned int removeLaserPointerShadow:1;
+ unsigned int drawInPresentation:1;
} pdfvFlags;
}
@@ -233,6 +235,8 @@
- (void)changeCursorStyle:(id)sender;
- (BOOL)removeCursorShadow;
- (void)toggleRemoveCursorShadow:(id)sender;
+- (BOOL)drawInPresentation;
+- (void)toggleDrawInPresentation:(id)sender;
- (void)addAnnotationForContext:(id)sender;
- (void)addAnnotationWithType:(SKNoteType)annotationType;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2023-08-12 10:09:39 UTC (rev 13571)
+++ trunk/SKPDFView.m 2023-08-13 09:20:46 UTC (rev 13572)
@@ -142,6 +142,7 @@
#define SKUseArrowCursorInPresentationKey @"SKUseArrowCursorInPresentation"
#define SKLaserPointerColorKey @"SKLaserPointerColor"
#define SKRemoveLaserPointerShadowKey @"SKRemoveLaserPointerShadows"
+#define SKDisableDrawingInPresentationKey @"SKDisableDrawingInPresentation"
#define SKAnnotationKey @"SKAnnotation"
@@ -316,6 +317,7 @@
pdfvFlags.cursorHidden = 0;
pdfvFlags.useArrowCursorInPresentation = [[NSUserDefaults
standardUserDefaults] boolForKey:SKUseArrowCursorInPresentationKey];
pdfvFlags.removeLaserPointerShadow = [[NSUserDefaults
standardUserDefaults] boolForKey:SKRemoveLaserPointerShadowKey];
+ pdfvFlags.drawInPresentation = NO == [[NSUserDefaults
standardUserDefaults] boolForKey:SKDisableDrawingInPresentationKey];
inKeyWindow = NO;
laserPointerColor = [[NSUserDefaults standardUserDefaults]
integerForKey:SKLaserPointerColorKey];
@@ -378,6 +380,7 @@
SKDESTROY(syncDot);
SKDESTROY(currentAnnotation);
SKDESTROY(temporaryAnnotations);
+ SKDESTROY(temporaryUndoManager);
SKDESTROY(typeSelectHelper);
SKDESTROY(transitionController);
SKDESTROY(navWindow);
@@ -659,6 +662,11 @@
}
- (NSUndoManager *)undoManager {
+ if (interactionMode == SKPresentationMode) {
+ if (temporaryUndoManager == nil)
+ temporaryUndoManager = [[NSUndoManager alloc] init];
+ return temporaryUndoManager;
+ }
NSUndoManager *undoManager = [super undoManager];
if (undoManager == nil && [[self delegate]
respondsToSelector:@selector(document)])
undoManager = [[(NSWindowController *)[self delegate] document]
undoManager];
@@ -739,6 +747,7 @@
[self annotationsChangedOnPage:page];
}
SKDESTROY(temporaryAnnotations);
+ SKDESTROY(temporaryUndoManager);
}
}
interactionMode = newInteractionMode;
@@ -1954,7 +1963,7 @@
} else if (([[self window] styleMask] & NSWindowStyleMaskResizable) !=
0 && NSEqualRects([[self window] frame], [[[self window] screen] frame]) == NO
&& [NSApp willDragMouse]) {
[[NSCursor closedHandCursor] set];
[self doDragWindowWithEvent:theEvent];
- } else if ([NSApp willDragMouse]) {
+ } else if (pdfvFlags.drawInPresentation && [NSApp willDragMouse]) {
[[NSCursor arrowCursor] set];
[self doDrawFreehandNoteWithEvent:theEvent];
[self setCurrentAnnotation:nil];
@@ -2934,6 +2943,29 @@
[oldPage release];
}
+- (void)addTemporaryAnnotation:(PDFAnnotation *)annotation toPage:(PDFPage
*)page {
+ [[[self undoManager] prepareWithInvocationTarget:self]
removeTemporaryAnnotation:annotation];
+ if (temporaryAnnotations == nil)
+ temporaryAnnotations = [[NSMutableArray alloc] init];
+ [temporaryAnnotations addObject:annotation];
+ [page addAnnotation:annotation];
+ [self setNeedsDisplayForAnnotation:annotation];
+ [self annotationsChangedOnPage:page];
+}
+
+- (void)removeTemporaryAnnotation:(PDFAnnotation *)annotation {
+ PDFAnnotation *wasAnnotation = [annotation retain];
+ PDFPage *page = [[wasAnnotation page] retain];
+
+ [[[self undoManager] prepareWithInvocationTarget:self]
addTemporaryAnnotation:wasAnnotation toPage:page];
+ [self setNeedsDisplayForAnnotation:wasAnnotation];
+ [temporaryAnnotations removeObject:annotation];
+ [page removeAnnotation:wasAnnotation];
+ [self annotationsChangedOnPage:page];
+ [wasAnnotation release];
+ [page release];
+}
+
- (void)editThisAnnotation:(id)sender {
[self editAnnotation:[sender representedObject]];
}
@@ -3591,6 +3623,15 @@
[[NSUserDefaults standardUserDefaults]
setBool:pdfvFlags.removeLaserPointerShadow
forKey:SKRemoveLaserPointerShadowKey];
}
+- (BOOL)drawInPresentation {
+ return pdfvFlags.removeLaserPointerShadow;
+}
+
+- (void)toggleDrawInPresentation:(id)sender {
+ pdfvFlags.drawInPresentation = pdfvFlags.drawInPresentation == NO;
+ [[NSUserDefaults standardUserDefaults] setBool:NO ==
pdfvFlags.drawInPresentation forKey:SKDisableDrawingInPresentationKey];
+}
+
#pragma mark Event handling
- (void)doMoveCurrentAnnotationForKey:(unichar)eventChar
byAmount:(CGFloat)delta {
@@ -4580,12 +4621,7 @@
[self addAnnotation:annotation toPage:page];
[[self undoManager] setActionName:NSLocalizedString(@"Add Note",
@"Undo action name")];
} else {
- if (temporaryAnnotations == nil)
- temporaryAnnotations = [[NSMutableArray alloc] init];
- [temporaryAnnotations addObject:annotation];
- [page addAnnotation:annotation];
- [self setNeedsDisplayForAnnotation:annotation];
- [self annotationsChangedOnPage:page];
+ [self addTemporaryAnnotation:annotation toPage:page];
}
[paths release];
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