Class: Conquer::Dzen::Interaction::TooltipListener
- Inherits:
-
Object
- Object
- Conquer::Dzen::Interaction::TooltipListener
- Includes:
- Celluloid, Celluloid::Notifications, Positioning
- Defined in:
- lib/conquer/dzen/interaction/tooltip_listener.rb
Constant Summary collapse
- MARGIN =
5
Instance Method Summary collapse
-
#initialize ⇒ TooltipListener
constructor
A new instance of TooltipListener.
- #show_tooltip(_, title, text, width = 150) ⇒ Object
Methods included from Positioning
#ignore_bg, #lock_x, #shift, #unlock_x
Constructor Details
#initialize ⇒ TooltipListener
Returns a new instance of TooltipListener.
14 15 16 17 |
# File 'lib/conquer/dzen/interaction/tooltip_listener.rb', line 14 def initialize @current_tooltip = nil subscribe('tooltip', :show_tooltip) end |
Instance Method Details
#show_tooltip(_, title, text, width = 150) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/conquer/dzen/interaction/tooltip_listener.rb', line 19 def show_tooltip(_, title, text, width = 150) Process.kill('TERM', @current_tooltip.pid) if @current_tooltip lines = text.lines.map { |line| shift(MARGIN) { line } } mouse = mouse_location dzen_command = dzen_command(mouse, lines.size, width + 2 * MARGIN) async.run_dzen(dzen_command, title, lines.join) end |