Class: Tuile::Component::InfoWindow

Inherits:
Window show all
Defined in:
lib/tuile/component/info_window.rb

Overview

A Window preconfigured with a List of static lines. Useful for showing read-only information.

Usable tiled (just add to a Layout) or as a popup via InfoWindow.open, which wraps it in a Popup.

Instance Attribute Summary

Attributes inherited from Window

#caption, #footer

Attributes included from HasContent

#content

Attributes inherited from Tuile::Component

#key_shortcut, #parent, #rect

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Window

#children, #content_size, #focusable?, #handle_key, #handle_mouse, #key_shortcut=, #rect=, #repaint, #scrollbar=, #visible?

Methods included from HasContent

#children, #handle_key, #handle_mouse, #on_focus, #rect=

Methods inherited from Tuile::Component

#active=, #active?, #attached?, #children, #content_size, #cursor_position, #depth, #find_shortcut_component, #focus, #focusable?, #handle_key, #handle_mouse, #keyboard_hint, #on_child_removed, #on_focus, #on_tree, #repaint, #root, #screen

Constructor Details

#initialize(caption = "", lines = []) ⇒ InfoWindow

Returns a new instance of InfoWindow.

Parameters:

  • caption (String) (defaults to: "")
  • lines (Array<String>) (defaults to: [])

    initial content; each entry may contain Rainbow formatting.



14
15
16
17
18
19
# File 'lib/tuile/component/info_window.rb', line 14

def initialize(caption = "", lines = [])
  super(caption)
  list = Component::List.new
  list.lines = lines
  self.content = list
end

Class Method Details

.open(caption, lines) ⇒ Popup

Opens the info window as a popup.

Parameters:

  • caption (String)
  • lines (Array<String>)

    the content, may contain formatting.

Returns:

  • (Popup)

    the opened popup.



25
26
27
# File 'lib/tuile/component/info_window.rb', line 25

def self.open(caption, lines)
  Popup.open(content: InfoWindow.new(caption, lines))
end