Revision: 14536
http://sourceforge.net/p/skim-app/code/14536
Author: hofman
Date: 2024-10-09 17:34:12 +0000 (Wed, 09 Oct 2024)
Log Message:
-----------
Separate updating transitions array and updating the table UI
Modified Paths:
--------------
trunk/SKPresentationOptionsSheetController.m
Modified: trunk/SKPresentationOptionsSheetController.m
===================================================================
--- trunk/SKPresentationOptionsSheetController.m 2024-10-09 16:13:38 UTC
(rev 14535)
+++ trunk/SKPresentationOptionsSheetController.m 2024-10-09 17:34:12 UTC
(rev 14536)
@@ -131,6 +131,75 @@
[notesDocumentPopUpButton selectItemAtIndex:docIndex == -1 ? 0 : docIndex];
}
+- (NSArray *)makeTransitions:(NSArray *)properties {
+ // determine the table width by getting the largest page label
+ NSTableColumn *tableColumn = [tableView
tableColumnWithIdentifier:PAGE_COLUMNID];
+ id cell = [[tableColumn dataCell] copy];
+ CGFloat labelWidth = 0.0;
+
+ [cell setFont:[[NSFontManager sharedFontManager] convertFont:[cell font]
toHaveTrait:NSBoldFontMask]];
+
+ NSMutableArray *array = [NSMutableArray array];
+ NSEnumerator *ptEnum = [properties objectEnumerator];
+ SKThumbnail *tn = nil;
+ SKLabeledTransitionInfo *info;
+
+ for (SKThumbnail *next in [controller thumbnails]) {
+ if (tn) {
+ if (properties)
+ info = [[SKLabeledTransitionInfo alloc]
initWithProperties:[ptEnum nextObject]];
+ else
+ info = [[SKLabeledTransitionInfo alloc]
initWithTransitionInfo:transition];
+ [info setThumbnail:tn];
+ [info setToThumbnail:next];
+ [array addObject:info];
+ [cell setStringValue:[info label] ?: @""];
+ labelWidth = fmax(labelWidth, [cell cellSize].width);
+ }
+ tn = next;
+ }
+
+ labelWidth = fmin(ceil(labelWidth), MAX_PAGE_COLUMN_WIDTH);
+ [tableColumn setMinWidth:labelWidth];
+ [tableColumn setMaxWidth:labelWidth];
+ [tableColumn setWidth:labelWidth];
+
+ NSScrollView *scrollView = [tableView enclosingScrollView];
+ CGFloat width = [[[tableView tableColumns] valueForKeyPath:@"@sum.width"]
doubleValue] + NSWidth([scrollView frame]) - [scrollView contentSize].width +
3.0 * [tableView intercellSpacing].width;
+ [tableWidthConstraint setConstant:width];
+
+ return array;
+}
+
+- (void)updateTableUI:(BOOL)initial {
+ NSWindow *window = [self window];
+
+ NSView *scrollView = [tableView enclosingScrollView];
+ BOOL hidden = separate == NO;
+ CGFloat width = BOX_OFFSET;
+
+ if (separate)
+ width += [tableWidthConstraint constant] + TABLE_OFFSET;
+
+ if (initial == NO && [NSView shouldShowSlideAnimation]) {
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
+ [[boxLeadingConstraint animator] setConstant:width];
+ [[scrollView animator] setHidden:hidden];
+ }
+ completionHandler:^{
+ NSRect frame = [window frame];
+ [window setFrameOrigin:NSMakePoint(NSMidX([[controller window]
frame]) - 0.5 * NSWidth(frame), NSMinY(frame))];
+ }];
+ } else {
+ [boxLeadingConstraint setConstant:width];
+ [scrollView setHidden:hidden];
+ if (initial == NO) {
+ NSRect frame = [window frame];
+ [window setFrameOrigin:NSMakePoint(NSMidX([[controller window]
frame]) - 0.5 * NSWidth(frame), NSMinY(frame))];
+ }
+ }
+}
+
- (void)windowDidLoad {
// add the filter names to the popup
NSMutableSet *titles = [NSMutableSet set];
@@ -151,6 +220,7 @@
[[notesDocumentPopUpButton itemAtIndex:2] setRepresentedObject:[controller
document]];
SKTransitionController *transitionController = [controller
transitionControllerCreating:NO];
+ NSArray *pageTransitions = [transitionController pageTransitions];
SKTransitionInfo *info = [transitionController transition];
if (info)
[transition setInfo:info];
@@ -171,10 +241,13 @@
[tableView setSupportsQuickLook:YES];
[tableView setDoubleAction:@selector(preview:)];
- if ([transitionController pageTransitions]) {
- [[self undoManager] disableUndoRegistration];
- [self setSeparate:YES];
- [[self undoManager] enableUndoRegistration];
+
+ if (pageTransitions) {
+ [self willChangeValueForKey:SEPARATE_KEY];
+ separate = YES;
+ [self didChangeValueForKey:SEPARATE_KEY];
+ [self setTransitions:[self makeTransitions:pageTransitions]];
+ [self updateTableUI:YES];
}
// set the current notes document and observe changes for the popup
@@ -190,46 +263,6 @@
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
}
-- (void)makeTransitions:(BOOL)initial {
- // determine the table width by getting the largest page label
- NSTableColumn *tableColumn = [tableView
tableColumnWithIdentifier:PAGE_COLUMNID];
- id cell = [[tableColumn dataCell] copy];
- CGFloat labelWidth = 0.0;
-
- [cell setFont:[[NSFontManager sharedFontManager] convertFont:[cell font]
toHaveTrait:NSBoldFontMask]];
-
- NSMutableArray *array = [NSMutableArray array];
- NSEnumerator *ptEnum = initial ? [[[controller
transitionControllerCreating:NO] pageTransitions] objectEnumerator] : nil;
- SKThumbnail *tn = nil;
- SKLabeledTransitionInfo *info;
-
- for (SKThumbnail *next in [controller thumbnails]) {
- if (tn) {
- if (initial)
- info = [[SKLabeledTransitionInfo alloc]
initWithProperties:[ptEnum nextObject]];
- else
- info = [[SKLabeledTransitionInfo alloc]
initWithTransitionInfo:transition];
- [info setThumbnail:tn];
- [info setToThumbnail:next];
- [array addObject:info];
- [cell setStringValue:[info label] ?: @""];
- labelWidth = fmax(labelWidth, [cell cellSize].width);
- }
- tn = next;
- }
-
- labelWidth = fmin(ceil(labelWidth), MAX_PAGE_COLUMN_WIDTH);
- [tableColumn setMinWidth:labelWidth];
- [tableColumn setMaxWidth:labelWidth];
- [tableColumn setWidth:labelWidth];
-
- NSScrollView *scrollView = [tableView enclosingScrollView];
- CGFloat width = [[[tableView tableColumns] valueForKeyPath:@"@sum.width"]
doubleValue] + NSWidth([scrollView frame]) - [scrollView contentSize].width +
3.0 * [tableView intercellSpacing].width;
- [tableWidthConstraint setConstant:width];
-
- [self setTransitions:array];
-}
-
- (NSString *)windowNibName {
return @"TransitionSheet";
}
@@ -391,6 +424,11 @@
}];
}
+- (void)updateTransitions:(NSArray *)newTransitions {
+ [[[self undoManager] prepareWithInvocationTarget:self]
updateTransitions:transitions];
+ [self setTransitions:newTransitions];
+}
+
- (void)setSeparate:(BOOL)newSeparate {
if (separate != newSeparate) {
separate = newSeparate;
@@ -398,51 +436,22 @@
[[SKImageToolTipWindow sharedToolTipWindow] orderOut:nil];
NSWindow *window = [self window];
- BOOL isVisible = [window isVisible];
- NSView *scrollView = [tableView enclosingScrollView];
- CGFloat width = BOX_OFFSET;
- BOOL hidden = separate == NO;
id firstResponder = [window firstResponder];
NSTextView *editor = nil;
-
if ([firstResponder isKindOfClass:[NSTextView class]]) {
editor = firstResponder;
if ([editor isFieldEditor])
firstResponder = [firstResponder delegate];
}
-
if ([arrayController commitEditing] &&
editor && [window firstResponder] != editor)
- [window makeFirstResponder:firstResponder];
+ [window makeFirstResponder:firstResponder];
- // when undo or redo will also set the transitions
- if ([[self undoManager] isUndoing] == NO && [[self undoManager]
isRedoing] == NO) {
- if (separate)
- [self makeTransitions:isVisible == NO];
- else
- [self setTransitions:@[transition]];
- }
+ // undo or redo will include updateTransitions: in the same group
+ if ([[self undoManager] isUndoing] == NO && [[self undoManager]
isRedoing] == NO)
+ [self updateTransitions:separate ? [self makeTransitions:nil] :
@[transition]];
+ [self updateTableUI:NO];
- if (separate)
- width += [tableWidthConstraint constant] + TABLE_OFFSET;
-
- if (isVisible && [NSView shouldShowSlideAnimation]) {
- [NSAnimationContext runAnimationGroup:^(NSAnimationContext
*context){
- [[boxLeadingConstraint animator] setConstant:width];
- [[scrollView animator] setHidden:hidden];
- }
- completionHandler:^{
- NSRect frame = [window frame];
- [window setFrameOrigin:NSMakePoint(NSMidX([[controller
window] frame]) - 0.5 * NSWidth(frame), NSMinY(frame))];
- }];
- } else {
- [boxLeadingConstraint setConstant:width];
- [scrollView setHidden:hidden];
- if (isVisible) {
- NSRect frame = [window frame];
- [window setFrameOrigin:NSMakePoint(NSMidX([[controller window]
frame]) - 0.5 * NSWidth(frame), NSMinY(frame))];
- }
- }
[[[self undoManager] prepareWithInvocationTarget:self]
setSeparate:separate == NO];
}
}
@@ -449,7 +458,6 @@
- (void)setTransitions:(NSArray *)newTransitions {
if (transitions != newTransitions) {
- [[[self undoManager] prepareWithInvocationTarget:self]
setTransitions:transitions];
[self stopObservingTransitions:transitions];
transitions = [newTransitions copy];
[self startObservingTransitions:transitions];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit