Revision: 15022
http://sourceforge.net/p/skim-app/code/15022
Author: hofman
Date: 2025-03-25 18:35:22 +0000 (Tue, 25 Mar 2025)
Log Message:
-----------
define bezel width offsets in inline function
Modified Paths:
--------------
trunk/SKColorSwatch.m
Modified: trunk/SKColorSwatch.m
===================================================================
--- trunk/SKColorSwatch.m 2025-03-25 18:28:16 UTC (rev 15021)
+++ trunk/SKColorSwatch.m 2025-03-25 18:35:22 UTC (rev 15022)
@@ -67,11 +67,6 @@
#define LARGE_SIZE_HEIGHT_OUTSET 4.5
#define LARGE_SIZE_WIDTH_OUTSET 5.0
-#define BEZEL_WIDTH_OFFSET_REGULAR 4.0
-#define BEZEL_WIDTH_OFFSET_SMALL 0.0
-#define BEZEL_WIDTH_OFFSET_MINI 0.0
-#define BEZEL_WIDTH_OFFSET_LARGE 2.0
-
#define SKControlSizeLarge 3
static inline CGFloat swatchRadius(NSControlSize controlSize) {
@@ -93,6 +88,16 @@
}
}
+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;
@end
@@ -900,7 +905,7 @@
NSSegmentedCell *cell = [[NSSegmentedCell alloc] init];
[cell setSegmentCount:1];
[cell setSegmentStyle:NSSegmentStyleTexturedSquare];
- [cell setWidth:fmax(0.0, NSWidth(frameRect) -
BEZEL_WIDTH_OFFSET_REGULAR - BEZEL_INSET_LEFT - BEZEL_INSET_RIGHT)
forSegment:0];
+ [cell setWidth:fmax(0.0, NSWidth(frameRect) -
bezelWidthOffset(NSControlSizeRegular) - BEZEL_INSET_LEFT - BEZEL_INSET_RIGHT)
forSegment:0];
[self setCell:cell];
}
return self;
@@ -908,22 +913,12 @@
- (BOOL)canBecomeKeyView { return NO; }
-- (CGFloat)bezelWidthOffset {
- switch ([self controlSize]) {
- case NSControlSizeRegular: return BEZEL_WIDTH_OFFSET_REGULAR;
- case NSControlSizeSmall: return BEZEL_WIDTH_OFFSET_SMALL;
- case NSControlSizeMini: return BEZEL_WIDTH_OFFSET_MINI;
- case SKControlSizeLarge: return BEZEL_WIDTH_OFFSET_LARGE;
- default: return BEZEL_WIDTH_OFFSET_REGULAR;
- }
-}
-
- (CGFloat)bezelWidth {
- return [[self cell] widthForSegment:0] + [self bezelWidthOffset];
+ return [[self cell] widthForSegment:0] + bezelWidthOffset([self
controlSize]);
}
- (void)setBezelWidth:(CGFloat)width {
- [[self cell] setWidth:width - [self bezelWidthOffset] forSegment:0];
+ [[self cell] setWidth:width - bezelWidthOffset([self controlSize])
forSegment:0];
[self setNeedsDisplay:YES];
}
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