Skip to content

Commit 17ebbb1

Browse files
committed
Prevent tooltips from getting cut off when showing up near the
window edge Also slightly changes the tooltip style to match the rest of the UI.
1 parent 813e09d commit 17ebbb1

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

app/ui/widgets.rb

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ def create_tooltip
9393
slot = slot.parent
9494
end
9595

96-
@tooltip = slot.tooltip(@tooltip_text, x, y-20,
97-
:fill => red, :stroke => white)
96+
@tooltip = slot.tooltip(@tooltip_text, x, y-20, "#f00", :stroke => white)
9897
end
9998

10099
def arrow_right
@@ -123,18 +122,28 @@ def menu
123122
end
124123

125124
module HH::Tooltip
126-
def tooltip str, x, y, opts={}
127-
f = nil
125+
def tooltip str, x, y, bg="#f00", opts={}
126+
s = nil
128127
#opts[:wrap] = "trim"
129128
slot = self
130129
app do
131-
slot.append do
132-
f = flow :left => x, :top => y do
133-
para str, opts
134-
end
135-
end
130+
slot.append do
131+
s = stack :left => x, :top => y do
132+
bg = background bg, :curve => 6, :height => 26, :width => 40
133+
p1 = nil
134+
flow :width => 300 do
135+
p1 = para str, opts
136+
end
137+
timer 0 do
138+
bg.width = p1.width
139+
if slot.width < s.left + bg.width
140+
s.left -= s.left + bg.width - slot.width
141+
end
142+
end
143+
end
144+
end
136145
end
137-
f
146+
s
138147
end
139148
end
140149

0 commit comments

Comments
 (0)