Class: Tuile::Component::InfoWindow

Inherits:
Window
  • Object
show all
Defined in:
lib/tuile/component/info_window.rb,
sig/tuile.rbs

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, #footer_text

Attributes included from HasContent

#content

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Window

#bottom_border, #children, #focusable?, #frame_caption, #handle_mouse, #key_shortcut=, #layout, #layout_footer, #on_focus, #rect=, #repaint, #repaint_border, #scrollbar=

Methods included from HasContent

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

Constructor Details

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

@param caption

@param lines — initial content; each entry may contain Rainbow formatting.

Parameters:

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


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, size: Fraction::HALF) ⇒ Popup

Opens the info window as a popup.

@param caption

@param lines — the content, may contain formatting.

@param size — the popup's size, applied top-down; the list wraps and scrolls within it. Defaults to Fraction::HALF.

@return — the opened popup.

Parameters:

  • caption (String)
  • lines (::Array[String])
  • size: (Size, Fraction) (defaults to: Fraction::HALF)

Returns:



27
28
29
# File 'lib/tuile/component/info_window.rb', line 27

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