You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(23) |
Apr
(254) |
May
(252) |
Jun
(209) |
Jul
(198) |
Aug
(192) |
Sep
(207) |
Oct
(120) |
Nov
(179) |
Dec
(52) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(48) |
Feb
(69) |
Mar
(129) |
Apr
(250) |
May
(113) |
Jun
(177) |
Jul
(228) |
Aug
(155) |
Sep
(218) |
Oct
(185) |
Nov
(109) |
Dec
(88) |
2009 |
Jan
(83) |
Feb
(39) |
Mar
(70) |
Apr
(47) |
May
(48) |
Jun
(67) |
Jul
(61) |
Aug
(97) |
Sep
(221) |
Oct
(141) |
Nov
(70) |
Dec
(61) |
2010 |
Jan
(45) |
Feb
(76) |
Mar
(178) |
Apr
(106) |
May
(57) |
Jun
(32) |
Jul
(64) |
Aug
(98) |
Sep
(96) |
Oct
(19) |
Nov
(34) |
Dec
(117) |
2011 |
Jan
(55) |
Feb
(48) |
Mar
(64) |
Apr
(21) |
May
(39) |
Jun
(53) |
Jul
(99) |
Aug
(56) |
Sep
(39) |
Oct
(26) |
Nov
(19) |
Dec
(69) |
2012 |
Jan
(17) |
Feb
(40) |
Mar
(17) |
Apr
|
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
(10) |
Sep
(10) |
Oct
(38) |
Nov
(48) |
Dec
(70) |
2013 |
Jan
(43) |
Feb
(47) |
Mar
(39) |
Apr
(37) |
May
(25) |
Jun
(6) |
Jul
(20) |
Aug
(49) |
Sep
(33) |
Oct
(34) |
Nov
(75) |
Dec
(6) |
2014 |
Jan
(32) |
Feb
(10) |
Mar
(17) |
Apr
|
May
|
Jun
(26) |
Jul
(5) |
Aug
|
Sep
(4) |
Oct
(23) |
Nov
(80) |
Dec
(48) |
2015 |
Jan
(80) |
Feb
(50) |
Mar
(58) |
Apr
(20) |
May
(11) |
Jun
(16) |
Jul
(24) |
Aug
(27) |
Sep
(56) |
Oct
(30) |
Nov
(16) |
Dec
(6) |
2016 |
Jan
(31) |
Feb
(14) |
Mar
(23) |
Apr
(17) |
May
(40) |
Jun
(12) |
Jul
(17) |
Aug
(9) |
Sep
(32) |
Oct
(36) |
Nov
(23) |
Dec
(9) |
2017 |
Jan
(37) |
Feb
(23) |
Mar
(65) |
Apr
(22) |
May
(6) |
Jun
(3) |
Jul
|
Aug
|
Sep
(3) |
Oct
(22) |
Nov
(63) |
Dec
(71) |
2018 |
Jan
(83) |
Feb
(21) |
Mar
(35) |
Apr
(44) |
May
(14) |
Jun
(12) |
Jul
(8) |
Aug
(18) |
Sep
(10) |
Oct
(145) |
Nov
(144) |
Dec
(76) |
2019 |
Jan
(18) |
Feb
(28) |
Mar
(5) |
Apr
(208) |
May
(291) |
Jun
(158) |
Jul
(27) |
Aug
(8) |
Sep
(10) |
Oct
(83) |
Nov
(41) |
Dec
(31) |
2020 |
Jan
(16) |
Feb
(46) |
Mar
(100) |
Apr
(78) |
May
(69) |
Jun
(71) |
Jul
(28) |
Aug
(131) |
Sep
(176) |
Oct
(89) |
Nov
(147) |
Dec
(19) |
2021 |
Jan
(19) |
Feb
(25) |
Mar
(91) |
Apr
(98) |
May
(14) |
Jun
(44) |
Jul
(8) |
Aug
(3) |
Sep
(38) |
Oct
(57) |
Nov
(97) |
Dec
(74) |
2022 |
Jan
(89) |
Feb
(47) |
Mar
(15) |
Apr
(50) |
May
(54) |
Jun
(56) |
Jul
(80) |
Aug
(12) |
Sep
(11) |
Oct
(60) |
Nov
(48) |
Dec
(4) |
2023 |
Jan
(75) |
Feb
(49) |
Mar
(84) |
Apr
(24) |
May
(13) |
Jun
(74) |
Jul
(32) |
Aug
(66) |
Sep
(50) |
Oct
(38) |
Nov
(105) |
Dec
(181) |
2024 |
Jan
(21) |
Feb
(49) |
Mar
(77) |
Apr
(84) |
May
(20) |
Jun
(71) |
Jul
(53) |
Aug
(33) |
Sep
(54) |
Oct
(124) |
Nov
(151) |
Dec
(73) |
2025 |
Jan
(61) |
Feb
(17) |
Mar
(136) |
Apr
(72) |
May
(200) |
Jun
(238) |
Jul
(91) |
Aug
(8) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ho...@us...> - 2025-03-29 22:31:14
|
Revision: 15048 http://sourceforge.net/p/skim-app/code/15048 Author: hofman Date: 2025-03-29 22:31:06 +0000 (Sat, 29 Mar 2025) Log Message: ----------- Np need to notify focus ring changes every time, thi is often implied eg when size changes. Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-29 16:40:29 UTC (rev 15047) +++ trunk/SKColorSwatch.m 2025-03-29 22:31:06 UTC (rev 15048) @@ -626,18 +626,16 @@ selectedIndex++; [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; } - if (focusedIndex >= i) + if (focusedIndex >= i) { focusedIndex++; + [self noteFocusRingMaskChanged]; + } [self didChangeColors]; - [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ [self updateItemViewFramesAnimating:YES]; [[self animator] setBezelWidth:[self contentWidth]]; if (autoResizes) [[self animator] setFrameSize:[self intrinsicFrameSize]]; - } - completionHandler:^{ - [self noteFocusRingMaskChanged]; }]; } } @@ -656,10 +654,11 @@ [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; } if (focusedIndex > i || - focusedIndex == (NSInteger)[itemViews count] - 1) + focusedIndex == (NSInteger)[itemViews count] - 1) { focusedIndex--; + [self noteFocusRingMaskChanged]; + } [self didChangeColors]; - [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ [[itemView animator] setFrame:[self frameForCollapsedItemViewAtIndex:i]]; [self updateItemViewFramesAnimating:YES]; @@ -669,7 +668,6 @@ } completionHandler:^{ [itemView removeFromSuperview]; - [self noteFocusRingMaskChanged]; }]; } } @@ -692,14 +690,16 @@ selectedIndex++; [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; } - if (focusedIndex == from) - focusedIndex = to; - else if (focusedIndex > from && focusedIndex <= to) - focusedIndex--; - else if (focusedIndex < from && focusedIndex >= to) - focusedIndex++; + if (focusedIndex >= MIN(from, to) && focusedIndex <= MAX(from, to)) { + if (focusedIndex == from) + focusedIndex = to; + else if (focusedIndex > from && focusedIndex <= to) + focusedIndex--; + else if (focusedIndex < from && focusedIndex >= to) + focusedIndex++; + [self noteFocusRingMaskChanged]; + } [self didChangeColors]; - [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ [self updateItemViewFramesAnimating:YES]; } @@ -706,7 +706,6 @@ completionHandler:^{ if (to < from) [self addSubview:itemView positioned:NSWindowBelow relativeTo:[itemViews objectAtIndex:to + 1]]; - [self noteFocusRingMaskChanged]; }]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 16:40:31
|
Revision: 15047 http://sourceforge.net/p/skim-app/code/15047 Author: hofman Date: 2025-03-29 16:40:29 +0000 (Sat, 29 Mar 2025) Log Message: ----------- don't use typed string Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-29 16:38:44 UTC (rev 15046) +++ trunk/SKColorSwatch.m 2025-03-29 16:40:29 UTC (rev 15047) @@ -118,7 +118,7 @@ @synthesize autoResizes, selects, alternate, clickedColorIndex=clickedIndex, selectedColorIndex=selectedIndex, bezelWidth; @dynamic colors, color, contentWidth; -+ (id)defaultAnimationForKey:(NSAnimatablePropertyKey)key { ++ (id)defaultAnimationForKey:(NSString *)key { if ([key isEqualToString:@"bezelWidth"]) { CABasicAnimation *anim = [CABasicAnimation animation]; [anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 16:38:50
|
Revision: 15046 http://sourceforge.net/p/skim-app/code/15046 Author: hofman Date: 2025-03-29 16:38:44 +0000 (Sat, 29 Mar 2025) Log Message: ----------- Use default timing function for status bar animation to synchronize with other animations Modified Paths: -------------- trunk/SKStatusBar.m Modified: trunk/SKStatusBar.m =================================================================== --- trunk/SKStatusBar.m 2025-03-29 16:36:17 UTC (rev 15045) +++ trunk/SKStatusBar.m 2025-03-29 16:38:44 UTC (rev 15046) @@ -68,9 +68,12 @@ @dynamic visible, icon, progressIndicatorStyle; + (id)defaultAnimationForKey:(NSString *)key { - if ([key isEqualToString:@"windowContentBorderThickness"]) - return [CABasicAnimation animation]; - return [super defaultAnimationForKey:key]; + if ([key isEqualToString:@"windowContentBorderThickness"]) { + CABasicAnimation *anim = [CABasicAnimation animation]; + [anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]]; + return anim; + } else + return [super defaultAnimationForKey:key]; } - (instancetype)initWithFrame:(NSRect)frame { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 16:36:29
|
Revision: 15045 http://sourceforge.net/p/skim-app/code/15045 Author: hofman Date: 2025-03-29 16:36:17 +0000 (Sat, 29 Mar 2025) Log Message: ----------- Don't bother sending color swatch color change notifications that nobody observes. Can KVO observe colors for this. Modified Paths: -------------- trunk/SKColorSwatch.h trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.h =================================================================== --- trunk/SKColorSwatch.h 2025-03-29 16:13:28 UTC (rev 15044) +++ trunk/SKColorSwatch.h 2025-03-29 16:36:17 UTC (rev 15045) @@ -40,8 +40,6 @@ NS_ASSUME_NONNULL_BEGIN -extern NSString *SKColorSwatchColorsChangedNotification; - @class SKColorSwatchItemView; @interface SKColorSwatch : NSControl <NSDraggingSource, NSAccessibilityGroup> { Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-29 16:13:28 UTC (rev 15044) +++ trunk/SKColorSwatch.m 2025-03-29 16:36:17 UTC (rev 15045) @@ -45,7 +45,6 @@ #import "NSGraphics_SKExtensions.h" #import "NSShadow_SKExtensions.h" -NSString *SKColorSwatchColorsChangedNotification = @"SKColorSwatchColorsChangedNotification"; NSString *SKColorSwatchOrWellWillActivateNotification = @"SKColorSwatchOrWellWillActivateNotification"; #define COLORS_KEY @"colors" @@ -501,7 +500,6 @@ [self sizeToFit]; [self setBezelWidth:[self contentWidth]]; } - [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; if (focusedIndex >= (NSInteger)count) focusedIndex = count - 1; } @@ -589,7 +587,6 @@ value = [valueTransformer reverseTransformedValue:value]; [observedObject setValue:value forKeyPath:observedKeyPath]; } - [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; } - (void)setColor:(NSColor *)color atIndex:(NSInteger)i fromPanel:(BOOL)fromPanel { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 16:13:35
|
Revision: 15044 http://sourceforge.net/p/skim-app/code/15044 Author: hofman Date: 2025-03-29 16:13:28 +0000 (Sat, 29 Mar 2025) Log Message: ----------- enumerate ussing block Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-29 16:05:56 UTC (rev 15043) +++ trunk/SKColorSwatch.m 2025-03-29 16:13:28 UTC (rev 15044) @@ -477,13 +477,12 @@ } - (void)setColors:(NSArray *)newColors { - NSUInteger i, iMax = [newColors count]; - BOOL changeSize = iMax != [itemViews count]; - if (selectedIndex != -1 && (selectedIndex >= (NSInteger)iMax || [[newColors objectAtIndex:selectedIndex] isEqual:[[itemViews objectAtIndex:selectedIndex] color]] == NO)) + NSUInteger count = [newColors count], oldCount = [itemViews count]; + if (selectedIndex != -1 && (selectedIndex >= (NSInteger)count || [[newColors objectAtIndex:selectedIndex] isEqual:[[itemViews objectAtIndex:selectedIndex] color]] == NO)) [self deactivate]; - for (i = 0; i < iMax; i++) { + [newColors enumerateObjectsUsingBlock:^(NSColor *color, NSUInteger i, BOOL *stop){ SKColorSwatchItemView *itemView; - if (i < [itemViews count]) { + if (i < oldCount) { itemView = [itemViews objectAtIndex:i]; } else { itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForItemViewAtIndex:i]]; @@ -491,20 +490,20 @@ [self addSubview:itemView]; [itemViews addObject:itemView]; } - [itemView setColor:[newColors objectAtIndex:i]]; + [itemView setColor:color]; + }]; + while ([itemViews count] > count) { + [[itemViews objectAtIndex:count] removeFromSuperview]; + [itemViews removeObjectAtIndex:count]; } - while ([itemViews count] > iMax) { - [[itemViews objectAtIndex:iMax] removeFromSuperview]; - [itemViews removeObjectAtIndex:iMax]; - } - if (changeSize) { + if (count != oldCount) { if (autoResizes) [self sizeToFit]; [self setBezelWidth:[self contentWidth]]; } [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; - if (focusedIndex >= (NSInteger)iMax) - focusedIndex = iMax - 1; + if (focusedIndex >= (NSInteger)count) + focusedIndex = count - 1; } - (NSColor *)color { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 16:05:57
|
Revision: 15043 http://sourceforge.net/p/skim-app/code/15043 Author: hofman Date: 2025-03-29 16:05:56 +0000 (Sat, 29 Mar 2025) Log Message: ----------- Set frame for new itemView in initializer Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-29 16:03:09 UTC (rev 15042) +++ trunk/SKColorSwatch.m 2025-03-29 16:05:56 UTC (rev 15043) @@ -168,6 +168,7 @@ [NSLayoutConstraint activateConstraints:constraints]; SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForItemViewAtIndex:0]]; + [itemView setAutoresizingMask:NSViewNotSizable]; [itemView setColor:[NSColor whiteColor]]; [self addSubview:itemView]; itemViews = [[NSMutableArray alloc] initWithObjects:itemView, nil]; @@ -485,7 +486,7 @@ if (i < [itemViews count]) { itemView = [itemViews objectAtIndex:i]; } else { - itemView = [[SKColorSwatchItemView alloc] init]; + itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForItemViewAtIndex:i]]; [itemView setAutoresizingMask:NSViewNotSizable]; [self addSubview:itemView]; [itemViews addObject:itemView]; @@ -501,7 +502,6 @@ [self sizeToFit]; [self setBezelWidth:[self contentWidth]]; } - [self updateItemViewFramesAnimating:NO]; [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; if (focusedIndex >= (NSInteger)iMax) focusedIndex = iMax - 1; @@ -618,6 +618,7 @@ [self willChangeColors]; bezelWidth = [self contentWidth]; SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForCollapsedItemViewAtIndex:i]]; + [itemView setAutoresizingMask:NSViewNotSizable]; [itemView setColor:color]; if (i < (NSInteger)[itemViews count]) [self addSubview:itemView positioned:NSWindowBelow relativeTo:[itemViews objectAtIndex:i]]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 16:03:20
|
Revision: 15042 http://sourceforge.net/p/skim-app/code/15042 Author: hofman Date: 2025-03-29 16:03:09 +0000 (Sat, 29 Mar 2025) Log Message: ----------- bezelWidth only changes when number of colors changes Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-29 16:00:16 UTC (rev 15041) +++ trunk/SKColorSwatch.m 2025-03-29 16:03:09 UTC (rev 15042) @@ -476,7 +476,8 @@ } - (void)setColors:(NSArray *)newColors { - NSUInteger i, iMax = [newColors count], oldCount = [itemViews count]; + NSUInteger i, iMax = [newColors count]; + BOOL changeSize = iMax != [itemViews count]; if (selectedIndex != -1 && (selectedIndex >= (NSInteger)iMax || [[newColors objectAtIndex:selectedIndex] isEqual:[[itemViews objectAtIndex:selectedIndex] color]] == NO)) [self deactivate]; for (i = 0; i < iMax; i++) { @@ -495,9 +496,11 @@ [[itemViews objectAtIndex:iMax] removeFromSuperview]; [itemViews removeObjectAtIndex:iMax]; } - if (autoResizes && iMax != oldCount) - [self sizeToFit]; - [self setBezelWidth:[self contentWidth]]; + if (changeSize) { + if (autoResizes) + [self sizeToFit]; + [self setBezelWidth:[self contentWidth]]; + } [self updateItemViewFramesAnimating:NO]; [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; if (focusedIndex >= (NSInteger)iMax) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 16:00:28
|
Revision: 15041 http://sourceforge.net/p/skim-app/code/15041 Author: hofman Date: 2025-03-29 16:00:16 +0000 (Sat, 29 Mar 2025) Log Message: ----------- use variable Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-29 15:51:44 UTC (rev 15040) +++ trunk/SKColorSwatch.m 2025-03-29 16:00:16 UTC (rev 15041) @@ -495,7 +495,7 @@ [[itemViews objectAtIndex:iMax] removeFromSuperview]; [itemViews removeObjectAtIndex:iMax]; } - if (autoResizes && [newColors count] != oldCount) + if (autoResizes && iMax != oldCount) [self sizeToFit]; [self setBezelWidth:[self contentWidth]]; [self updateItemViewFramesAnimating:NO]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-29 15:51:45
|
Revision: 15040 http://sourceforge.net/p/skim-app/code/15040 Author: hofman Date: 2025-03-29 15:51:44 +0000 (Sat, 29 Mar 2025) Log Message: ----------- only change item view frame when it changes Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-28 17:20:17 UTC (rev 15039) +++ trunk/SKColorSwatch.m 2025-03-29 15:51:44 UTC (rev 15040) @@ -287,7 +287,9 @@ - (void)updateItemViewFramesAnimating:(BOOL)animate { [itemViews enumerateObjectsUsingBlock:^(SKColorSwatchItemView *itemView, NSUInteger i, BOOL *stop){ - [animate ? [itemView animator] : itemView setFrame:[self frameForItemViewAtIndex:i]]; + NSRect rect = [self frameForItemViewAtIndex:i]; + if (NSEqualRects(rect, [itemView frame]) == NO) + [animate ? [itemView animator] : itemView setFrame:rect]; }]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-28 17:20:29
|
Revision: 15039 http://sourceforge.net/p/skim-app/code/15039 Author: hofman Date: 2025-03-28 17:20:17 +0000 (Fri, 28 Mar 2025) Log Message: ----------- enumerate with block Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-28 16:55:52 UTC (rev 15038) +++ trunk/SKColorSwatch.m 2025-03-28 17:20:17 UTC (rev 15039) @@ -724,15 +724,14 @@ #pragma mark NSDraggingDestination protocol - (void)setDropLocation:(SKColorSwatchDropLocation)dropLocation atIndex:(NSInteger)anIndex { - NSInteger i, iMax = [itemViews count]; - for (i = 0; i < iMax; i++) { + [itemViews enumerateObjectsUsingBlock:^(SKColorSwatchItemView *itemView, NSUInteger i, BOOL *stop){ SKColorSwatchDropLocation location = SKColorSwatchNoDrop; - if (i == anIndex) + if ((NSInteger)i == anIndex) location = dropLocation; - else if (dropLocation == SKColorSwatchDropBefore && i + 1 == anIndex) + else if (dropLocation == SKColorSwatchDropBefore && (NSInteger)i + 1 == anIndex) location = SKColorSwatchDropAfter; [[itemViews objectAtIndex:i] setDropLocation:location]; - } + }]; } - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-28 16:56:03
|
Revision: 15038 http://sourceforge.net/p/skim-app/code/15038 Author: hofman Date: 2025-03-28 16:55:52 +0000 (Fri, 28 Mar 2025) Log Message: ----------- Only deactivate color swatch when selected color changes Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-28 16:49:05 UTC (rev 15037) +++ trunk/SKColorSwatch.m 2025-03-28 16:55:52 UTC (rev 15038) @@ -475,7 +475,8 @@ - (void)setColors:(NSArray *)newColors { NSUInteger i, iMax = [newColors count], oldCount = [itemViews count]; - [self deactivate]; + if (selectedIndex != -1 && (selectedIndex >= (NSInteger)iMax || [[newColors objectAtIndex:selectedIndex] isEqual:[[itemViews objectAtIndex:selectedIndex] color]] == NO)) + [self deactivate]; for (i = 0; i < iMax; i++) { SKColorSwatchItemView *itemView; if (i < [itemViews count]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-28 16:49:07
|
Revision: 15037 http://sourceforge.net/p/skim-app/code/15037 Author: hofman Date: 2025-03-28 16:49:05 +0000 (Fri, 28 Mar 2025) Log Message: ----------- make sure focusedIndex does not become invalid Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-28 16:43:46 UTC (rev 15036) +++ trunk/SKColorSwatch.m 2025-03-28 16:49:05 UTC (rev 15037) @@ -497,6 +497,8 @@ [self setBezelWidth:[self contentWidth]]; [self updateItemViewFramesAnimating:NO]; [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; + if (focusedIndex >= (NSInteger)iMax) + focusedIndex = iMax - 1; } - (NSColor *)color { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-28 16:43:52
|
Revision: 15036 http://sourceforge.net/p/skim-app/code/15036 Author: hofman Date: 2025-03-28 16:43:46 +0000 (Fri, 28 Mar 2025) Log Message: ----------- explicit KVO notifications instead of setter Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-28 16:27:11 UTC (rev 15035) +++ trunk/SKColorSwatch.m 2025-03-28 16:43:46 UTC (rev 15036) @@ -108,7 +108,6 @@ @end @interface SKColorSwatch () -@property (nonatomic) NSInteger selectedColorIndex; @property (nonatomic, readonly) CGFloat contentWidth; @property (nonatomic) CGFloat bezelWidth; - (NSRect)frameForItemViewAtIndex:(NSInteger)anIndex; @@ -529,7 +528,9 @@ [[[NSApp keyWindow] contentView] deactivateColorWellSubcontrols]; if (selectedIndex != -1) [[itemViews objectAtIndex:selectedIndex] setSelected:NO]; - [self setSelectedColorIndex:idx]; + [self willChangeValueForKey:SELECTEDCOLORINDEX_KEY]; + selectedIndex = idx; + [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; [[itemViews objectAtIndex:selectedIndex] setSelected:YES]; [colorPanel setColor:[[itemViews objectAtIndex:selectedIndex] color]]; [colorPanel orderFront:nil]; @@ -544,7 +545,9 @@ [nc removeObserver:self name:SKColorSwatchOrWellWillActivateNotification object:nil]; if (selectedIndex != -1) [[itemViews objectAtIndex:selectedIndex] setSelected:NO]; - [self setSelectedColorIndex:-1]; + [self willChangeValueForKey:SELECTEDCOLORINDEX_KEY]; + selectedIndex = -1; + [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-28 16:27:17
|
Revision: 15035 http://sourceforge.net/p/skim-app/code/15035 Author: hofman Date: 2025-03-28 16:27:11 +0000 (Fri, 28 Mar 2025) Log Message: ----------- Always set bezelWidth variable, calculate when it changes. Send KVO notifications when selectedIndex changes. Modified Paths: -------------- trunk/SKColorSwatch.h trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.h =================================================================== --- trunk/SKColorSwatch.h 2025-03-28 10:11:19 UTC (rev 15034) +++ trunk/SKColorSwatch.h 2025-03-28 16:27:11 UTC (rev 15035) @@ -47,8 +47,8 @@ @interface SKColorSwatch : NSControl <NSDraggingSource, NSAccessibilityGroup> { NSMutableArray<SKColorSwatchItemView *> *itemViews; NSControl *backgroundView; + CGFloat bezelWidth; CGFloat bezelHeight; - CGFloat bezelWidth; NSInteger clickedIndex; NSInteger selectedIndex; Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-28 10:11:19 UTC (rev 15034) +++ trunk/SKColorSwatch.m 2025-03-28 16:27:11 UTC (rev 15035) @@ -54,7 +54,8 @@ #define SELECTS_KEY @"selects" #define BEZELHEIGHT_KEY @"bezelHeight" -#define COLOR_KEY @"color" +#define COLOR_KEY @"color" +#define SELECTEDCOLORINDEX_KEY @"selectedColorIndex" #define BEZEL_INSET_LEFT 1.0 #define BEZEL_INSET_RIGHT 1.0 @@ -108,6 +109,7 @@ @interface SKColorSwatch () @property (nonatomic) NSInteger selectedColorIndex; +@property (nonatomic, readonly) CGFloat contentWidth; @property (nonatomic) CGFloat bezelWidth; - (NSRect)frameForItemViewAtIndex:(NSInteger)anIndex; - (void)setColor:(NSColor *)color atIndex:(NSInteger)i fromPanel:(BOOL)fromPanel; @@ -116,7 +118,7 @@ @implementation SKColorSwatch @synthesize autoResizes, selects, alternate, clickedColorIndex=clickedIndex, selectedColorIndex=selectedIndex, bezelWidth; -@dynamic colors, color; +@dynamic colors, color, contentWidth; + (id)defaultAnimationForKey:(NSAnimatablePropertyKey)key { if ([key isEqualToString:@"bezelWidth"]) { @@ -140,7 +142,7 @@ selectedIndex = -1; draggedIndex = -1; - bezelWidth = 0.0; + bezelWidth = [self contentWidth]; [self registerForDraggedTypes:[NSColor readableTypesForPasteboard:[NSPasteboard pasteboardWithName:NSPasteboardNameDrag]]]; } @@ -154,8 +156,6 @@ autoResizes = YES; selects = NO; bezelHeight = 22.0; - - [self commonInit]; backgroundView = [[SKColorSwatchBackgroundView alloc] initWithFrame:[self bounds]]; [backgroundView setTranslatesAutoresizingMaskIntoConstraints:NO]; @@ -172,6 +172,8 @@ [itemView setColor:[NSColor whiteColor]]; [self addSubview:itemView]; itemViews = [[NSMutableArray alloc] initWithObjects:itemView, nil]; + + [self commonInit]; } return self; } @@ -183,10 +185,7 @@ selects = [decoder decodeBoolForKey:SELECTS_KEY]; bezelHeight = [decoder decodeDoubleForKey:BEZELHEIGHT_KEY]; - [self commonInit]; - itemViews = [[NSMutableArray alloc] init]; - for (NSView *view in [self subviews]) { if ([view isKindOfClass:[SKColorSwatchBackgroundView class]]) backgroundView = (SKColorSwatchBackgroundView *)view; @@ -193,6 +192,8 @@ else if ([view isKindOfClass:[SKColorSwatchItemView class]]) [itemViews addObject:(SKColorSwatchItemView *)view]; } + + [self commonInit]; } return self; } @@ -263,8 +264,13 @@ return COLOR_INSET + [itemViews count] * DISTANCE_BETWEEN_COLORS; } +- (void)setBezelWidth:(CGFloat)width { + bezelWidth = width; + [self invalidateIntrinsicContentSize]; +} + - (NSSize)intrinsicContentSize { - return NSMakeSize(bezelWidth ?: [self contentWidth], bezelHeight); + return NSMakeSize(bezelWidth, bezelHeight); } - (NSSize)intrinsicFrameSize { @@ -290,8 +296,8 @@ CGFloat height = [backgroundView intrinsicContentSize].height; if (fabs(height - bezelHeight) > 0.0) { bezelHeight = height; + [self setBezelWidth:[self contentWidth]]; [self updateItemViewFramesAnimating:NO]; - [self invalidateIntrinsicContentSize]; if (autoResizes) [self sizeToFit]; } @@ -489,8 +495,8 @@ } if (autoResizes && [newColors count] != oldCount) [self sizeToFit]; + [self setBezelWidth:[self contentWidth]]; [self updateItemViewFramesAnimating:NO]; - [self invalidateIntrinsicContentSize]; [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; } @@ -504,11 +510,6 @@ [super setEnabled:enabled]; } -- (void)setBezelWidth:(CGFloat)width { - bezelWidth = width; - [self invalidateIntrinsicContentSize]; -} - #pragma mark Modification - (void)selectColorAtIndex:(NSInteger)idx { @@ -612,8 +613,11 @@ else [self addSubview:itemView positioned:NSWindowAbove relativeTo:nil]; [itemViews insertObject:itemView atIndex:i]; - if (selectedIndex >= i) + if (selectedIndex >= i) { + [self willChangeValueForKey:SELECTEDCOLORINDEX_KEY]; selectedIndex++; + [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; + } if (focusedIndex >= i) focusedIndex++; [self didChangeColors]; @@ -625,9 +629,6 @@ [[self animator] setFrameSize:[self intrinsicFrameSize]]; } completionHandler:^{ - [self setBezelWidth:0.0]; - if (autoResizes) - [self sizeToFit]; [self noteFocusRingMaskChanged]; }]; } @@ -635,16 +636,20 @@ - (void)removeColorAtIndex:(NSInteger)i { if (i >= 0 && i < (NSInteger)[itemViews count] && [itemViews count] > 1) { - if (selectedIndex > i) - selectedIndex--; - else if (selectedIndex == i) + if (selectedIndex == i) [self deactivate]; - if (focusedIndex > i) - focusedIndex--; [self willChangeColors]; bezelWidth = [self contentWidth]; SKColorSwatchItemView *itemView = [itemViews objectAtIndex:i]; [itemViews removeObjectAtIndex:i]; + if (selectedIndex > i) { + [self willChangeValueForKey:SELECTEDCOLORINDEX_KEY]; + selectedIndex--; + [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; + } + if (focusedIndex > i || + focusedIndex == (NSInteger)[itemViews count] - 1) + focusedIndex--; [self didChangeColors]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ @@ -656,9 +661,6 @@ } completionHandler:^{ [itemView removeFromSuperview]; - [self setBezelWidth:0.0]; - if (autoResizes) - [self sizeToFit]; [self noteFocusRingMaskChanged]; }]; } @@ -666,12 +668,22 @@ - (void)moveColorAtIndex:(NSInteger)from toIndex:(NSInteger)to { if (from >= 0 && to >= 0 && from != to) { - if (selectedIndex == from) - selectedIndex = to; - else if (selectedIndex > from && selectedIndex <= to) - selectedIndex--; - else if (selectedIndex < from && selectedIndex >= to) - selectedIndex++; + [self willChangeColors]; + SKColorSwatchItemView *itemView = [itemViews objectAtIndex:from]; + [itemViews removeObjectAtIndex:from]; + [itemViews insertObject:itemView atIndex:to]; + if (to > from) + [self addSubview:itemView positioned:NSWindowAbove relativeTo:[itemViews objectAtIndex:to - 1]]; + if (selectedIndex >= MIN(from, to) && selectedIndex <= MAX(from, to)) { + [self willChangeValueForKey:SELECTEDCOLORINDEX_KEY]; + if (selectedIndex == from) + selectedIndex = to; + else if (selectedIndex > from) + selectedIndex--; + else + selectedIndex++; + [self didChangeValueForKey:SELECTEDCOLORINDEX_KEY]; + } if (focusedIndex == from) focusedIndex = to; else if (focusedIndex > from && focusedIndex <= to) @@ -678,12 +690,6 @@ focusedIndex--; else if (focusedIndex < from && focusedIndex >= to) focusedIndex++; - [self willChangeColors]; - SKColorSwatchItemView *itemView = [itemViews objectAtIndex:from]; - [itemViews removeObjectAtIndex:from]; - [itemViews insertObject:itemView atIndex:to]; - if (to > from) - [self addSubview:itemView positioned:NSWindowAbove relativeTo:[itemViews objectAtIndex:to - 1]]; [self didChangeColors]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ @@ -1084,4 +1090,3 @@ } @end - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-28 10:11:26
|
Revision: 15034 http://sourceforge.net/p/skim-app/code/15034 Author: hofman Date: 2025-03-28 10:11:19 +0000 (Fri, 28 Mar 2025) Log Message: ----------- Don't autoresize color swatch control on 11.0+, let autolayout do its work. Not sure if it is needed on 10.15- for toolbar items. Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-28 10:05:19 UTC (rev 15033) +++ trunk/SKColorSwatch.m 2025-03-28 10:11:19 UTC (rev 15034) @@ -148,7 +148,10 @@ - (instancetype)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { - autoResizes = YES; + if (@available(macOS 11.0, *)) + autoResizes = NO; + else + autoResizes = YES; selects = NO; bezelHeight = 22.0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-28 10:05:30
|
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. |
From: <ho...@us...> - 2025-03-27 22:38:57
|
Revision: 15032 http://sourceforge.net/p/skim-app/code/15032 Author: hofman Date: 2025-03-27 22:38:45 +0000 (Thu, 27 Mar 2025) Log Message: ----------- Store colors for color swatch only in item view, no need to also keep them in an array Modified Paths: -------------- trunk/SKColorSwatch.h trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.h =================================================================== --- trunk/SKColorSwatch.h 2025-03-27 17:37:30 UTC (rev 15031) +++ trunk/SKColorSwatch.h 2025-03-27 22:38:45 UTC (rev 15032) @@ -45,7 +45,6 @@ @class SKColorSwatchItemView; @interface SKColorSwatch : NSControl <NSDraggingSource, NSAccessibilityGroup> { - NSMutableArray<NSColor *> *colors; NSMutableArray<SKColorSwatchItemView *> *itemViews; NSControl *backgroundView; CGFloat bezelHeight; Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-27 17:37:30 UTC (rev 15031) +++ trunk/SKColorSwatch.m 2025-03-27 22:38:45 UTC (rev 15032) @@ -115,8 +115,8 @@ @implementation SKColorSwatch -@synthesize colors, autoResizes, selects, alternate, clickedColorIndex=clickedIndex, selectedColorIndex=selectedIndex, bezelWidth; -@dynamic color; +@synthesize autoResizes, selects, alternate, clickedColorIndex=clickedIndex, selectedColorIndex=selectedIndex, bezelWidth; +@dynamic colors, color; + (id)defaultAnimationForKey:(NSAnimatablePropertyKey)key { if ([key isEqualToString:@"bezelWidth"]) { @@ -148,7 +148,6 @@ - (instancetype)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { - colors = [[NSMutableArray alloc] initWithObjects:[NSColor whiteColor], nil]; autoResizes = YES; selects = NO; bezelHeight = 22.0; @@ -177,7 +176,6 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (self) { - colors = [[NSMutableArray alloc] initWithArray:[decoder decodeObjectForKey:COLORS_KEY]]; autoResizes = [decoder decodeBoolForKey:AUTORESIZES_KEY]; selects = [decoder decodeBoolForKey:SELECTS_KEY]; bezelHeight = [decoder decodeDoubleForKey:BEZELHEIGHT_KEY]; @@ -198,7 +196,6 @@ - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; - [coder encodeObject:colors forKey:COLORS_KEY]; [coder encodeBool:autoResizes forKey:AUTORESIZES_KEY]; [coder encodeBool:selects forKey:SELECTS_KEY]; [coder encodeDouble:bezelHeight forKey:BEZELHEIGHT_KEY]; @@ -236,7 +233,7 @@ - (NSInteger)colorIndexAtPoint:(NSPoint)point { NSRect rect = [self frameForColorAtIndex:0]; - NSInteger i, count = [colors count]; + NSInteger i, count = [itemViews count]; for (i = 0; i < count; i++) { if (NSMouseInRect(point, rect, [self isFlipped])) @@ -249,7 +246,7 @@ - (NSInteger)insertionIndexAtPoint:(NSPoint)point { NSRect rect = [self frameForColorAtIndex:0]; CGFloat x = NSMidX(rect); - NSInteger i, count = [colors count]; + NSInteger i, count = [itemViews count]; for (i = 0; i < count; i++) { if (point.x < x) @@ -260,7 +257,7 @@ } - (CGFloat)contentWidth { - return COLOR_INSET + [colors count] * DISTANCE_BETWEEN_COLORS; + return COLOR_INSET + [itemViews count] * DISTANCE_BETWEEN_COLORS; } - (NSSize)intrinsicContentSize { @@ -384,7 +381,7 @@ draggedIndex = i; - NSColor *color = [colors objectAtIndex:i]; + NSColor *color = [[itemViews objectAtIndex:i] color]; CGFloat r = cornerRadius(NSControlSizeRegular) - 0.5; @@ -449,7 +446,7 @@ } - (void)moveRight:(id)sender { - if (++focusedIndex >= (NSInteger)[colors count]) + if (++focusedIndex >= (NSInteger)[itemViews count]) focusedIndex = 0; [self noteFocusRingMaskChanged]; NSAccessibilityPostNotification(self, NSAccessibilityFocusedUIElementChangedNotification); @@ -457,7 +454,7 @@ - (void)moveLeft:(id)sender { if (--focusedIndex < 0) - focusedIndex = (NSInteger)[colors count] - 1; + focusedIndex = (NSInteger)[itemViews count] - 1; [self noteFocusRingMaskChanged]; NSAccessibilityPostNotification(self, NSAccessibilityFocusedUIElementChangedNotification); } @@ -465,16 +462,12 @@ #pragma mark Accessors - (NSArray *)colors { - return [colors copy]; + return [itemViews valueForKey:COLOR_KEY]; } - (void)setColors:(NSArray *)newColors { - NSArray *oldColors = [self colors]; - NSUInteger i, iMax = [newColors count]; + NSUInteger i, iMax = [newColors count], oldCount = [itemViews count]; [self deactivate]; - [colors setArray:newColors]; - if (autoResizes && [newColors count] != [oldColors count]) - [self sizeToFit]; for (i = 0; i < iMax; i++) { SKColorSwatchItemView *itemView; if (i < [itemViews count]) { @@ -491,6 +484,8 @@ [[itemViews objectAtIndex:iMax] removeFromSuperview]; [itemViews removeObjectAtIndex:iMax]; } + if (autoResizes && [newColors count] != oldCount) + [self sizeToFit]; [self updateItemViewFrames]; [self invalidateIntrinsicContentSize]; [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; @@ -497,7 +492,7 @@ } - (NSColor *)color { - return clickedIndex == -1 ? nil : [colors objectAtIndex:clickedIndex]; + return clickedIndex == -1 ? nil : [[itemViews objectAtIndex:clickedIndex] color]; } - (void)setEnabled:(BOOL)enabled { @@ -532,7 +527,7 @@ [[itemViews objectAtIndex:selectedIndex] setSelected:NO]; [self setSelectedColorIndex:idx]; [[itemViews objectAtIndex:selectedIndex] setSelected:YES]; - [colorPanel setColor:[[self colors] objectAtIndex:selectedIndex]]; + [colorPanel setColor:[[itemViews objectAtIndex:selectedIndex] color]]; [colorPanel orderFront:nil]; [nc addObserver:self selector:@selector(handleColorPanelColorChanged:) name:NSColorPanelColorDidChangeNotification object:colorPanel]; } @@ -568,7 +563,7 @@ id observedObject = [info objectForKey:NSObservedObjectKey]; NSString *observedKeyPath = [info objectForKey:NSObservedKeyPathKey]; if (observedObject && observedKeyPath) { - id value = [colors copy]; + id value = [self colors]; NSValueTransformer *valueTransformer = [[info objectForKey:NSOptionsKey] objectForKey:NSValueTransformerBindingOption]; if (valueTransformer == nil || [valueTransformer isEqual:[NSNull null]]) { NSString *transformerName = [[info objectForKey:NSOptionsKey] objectForKey:NSValueTransformerNameBindingOption]; @@ -584,9 +579,8 @@ } - (void)setColor:(NSColor *)color atIndex:(NSInteger)i fromPanel:(BOOL)fromPanel { - if (color && i >= 0 && i < (NSInteger)[colors count]) { + if (color && i >= 0 && i < (NSInteger)[itemViews count]) { [self willChangeColors]; - [colors replaceObjectAtIndex:i withObject:color]; [[itemViews objectAtIndex:i] setColor:color]; NSAccessibilityPostNotification([itemViews objectAtIndex:i], NSAccessibilityValueChangedNotification); [self didChangeColors]; @@ -613,10 +607,9 @@ } - (void)insertColor:(NSColor *)color atIndex:(NSInteger)i { - if (color && i >= 0 && i <= (NSInteger)[colors count]) { + if (color && i >= 0 && i <= (NSInteger)[itemViews count]) { [self willChangeColors]; bezelWidth = [self contentWidth]; - [colors insertObject:color atIndex:i]; SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForCollapsedItemViewAtIndex:i]]; [itemView setColor:color]; if (i < (NSInteger)[itemViews count]) @@ -646,7 +639,7 @@ } - (void)removeColorAtIndex:(NSInteger)i { - if (i >= 0 && i < (NSInteger)[colors count] && [colors count] > 1) { + if (i >= 0 && i < (NSInteger)[itemViews count] && [itemViews count] > 1) { if (selectedIndex > i) selectedIndex--; else if (selectedIndex == i) @@ -655,7 +648,6 @@ focusedIndex--; [self willChangeColors]; bezelWidth = [self contentWidth]; - [colors removeObjectAtIndex:i]; SKColorSwatchItemView *itemView = [itemViews objectAtIndex:i]; [itemViews removeObjectAtIndex:i]; [self didChangeColors]; @@ -679,7 +671,6 @@ - (void)moveColorAtIndex:(NSInteger)from toIndex:(NSInteger)to { if (from >= 0 && to >= 0 && from != to) { - NSColor *color = [colors objectAtIndex:from]; if (selectedIndex == from) selectedIndex = to; else if (selectedIndex > from && selectedIndex <= to) @@ -693,8 +684,6 @@ else if (focusedIndex < from && focusedIndex >= to) focusedIndex++; [self willChangeColors]; - [colors removeObjectAtIndex:from]; - [colors insertObject:color atIndex:to]; SKColorSwatchItemView *itemView = [itemViews objectAtIndex:from]; [itemViews removeObjectAtIndex:from]; [itemViews insertObject:itemView atIndex:to]; @@ -716,7 +705,7 @@ #pragma mark NSDraggingSource protocol - (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { - return context == NSDraggingContextWithinApplication ? NSDragOperationGeneric : [colors count] > 1 ? NSDragOperationDelete : NSDragOperationNone; + return context == NSDraggingContextWithinApplication ? NSDragOperationGeneric : [itemViews count] > 1 ? NSDragOperationDelete : NSDragOperationNone; } - (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { @@ -839,7 +828,7 @@ } - (id)accessibilityFocusedUIElement { - if (focusedIndex != -1 && focusedIndex < (NSInteger)[colors count]) + if (focusedIndex != -1 && focusedIndex < (NSInteger)[itemViews count]) return NSAccessibilityUnignoredAncestor([itemViews objectAtIndex:focusedIndex]); else return NSAccessibilityUnignoredAncestor(self); @@ -852,7 +841,7 @@ - (void)itemView:(SKColorSwatchItemView *)itemView setFocused:(BOOL)focused { if (focused) { NSUInteger anIndex = [itemViews indexOfObject:itemView]; - if (anIndex < [[self colors] count]) { + if (anIndex < [itemViews count]) { focusedIndex = anIndex; [self noteFocusRingMaskChanged]; } @@ -867,7 +856,7 @@ - (void)pressItemView:(SKColorSwatchItemView *)itemView alternate:(BOOL)isAlternate { NSUInteger anIndex = [itemViews indexOfObject:itemView]; - if (anIndex < [[self colors] count]) { + if (anIndex < [itemViews count]) { alternate = isAlternate; [self performClickAtIndex:anIndex]; alternate = NO; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-27 17:37:41
|
Revision: 15031 http://sourceforge.net/p/skim-app/code/15031 Author: hofman Date: 2025-03-27 17:37:30 +0000 (Thu, 27 Mar 2025) Log Message: ----------- Shift selected and focused index when changing swatch colors Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-27 16:53:35 UTC (rev 15030) +++ trunk/SKColorSwatch.m 2025-03-27 17:37:30 UTC (rev 15031) @@ -614,7 +614,6 @@ - (void)insertColor:(NSColor *)color atIndex:(NSInteger)i { if (color && i >= 0 && i <= (NSInteger)[colors count]) { - [self deactivate]; [self willChangeColors]; bezelWidth = [self contentWidth]; [colors insertObject:color atIndex:i]; @@ -625,6 +624,10 @@ else [self addSubview:itemView positioned:NSWindowAbove relativeTo:nil]; [itemViews insertObject:itemView atIndex:i]; + if (selectedIndex >= i) + selectedIndex++; + if (focusedIndex >= i) + focusedIndex++; [self didChangeColors]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ @@ -644,7 +647,12 @@ - (void)removeColorAtIndex:(NSInteger)i { if (i >= 0 && i < (NSInteger)[colors count] && [colors count] > 1) { - [self deactivate]; + if (selectedIndex > i) + selectedIndex--; + else if (selectedIndex == i) + [self deactivate]; + if (focusedIndex > i) + focusedIndex--; [self willChangeColors]; bezelWidth = [self contentWidth]; [colors removeObjectAtIndex:i]; @@ -672,7 +680,18 @@ - (void)moveColorAtIndex:(NSInteger)from toIndex:(NSInteger)to { if (from >= 0 && to >= 0 && from != to) { NSColor *color = [colors objectAtIndex:from]; - [self deactivate]; + if (selectedIndex == from) + selectedIndex = to; + else if (selectedIndex > from && selectedIndex <= to) + selectedIndex--; + else if (selectedIndex < from && selectedIndex >= to) + selectedIndex++; + if (focusedIndex == from) + focusedIndex = to; + else if (focusedIndex > from && focusedIndex <= to) + focusedIndex--; + else if (focusedIndex < from && focusedIndex >= to) + focusedIndex++; [self willChangeColors]; [colors removeObjectAtIndex:from]; [colors insertObject:color atIndex:to]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-27 16:53:47
|
Revision: 15030 http://sourceforge.net/p/skim-app/code/15030 Author: hofman Date: 2025-03-27 16:53:35 +0000 (Thu, 27 Mar 2025) Log Message: ----------- Animate color swatch width for autolayout. Always update colors and itemViews before animating for insert/remove/move. Modified Paths: -------------- trunk/SKColorSwatch.h trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.h =================================================================== --- trunk/SKColorSwatch.h 2025-03-27 10:23:44 UTC (rev 15029) +++ trunk/SKColorSwatch.h 2025-03-27 16:53:35 UTC (rev 15030) @@ -49,6 +49,7 @@ NSMutableArray<SKColorSwatchItemView *> *itemViews; NSControl *backgroundView; CGFloat bezelHeight; + CGFloat bezelWidth; NSInteger clickedIndex; NSInteger selectedIndex; Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-27 10:23:44 UTC (rev 15029) +++ trunk/SKColorSwatch.m 2025-03-27 16:53:35 UTC (rev 15030) @@ -108,15 +108,25 @@ @interface SKColorSwatch () @property (nonatomic) NSInteger selectedColorIndex; -- (NSRect)frameForItemViewAtIndex:(NSInteger)anIndex collapsedIndex:(NSInteger)collapsedIndex; +@property (nonatomic) CGFloat bezelWidth; +- (NSRect)frameForItemViewAtIndex:(NSInteger)anIndex; - (void)setColor:(NSColor *)color atIndex:(NSInteger)i fromPanel:(BOOL)fromPanel; @end @implementation SKColorSwatch -@synthesize colors, autoResizes, selects, alternate, clickedColorIndex=clickedIndex, selectedColorIndex=selectedIndex; +@synthesize colors, autoResizes, selects, alternate, clickedColorIndex=clickedIndex, selectedColorIndex=selectedIndex, bezelWidth; @dynamic color; ++ (id)defaultAnimationForKey:(NSAnimatablePropertyKey)key { + if ([key isEqualToString:@"bezelWidth"]) { + CABasicAnimation *anim = [CABasicAnimation animation]; + [anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]]; + return anim; + } else + return [super defaultAnimationForKey:key]; +} + - (Class)valueClassForBinding:(NSString *)binding { if ([binding isEqualToString:COLORS_KEY]) return [NSArray class]; @@ -130,6 +140,8 @@ selectedIndex = -1; draggedIndex = -1; + bezelWidth = 0.0; + [self registerForDraggedTypes:[NSColor readableTypesForPasteboard:[NSPasteboard pasteboardWithName:NSPasteboardNameDrag]]]; } @@ -154,7 +166,7 @@ [constraints setValue:@YES forKey:@"shouldBeArchived"]; [NSLayoutConstraint activateConstraints:constraints]; - SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForItemViewAtIndex:0 collapsedIndex:-1]]; + SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForItemViewAtIndex:0]]; [itemView setColor:[NSColor whiteColor]]; [self addSubview:itemView]; itemViews = [[NSMutableArray alloc] initWithObjects:itemView, nil]; @@ -214,16 +226,14 @@ return rect; } -- (NSRect)frameForItemViewAtIndex:(NSInteger)anIndex collapsedIndex:(NSInteger)collapsedIndex { - NSInteger i = anIndex; - if (collapsedIndex != -1 && anIndex > collapsedIndex) - i--; - NSRect rect = NSInsetRect([self frameForColorAtIndex:i], -COLOR_INSET, -COLOR_INSET); - if (collapsedIndex == anIndex) - rect.size.width -= DISTANCE_BETWEEN_COLORS; - return rect; +- (NSRect)frameForItemViewAtIndex:(NSInteger)anIndex { + return NSInsetRect([self frameForColorAtIndex:anIndex], -COLOR_INSET, -COLOR_INSET); } +- (NSRect)frameForCollapsedItemViewAtIndex:(NSInteger)anIndex { + return SKShrinkRect([self frameForItemViewAtIndex:anIndex], DISTANCE_BETWEEN_COLORS, NSMaxXEdge); +} + - (NSInteger)colorIndexAtPoint:(NSPoint)point { NSRect rect = [self frameForColorAtIndex:0]; NSInteger i, count = [colors count]; @@ -249,17 +259,21 @@ return count; } -- (NSSize)sizeForNumberOfColors:(NSUInteger)count { - NSEdgeInsets insets = [self alignmentRectInsets]; - return NSMakeSize(COLOR_INSET + count * DISTANCE_BETWEEN_COLORS + insets.left + insets.right, bezelHeight + insets.bottom + insets.top); +- (CGFloat)contentWidth { + return COLOR_INSET + [colors count] * DISTANCE_BETWEEN_COLORS; } - (NSSize)intrinsicContentSize { - return NSMakeSize(COLOR_INSET + [colors count] * DISTANCE_BETWEEN_COLORS, bezelHeight); + return NSMakeSize(bezelWidth ?: [self contentWidth], bezelHeight); } +- (NSSize)intrinsicFrameSize { + NSEdgeInsets insets = [self alignmentRectInsets]; + return NSMakeSize([self contentWidth] + insets.left + insets.right, bezelHeight + insets.bottom + insets.top); +} + - (void)sizeToFit { - [self setFrameSize:[self sizeForNumberOfColors:[colors count]]]; + [self setFrameSize:[self intrinsicFrameSize]]; } - (NSEdgeInsets)alignmentRectInsets { @@ -269,7 +283,7 @@ - (void)updateItemViewFrames { NSUInteger i, iMax = [itemViews count]; for (i = 0; i < iMax; i++) - [[itemViews objectAtIndex:i] setFrame:[self frameForItemViewAtIndex:i collapsedIndex:-1]]; + [[itemViews objectAtIndex:i] setFrame:[self frameForItemViewAtIndex:i]]; } - (void)updateBezelHeight { @@ -492,6 +506,11 @@ [super setEnabled:enabled]; } +- (void)setBezelWidth:(CGFloat)width { + bezelWidth = width; + [self invalidateIntrinsicContentSize]; +} + #pragma mark Modification - (void)selectColorAtIndex:(NSInteger)idx { @@ -585,9 +604,9 @@ [self setColor:color atIndex:i fromPanel:NO]; } -- (void)animateItemViewsCollapsing:(NSInteger)collapsedIndex { +- (void)animateItemViewFrames { [itemViews enumerateObjectsUsingBlock:^(SKColorSwatchItemView *itemView, NSUInteger i, BOOL *stop){ - NSRect frame = [self frameForItemViewAtIndex:i collapsedIndex:collapsedIndex]; + NSRect frame = [self frameForItemViewAtIndex:i]; if (NSEqualRects(frame, [itemView frame]) == NO) [[itemView animator] setFrame:frame]; }]; @@ -597,9 +616,9 @@ if (color && i >= 0 && i <= (NSInteger)[colors count]) { [self deactivate]; [self willChangeColors]; + bezelWidth = [self contentWidth]; [colors insertObject:color atIndex:i]; - [self invalidateIntrinsicContentSize]; - SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForItemViewAtIndex:i collapsedIndex:i]]; + SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForCollapsedItemViewAtIndex:i]]; [itemView setColor:color]; if (i < (NSInteger)[itemViews count]) [self addSubview:itemView positioned:NSWindowBelow relativeTo:[itemViews objectAtIndex:i]]; @@ -606,19 +625,20 @@ else [self addSubview:itemView positioned:NSWindowAbove relativeTo:nil]; [itemViews insertObject:itemView atIndex:i]; - NSSize size = [self sizeForNumberOfColors:[colors count]]; + [self didChangeColors]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ - [self animateItemViewsCollapsing:-1]; + [self animateItemViewFrames]; + [[self animator] setBezelWidth:[self contentWidth]]; if (autoResizes) - [[self animator] setFrameSize:size]; + [[self animator] setFrameSize:[self intrinsicFrameSize]]; } completionHandler:^{ + [self setBezelWidth:0.0]; if (autoResizes) [self sizeToFit]; [self noteFocusRingMaskChanged]; }]; - [self didChangeColors]; } } @@ -625,22 +645,25 @@ - (void)removeColorAtIndex:(NSInteger)i { if (i >= 0 && i < (NSInteger)[colors count] && [colors count] > 1) { [self deactivate]; - NSSize size = [self sizeForNumberOfColors:[colors count] - 1]; + [self willChangeColors]; + bezelWidth = [self contentWidth]; + [colors removeObjectAtIndex:i]; + SKColorSwatchItemView *itemView = [itemViews objectAtIndex:i]; + [itemViews removeObjectAtIndex:i]; + [self didChangeColors]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ - [self animateItemViewsCollapsing:i]; + [[itemView animator] setFrame:[self frameForCollapsedItemViewAtIndex:i]]; + [self animateItemViewFrames]; + [[self animator] setBezelWidth:[self contentWidth]]; if (autoResizes) - [[self animator] setFrameSize:size]; + [[self animator] setFrameSize:[self intrinsicFrameSize]]; } completionHandler:^{ - [self willChangeColors]; - [colors removeObjectAtIndex:i]; - [[itemViews objectAtIndex:i] removeFromSuperview]; - [itemViews removeObjectAtIndex:i]; - [self didChangeColors]; + [itemView removeFromSuperview]; + [self setBezelWidth:0.0]; if (autoResizes) [self sizeToFit]; - [self invalidateIntrinsicContentSize]; [self noteFocusRingMaskChanged]; }]; } @@ -658,9 +681,10 @@ [itemViews insertObject:itemView atIndex:to]; if (to > from) [self addSubview:itemView positioned:NSWindowAbove relativeTo:[itemViews objectAtIndex:to - 1]]; + [self didChangeColors]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ - [self animateItemViewsCollapsing:-1]; + [self animateItemViewFrames]; } completionHandler:^{ if (to < from) @@ -667,7 +691,6 @@ [self addSubview:itemView positioned:NSWindowBelow relativeTo:[itemViews objectAtIndex:to + 1]]; [self noteFocusRingMaskChanged]; }]; - [self didChangeColors]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-27 10:23:46
|
Revision: 15029 http://sourceforge.net/p/skim-app/code/15029 Author: hofman Date: 2025-03-27 10:23:44 +0000 (Thu, 27 Mar 2025) Log Message: ----------- enumerate using block Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-27 10:07:11 UTC (rev 15028) +++ trunk/SKColorSwatch.m 2025-03-27 10:23:44 UTC (rev 15029) @@ -586,12 +586,11 @@ } - (void)animateItemViewsCollapsing:(NSInteger)collapsedIndex { - NSUInteger i = 0; - for (SKColorSwatchItemView *itemView in itemViews) { - NSRect frame = [self frameForItemViewAtIndex:i++ collapsedIndex:collapsedIndex]; + [itemViews enumerateObjectsUsingBlock:^(SKColorSwatchItemView *itemView, NSUInteger i, BOOL *stop){ + NSRect frame = [self frameForItemViewAtIndex:i collapsedIndex:collapsedIndex]; if (NSEqualRects(frame, [itemView frame]) == NO) [[itemView animator] setFrame:frame]; - } + }]; } - (void)insertColor:(NSColor *)color atIndex:(NSInteger)i { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-27 10:07:12
|
Revision: 15028 http://sourceforge.net/p/skim-app/code/15028 Author: hofman Date: 2025-03-27 10:07:11 +0000 (Thu, 27 Mar 2025) Log Message: ----------- Animate color swatch frame separately. Only animate item view frames that change. Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-26 23:08:27 UTC (rev 15027) +++ trunk/SKColorSwatch.m 2025-03-27 10:07:11 UTC (rev 15028) @@ -585,12 +585,13 @@ [self setColor:color atIndex:i fromPanel:NO]; } -- (void)animateItemViewsCollapsing:(NSInteger)collapsedIndex frameSize:(NSSize)size { +- (void)animateItemViewsCollapsing:(NSInteger)collapsedIndex { NSUInteger i = 0; - for (SKColorSwatchItemView *itemView in itemViews) - [[itemView animator] setFrame:[self frameForItemViewAtIndex:i++ collapsedIndex:collapsedIndex]]; - if (NSEqualSizes(size, NSZeroSize) == NO && autoResizes) - [[self animator] setFrameSize:size]; + for (SKColorSwatchItemView *itemView in itemViews) { + NSRect frame = [self frameForItemViewAtIndex:i++ collapsedIndex:collapsedIndex]; + if (NSEqualRects(frame, [itemView frame]) == NO) + [[itemView animator] setFrame:frame]; + } } - (void)insertColor:(NSColor *)color atIndex:(NSInteger)i { @@ -609,7 +610,9 @@ NSSize size = [self sizeForNumberOfColors:[colors count]]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ - [self animateItemViewsCollapsing:-1 frameSize:size]; + [self animateItemViewsCollapsing:-1]; + if (autoResizes) + [[self animator] setFrameSize:size]; } completionHandler:^{ if (autoResizes) @@ -626,7 +629,9 @@ NSSize size = [self sizeForNumberOfColors:[colors count] - 1]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ - [self animateItemViewsCollapsing:i frameSize:size]; + [self animateItemViewsCollapsing:i]; + if (autoResizes) + [[self animator] setFrameSize:size]; } completionHandler:^{ [self willChangeColors]; @@ -656,7 +661,7 @@ [self addSubview:itemView positioned:NSWindowAbove relativeTo:[itemViews objectAtIndex:to - 1]]; [self noteFocusRingMaskChanged]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){ - [self animateItemViewsCollapsing:-1 frameSize:NSZeroSize]; + [self animateItemViewsCollapsing:-1]; } completionHandler:^{ if (to < from) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-26 23:08:39
|
Revision: 15027 http://sourceforge.net/p/skim-app/code/15027 Author: hofman Date: 2025-03-26 23:08:27 +0000 (Wed, 26 Mar 2025) Log Message: ----------- fix method declaration Modified Paths: -------------- trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-26 17:04:40 UTC (rev 15026) +++ trunk/SKColorSwatch.m 2025-03-26 23:08:27 UTC (rev 15027) @@ -103,7 +103,7 @@ @interface SKColorSwatch (SKAccessibilityColorSwatchElementParent) - (BOOL)isItemViewFocused:(SKColorSwatchItemView *)itemView; - (void)itemView:(SKColorSwatchItemView *)itemView setFocused:(BOOL)focused; -- (void)pressItemView:(SKColorSwatchItemView *)itemView; +- (void)pressItemView:(SKColorSwatchItemView *)itemView alternate:(BOOL)alternate; @end @interface SKColorSwatch () This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-26 17:04:48
|
Revision: 15026 http://sourceforge.net/p/skim-app/code/15026 Author: hofman Date: 2025-03-26 17:04:40 +0000 (Wed, 26 Mar 2025) Log Message: ----------- No need to store target and action, NSControl already does that since 10.10 Modified Paths: -------------- trunk/SKLineWell.h trunk/SKLineWell.m Modified: trunk/SKLineWell.h =================================================================== --- trunk/SKLineWell.h 2025-03-26 16:57:47 UTC (rev 15025) +++ trunk/SKLineWell.h 2025-03-26 17:04:40 UTC (rev 15026) @@ -71,9 +71,6 @@ unsigned int existsActiveLineWell:1; unsigned int highlighted:1; } lwFlags; - - id target; - SEL action; } @property (nonatomic, readonly, getter=isActive) BOOL active; Modified: trunk/SKLineWell.m =================================================================== --- trunk/SKLineWell.m 2025-03-26 16:57:47 UTC (rev 15025) +++ trunk/SKLineWell.m 2025-03-26 17:04:40 UTC (rev 15026) @@ -52,8 +52,6 @@ #define DISPLAYSTYLE_KEY @"lwFlags.displayStyle" #define ACTIVE_KEY @"active" -#define ACTION_KEY @"action" -#define TARGET_KEY @"target" #define SKLineWellWillBecomeActiveNotification @"SKLineWellWillBecomeActiveNotification" #define EXCLUSIVE_KEY @"exclusive" @@ -90,9 +88,6 @@ lwFlags.canActivate = 0; lwFlags.existsActiveLineWell = 0; - target = nil; - action = NULL; - [self commonInit]; } return self; @@ -108,8 +103,6 @@ endLineStyle = [decoder decodeIntegerForKey:SKLineWellEndLineStyleKey]; lwFlags.displayStyle = [decoder decodeIntegerForKey:DISPLAYSTYLE_KEY]; lwFlags.active = [decoder decodeBoolForKey:ACTIVE_KEY]; - action = NSSelectorFromString([decoder decodeObjectForKey:ACTION_KEY]); - target = [decoder decodeObjectForKey:TARGET_KEY]; [self commonInit]; } return self; @@ -124,8 +117,6 @@ [coder encodeInteger:endLineStyle forKey:SKLineWellEndLineStyleKey]; [coder encodeInteger:(NSInteger)(lwFlags.displayStyle) forKey:DISPLAYSTYLE_KEY]; [coder encodeBool:(BOOL)(lwFlags.active) forKey:ACTIVE_KEY]; - [coder encodeObject:NSStringFromSelector(action) forKey:ACTION_KEY]; - [coder encodeConditionalObject:target forKey:TARGET_KEY]; } - (void)dealloc { @@ -436,14 +427,6 @@ #pragma mark Accessors -- (SEL)action { return action; } - -- (void)setAction:(SEL)newAction { action = newAction; } - -- (id)target { return target; } - -- (void)setTarget:(id)newTarget { target = newTarget; } - - (BOOL)isActive { return lwFlags.active; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-26 16:58:00
|
Revision: 15025 http://sourceforge.net/p/skim-app/code/15025 Author: hofman Date: 2025-03-26 16:57:47 +0000 (Wed, 26 Mar 2025) Log Message: ----------- No need to store target and action, NSControl already does that since 10.10 Modified Paths: -------------- trunk/SKColorSwatch.h trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.h =================================================================== --- trunk/SKColorSwatch.h 2025-03-26 16:44:37 UTC (rev 15024) +++ trunk/SKColorSwatch.h 2025-03-26 16:57:47 UTC (rev 15025) @@ -55,9 +55,6 @@ NSInteger focusedIndex; NSInteger draggedIndex; - SEL action; - id target; - BOOL autoResizes; BOOL selects; BOOL alternate; Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-26 16:44:37 UTC (rev 15024) +++ trunk/SKColorSwatch.m 2025-03-26 16:57:47 UTC (rev 15025) @@ -50,8 +50,6 @@ #define COLORS_KEY @"colors" -#define ACTION_KEY @"action" -#define TARGET_KEY @"target" #define AUTORESIZES_KEY @"autoResizes" #define SELECTS_KEY @"selects" #define BEZELHEIGHT_KEY @"bezelHeight" @@ -139,8 +137,6 @@ self = [super initWithFrame:frame]; if (self) { colors = [[NSMutableArray alloc] initWithObjects:[NSColor whiteColor], nil]; - action = NULL; - target = nil; autoResizes = YES; selects = NO; bezelHeight = 22.0; @@ -170,8 +166,6 @@ self = [super initWithCoder:decoder]; if (self) { colors = [[NSMutableArray alloc] initWithArray:[decoder decodeObjectForKey:COLORS_KEY]]; - action = NSSelectorFromString([decoder decodeObjectForKey:ACTION_KEY]); - target = [decoder decodeObjectForKey:TARGET_KEY]; autoResizes = [decoder decodeBoolForKey:AUTORESIZES_KEY]; selects = [decoder decodeBoolForKey:SELECTS_KEY]; bezelHeight = [decoder decodeDoubleForKey:BEZELHEIGHT_KEY]; @@ -193,8 +187,6 @@ - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; [coder encodeObject:colors forKey:COLORS_KEY]; - [coder encodeObject:NSStringFromSelector(action) forKey:ACTION_KEY]; - [coder encodeConditionalObject:target forKey:TARGET_KEY]; [coder encodeBool:autoResizes forKey:AUTORESIZES_KEY]; [coder encodeBool:selects forKey:SELECTS_KEY]; [coder encodeDouble:bezelHeight forKey:BEZELHEIGHT_KEY]; @@ -458,14 +450,6 @@ #pragma mark Accessors -- (SEL)action { return action; } - -- (void)setAction:(SEL)newAction { action = newAction; } - -- (id)target { return target; } - -- (void)setTarget:(id)newTarget { target = newTarget; } - - (NSArray *)colors { return [colors copy]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-03-26 16:44:40
|
Revision: 15024 http://sourceforge.net/p/skim-app/code/15024 Author: hofman Date: 2025-03-26 16:44:37 +0000 (Wed, 26 Mar 2025) Log Message: ----------- Use segmented control and auto layout fo background of color swatch control. Its alignment rect should always be the bezel rect. Modified Paths: -------------- trunk/SKColorSwatch.h trunk/SKColorSwatch.m Modified: trunk/SKColorSwatch.h =================================================================== --- trunk/SKColorSwatch.h 2025-03-25 22:56:08 UTC (rev 15023) +++ trunk/SKColorSwatch.h 2025-03-26 16:44:37 UTC (rev 15024) @@ -42,12 +42,12 @@ extern NSString *SKColorSwatchColorsChangedNotification; -@class SKColorSwatchBackgroundView, SKColorSwatchItemView; +@class SKColorSwatchItemView; @interface SKColorSwatch : NSControl <NSDraggingSource, NSAccessibilityGroup> { NSMutableArray<NSColor *> *colors; NSMutableArray<SKColorSwatchItemView *> *itemViews; - SKColorSwatchBackgroundView *backgroundView; + NSControl *backgroundView; CGFloat bezelHeight; NSInteger clickedIndex; Modified: trunk/SKColorSwatch.m =================================================================== --- trunk/SKColorSwatch.m 2025-03-25 22:56:08 UTC (rev 15023) +++ trunk/SKColorSwatch.m 2025-03-26 16:44:37 UTC (rev 15024) @@ -64,12 +64,7 @@ #define BEZEL_INSET_BOTTOM 2.0 #define COLOR_INSET 2.0 -#define LARGE_SIZE_HEIGHT_OUTSET 4.5 -#define LARGE_SIZE_WIDTH_OUTSET 5.0 - -#define SKControlSizeLarge 3 - -static inline CGFloat swatchRadius(NSControlSize controlSize) { +static inline CGFloat cornerRadius(NSControlSize controlSize) { if (@available(macOS 11.0, *)) { switch (controlSize) { case NSControlSizeRegular: return 3.0; @@ -76,30 +71,13 @@ case NSControlSizeSmall: return 2.0; case NSControlSizeMini: return 1.0; case NSControlSizeLarge: return 4.0; - default: return 3.0; } } else { - switch (controlSize) { - case NSControlSizeRegular: return 2.0; - case NSControlSizeSmall: return 1.0; - case NSControlSizeMini: return 0.5; - default: return 2.0; - } + return controlSize == NSControlSizeRegular ? 2.0 : 1.0; } } -static inline CGFloat bezelWidthOffset(NSControlSize controlSize) { - switch (controlSize) { - case NSControlSizeRegular: return 4.0; - case NSControlSizeSmall: return 0.0; - case NSControlSizeMini: return 0.0; - case SKControlSizeLarge: return 2.0; - default: return 4.0; - } -} - -@interface SKColorSwatchBackgroundView : NSControl -@property (nonatomic) CGFloat bezelWidth; +@interface SKColorSwatchBackgroundView : NSSegmentedControl @end typedef NS_ENUM(NSUInteger, SKColorSwatchDropLocation) { @@ -169,11 +147,16 @@ [self commonInit]; - SKColorSwatchBackgroundView *view = [[SKColorSwatchBackgroundView alloc] initWithFrame:[self bounds]]; - [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - [view setBezelWidth:[self intrinsicContentSize].width]; - [self addSubview:view]; - backgroundView = view; + backgroundView = [[SKColorSwatchBackgroundView alloc] initWithFrame:[self bounds]]; + [backgroundView setTranslatesAutoresizingMaskIntoConstraints:NO]; + [self addSubview:backgroundView]; + NSArray *constraints = @[ + [[backgroundView leadingAnchor] constraintEqualToAnchor:[self leadingAnchor]], + [[self trailingAnchor] constraintEqualToAnchor:[backgroundView trailingAnchor]], + [[backgroundView topAnchor] constraintEqualToAnchor:[self topAnchor]], + [[self bottomAnchor] constraintEqualToAnchor:[backgroundView bottomAnchor]]]; + [constraints setValue:@YES forKey:@"shouldBeArchived"]; + [NSLayoutConstraint activateConstraints:constraints]; SKColorSwatchItemView *itemView = [[SKColorSwatchItemView alloc] initWithFrame:[self frameForItemViewAtIndex:0 collapsedIndex:-1]]; [itemView setColor:[NSColor whiteColor]]; @@ -291,20 +274,17 @@ return NSEdgeInsetsMake(BEZEL_INSET_TOP, BEZEL_INSET_LEFT, BEZEL_INSET_BOTTOM, BEZEL_INSET_RIGHT); } -- (void)updateSubviewLayout { +- (void)updateItemViewFrames { NSUInteger i, iMax = [itemViews count]; for (i = 0; i < iMax; i++) [[itemViews objectAtIndex:i] setFrame:[self frameForItemViewAtIndex:i collapsedIndex:-1]]; - [backgroundView setBezelWidth:[self intrinsicContentSize].width]; } - (void)updateBezelHeight { - CGFloat height = [[backgroundView cell] cellSize].height - BEZEL_INSET_TOP - BEZEL_INSET_BOTTOM; - if ([backgroundView controlSize] == SKControlSizeLarge) - height -= 2.0 * LARGE_SIZE_HEIGHT_OUTSET; + CGFloat height = [backgroundView intrinsicContentSize].height; if (fabs(height - bezelHeight) > 0.0) { bezelHeight = height; - [self updateSubviewLayout]; + [self updateItemViewFrames]; [self invalidateIntrinsicContentSize]; if (autoResizes) [self sizeToFit]; @@ -312,15 +292,9 @@ } - (void)setControlSize:(NSControlSize)controlSize { - if (controlSize != [self controlSize]) { - [super setControlSize:controlSize]; + [super setControlSize:controlSize]; + if (controlSize != [backgroundView controlSize]) { [backgroundView setControlSize:controlSize]; - NSRect bgFrame = [self bounds]; - if (controlSize == SKControlSizeLarge) { - bgFrame = NSInsetRect(bgFrame, -LARGE_SIZE_WIDTH_OUTSET, -LARGE_SIZE_HEIGHT_OUTSET); - bgFrame.origin.y = ceil(bgFrame.origin.y); - } - [backgroundView setFrame:bgFrame]; [self updateBezelHeight]; } } @@ -336,7 +310,7 @@ - (void)drawFocusRingMask { NSRect rect = [self focusRingMaskBounds]; if (NSIsEmptyRect(rect) == NO) { - CGFloat r = swatchRadius([self controlSize]); + CGFloat r = cornerRadius([self controlSize]); [[NSBezierPath bezierPathWithRoundedRect:rect xRadius:r yRadius:r] fill]; } } @@ -357,19 +331,20 @@ - (void)handleKeyOrMainStateChanged:(NSNotification *)note { if ([[note name] isEqualToString:NSWindowDidResignMainNotification]) [self deactivate]; - [[self subviews] setValue:[NSNumber numberWithInt:YES] forKey:@"needsDisplay"]; + [[self subviews] setValue:@YES forKey:@"needsDisplay"]; } - (void)viewWillMoveToWindow:(NSWindow *)newWindow { NSWindow *oldWindow = [self window]; NSArray *names = @[NSWindowDidBecomeMainNotification, NSWindowDidResignMainNotification, NSWindowDidBecomeKeyNotification, NSWindowDidResignKeyNotification]; + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; if (oldWindow) { for (NSString *name in names) - [[NSNotificationCenter defaultCenter] removeObserver:self name:name object:oldWindow]; + [nc removeObserver:self name:name object:oldWindow]; } if (newWindow) { for (NSString *name in names) - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyOrMainStateChanged:) name:name object:newWindow]; + [nc addObserver:self selector:@selector(handleKeyOrMainStateChanged:) name:name object:newWindow]; } [self deactivate]; [super viewWillMoveToWindow:newWindow]; @@ -405,7 +380,7 @@ NSColor *color = [colors objectAtIndex:i]; - CGFloat r = swatchRadius(NSControlSizeRegular) - 0.5; + CGFloat r = cornerRadius(NSControlSizeRegular) - 0.5; NSImage *image = [NSImage bitmapImageWithSize:NSMakeSize(12.0, 12.0) forView:self drawingHandler:^(NSRect rect){ [color drawSwatchInRect:NSInsetRect(rect, 1.0, 1.0)]; @@ -518,7 +493,7 @@ [[itemViews objectAtIndex:iMax] removeFromSuperview]; [itemViews removeObjectAtIndex:iMax]; } - [self updateSubviewLayout]; + [self updateItemViewFrames]; [self invalidateIntrinsicContentSize]; [[NSNotificationCenter defaultCenter] postNotificationName:SKColorSwatchColorsChangedNotification object:self]; } @@ -630,11 +605,8 @@ NSUInteger i = 0; for (SKColorSwatchItemView *itemView in itemViews) [[itemView animator] setFrame:[self frameForItemViewAtIndex:i++ collapsedIndex:collapsedIndex]]; - if (NSEqualSizes(size, NSZeroSize) == NO) { - [[backgroundView animator] setBezelWidth:size.width - BEZEL_INSET_LEFT - BEZEL_INSET_RIGHT]; - if (autoResizes) - [[self animator] setFrameSize:size]; - } + if (NSEqualSizes(size, NSZeroSize) == NO && autoResizes) + [[self animator] setFrameSize:size]; } - (void)insertColor:(NSColor *)color atIndex:(NSInteger)i { @@ -888,25 +860,17 @@ @implementation SKColorSwatchBackgroundView -@dynamic bezelWidth; - -+ (id)defaultAnimationForKey:(NSString *)key { - if ([key isEqualToString:@"bezelWidth"]) { - CABasicAnimation *anim = [CABasicAnimation animation]; - [anim setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]]; - return anim; - } else - return [super defaultAnimationForKey:key]; -} - - (instancetype)initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; if (self) { - NSSegmentedCell *cell = [[NSSegmentedCell alloc] init]; - [cell setSegmentCount:1]; - [cell setSegmentStyle:NSSegmentStyleTexturedSquare]; - [cell setWidth:fmax(0.0, NSWidth(frameRect) - bezelWidthOffset(NSControlSizeRegular) - BEZEL_INSET_LEFT - BEZEL_INSET_RIGHT) forSegment:0]; - [self setCell:cell]; + [self setSegmentCount:1]; + [self setWidth:0.0 forSegment:0]; + [self setSegmentDistribution:NSSegmentDistributionFill]; + [self setSegmentStyle:NSSegmentStyleTexturedSquare]; + [self setContentHuggingPriority:1 forOrientation:NSLayoutConstraintOrientationHorizontal]; + [self setContentHuggingPriority:1 forOrientation:NSLayoutConstraintOrientationVertical]; + [self setContentCompressionResistancePriority:1 forOrientation:NSLayoutConstraintOrientationHorizontal]; + [self setContentCompressionResistancePriority:1 forOrientation:NSLayoutConstraintOrientationVertical]; } return self; } @@ -913,23 +877,20 @@ - (BOOL)canBecomeKeyView { return NO; } -- (CGFloat)bezelWidth { - return [[self cell] widthForSegment:0] + bezelWidthOffset([self controlSize]); +- (void)mouseDown:(NSEvent *)event { + [[self superview] mouseDown:event]; } -- (void)setBezelWidth:(CGFloat)width { - [[self cell] setWidth:width - bezelWidthOffset([self controlSize]) forSegment:0]; - [self setNeedsDisplay:YES]; +- (void)rightMouseDown:(NSEvent *)event { + [[self superview] rightMouseDown:event]; } -- (void)mouseDown:(NSEvent *)event { - [[self superview] mouseDown:event]; -} - - (void)keyDown:(NSEvent *)event { [[self superview] keyDown:event]; } +- (void)performClick:(id)sender {} + - (BOOL)isAccessibilityElement { return NO; } @@ -992,7 +953,7 @@ if (NSWidth(rect) < 5.0) return; rect = NSInsetRect(rect, COLOR_INSET, COLOR_INSET); - CGFloat r = swatchRadius([(SKColorSwatch *)[self superview] controlSize]); + CGFloat r = cornerRadius([(SKColorSwatch *)[self superview] controlSize]); BOOL disabled = NO; if (@available(macOS 10.14, *)) disabled = [[self window] isMainWindow] == NO && [[self window] isKeyWindow] == NO && ([self isDescendantOf:[[self window] contentView]] == NO || [[self window] isKindOfClass:NSClassFromString(@"NSToolbarSnapshotWindow")]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |