Skip to content

Commit 128c8f3

Browse files
committed
fix(SquirrelPanel): highlight overlapping between adjacent candidates
Issue illustrated here: #240 (comment)
1 parent 026c698 commit 128c8f3

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

SquirrelPanel.m

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,43 @@ - (void)drawRect:(NSRect)dirtyRect {
6262
// Add extra width and height to overcome rounding errors and ensure
6363
// highlighted area fully covers paddings near right and top edges.
6464
const CGFloat ROUND_UP = 1;
65-
CGFloat cornerRadius = self.hilitedCornerRadius;
65+
CGFloat corner = self.hilitedCornerRadius / 2;
6666
CGFloat edgeWidth = self.edgeInset.width;
6767
CGFloat edgeHeight = self.edgeInset.height;
6868
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+
}
7176
} else {
72-
stripRect.size.width += cornerRadius;
73-
stripRect.origin.x += edgeWidth - cornerRadius / 2;
77+
stripRect.origin.x += edgeWidth;
7478
}
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+
}
7885
}
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+
}
8193
} else {
82-
stripRect.size.height += cornerRadius;
83-
stripRect.origin.y += edgeHeight - cornerRadius / 2;
94+
stripRect.origin.y += edgeHeight;
8495
}
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+
}
88102
}
89103
[self.highlightedStripColor setFill];
90104
if (self.hilitedCornerRadius > 0) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy