Revision: 15033
          http://sourceforge.net/p/skim-app/code/15033
Author:   hofman
Date:     2025-03-28 10:05:19 +0000 (Fri, 28 Mar 2025)
Log Message:
-----------
Combine methods to update the frame of item views

Modified Paths:
--------------
    trunk/SKColorSwatch.m

Modified: trunk/SKColorSwatch.m
===================================================================
--- trunk/SKColorSwatch.m       2025-03-27 22:38:45 UTC (rev 15032)
+++ trunk/SKColorSwatch.m       2025-03-28 10:05:19 UTC (rev 15033)
@@ -277,10 +277,10 @@
     return NSEdgeInsetsMake(BEZEL_INSET_TOP, BEZEL_INSET_LEFT, 
BEZEL_INSET_BOTTOM, BEZEL_INSET_RIGHT);
 }
 
-- (void)updateItemViewFrames {
-    NSUInteger i, iMax = [itemViews count];
-    for (i = 0; i < iMax; i++)
-        [[itemViews objectAtIndex:i] setFrame:[self 
frameForItemViewAtIndex:i]];
+- (void)updateItemViewFramesAnimating:(BOOL)animate {
+    [itemViews enumerateObjectsUsingBlock:^(SKColorSwatchItemView *itemView, 
NSUInteger i, BOOL *stop){
+        [animate ? [itemView animator] : itemView setFrame:[self 
frameForItemViewAtIndex:i]];
+    }];
 }
 
 - (void)updateBezelHeight {
@@ -287,7 +287,7 @@
     CGFloat height = [backgroundView intrinsicContentSize].height;
     if (fabs(height - bezelHeight) > 0.0) {
         bezelHeight = height;
-        [self updateItemViewFrames];
+        [self updateItemViewFramesAnimating:NO];
         [self invalidateIntrinsicContentSize];
         if (autoResizes)
             [self sizeToFit];
@@ -486,7 +486,7 @@
     }
     if (autoResizes && [newColors count] != oldCount)
         [self sizeToFit];
-    [self updateItemViewFrames];
+    [self updateItemViewFramesAnimating:NO];
     [self invalidateIntrinsicContentSize];
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKColorSwatchColorsChangedNotification object:self];
 }
@@ -598,14 +598,6 @@
     [self setColor:color atIndex:i fromPanel:NO];
 }
 
-- (void)animateItemViewFrames {
-    [itemViews enumerateObjectsUsingBlock:^(SKColorSwatchItemView *itemView, 
NSUInteger i, BOOL *stop){
-        NSRect frame = [self frameForItemViewAtIndex:i];
-        if (NSEqualRects(frame, [itemView frame]) == NO)
-            [[itemView animator] setFrame:frame];
-    }];
-}
-
 - (void)insertColor:(NSColor *)color atIndex:(NSInteger)i {
     if (color && i >= 0 && i <= (NSInteger)[itemViews count]) {
         [self willChangeColors];
@@ -624,7 +616,7 @@
         [self didChangeColors];
         [self noteFocusRingMaskChanged];
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
-                [self animateItemViewFrames];
+                [self updateItemViewFramesAnimating:YES];
                 [[self animator] setBezelWidth:[self contentWidth]];
                 if (autoResizes)
                     [[self animator] setFrameSize:[self intrinsicFrameSize]];
@@ -654,7 +646,7 @@
         [self noteFocusRingMaskChanged];
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
                 [[itemView animator] setFrame:[self 
frameForCollapsedItemViewAtIndex:i]];
-                [self animateItemViewFrames];
+                [self updateItemViewFramesAnimating:YES];
                 [[self animator] setBezelWidth:[self contentWidth]];
                 if (autoResizes)
                     [[self animator] setFrameSize:[self intrinsicFrameSize]];
@@ -692,7 +684,7 @@
         [self didChangeColors];
         [self noteFocusRingMaskChanged];
         [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
-                [self animateItemViewFrames];
+                [self updateItemViewFramesAnimating:YES];
             }
             completionHandler:^{
                 if (to < from)

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

Reply via email to