Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

always resize deleted-notes sheet to show notes

  • Loading branch information...
commit a176bcbb19a160b553b5036c5647c3f54a568b04 1 parent f298fcd
Zachary Schneirov authored
Showing with 31 additions and 2 deletions.
  1. +2 −0  DeletionManager.h
  2. +29 −2 DeletionManager.m
View
2  DeletionManager.h
@@ -23,6 +23,8 @@
- (void)addDeletedNote:(NoteObject*)aNote;
- (void)processDeletedNotes;
- (void)removeDeletedNotes;
+- (NSRect)windowSizeForNotes;
+- (void)_updateSheetForNotes;
- (void)showSheetForDeletedNotes;
- (IBAction)deleteAction:(id)sender;
- (IBAction)restoreAction:(id)sender;
View
31 DeletionManager.m
@@ -75,7 +75,8 @@ - (void)addDeletedNotes:(NSArray*)array {
}
[array makeObjectsPerformSelector:@selector(invalidateFSRef)];
- [tableView reloadData];
+
+ [self _updateSheetForNotes];
}
}
@@ -93,10 +94,15 @@ - (void)addDeletedNote:(NoteObject*)aNote {
//if they are to be deleted, we don't care about them, anyway--they should already be gone
[aNote invalidateFSRef];
- [tableView reloadData];
+ [self _updateSheetForNotes];
}
}
+- (void)_updateSheetForNotes {
+ [tableView reloadData];
+ [window setFrame:[self windowSizeForNotes] display:[window isVisible] animate:[window isVisible]];
+}
+
- (void)processDeletedNotes {
@@ -107,6 +113,23 @@ - (void)processDeletedNotes {
}
}
+- (NSRect)windowSizeForNotes {
+ float oldHeight = 0.0;
+ float newHeight = 0.0;
+ NSRect newFrame = [window frame];
+ NSSize intercellSpacing = [tableView intercellSpacing];
+
+ int numRows = MIN(20, [tableView numberOfRows]);
+ newHeight = MAX(2, numRows) * ([tableView rowHeight] + intercellSpacing.height);
+ oldHeight = [[[tableView enclosingScrollView] contentView] frame].size.height;
+ newHeight = [window frame].size.height - oldHeight + newHeight;
+
+ newFrame.origin.y = newFrame.origin.y + newFrame.size.height - newHeight;
+
+ newFrame.size.height = newHeight;
+ return newFrame;
+}
+
- (void)showSheetForDeletedNotes {
if (!window) {
@@ -122,9 +145,13 @@ - (void)showSheetForDeletedNotes {
needsToShowSheet = YES;
+ [window setFrame:[self windowSizeForNotes] display:NO];
+
[NSApp beginSheet:window modalForWindow:mainWindow modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:NULL];
+ [NSApp cancelUserAttentionRequest:0];
+
if ([mainWindow attachedSheet] == window)
needsToShowSheet = NO;
}

0 comments on commit a176bcb

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