@@ -62,29 +62,43 @@ - (void)drawRect:(NSRect)dirtyRect {
62
62
// Add extra width and height to overcome rounding errors and ensure
63
63
// highlighted area fully covers paddings near right and top edges.
64
64
const CGFloat ROUND_UP = 1 ;
65
- CGFloat cornerRadius = self.hilitedCornerRadius ;
65
+ CGFloat corner = self.hilitedCornerRadius / 2 ;
66
66
CGFloat edgeWidth = self.edgeInset .width ;
67
67
CGFloat edgeHeight = self.edgeInset .height ;
68
68
NSRect stripRect = self.highlightedRect ;
69
- if (cornerRadius == 0 && NSMinX (stripRect) < FLT_EPSILON) {
70
- stripRect.size .width += edgeWidth;
69
+ if (NSMinX (stripRect) < FLT_EPSILON) {
70
+ if (corner == 0 ) {
71
+ stripRect.size .width += edgeWidth;
72
+ } else {
73
+ stripRect.size .width += corner;
74
+ stripRect.origin .x += edgeWidth - corner;
75
+ }
71
76
} else {
72
- stripRect.size .width += cornerRadius;
73
- stripRect.origin .x += edgeWidth - cornerRadius / 2 ;
77
+ stripRect.origin .x += edgeWidth;
74
78
}
75
- if (cornerRadius == 0 &&
76
- NSMaxX (stripRect) + edgeWidth + ROUND_UP > NSWidth (self.bounds )) {
77
- stripRect.size .width += edgeWidth + ROUND_UP;
79
+ if (NSMaxX (stripRect) + edgeWidth + ROUND_UP > NSWidth (self.bounds )) {
80
+ if (corner == 0 ) {
81
+ stripRect.size .width += edgeWidth + ROUND_UP;
82
+ } else {
83
+ stripRect.size .width += corner;
84
+ }
78
85
}
79
- if (cornerRadius == 0 && NSMinY (stripRect) < FLT_EPSILON) {
80
- stripRect.size .height += edgeHeight;
86
+ if (NSMinY (stripRect) < FLT_EPSILON) {
87
+ if (corner == 0 ) {
88
+ stripRect.size .height += edgeHeight;
89
+ } else {
90
+ stripRect.size .height += corner;
91
+ stripRect.origin .y += edgeHeight - corner;
92
+ }
81
93
} else {
82
- stripRect.size .height += cornerRadius;
83
- stripRect.origin .y += edgeHeight - cornerRadius / 2 ;
94
+ stripRect.origin .y += edgeHeight;
84
95
}
85
- if (cornerRadius == 0 &&
86
- NSMaxY (stripRect) + edgeHeight + ROUND_UP > NSHeight (self.bounds )) {
87
- stripRect.size .height += edgeHeight + ROUND_UP;
96
+ if (NSMaxY (stripRect) + edgeHeight + ROUND_UP > NSHeight (self.bounds )) {
97
+ if (corner == 0 ) {
98
+ stripRect.size .height += edgeHeight + ROUND_UP;
99
+ } else {
100
+ stripRect.size .height += corner;
101
+ }
88
102
}
89
103
[self .highlightedStripColor setFill ];
90
104
if (self.hilitedCornerRadius > 0 ) {
0 commit comments