Revision: 13022
          http://sourceforge.net/p/skim-app/code/13022
Author:   hofman
Date:     2022-07-15 14:19:12 +0000 (Fri, 15 Jul 2022)
Log Message:
-----------
Extend cell frame of outline column for note text to full width,rather than 
adding a separate cell view to the row view. This way it is included in the 
accessibility hierachy. Make sure the frame is set to the full width cell frame 
on 10.x, as I seem to remember AppKit does not always go through 
frameOfCellAtColumn:row: when updating the cell view frames.

Modified Paths:
--------------
    trunk/NotesDocument.xib
    trunk/RightSideView.xib
    trunk/SKMainWindowController_UI.m
    trunk/SKNoteOutlineView.m
    trunk/SKNoteTableRowView.h
    trunk/SKNoteTableRowView.m
    trunk/SKNotesDocument.m

Modified: trunk/NotesDocument.xib
===================================================================
--- trunk/NotesDocument.xib     2022-07-14 16:44:26 UTC (rev 13021)
+++ trunk/NotesDocument.xib     2022-07-15 14:19:12 UTC (rev 13022)
@@ -59,7 +59,7 @@
                                                     <rect key="frame" x="11" 
y="1" width="389" height="17"/>
                                                     <autoresizingMask 
key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                 </customView>
-                                                <tableCellView id="6Wp-hg-AAV">
+                                                <tableCellView id="6Wp-hg-AAV" 
customClass="SKNoteTableCellView">
                                                     <rect key="frame" x="11" 
y="20" width="389" height="17"/>
                                                     <autoresizingMask 
key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                                     <subviews>

Modified: trunk/RightSideView.xib
===================================================================
--- trunk/RightSideView.xib     2022-07-14 16:44:26 UTC (rev 13021)
+++ trunk/RightSideView.xib     2022-07-15 14:19:12 UTC (rev 13022)
@@ -110,7 +110,7 @@
                                 </textFieldCell>
                                 <tableColumnResizingMask key="resizingMask" 
resizeWithTable="YES" userResizable="YES"/>
                                 <prototypeCellViews>
-                                    <tableCellView id="ZGN-Pg-55C">
+                                    <tableCellView id="ZGN-Pg-55C" 
customClass="SKNoteTableCellView">
                                         <rect key="frame" x="11" y="1" 
width="93" height="15"/>
                                         <autoresizingMask 
key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
@@ -122,8 +122,17 @@
                                                     <color 
key="backgroundColor" name="controlColor" catalog="System" 
colorSpace="catalog"/>
                                                 </textFieldCell>
                                                 <connections>
-                                                    <binding 
destination="ZGN-Pg-55C" name="value" keyPath="objectValue.objectValue" 
id="dWq-ky-T1D"/>
+                                                    <binding 
destination="ZGN-Pg-55C" name="editable" keyPath="objectValue.type" 
id="d6c-t3-IzB">
+                                                        <dictionary 
key="options">
+                                                            <string 
key="NSValueTransformerName">NSIsNotNil</string>
+                                                        </dictionary>
+                                                    </binding>
                                                     <binding 
destination="ZGN-Pg-55C" name="toolTip" keyPath="objectValue.string" 
id="R78-BC-j6A"/>
+                                                    <binding 
destination="ZGN-Pg-55C" name="value" keyPath="objectValue.objectValue" 
id="Dhp-4I-hEo">
+                                                        <dictionary 
key="options">
+                                                            <bool 
key="NSConditionallySetsEditable" value="NO"/>
+                                                        </dictionary>
+                                                    </binding>
                                                 </connections>
                                             </textField>
                                         </subviews>
@@ -356,7 +365,7 @@
             <rect key="frame" x="0.0" y="0.0" width="200" height="400"/>
             <clipView key="contentView" drawsBackground="NO" 
translatesAutoresizingMaskIntoConstraints="NO" id="GlW-dx-lwj">
                 <rect key="frame" x="1" y="1" width="198" height="398"/>
-                <autoresizingMask key="autoresizingMask" widthSizable="YES" 
heightSizable="YES"/>
+                <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <tableView focusRingType="none" 
verticalHuggingPriority="750" allowsExpansionToolTips="YES" 
columnAutoresizingStyle="firstColumnOnly" columnReordering="NO" 
columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" 
rowHeight="32" viewBased="YES" translatesAutoresizingMaskIntoConstraints="NO" 
id="13" customClass="SKTableView">
                         <rect key="frame" x="0.0" y="0.0" width="198" 
height="398"/>

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2022-07-14 16:44:26 UTC (rev 13021)
+++ trunk/SKMainWindowController_UI.m   2022-07-15 14:19:12 UTC (rev 13022)
@@ -262,7 +262,6 @@
             [[pdfView document] cancelFindString];
         if ((mwcFlags.isEditingTable || [pdfView isEditing]) && [self 
commitEditing] == NO)
             [self discardEditing];
-        [rightSideController.noteOutlineView 
enumerateAvailableRowViewsUsingBlock:^(SKNoteTableRowView *rowView, NSInteger 
row){ [[rowView rowCellView] setObjectValue:nil]; }];
         [self cleanup]; // clean up everything
     }
 }
@@ -728,7 +727,7 @@
     if ([ov isEqual:leftSideController.tocOutlineView]) {
         return [ov makeViewWithIdentifier:[tableColumn identifier] owner:self];
     } else if ([ov isEqual:rightSideController.noteOutlineView]) {
-        if ([(PDFAnnotation *)item type]) {
+        if ([(PDFAnnotation *)item type] || tableColumn == [ov 
outlineTableColumn]) {
             NSTableCellView *view = [ov makeViewWithIdentifier:[tableColumn 
identifier] owner:self];
             if ([[tableColumn identifier] isEqualToString:TYPE_COLUMNID])
                 [(SKAnnotationTypeImageView *)[view imageView] 
setHasOutline:[pdfView activeAnnotation] == item];
@@ -750,38 +749,6 @@
     return nil;
 }
 
-- (void)outlineView:(NSOutlineView *)ov didAddRowView:(NSTableRowView 
*)rowView forRow:(NSInteger)row {
-    if ([ov isEqual:rightSideController.noteOutlineView]) {
-        SKNoteTableRowView *noteRowView = [rowView 
isKindOfClass:[SKNoteTableRowView class]] ? (SKNoteTableRowView *)rowView : nil;
-        id item = [ov itemAtRow:row];
-        if ([(PDFAnnotation *)item type] == nil) {
-            NSTableCellView *view = [ov makeViewWithIdentifier:NOTE_COLUMNID 
owner:self];
-            [view setObjectValue:item];
-            [[view textField] setEditable:NO];
-            [view setFrame:[ov convertRect:[ov frameOfCellAtColumn:-1 row:row] 
toView:rowView]];
-            [rowView addSubview:view];
-            [noteRowView setRowCellView:view];
-        }
-    }
-}
-
-- (void)outlineView:(NSOutlineView *)ov didRemoveRowView:(NSTableRowView 
*)rowView forRow:(NSInteger)row {
-    if ([ov isEqual:rightSideController.noteOutlineView]) {
-        SKNoteTableRowView *noteRowView = [rowView 
isKindOfClass:[SKNoteTableRowView class]] ? (SKNoteTableRowView *)rowView : nil;
-        NSTableCellView *view = [noteRowView rowCellView];
-        if (view) {
-            [noteRowView setRowCellView:nil];
-            [view setObjectValue:nil];
-            @try {
-                [[view textField] unbind:NSValueBinding];
-                [[view textField] unbind:NSToolTipBinding];
-            }
-            @catch (id e) {};
-            [view removeFromSuperview];
-        }
-    }
-}
-
 - (void)outlineView:(NSOutlineView *)ov didClickTableColumn:(NSTableColumn 
*)tableColumn {
     if ([ov isEqual:rightSideController.noteOutlineView]) {
         NSTableColumn *oldTableColumn = [ov highlightedTableColumn];
@@ -862,19 +829,11 @@
 }
 
 - (void)outlineViewColumnDidMove:(NSNotification *)notification {
-    if ([[notification object] isEqual:rightSideController.noteOutlineView]) {
+    if ([[notification object] isEqual:rightSideController.noteOutlineView] && 
mwcFlags.autoResizeNoteRows) {
         NSInteger oldColumn = [[[notification userInfo] 
objectForKey:@"NSOldColumn"] integerValue];
         NSInteger newColumn = [[[notification userInfo] 
objectForKey:@"NSNewColumn"] integerValue];
-        if (oldColumn == 0 || newColumn == 0) {
-            SKNoteOutlineView *ov = [notification object];
-            [ov enumerateAvailableRowViewsUsingBlock:^(SKNoteTableRowView 
*rowView, NSInteger row){
-                NSTableCellView *rowCellView = [rowView rowCellView];
-                if (rowCellView)
-                    [rowCellView setFrame:[ov convertRect:[ov 
frameOfCellAtColumn:-1 row:row] toView:rowView]];
-            }];
-            if (mwcFlags.autoResizeNoteRows)
-                [self performSelectorOnce:@selector(resetNoteRowHeights) 
afterDelay:0.0];
-        }
+        if (oldColumn == 0 || newColumn == 0)
+            [self performSelectorOnce:@selector(resetNoteRowHeights) 
afterDelay:0.0];
     }
 }
 

Modified: trunk/SKNoteOutlineView.m
===================================================================
--- trunk/SKNoteOutlineView.m   2022-07-14 16:44:26 UTC (rev 13021)
+++ trunk/SKNoteOutlineView.m   2022-07-15 14:19:12 UTC (rev 13022)
@@ -169,7 +169,7 @@
 }
 
 - (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
-    if (column == -1) {
+    if (column == -1 || ([self levelForRow:row] > 0 && [[self tableColumns] 
objectAtIndex:column] == [self outlineTableColumn])) {
         NSRect frame = NSZeroRect;
         NSInteger numColumns = [self numberOfColumns];
         NSArray *tcs = [self tableColumns];

Modified: trunk/SKNoteTableRowView.h
===================================================================
--- trunk/SKNoteTableRowView.h  2022-07-14 16:44:26 UTC (rev 13021)
+++ trunk/SKNoteTableRowView.h  2022-07-15 14:19:12 UTC (rev 13022)
@@ -40,10 +40,10 @@
 
 
 @interface SKNoteTableRowView : NSTableRowView {
-    NSTableCellView *rowCellView;
     NSImageCell *resizeIndicatorCell;
 }
+@end
 
-@property (nonatomic, assign) NSTableCellView *rowCellView;
 
+@interface SKNoteTableCellView : NSTableCellView
 @end

Modified: trunk/SKNoteTableRowView.m
===================================================================
--- trunk/SKNoteTableRowView.m  2022-07-14 16:44:26 UTC (rev 13021)
+++ trunk/SKNoteTableRowView.m  2022-07-15 14:19:12 UTC (rev 13022)
@@ -38,15 +38,14 @@
 
 #import "SKNoteTableRowView.h"
 #import "NSGeometry_SKExtensions.h"
+#import "SKNoteText.h"
+#import "SKNoteOutlineView.h"
 
 #define RESIZE_EDGE_HEIGHT 5.0
 
 @implementation SKNoteTableRowView
 
-@synthesize rowCellView;
-
 - (void)dealloc {
-    rowCellView = nil;
     SKDESTROY(resizeIndicatorCell);
     [super dealloc];
 }
@@ -73,16 +72,6 @@
     [resizeIndicatorCell drawWithFrame:[self bounds] inView:self];
 }
 
-- (void)setEmphasized:(BOOL)emphasized {
-    [super setEmphasized:emphasized];
-    [[self rowCellView] setBackgroundStyle:[self interiorBackgroundStyle]];
-}
-
-- (void)setSelected:(BOOL)selected {
-    [super setSelected:selected];
-    [[self rowCellView] setBackgroundStyle:[self interiorBackgroundStyle]];
-}
-
 - (void)resetCursorRects {
     [self discardCursorRects];
     [super resetCursorRects];
@@ -91,3 +80,20 @@
 }
 
 @end
+
+
+@implementation SKNoteTableCellView
+
+- (void)setFrame:(NSRect)frame {
+    if (!RUNNING_AFTER(10_15) && [[self objectValue] isKindOfClass:[SKNoteText 
class]]) {
+        SKNoteOutlineView *ov = (id)[[self superview] superview];
+        if ([ov isKindOfClass:[SKNoteOutlineView class]]) {
+            NSInteger row = [ov rowForView:self];
+            if (row != -1)
+                frame = [ov convertRect:[ov frameOfCellAtColumn:-1 row:row] 
toView:[self superview]];
+        }
+    }
+    [super setFrame:frame];
+}
+
+@end

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2022-07-14 16:44:26 UTC (rev 13021)
+++ trunk/SKNotesDocument.m     2022-07-15 14:19:12 UTC (rev 13022)
@@ -202,7 +202,6 @@
 
 - (void)windowWillClose:(NSNotification *)notification {
     [pdfDocument setContainingDocument:nil];
-    [outlineView enumerateAvailableRowViewsUsingBlock:^(SKNoteTableRowView 
*rowView, NSInteger row){ [[rowView rowCellView] setObjectValue:nil]; }];
 }
 
 - (void)windowDidResize:(NSNotification *)notification {
@@ -683,7 +682,7 @@
 }
 
 - (NSView *)outlineView:(NSOutlineView *)ov viewForTableColumn:(NSTableColumn 
*)tableColumn item:(id)item {
-    if ([(PDFAnnotation *)item type]) {
+    if ([(PDFAnnotation *)item type] || tableColumn == [ov 
outlineTableColumn]) {
         return [ov makeViewWithIdentifier:[tableColumn identifier] owner:self];
     }
     return nil;
@@ -693,30 +692,6 @@
     return [ov makeViewWithIdentifier:ROWVIEW_IDENTIFIER owner:self];
 }
 
-- (void)outlineView:(NSOutlineView *)ov didAddRowView:(NSTableRowView 
*)rowView forRow:(NSInteger)row {
-    SKNoteTableRowView *noteRowView = [rowView 
isKindOfClass:[SKNoteTableRowView class]] ? (SKNoteTableRowView *)rowView : nil;
-    id item = [ov itemAtRow:row];
-    if ([(PDFAnnotation *)item type] == nil) {
-        NSTableCellView *view = [ov makeViewWithIdentifier:NOTE_COLUMNID 
owner:self];
-        [view setObjectValue:item];
-        [view setFrame:[outlineView convertRect:[outlineView 
frameOfCellAtColumn:-1 row:row] toView:rowView]];
-        [rowView addSubview:view];
-        [noteRowView setRowCellView:view];
-    }
-}
-
-- (void)outlineView:(NSOutlineView *)ov didRemoveRowView:(NSTableRowView 
*)rowView forRow:(NSInteger)row {
-    SKNoteTableRowView *noteRowView = [rowView 
isKindOfClass:[SKNoteTableRowView class]] ? (SKNoteTableRowView *)rowView : nil;
-    NSTableCellView *view = [noteRowView rowCellView];
-    if (view) {
-        [noteRowView setRowCellView:nil];
-        [view setObjectValue:nil];
-        @try { [[view textField] unbind:NSValueBinding]; }
-        @catch (id e) {}
-        [view removeFromSuperview];
-    }
-}
-
 - (void)outlineView:(NSOutlineView *)ov didClickTableColumn:(NSTableColumn 
*)tableColumn {
     NSTableColumn *oldTableColumn = [ov highlightedTableColumn];
     NSTableColumn *newTableColumn = ([NSEvent modifierFlags] & 
NSCommandKeyMask) ? nil : [ov highlightedTableColumn];
@@ -762,16 +737,11 @@
 }
 
 - (void)outlineViewColumnDidMove:(NSNotification *)notification {
-    NSInteger oldColumn = [[[notification userInfo] 
objectForKey:@"NSOldColumn"] integerValue];
-    NSInteger newColumn = [[[notification userInfo] 
objectForKey:@"NSNewColumn"] integerValue];
-    if (oldColumn == 0 || newColumn == 0) {
-        [outlineView enumerateAvailableRowViewsUsingBlock:^(SKNoteTableRowView 
*rowView, NSInteger row){
-            NSTableCellView *rowCellView = [rowView rowCellView];
-            if (rowCellView)
-                [rowCellView setFrame:[outlineView convertRect:[outlineView 
frameOfCellAtColumn:-1 row:row] toView:rowView]];
-        }];
-        if (ndFlags.autoResizeRows)
-            [self performSelectorOnce:@selector(resetRowHeights) 
afterDelay:0.0];
+    if (ndFlags.autoResizeRows) {
+        NSInteger oldColumn = [[[notification userInfo] 
objectForKey:@"NSOldColumn"] integerValue];
+        NSInteger newColumn = [[[notification userInfo] 
objectForKey:@"NSNewColumn"] integerValue];
+        if (oldColumn == 0 || newColumn == 0)
+                [self performSelectorOnce:@selector(resetRowHeights) 
afterDelay:0.0];
     }
 }
 

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

Reply via email to