Revision: 12743 http://sourceforge.net/p/skim-app/code/12743 Author: hofman Date: 2022-01-24 16:03:16 +0000 (Mon, 24 Jan 2022) Log Message: ----------- Save row heights as integers, should be integral now anyway
Modified Paths: -------------- trunk/SKMainWindowController.h trunk/SKMainWindowController.m trunk/SKMainWindowController_Actions.m trunk/SKMainWindowController_UI.m trunk/SKNotesDocument.h trunk/SKNotesDocument.m Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2022-01-24 15:43:40 UTC (rev 12742) +++ trunk/SKMainWindowController.h 2022-01-24 16:03:16 UTC (rev 12743) @@ -65,7 +65,7 @@ SKWindowOptionFit }; -@class PDFAnnotation, PDFSelection, SKGroupedSearchResult, SKFloatMapTable; +@class PDFAnnotation, PDFSelection, SKGroupedSearchResult; @class SKPDFView, SKSecondaryPDFView, SKStatusBar, SKFindController, SKSplitView, SKFieldEditor, SKOverviewView, SKSideWindow; @class SKLeftSideViewController, SKRightSideViewController, SKMainToolbarController, SKMainTouchBarController, SKProgressController, SKPresentationOptionsSheetController, SKNoteTypeSheetController, SKSnapshotWindowController; @@ -108,7 +108,7 @@ SKNoteTypeSheetController *noteTypeSheetController; NSMutableArray *notes; - SKFloatMapTable *rowHeights; + NSMapTable *rowHeights; NSMapTable *widgets; NSMapTable *widgetValues; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2022-01-24 15:43:40 UTC (rev 12742) +++ trunk/SKMainWindowController.m 2022-01-24 16:03:16 UTC (rev 12743) @@ -92,7 +92,6 @@ #import "NSResponder_SKExtensions.h" #import "PDFOutline_SKExtensions.h" #import "NSPointerArray_SKExtensions.h" -#import "SKFloatMapTable.h" #import "SKColorCell.h" #import "PDFDocument_SKExtensions.h" #import "SKPDFPage.h" @@ -261,7 +260,7 @@ dirtySnapshots = [[NSMutableArray alloc] init]; pageLabels = [[NSMutableArray alloc] init]; lastViewedPages = [[NSPointerArray alloc] initWithOptions:NSPointerFunctionsOpaqueMemory | NSPointerFunctionsIntegerPersonality]; - rowHeights = [[SKFloatMapTable alloc] init]; + rowHeights = NSCreateMapTable(NSObjectMapKeyCallBacks, NSIntegerMapValueCallBacks, 0); savedNormalSetup = [[NSMutableDictionary alloc] init]; mwcFlags.leftSidePaneState = SKSidePaneStateThumbnail; mwcFlags.rightSidePaneState = SKSidePaneStateNote; @@ -1359,8 +1358,8 @@ [[self windowControllerForNote:note] close]; if ([note hasNoteText]) - [rowHeights removeFloatForKey:[note noteText]]; - [rowHeights removeFloatForKey:note]; + NSMapRemove(rowHeights, [note noteText]); + NSMapRemove(rowHeights, note); // Stop observing the removed notes [self stopObservingNotes:[NSArray arrayWithObject:note]]; @@ -1377,7 +1376,7 @@ } [wcs release]; - [rowHeights removeAllFloats]; + NSResetMapTable(rowHeights); [self stopObservingNotes:notes]; @@ -2556,9 +2555,9 @@ if (mwcFlags.autoResizeNoteRows) { if ([keyPath isEqualToString:SKNPDFAnnotationStringKey]) - [rowHeights removeFloatForKey:note]; + NSMapRemove(rowHeights, note); if ([keyPath isEqualToString:SKNPDFAnnotationTextKey]) - [rowHeights removeFloatForKey:[note noteText]]; + NSMapRemove(rowHeights, [note noteText]); } if ([self notesNeedReloadForKey:keyPath]) { [rightSideController.noteArrayController rearrangeObjects]; Modified: trunk/SKMainWindowController_Actions.m =================================================================== --- trunk/SKMainWindowController_Actions.m 2022-01-24 15:43:40 UTC (rev 12742) +++ trunk/SKMainWindowController_Actions.m 2022-01-24 16:03:16 UTC (rev 12743) @@ -77,7 +77,6 @@ #import "SKNoteTextView.h" #import "SKMainTouchBarController.h" #import "SKThumbnailItem.h" -#import "SKFloatMapTable.h" #import "PDFSelection_SKExtensions.h" #define STATUSBAR_HEIGHT 22.0 Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2022-01-24 15:43:40 UTC (rev 12742) +++ trunk/SKMainWindowController_UI.m 2022-01-24 16:03:16 UTC (rev 12743) @@ -68,7 +68,6 @@ #import "SKFieldEditor.h" #import "PDFOutline_SKExtensions.h" #import "SKDocumentController.h" -#import "SKFloatMapTable.h" #import "SKFindController.h" #import "NSColor_SKExtensions.h" #import "SKSplitView.h" @@ -854,7 +853,7 @@ } - (void)resetNoteRowHeights { - [rowHeights removeAllFloats]; + NSResetMapTable(rowHeights); [rightSideController.noteOutlineView noteHeightOfRowsChangedAnimating:YES]; } @@ -899,7 +898,7 @@ - (CGFloat)outlineView:(NSOutlineView *)ov heightOfRowByItem:(id)item { if ([ov isEqual:rightSideController.noteOutlineView]) { - CGFloat rowHeight = [rowHeights floatForKey:item]; + CGFloat rowHeight = (NSInteger)NSMapGet(rowHeights, item); if (rowHeight <= 0.0) { if (mwcFlags.autoResizeNoteRows) { NSTableColumn *tableColumn = [ov outlineTableColumn]; @@ -917,8 +916,8 @@ } if (width > 0.0) rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].height; - rowHeight = fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT; - [rowHeights setFloat:rowHeight forKey:item]; + rowHeight = round(fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT); + NSMapInsert(rowHeights, item, (NSInteger)rowHeight); } else { rowHeight = [(PDFAnnotation *)item type] ? [ov rowHeight] + EXTRA_ROW_HEIGHT : ([[(SKNoteText *)item note] isNote] ? DEFAULT_TEXT_ROW_HEIGHT : DEFAULT_MARKUP_ROW_HEIGHT); } @@ -929,7 +928,7 @@ } - (void)outlineView:(NSOutlineView *)ov setHeight:(CGFloat)newHeight ofRowByItem:(id)item { - [rowHeights setFloat:newHeight forKey:item]; + NSMapInsert(rowHeights, item, (NSInteger)round(newHeight)); } - (NSArray *)noteItems:(NSArray *)items { @@ -1195,7 +1194,7 @@ height = [cell cellSizeForBounds:rect].height; else height = 0.0; - [rowHeights setFloat:fmax(height, rowHeight) + EXTRA_ROW_HEIGHT forKey:item]; + NSMapInsert(rowHeights, item, (NSInteger)round(fmax(height, rowHeight) + EXTRA_ROW_HEIGHT)); if (rowIndexes) { row = [ov rowForItem:item]; if (row != -1) @@ -1213,7 +1212,7 @@ SKNoteOutlineView *ov = rightSideController.noteOutlineView; NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; for (id item in items) { - [rowHeights removeFloatForKey:item]; + NSMapRemove(rowHeights, item); NSInteger row = [ov rowForItem:item]; if (row != -1) [indexes addIndex:row]; @@ -2087,7 +2086,7 @@ - (void)handleNoteViewFrameDidChangeNotification:(NSNotification *)notification { if (mwcFlags.autoResizeNoteRows && [splitView isAnimating] == NO) { - [rowHeights removeAllFloats]; + NSResetMapTable(rowHeights); [rightSideController.noteOutlineView noteHeightOfRowsChangedAnimating:NO]; } } Modified: trunk/SKNotesDocument.h =================================================================== --- trunk/SKNotesDocument.h 2022-01-24 15:43:40 UTC (rev 12742) +++ trunk/SKNotesDocument.h 2022-01-24 16:03:16 UTC (rev 12743) @@ -42,7 +42,7 @@ #import "SKNoteTypeSheetController.h" #import "NSDocument_SKExtensions.h" -@class SKNoteOutlineView, SKStatusBar, SKFloatMapTable; +@class SKNoteOutlineView, SKStatusBar; @interface SKNotesDocument : NSDocument <NSWindowDelegate, NSToolbarDelegate, SKNoteOutlineViewDelegate, NSOutlineViewDataSource, SKNoteTypeSheetControllerDelegate> { SKNoteOutlineView *outlineView; @@ -54,7 +54,7 @@ NSArray *widgets; PDFDocument *pdfDocument; NSURL *sourceFileURL; - SKFloatMapTable *rowHeights; + NSMapTable *rowHeights; SKNoteTypeSheetController *noteTypeSheetController; NSRect windowRect; struct _ndFlags { Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2022-01-24 15:43:40 UTC (rev 12742) +++ trunk/SKNotesDocument.m 2022-01-24 16:03:16 UTC (rev 12743) @@ -61,7 +61,6 @@ #import "SKPrintableView.h" #import "SKPDFView.h" #import "NSPointerArray_SKExtensions.h" -#import "SKFloatMapTable.h" #import "SKScrollView.h" #import "NSColor_SKExtensions.h" #import "NSString_SKExtensions.h" @@ -113,7 +112,7 @@ if (self) { notes = [[NSArray alloc] init]; pdfDocument = nil; - rowHeights = [[SKFloatMapTable alloc] init]; + rowHeights = NSCreateMapTable(NSObjectMapKeyCallBacks, NSIntegerMapValueCallBacks, 0); windowRect = NSZeroRect; memset(&ndFlags, 0, sizeof(ndFlags)); ndFlags.caseInsensitiveSearch = [[NSUserDefaults standardUserDefaults] boolForKey:SKCaseInsensitiveNoteSearchKey]; @@ -212,7 +211,7 @@ - (void)windowDidResize:(NSNotification *)notification { if (ndFlags.autoResizeRows) { - [rowHeights removeAllFloats]; + NSResetMapTable(rowHeights); [outlineView noteHeightOfRowsChangedAnimating:NO]; } } @@ -370,7 +369,7 @@ } [self didChangeValueForKey:PAGES_KEY]; - [rowHeights removeAllFloats]; + NSResetMapTable(rowHeights); [self willChangeValueForKey:NOTES_KEY]; [notes autorelease]; @@ -567,7 +566,7 @@ height = [cell cellSizeForBounds:fullRect].height; else height = 0.0; - [rowHeights setFloat:fmax(height, rowHeight) + EXTRA_ROW_HEIGHT forKey:item]; + NSMapInsert(rowHeights, item, (NSInteger)round(fmax(height, rowHeight) + EXTRA_ROW_HEIGHT)); if (rowIndexes) { row = [outlineView rowForItem:item]; if (row != -1) @@ -578,7 +577,7 @@ } - (void)resetRowHeights { - [rowHeights removeAllFloats]; + NSResetMapTable(rowHeights); [outlineView noteHeightOfRowsChangedAnimating:YES]; } @@ -589,7 +588,7 @@ } else { NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; for (id item in items) { - [rowHeights removeFloatForKey:item]; + NSMapRemove(rowHeights, item); NSInteger row = [outlineView rowForItem:item]; if (row != -1) [indexes addIndex:row]; @@ -843,7 +842,7 @@ } - (CGFloat)outlineView:(NSOutlineView *)ov heightOfRowByItem:(id)item { - CGFloat rowHeight = [rowHeights floatForKey:item]; + CGFloat rowHeight = (NSInteger)NSMapGet(rowHeights, item); if (rowHeight <= 0.0) { if (ndFlags.autoResizeRows) { NSTableColumn *tableColumn = [ov outlineTableColumn]; @@ -860,8 +859,8 @@ } if (width > 0.0) rowHeight = [cell cellSizeForBounds:NSMakeRect(0.0, 0.0, width, CGFLOAT_MAX)].height; - rowHeight = fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT; - [rowHeights setFloat:rowHeight forKey:item]; + rowHeight = round(fmax(rowHeight, [ov rowHeight]) + EXTRA_ROW_HEIGHT); + NSMapInsert(rowHeights, item, (NSInteger)rowHeight); } else { rowHeight = [(PDFAnnotation *)item type] ? [ov rowHeight] + EXTRA_ROW_HEIGHT : DEFAULT_TEXT_ROW_HEIGHT; } @@ -870,7 +869,7 @@ } - (void)outlineView:(NSOutlineView *)ov setHeight:(CGFloat)newHeight ofRowByItem:(id)item { - [rowHeights setFloat:newHeight forKey:item]; + NSMapInsert(rowHeights, item, (NSInteger)round(newHeight)); } - (NSArray *)outlineView:(NSOutlineView *)ov typeSelectHelperSelectionStrings:(SKTypeSelectHelper *)typeSelectHelper { 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