Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ensure note preview generation does not affect launch time; fix non-a…

…uto-resizing column resizing
  • Loading branch information...
commit 2d4a50ee24277c1ff6649124cc3c2e06bfb1393c 1 parent 9dd65bb
authored December 04, 2009
9  AppController.m
@@ -238,6 +238,9 @@ - (void)setNotationController:(NotationController*)newNotation {
238 238
 			[prefsController setAliasDataForDefaultDirectory:[notationController aliasDataForNoteDirectory] sender:self];
239 239
 		}
240 240
 		
  241
+		float width = [[notesTableView noteAttributeColumnForIdentifier:NoteTitleColumnString] width] - [NSScroller scrollerWidthForControlSize:NSRegularControlSize];
  242
+		[notationController regeneratePreviewsForWidth:width visibleFilteredRows:[notesTableView rowsInRect:[notesTableView visibleRect]]];	
  243
+		
241 244
 		[oldNotation autorelease];		
242 245
     }
243 246
 }
@@ -1193,12 +1196,18 @@ - (void)willAdjustSubviews:(RBSplitView*)sender {
1193 1196
 }
1194 1197
 - (void)tableViewColumnDidResize:(NSNotification *)aNotification {
1195 1198
 	NoteAttributeColumn *col = [[aNotification userInfo] objectForKey:@"NSTableColumn"];
  1199
+//NSLog(@"resized column %@ from %g to %g", [col identifier], [[[aNotification userInfo] objectForKey:@"NSOldWidth"] floatValue], [col width]);
1196 1200
 	if ([col objectAttribute] == tableTitleOfNote) {
1197 1201
 		float width = [col width] - [NSScroller scrollerWidthForControlSize:NSRegularControlSize];
1198 1202
 		[notationController regeneratePreviewsForWidth:width visibleFilteredRows:[notesTableView rowsInRect:[notesTableView visibleRect]]];	
  1203
+		//call reloadData for those cases involving resizing or moving a column that would not trigger it automatically
1199 1204
 	}
1200 1205
 }
1201 1206
 
  1207
+- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation {
  1208
+	return nil;
  1209
+}
  1210
+
1202 1211
 //the notationcontroller must call notationListShouldChange: first 
1203 1212
 //if it's going to do something that could mess up the tableview's field eidtor
1204 1213
 - (BOOL)notationListShouldChange:(NotationController*)someNotation {
5  GlobalPrefs.m
@@ -79,15 +79,14 @@ - (id)init {
79 79
 			[NSNumber numberWithBool:NO], UseSoftTabsKey,
80 80
 			[NSNumber numberWithInt:4], NumberOfSpacesInTabKey,
81 81
 			[NSNumber numberWithBool:NO], PastePreservesStyleKey,
82  
-			[NSNumber numberWithBool:NO], TabKeyIndentsKey,
  82
+			[NSNumber numberWithBool:YES], TabKeyIndentsKey,
83 83
 			[NSNumber numberWithBool:YES], ConfirmNoteDeletionKey,
84 84
 			[NSNumber numberWithBool:YES], CheckSpellingInNoteBodyKey, 
85  
-		    [NSNumber numberWithBool:YES], AutoCompleteSearchesKey, 
  85
+			[NSNumber numberWithBool:YES], AutoCompleteSearchesKey, 
86 86
 			[NSNumber numberWithBool:YES], QuitWhenClosingMainWindowKey, 
87 87
 			[NSNumber numberWithBool:NO], TriedToImportBlorKey,
88 88
 			[NSNumber numberWithBool:NO], DrawFocusRingKey,
89 89
 			[NSNumber numberWithBool:YES], MakeURLsClickableKey,
90  
-			
91 90
 			@"General", LastSelectedPreferencesPaneKey, 
92 91
 			
93 92
 			[NSArchiver archivedDataWithRootObject:
6  HeaderViewWIthMenu.h
@@ -2,10 +2,16 @@
2 2
 
3 3
 #import <Cocoa/Cocoa.h>
4 4
 
  5
+@interface NSTableHeaderView (Private)
  6
+- (void)_resizeColumn:(NSInteger)resizedColIdx withEvent:(id)event;
  7
+@end
  8
+
5 9
 @interface HeaderViewWithMenu : NSTableHeaderView
6 10
 {
7 11
 	BOOL isReloading;
8 12
 }
9 13
 
  14
+- (void)_resizeColumn:(NSInteger)resizedColIdx withEvent:(id)event;
  15
+
10 16
 - (void)setIsReloading:(BOOL)reloading;
11 17
 @end
20  HeaderViewWIthMenu.m
... ...
@@ -1,4 +1,5 @@
1 1
 #import "HeaderViewWIthMenu.h"
  2
+#import "NoteAttributeColumn.h"
2 3
 
3 4
 @implementation HeaderViewWithMenu
4 5
 
@@ -9,6 +10,25 @@ - (id)init {
9 10
 	return self;
10 11
 }
11 12
 
  13
+- (void)_resizeColumn:(NSInteger)resizedColIdx withEvent:(id)event {	
  14
+	//use a more understandable column resizing by changing the resizing mask immediately before calling through to the private method,
  15
+	//and reverting it back to the original at the next runloop iteration
  16
+	if (RunningTigerAppKitOrHigher) {
  17
+		NSUInteger originalResizingMask = 0;
  18
+		int i;
  19
+		//change all user-resizable-only columns
  20
+		for (i=0; i<[[self tableView] numberOfColumns]; i++) {
  21
+			NoteAttributeColumn *col = [[[self tableView] tableColumns] objectAtIndex:i];
  22
+			if ((originalResizingMask = [col resizingMask]) == NSTableColumnUserResizingMask) {
  23
+				[col setResizingMask: NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask];
  24
+				[col performSelector:@selector(setResizingMaskNumber:) withObject:[NSNumber numberWithUnsignedInt:originalResizingMask] afterDelay:0];
  25
+			}
  26
+		}
  27
+	}
  28
+	
  29
+	[super _resizeColumn:resizedColIdx withEvent:event];
  30
+}
  31
+	
12 32
 - (void)setIsReloading:(BOOL)reloading {
13 33
 	isReloading = reloading;
14 34
 }
4  NSString_NV.m
@@ -294,7 +294,7 @@ - (NSAttributedString*)attributedPreviewFromBodyText:(NSAttributedString*)bodyTe
294 294
 	static NSDictionary *grayTextAttributes = nil;
295 295
 	if (!grayTextAttributes) {
296 296
 		lineBreaksStyle = [[NSMutableParagraphStyle alloc] init];
297  
-		[lineBreaksStyle setLineBreakMode:NSLineBreakByClipping];
  297
+		[lineBreaksStyle setLineBreakMode:NSLineBreakByTruncatingTail];
298 298
 
299 299
 		grayTextAttributes = [[NSDictionary dictionaryWithObjectsAndKeys:
300 300
 			[NSColor grayColor], NSForegroundColorAttributeName, nil] retain];
@@ -303,7 +303,7 @@ - (NSAttributedString*)attributedPreviewFromBodyText:(NSAttributedString*)bodyTe
303 303
 	NSString *bodyString = [bodyText string];
304 304
 	
305 305
 	//compute the char count for this note based on the width of the title column and the length of the receiver
306  
-	size_t expectedCharCountToFitInWidth = (size_t)(upToWidth / 5.0f);
  306
+	size_t expectedCharCountToFitInWidth = (size_t)(upToWidth / 4.5f);
307 307
 	size_t bodyCharCount = expectedCharCountToFitInWidth - [self length];
308 308
 	
309 309
 	bodyCharCount = MIN(bodyCharCount, [bodyString length]);
2  NoteAttributeColumn.h
@@ -24,4 +24,6 @@ id columnAttributeForObject(NoteAttributeColumn *col, id object);
24 24
 - (NSInteger (*)(id*, id*))reverseSortFunction;
25 25
 - (id (*) (id))objectAttribute;
26 26
 
  27
+- (void)setResizingMaskNumber:(NSNumber*)resizingMaskNumber;
  28
+
27 29
 @end
4  NoteAttributeColumn.m
@@ -63,4 +63,8 @@ - (void)setReverseSortingFunction:(NSInteger (*)(id*, id*))aFunction {
63 63
 	return objectAttribute;
64 64
 }
65 65
 
  66
+- (void)setResizingMaskNumber:(NSNumber*)resizingMaskNumber {
  67
+	[self setResizingMask:[resizingMaskNumber unsignedIntValue]];
  68
+}
  69
+
66 70
 @end
2  NoteObject.m
@@ -338,7 +338,7 @@ - (id)initWithCoder:(NSCoder*)decoder {
338 338
 		dateCreatedString = [[NSString relativeDateStringWithAbsoluteTime:createdDate] retain];
339 339
 		dateModifiedString = [[NSString relativeDateStringWithAbsoluteTime:modifiedDate] retain];
340 340
 		
341  
-		[self updateTablePreviewString];
  341
+		//[self updateTablePreviewString];
342 342
 		
343 343
 		if (!titleString && !contentString && !labelString) return nil;
344 344
 	}
2  NotesTableView.m
@@ -84,7 +84,7 @@ - (id)initWithCoder:(NSCoder *)decoder {
84 84
 		[[self noteAttributeColumnForIdentifier:NoteDateCreatedColumnString] setResizingMask:NSTableColumnUserResizingMask];
85 85
 		[[self noteAttributeColumnForIdentifier:NoteDateModifiedColumnString] setResizingMask:NSTableColumnUserResizingMask];
86 86
 		[self setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle];
87  
-	}else {
  87
+	} else {
88 88
 		//what the hell is wrong with 10.3? when this is on, window resizing snaps columns to center
89 89
 		//which is really, really annoying. oh well--they'll upgrade their OS eventually.
90 90
 		[self setAutoresizesAllColumnsToFit:NO];

0 notes on commit 2d4a50e

Please sign in to comment.
Something went wrong with that request. Please try again.