Skip to content

Commit

Permalink
Make more room between preedit and candidates when hilighted corner r…
Browse files Browse the repository at this point in the history
…adius is used
  • Loading branch information
LEOYoon-Tsaw committed Jan 19, 2021
1 parent f54e354 commit a8afe95
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions SquirrelPanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,8 @@ - (void)drawRect:(NSRect)dirtyRect {
if (_preeditRange.length > 0) {
preeditRect = [self contentRectForRange:_preeditRange];
preeditRect.size.width = textField.size.width;
preeditRect.size.height += current.preeditLinespace;
preeditRect.size.height += current.edgeInset.height + current.preeditLinespace + current.hilitedCornerRadius / 2;
preeditRect.origin = NSMakePoint(textField.origin.x - current.edgeInset.width, textField.origin.y - current.edgeInset.height);
preeditRect.size.height += current.edgeInset.height;
if (_highlightedRange.location - (_preeditRange.location+_preeditRange.length) <= 1) {
if (_preeditRange.length > 0 && !current.linear) {
preeditRect.size.height -= current.hilitedCornerRadius / 2;
}
}
if (_highlightedRange.length == 0) {
preeditRect.size.height += current.edgeInset.height - current.preeditLinespace;
}
Expand Down Expand Up @@ -514,8 +508,8 @@ - (void)drawRect:(NSRect)dirtyRect {
innerBox.origin.y += current.edgeInset.height + 1;
innerBox.size.height -= (current.edgeInset.height + 1) * 2;
} else {
innerBox.origin.y += preeditRect.size.height + current.halfLinespace + 1;
innerBox.size.height -= current.edgeInset.height + preeditRect.size.height + current.halfLinespace + 2;
innerBox.origin.y += preeditRect.size.height + current.halfLinespace + current.hilitedCornerRadius / 2 + 1;
innerBox.size.height -= current.edgeInset.height + preeditRect.size.height + current.halfLinespace + current.hilitedCornerRadius / 2 + 2;
}
NSRect outerBox = backgroundRect;
outerBox.size.height -= current.hilitedCornerRadius + preeditRect.size.height;
Expand Down Expand Up @@ -585,7 +579,7 @@ - (void)drawRect:(NSRect)dirtyRect {
if (_highlightedRange.length == 0) {
innerBox.size.height -= (current.edgeInset.height + 1) * 2;
} else {
innerBox.size.height -= current.edgeInset.height+current.preeditLinespace + 2;
innerBox.size.height -= current.edgeInset.height + current.preeditLinespace + current.hilitedCornerRadius / 2 + 2;
}
NSRect outerBox = preeditRect;
outerBox.size.height -= current.hilitedCornerRadius;
Expand Down Expand Up @@ -1118,11 +1112,18 @@ - (void)showPreedit:(NSString *)preedit
initWithString:(_linear ? @" " : @"\n")
attributes:attrs];
_view.seperatorWidth = [separator boundingRectWithSize:NSZeroSize options:NULL].size.width;
if (i > 0) {

NSMutableParagraphStyle *paragraphStyleCandidate;
if (i == 0) {
paragraphStyleCandidate = [current.paragraphStyle mutableCopy];
} else {
NSMutableParagraphStyle *firstParagraphStyle = [current.paragraphStyle mutableCopy];
firstParagraphStyle.paragraphSpacingBefore = current.halfLinespace;
paragraphStyleCandidate = firstParagraphStyle;

[text appendAttributedString:separator];
}

NSMutableParagraphStyle *paragraphStyleCandidate = [current.paragraphStyle mutableCopy];

if (_vertical) {
convertToVerticalGlyph(line, NSMakeRange(candidateStart, line.length-candidateStart));
paragraphStyleCandidate.minimumLineHeight = minimumHeight(attrs);
Expand Down Expand Up @@ -1492,11 +1493,11 @@ -(void)updateConfig:(SquirrelConfig *)config forDarkMode:(BOOL)isDark {
NSMutableParagraphStyle *paragraphStyle =
[[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.paragraphSpacing = lineSpacing / 2;
paragraphStyle.paragraphSpacingBefore = lineSpacing / 2;
paragraphStyle.paragraphSpacingBefore = lineSpacing / 2 + hilitedCornerRadius / 2;

NSMutableParagraphStyle *preeditParagraphStyle =
[[NSParagraphStyle defaultParagraphStyle] mutableCopy];
preeditParagraphStyle.paragraphSpacing = spacing;
preeditParagraphStyle.paragraphSpacing = spacing + hilitedCornerRadius / 2;

SquirrelLayout *current = isDark ? _view.darkLayout : _view.layout;
NSMutableDictionary *attrs = [current.attrs mutableCopy];
Expand Down

0 comments on commit a8afe95

Please sign in to comment.