Skip to content

Commit 20fed36

Browse files
committed
refactor(text): move all candidates down once one of them has comment
1 parent bc070b7 commit 20fed36

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/src/main/java/com/osfans/trime/ime/text/Candidate.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ protected void onDraw(Canvas canvas) {
228228
if (candidates == null) return;
229229
super.onDraw(canvas);
230230

231+
boolean moveAllCandidatesDown = false;
231232
for (ComputedCandidate computedCandidate : computedCandidates) {
232233
int i = computedCandidates.indexOf(computedCandidate);
233234
// Draw highlight
@@ -243,11 +244,12 @@ protected void onDraw(Canvas canvas) {
243244
- (candidatePaint.ascent() + candidatePaint.descent()) / 2;
244245
if (shouldShowComment) {
245246
String comment = ((ComputedCandidate.Word) computedCandidate).getComment();
247+
moveAllCandidatesDown |= comment != null && !comment.isEmpty();
248+
if (moveAllCandidatesDown) wordY += commentHeight / 2.0f;
246249
if (comment != null && !comment.isEmpty()) {
247250
float commentX = computedCandidate.getGeometry().centerX();
248251
float commentY =
249252
commentHeight / 2.0f - (commentPaint.ascent() + commentPaint.descent()) / 2;
250-
wordY += commentHeight / 2.0f;
251253
if (!isCommentOnTop) {
252254
float commentWidth = GraphicUtils.measureText(commentPaint, comment, commentFont);
253255
commentX = computedCandidate.getGeometry().right - commentWidth / 2;

0 commit comments

Comments
 (0)