Revision: 15017
          http://sourceforge.net/p/skim-app/code/15017
Author:   hofman
Date:     2025-03-24 16:48:16 +0000 (Mon, 24 Mar 2025)
Log Message:
-----------
separate method to update bezel height

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

Modified: trunk/SKColorSwatch.m
===================================================================
--- trunk/SKColorSwatch.m       2025-03-24 15:52:08 UTC (rev 15016)
+++ trunk/SKColorSwatch.m       2025-03-24 16:48:16 UTC (rev 15017)
@@ -69,7 +69,6 @@
 
 @interface SKColorSwatchBackgroundView : NSControl
 @property (nonatomic) CGFloat bezelWidth;
-@property (nonatomic, readonly) CGFloat bezelHeight;
 @end
  
 typedef NS_ENUM(NSUInteger, SKColorSwatchDropLocation) {
@@ -275,9 +274,32 @@
     for (i = 0; i < iMax; i++)
         [[itemViews objectAtIndex:i] setFrame:[self frameForItemViewAtIndex:i 
collapsedIndex:-1]];
     [backgroundView setBezelWidth:[self intrinsicContentSize].width];
-    [self invalidateIntrinsicContentSize];
 }
 
+- (void)updateBezelHeight {
+    CGFloat height = [[backgroundView cell] cellSize].height - BEZEL_INSET_TOP 
- BEZEL_INSET_BOTTOM;
+    if (@available(macOS 11.0, *)) {
+        if ([backgroundView controlSize] == NSControlSizeLarge)
+            height -= LARGE_SIZE_HEIGHT_OFFSET;
+    }
+    if (fabs(height - bezelHeight) > 0.0) {
+        bezelHeight = height;
+        [self updateSubviewLayout];
+        [self invalidateIntrinsicContentSize];
+        if (autoResizes)
+            [self sizeToFit];
+    }
+}
+
+- (void)setControlSize:(NSControlSize)controlSize {
+    if (controlSize != [self controlSize]) {
+        [super setControlSize:controlSize];
+        [backgroundView setControlSize:controlSize];
+        [backgroundView setFrame:controlSize == 3 ? NSInsetRect([self bounds], 
-LARGE_SIZE_WIDTH_OUTSET, 0.0) : [self bounds]];
+        [self updateBezelHeight];
+    }
+}
+
 #pragma mark Drawing
 
 - (NSRect)focusRingMaskBounds {
@@ -296,21 +318,6 @@
     }
 }
 
-- (void)setControlSize:(NSControlSize)controlSize {
-    if (controlSize != [self controlSize]) {
-        [super setControlSize:controlSize];
-        [backgroundView setControlSize:controlSize];
-        [backgroundView setFrame:controlSize == 3 ? NSInsetRect([self bounds], 
-LARGE_SIZE_WIDTH_OUTSET, 0.0) : [self bounds]];
-        CGFloat height = [backgroundView bezelHeight];
-        if (fabs(height - bezelHeight) > 0.0) {
-            bezelHeight = height;
-            [self updateSubviewLayout];
-            if (autoResizes)
-                [self sizeToFit];
-        }
-    }
-}
-
 #pragma mark Notification handling
 
 - (void)deactivate:(NSNotification *)note {
@@ -347,15 +354,8 @@
 
 - (void)viewDidMoveToWindow {
     [super viewDidMoveToWindow];
-    if ([self window]) {
-        CGFloat height = [backgroundView bezelHeight];
-        if (fabs(height - bezelHeight) > 0.0) {
-            bezelHeight = height;
-            [self updateSubviewLayout];
-            if (autoResizes)
-                [self sizeToFit];
-        }
-    }
+    if ([self window])
+        [self updateBezelHeight];
 }
 
 #pragma mark Event handling and actions
@@ -498,6 +498,7 @@
         [itemViews removeObjectAtIndex:iMax];
     }
     [self updateSubviewLayout];
+    [self invalidateIntrinsicContentSize];
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKColorSwatchColorsChangedNotification object:self];
 }
 
@@ -866,7 +867,7 @@
 
 @implementation SKColorSwatchBackgroundView
 
-@dynamic bezelWidth, bezelHeight;
+@dynamic bezelWidth;
 
 + (id)defaultAnimationForKey:(NSString *)key {
     if ([key isEqualToString:@"bezelWidth"]) {
@@ -902,15 +903,6 @@
     [self setNeedsDisplay:YES];
 }
 
-- (CGFloat)bezelHeight {
-    CGFloat height = [[self cell] cellSize].height - BEZEL_INSET_TOP - 
BEZEL_INSET_BOTTOM;
-    if (@available(macOS 11.0, *)) {
-        if ([self controlSize] == NSControlSizeLarge)
-            height -= LARGE_SIZE_HEIGHT_OFFSET;
-    }
-    return height;
-}
-
 - (void)mouseDown:(NSEvent *)event {
     [[self superview] mouseDown:event];
 }

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