Revision: 12501 http://sourceforge.net/p/skim-app/code/12501 Author: hofman Date: 2021-11-01 15:59:28 +0000 (Mon, 01 Nov 2021) Log Message: ----------- Use image view to indicate whether snapshot window is open
Modified Paths: -------------- trunk/NSValueTransformer_SKExtensions.h trunk/NSValueTransformer_SKExtensions.m trunk/RightSideView.xib trunk/SKSnapshotWindowController.h trunk/SKSnapshotWindowController.m Modified: trunk/NSValueTransformer_SKExtensions.h =================================================================== --- trunk/NSValueTransformer_SKExtensions.h 2021-11-01 15:19:08 UTC (rev 12500) +++ trunk/NSValueTransformer_SKExtensions.h 2021-11-01 15:59:28 UTC (rev 12501) @@ -41,6 +41,7 @@ extern NSString *SKUnarchiveColorTransformerName; extern NSString *SKUnarchiveColorArrayTransformerName; extern NSString *SKTypeImageTransformerName; +extern NSString *SKHasWindowImageTransformerName; extern NSString *SKIsZeroTransformerName; extern NSString *SKIsOneTransformerName; extern NSString *SKIsTwoTransformerName; Modified: trunk/NSValueTransformer_SKExtensions.m =================================================================== --- trunk/NSValueTransformer_SKExtensions.m 2021-11-01 15:19:08 UTC (rev 12500) +++ trunk/NSValueTransformer_SKExtensions.m 2021-11-01 15:59:28 UTC (rev 12501) @@ -43,6 +43,7 @@ NSString *SKUnarchiveColorTransformerName = @"SKUnarchiveColor"; NSString *SKUnarchiveColorArrayTransformerName = @"SKUnarchiveArrayColor"; NSString *SKTypeImageTransformerName = @"SKTypeImage"; +NSString *SKHasWindowImageTransformerName = @"SKHasWindowImage"; NSString *SKIsZeroTransformerName = @"SKIsZero"; NSString *SKIsOneTransformerName = @"SKIsOne"; NSString *SKIsTwoTransformerName = @"SKIsTwo"; @@ -62,6 +63,11 @@ #pragma mark - +@interface SKHasWindowImageTransformer : NSValueTransformer +@end + +#pragma mark - + @interface SKRadioTransformer : NSValueTransformer { NSInteger targetValue; } @@ -76,6 +82,7 @@ [NSValueTransformer setValueTransformer:[[[SKUnarchiveColorTransformer alloc] init] autorelease] forName:SKUnarchiveColorTransformerName]; [NSValueTransformer setValueTransformer:[[[SKUnarchiveColorArrayTransformer alloc] init] autorelease] forName:SKUnarchiveColorArrayTransformerName]; [NSValueTransformer setValueTransformer:[[[SKTypeImageTransformer alloc] init] autorelease] forName:SKTypeImageTransformerName]; + [NSValueTransformer setValueTransformer:[[[SKHasWindowImageTransformer alloc] init] autorelease] forName:SKHasWindowImageTransformerName]; [NSValueTransformer setValueTransformer:[[[SKRadioTransformer alloc] initWithTargetValue:0] autorelease] forName:SKIsZeroTransformerName]; [NSValueTransformer setValueTransformer:[[[SKRadioTransformer alloc] initWithTargetValue:1] autorelease] forName:SKIsOneTransformerName]; [NSValueTransformer setValueTransformer:[[[SKRadioTransformer alloc] initWithTargetValue:2] autorelease] forName:SKIsTwoTransformerName]; @@ -187,6 +194,44 @@ #pragma mark - +@implementation SKHasWindowImageTransformer + ++ (Class)transformedValueClass { + return [NSImage class]; +} + ++ (BOOL)allowsReverseTransformation { + return NO; +} + +- (id)transformedValue:(id)hasWindow { + if ([hasWindow boolValue]) { + static NSImage *windowImage = nil; + if (windowImage == nil) { + windowImage = [[NSImage imageWithSize:NSMakeSize(12.0, 12.0) flipped:NO drawingHandler:^(NSRect dstRect){ + NSBezierPath *path = [NSBezierPath bezierPath]; + [path moveToPoint:NSMakePoint(1.0, 2.0)]; + [path appendBezierPathWithArcWithCenter:NSMakePoint(3.0, 10.0) radius:2.0 startAngle:180.0 endAngle:90.0 clockwise:YES]; + [path appendBezierPathWithArcWithCenter:NSMakePoint(9.0, 10.0) radius:2.0 startAngle:90.0 endAngle:0.0 clockwise:YES]; + [path lineToPoint:NSMakePoint(11.0, 2.0)]; + [path closePath]; + [path appendBezierPath:[NSBezierPath bezierPathWithRect:NSMakeRect(2.0, 3.0, 8.0, 7.0)]]; + [path setWindingRule:NSEvenOddWindingRule]; + [[NSColor blackColor] setFill]; + [path fill]; + return YES; + }] retain]; + [windowImage setTemplate:YES]; + } + return windowImage; + } + return nil; +} + +@end + +#pragma mark - + @implementation SKRadioTransformer + (Class)transformedValueClass { Modified: trunk/RightSideView.xib =================================================================== --- trunk/RightSideView.xib 2021-11-01 15:19:08 UTC (rev 12500) +++ trunk/RightSideView.xib 2021-11-01 15:59:28 UTC (rev 12501) @@ -113,7 +113,7 @@ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView translatesAutoresizingMaskIntoConstraints="NO" id="ZGN-Pg-55C"> - <rect key="frame" x="11" y="1" width="93" height="15"/> + <rect key="frame" x="0.0" y="0.0" width="93" height="15"/> <subviews> <textField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" preferredMaxLayoutWidth="122" translatesAutoresizingMaskIntoConstraints="NO" id="T6H-tX-biW"> <rect key="frame" x="0.0" y="0.0" width="93" height="15"/> @@ -152,7 +152,7 @@ <imageCell key="dataCell" refusesFirstResponder="YES" alignment="left" animates="YES" id="38" customClass="SKAnnotationTypeImageCell"/> <prototypeCellViews> <tableCellView translatesAutoresizingMaskIntoConstraints="NO" id="dka-Zp-1o0"> - <rect key="frame" x="107" y="1" width="21" height="17"/> + <rect key="frame" x="0.0" y="0.0" width="21" height="17"/> <subviews> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Wy1-6F-s9I" customClass="SKAnnotationTypeImageView"> <rect key="frame" x="0.0" y="0.0" width="21" height="17"/> @@ -190,7 +190,7 @@ </customCell> <prototypeCellViews> <tableCellView translatesAutoresizingMaskIntoConstraints="NO" id="qmc-ew-Bi0"> - <rect key="frame" x="1" y="1" width="0.0" height="17"/> + <rect key="frame" x="0.0" y="0.0" width="0.0" height="17"/> <subviews> <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="bUx-hD-kOV" customClass="SKColorView"> <rect key="frame" x="0.0" y="0.0" width="0.0" height="17"/> @@ -224,7 +224,7 @@ </textFieldCell> <prototypeCellViews> <tableCellView translatesAutoresizingMaskIntoConstraints="NO" id="rnK-rN-FoS"> - <rect key="frame" x="131" y="1" width="46" height="17"/> + <rect key="frame" x="0.0" y="0.0" width="46" height="17"/> <subviews> <textField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="iuK-OP-ap6"> <rect key="frame" x="0.0" y="1" width="46" height="15"/> @@ -262,7 +262,7 @@ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView translatesAutoresizingMaskIntoConstraints="NO" id="I4N-kX-XRY"> - <rect key="frame" x="1" y="1" width="0.0" height="17"/> + <rect key="frame" x="0.0" y="0.0" width="0.0" height="17"/> <subviews> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="C5T-Ik-oBo"> <rect key="frame" x="0.0" y="1" width="4" height="15"/> @@ -301,7 +301,7 @@ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView translatesAutoresizingMaskIntoConstraints="NO" id="pRJ-Qg-L6f"> - <rect key="frame" x="1" y="1" width="0.0" height="17"/> + <rect key="frame" x="0.0" y="0.0" width="0.0" height="17"/> <subviews> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="dIJ-ix-es0"> <rect key="frame" x="0.0" y="1" width="4" height="16"/> @@ -398,7 +398,7 @@ <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/> </tableHeaderCell> - <textFieldCell key="dataCell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" alignment="right" id="17" customClass="SKSnapshotPageCell"> + <textFieldCell key="dataCell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" alignment="right" id="17"> <font key="font" metaFont="cellTitle"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> @@ -408,25 +408,38 @@ <tableCellView translatesAutoresizingMaskIntoConstraints="NO" id="EU8-lX-Lad"> <rect key="frame" x="141" y="1" width="36" height="15"/> <subviews> - <textField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="r6v-xw-N5B"> + <textField horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="r6v-xw-N5B"> <rect key="frame" x="0.0" y="0.0" width="36" height="15"/> - <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" id="dwa-9x-zmD" customClass="SKSnapshotPageCell"> + <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" id="dwa-9x-zmD"> <font key="font" metaFont="cellTitle"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <binding destination="EU8-lX-Lad" name="value" keyPath="objectValue.pageAndWindow" id="trt-hs-DrI"/> + <binding destination="EU8-lX-Lad" name="value" keyPath="objectValue.pageLabel" id="eEq-wq-iac"/> </connections> </textField> + <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="yPF-xB-g7l"> + <rect key="frame" x="1" y="-1" width="0.0" height="0.0"/> + <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="rMQ-wW-cJx"/> + <connections> + <binding destination="EU8-lX-Lad" name="value" keyPath="objectValue.hasWindow" id="cVt-gk-MFY"> + <dictionary key="options"> + <string key="NSValueTransformerName">SKHasWindowImage</string> + </dictionary> + </binding> + </connections> + </imageView> </subviews> <constraints> <constraint firstAttribute="trailing" secondItem="r6v-xw-N5B" secondAttribute="trailing" constant="2" id="70B-Rx-FDy"/> <constraint firstItem="r6v-xw-N5B" firstAttribute="top" secondItem="EU8-lX-Lad" secondAttribute="top" id="Oi3-fK-0Ym"/> - <constraint firstAttribute="bottom" secondItem="r6v-xw-N5B" secondAttribute="bottom" id="dhj-Bv-oMZ"/> <constraint firstItem="r6v-xw-N5B" firstAttribute="leading" secondItem="EU8-lX-Lad" secondAttribute="leading" constant="2" id="i2r-tu-Hlq"/> + <constraint firstItem="yPF-xB-g7l" firstAttribute="leading" secondItem="EU8-lX-Lad" secondAttribute="leading" constant="1" id="jSB-NQ-Ogi"/> + <constraint firstItem="yPF-xB-g7l" firstAttribute="top" secondItem="r6v-xw-N5B" secondAttribute="bottom" constant="1" id="o6n-cl-l52"/> </constraints> <connections> + <outlet property="imageView" destination="yPF-xB-g7l" id="ZG4-UV-DUP"/> <outlet property="textField" destination="r6v-xw-N5B" id="P4G-Jw-Q4d"/> </connections> </tableCellView> Modified: trunk/SKSnapshotWindowController.h =================================================================== --- trunk/SKSnapshotWindowController.h 2021-11-01 15:19:08 UTC (rev 12500) +++ trunk/SKSnapshotWindowController.h 2021-11-01 15:59:28 UTC (rev 12501) @@ -71,7 +71,6 @@ @property (nonatomic, readonly, copy) NSString *pageLabel; @property (nonatomic, copy) NSString *string; @property (nonatomic, readonly) BOOL hasWindow; -@property (nonatomic, readonly) NSDictionary *pageAndWindow; @property (nonatomic, readonly) NSDictionary *currentSetup; @property (nonatomic) BOOL forceOnTop; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2021-11-01 15:19:08 UTC (rev 12500) +++ trunk/SKSnapshotWindowController.m 2021-11-01 15:59:28 UTC (rev 12501) @@ -49,7 +49,6 @@ #import "NSUserDefaultsController_SKExtensions.h" #import "NSGeometry_SKExtensions.h" #import "PDFPage_SKExtensions.h" -#import "SKSnapshotPageCell.h" #import "PDFAnnotation_SKExtensions.h" #import "PDFView_SKExtensions.h" #import "NSUserDefaults_SKExtensions.h" @@ -79,7 +78,6 @@ #define WINDOWFRAME_KEY @"windowFrame" #define HASWINDOW_KEY @"hasWindow" #define PAGELABEL_KEY @"pageLabel" -#define PAGEANDWINDOW_KEY @"pageAndWindow" #define SKSnapshotWindowFrameAutosaveName @"SKSnapshotWindow" #define SKSnapshotViewChangedNotification @"SKSnapshotViewChangedNotification" @@ -95,15 +93,8 @@ @implementation SKSnapshotWindowController @synthesize pdfView, delegate, thumbnail, pageLabel, string, hasWindow, forceOnTop; -@dynamic bounds, pageIndex, pageAndWindow, currentSetup, thumbnailAttachment, thumbnail512Attachment, thumbnail256Attachment, thumbnail128Attachment, thumbnail64Attachment, thumbnail32Attachment; +@dynamic bounds, pageIndex, currentSetup, thumbnailAttachment, thumbnail512Attachment, thumbnail256Attachment, thumbnail128Attachment, thumbnail64Attachment, thumbnail32Attachment; -+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { - NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; - if ([key isEqualToString:PAGEANDWINDOW_KEY]) - keyPaths = [keyPaths setByAddingObjectsFromSet:[NSSet setWithObjects:PAGELABEL_KEY, HASWINDOW_KEY, nil]]; - return keyPaths; -} - - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver: self]; delegate = nil; @@ -402,10 +393,6 @@ } } -- (NSDictionary *)pageAndWindow { - return [NSDictionary dictionaryWithObjectsAndKeys:[self pageLabel], SKSnapshotPageCellLabelKey, [NSNumber numberWithBool:[self hasWindow]], SKSnapshotPageCellHasWindowKey, nil]; -} - - (void)setForceOnTop:(BOOL)flag { forceOnTop = flag; if ([[self window] isVisible]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit