Skip to content

Commit 23dbff7

Browse files
committed
Fix tooltip placement algorithm
1 parent bf0c069 commit 23dbff7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

ui/ui.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -632,19 +632,21 @@ func (g *Group) Tooltip(tip string, rect glitch.Rect, style Style) {
632632

633633
var movement glitch.Vec2
634634
if quadrant[0] < 0 {
635-
movement[0] = -1
636-
} else {
637635
movement[0] = 1
638-
}
639-
640-
if quadrant[1] < 0 {
641-
movement[1] = -1
642636
} else {
643-
movement[1] = 1
637+
movement[0] = 0
644638
}
645639

640+
// TODO: Maybe make this configurable? I removed the Y flip because most tooltips are just single lines, and the cursor ends up blocking the text if we anchor below
641+
// if quadrant[1] < 0 {
642+
// movement[1] = 1
643+
// } else {
644+
// movement[1] = 0
645+
// }
646+
646647
cursorRect := glitch.R(0, 0, 0, 0).WithCenter(g.mousePos)
647-
style.Text = style.Text.Anchor(movement.Scaled(-1))
648+
// style.Text = style.Text.Anchor(movement.Scaled(-1)).Pivot(glitch.Vec2{0.5, 0.5})
649+
style.Text = style.Text.Anchor(movement)
648650
g.draw(tip, cursorRect, style.Normal, style.Text)
649651

650652
// text := g.getText(tip)

0 commit comments

Comments
 (0)