Permalink
Browse files

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

…uto-resizing column resizing
  • Loading branch information...
1 parent 9dd65bb commit 2d4a50ee24277c1ff6649124cc3c2e06bfb1393c Zachary Schneirov committed Dec 4, 2009
Showing with 47 additions and 7 deletions.
  1. +9 −0 AppController.m
  2. +2 −3 GlobalPrefs.m
  3. +6 −0 HeaderViewWIthMenu.h
  4. +20 −0 HeaderViewWIthMenu.m
  5. +2 −2 NSString_NV.m
  6. +2 −0 NoteAttributeColumn.h
  7. +4 −0 NoteAttributeColumn.m
  8. +1 −1 NoteObject.m
  9. +1 −1 NotesTableView.m
View
@@ -238,6 +238,9 @@ - (void)setNotationController:(NotationController*)newNotation {
[prefsController setAliasDataForDefaultDirectory:[notationController aliasDataForNoteDirectory] sender:self];
}
+ float width = [[notesTableView noteAttributeColumnForIdentifier:NoteTitleColumnString] width] - [NSScroller scrollerWidthForControlSize:NSRegularControlSize];
+ [notationController regeneratePreviewsForWidth:width visibleFilteredRows:[notesTableView rowsInRect:[notesTableView visibleRect]]];
+
[oldNotation autorelease];
}
}
@@ -1193,12 +1196,18 @@ - (void)willAdjustSubviews:(RBSplitView*)sender {
}
- (void)tableViewColumnDidResize:(NSNotification *)aNotification {
NoteAttributeColumn *col = [[aNotification userInfo] objectForKey:@"NSTableColumn"];
+//NSLog(@"resized column %@ from %g to %g", [col identifier], [[[aNotification userInfo] objectForKey:@"NSOldWidth"] floatValue], [col width]);
if ([col objectAttribute] == tableTitleOfNote) {
float width = [col width] - [NSScroller scrollerWidthForControlSize:NSRegularControlSize];
[notationController regeneratePreviewsForWidth:width visibleFilteredRows:[notesTableView rowsInRect:[notesTableView visibleRect]]];
+ //call reloadData for those cases involving resizing or moving a column that would not trigger it automatically
}
}
+- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)row mouseLocation:(NSPoint)mouseLocation {
+ return nil;
+}
+
//the notationcontroller must call notationListShouldChange: first
//if it's going to do something that could mess up the tableview's field eidtor
- (BOOL)notationListShouldChange:(NotationController*)someNotation {
View
@@ -79,15 +79,14 @@ - (id)init {
[NSNumber numberWithBool:NO], UseSoftTabsKey,
[NSNumber numberWithInt:4], NumberOfSpacesInTabKey,
[NSNumber numberWithBool:NO], PastePreservesStyleKey,
- [NSNumber numberWithBool:NO], TabKeyIndentsKey,
+ [NSNumber numberWithBool:YES], TabKeyIndentsKey,
[NSNumber numberWithBool:YES], ConfirmNoteDeletionKey,
[NSNumber numberWithBool:YES], CheckSpellingInNoteBodyKey,
- [NSNumber numberWithBool:YES], AutoCompleteSearchesKey,
+ [NSNumber numberWithBool:YES], AutoCompleteSearchesKey,
[NSNumber numberWithBool:YES], QuitWhenClosingMainWindowKey,
[NSNumber numberWithBool:NO], TriedToImportBlorKey,
[NSNumber numberWithBool:NO], DrawFocusRingKey,
[NSNumber numberWithBool:YES], MakeURLsClickableKey,
-
@"General", LastSelectedPreferencesPaneKey,
[NSArchiver archivedDataWithRootObject:
@@ -2,10 +2,16 @@
#import <Cocoa/Cocoa.h>
+@interface NSTableHeaderView (Private)
+- (void)_resizeColumn:(NSInteger)resizedColIdx withEvent:(id)event;
+@end
+
@interface HeaderViewWithMenu : NSTableHeaderView
{
BOOL isReloading;
}
+- (void)_resizeColumn:(NSInteger)resizedColIdx withEvent:(id)event;
+
- (void)setIsReloading:(BOOL)reloading;
@end
View
@@ -1,4 +1,5 @@
#import "HeaderViewWIthMenu.h"
+#import "NoteAttributeColumn.h"
@implementation HeaderViewWithMenu
@@ -9,6 +10,25 @@ - (id)init {
return self;
}
+- (void)_resizeColumn:(NSInteger)resizedColIdx withEvent:(id)event {
+ //use a more understandable column resizing by changing the resizing mask immediately before calling through to the private method,
+ //and reverting it back to the original at the next runloop iteration
+ if (RunningTigerAppKitOrHigher) {
+ NSUInteger originalResizingMask = 0;
+ int i;
+ //change all user-resizable-only columns
+ for (i=0; i<[[self tableView] numberOfColumns]; i++) {
+ NoteAttributeColumn *col = [[[self tableView] tableColumns] objectAtIndex:i];
+ if ((originalResizingMask = [col resizingMask]) == NSTableColumnUserResizingMask) {
+ [col setResizingMask: NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask];
+ [col performSelector:@selector(setResizingMaskNumber:) withObject:[NSNumber numberWithUnsignedInt:originalResizingMask] afterDelay:0];
+ }
+ }
+ }
+
+ [super _resizeColumn:resizedColIdx withEvent:event];
+}
+
- (void)setIsReloading:(BOOL)reloading {
isReloading = reloading;
}
View
@@ -294,7 +294,7 @@ - (NSAttributedString*)attributedPreviewFromBodyText:(NSAttributedString*)bodyTe
static NSDictionary *grayTextAttributes = nil;
if (!grayTextAttributes) {
lineBreaksStyle = [[NSMutableParagraphStyle alloc] init];
- [lineBreaksStyle setLineBreakMode:NSLineBreakByClipping];
+ [lineBreaksStyle setLineBreakMode:NSLineBreakByTruncatingTail];
grayTextAttributes = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSColor grayColor], NSForegroundColorAttributeName, nil] retain];
@@ -303,7 +303,7 @@ - (NSAttributedString*)attributedPreviewFromBodyText:(NSAttributedString*)bodyTe
NSString *bodyString = [bodyText string];
//compute the char count for this note based on the width of the title column and the length of the receiver
- size_t expectedCharCountToFitInWidth = (size_t)(upToWidth / 5.0f);
+ size_t expectedCharCountToFitInWidth = (size_t)(upToWidth / 4.5f);
size_t bodyCharCount = expectedCharCountToFitInWidth - [self length];
bodyCharCount = MIN(bodyCharCount, [bodyString length]);
@@ -24,4 +24,6 @@ id columnAttributeForObject(NoteAttributeColumn *col, id object);
- (NSInteger (*)(id*, id*))reverseSortFunction;
- (id (*) (id))objectAttribute;
+- (void)setResizingMaskNumber:(NSNumber*)resizingMaskNumber;
+
@end
@@ -63,4 +63,8 @@ - (void)setReverseSortingFunction:(NSInteger (*)(id*, id*))aFunction {
return objectAttribute;
}
+- (void)setResizingMaskNumber:(NSNumber*)resizingMaskNumber {
+ [self setResizingMask:[resizingMaskNumber unsignedIntValue]];
+}
+
@end
View
@@ -338,7 +338,7 @@ - (id)initWithCoder:(NSCoder*)decoder {
dateCreatedString = [[NSString relativeDateStringWithAbsoluteTime:createdDate] retain];
dateModifiedString = [[NSString relativeDateStringWithAbsoluteTime:modifiedDate] retain];
- [self updateTablePreviewString];
+ //[self updateTablePreviewString];
if (!titleString && !contentString && !labelString) return nil;
}
View
@@ -84,7 +84,7 @@ - (id)initWithCoder:(NSCoder *)decoder {
[[self noteAttributeColumnForIdentifier:NoteDateCreatedColumnString] setResizingMask:NSTableColumnUserResizingMask];
[[self noteAttributeColumnForIdentifier:NoteDateModifiedColumnString] setResizingMask:NSTableColumnUserResizingMask];
[self setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle];
- }else {
+ } else {
//what the hell is wrong with 10.3? when this is on, window resizing snaps columns to center
//which is really, really annoying. oh well--they'll upgrade their OS eventually.
[self setAutoresizesAllColumnsToFit:NO];

0 comments on commit 2d4a50e

Please sign in to comment.