Class: Nuklear::UI::Popup

Inherits:
Window show all
Defined in:
lib/nuklear/ui/popup.rb

Instance Attribute Summary collapse

Attributes inherited from Window

#content_area, #flags, #height, #id, #left, #title, #top, #width

Instance Method Summary collapse

Methods inherited from Window

#background=, #background?, #border=, #border?, #check_flag, #closable=, #closable?, #close, #enabled=, #minimizable=, #minimizable?, #movable=, #movable?, #no_input=, #no_input?, #no_scrollbar=, #no_scrollbar?, #scalable=, #scalable?, #scale_left=, #scale_left?, #scroll_auto_hide=, #scroll_auto_hide?, #set_flag, #titlebar=, #titlebar?

Methods included from Container

#<<, #commands, #find, #layout_row_dynamic, #method_missing, #run_command, #run_commands, #traverse, #ui_checkbox, #ui_color_picker, #ui_combo, #ui_edit_focus, #ui_edit_string, #ui_layout_row_begin, #ui_layout_row_dynamic, #ui_layout_row_push, #ui_layout_row_static, #ui_layout_row_template_begin, #ui_layout_row_template_dynamic, #ui_layout_row_template_end, #ui_layout_row_template_static, #ui_layout_row_template_variable, #ui_layout_space_begin, #ui_layout_space_end, #ui_layout_space_push, #ui_layout_widget_bounds, #ui_menu_item, #ui_option, #ui_selectable, #ui_window_close

Methods inherited from Base

descendants, #dsl, inherited

Methods included from Enableable

#disable, #disabled=, #disabled?, #enable, #enabled=, #enabled?

Methods included from Events

#event_listeners_for, #on, #trigger

Constructor Details

#initialize(title, type: :static, enabled: false, **options) ⇒ Popup

Returns a new instance of Popup.



8
9
10
11
12
13
# File 'lib/nuklear/ui/popup.rb', line 8

def initialize(title, type: :static, enabled: false, **options)
  super title, enabled: enabled, **options
  self.type = type
  on(:visible) { self.enabled = true }
  on(:hidden) { self.enabled = false }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Nuklear::UI::Container

Instance Attribute Details

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/nuklear/ui/popup.rb', line 6

def type
  @type
end

Instance Method Details

#result(visibility, context) ⇒ Object



31
32
33
34
# File 'lib/nuklear/ui/popup.rb', line 31

def result(visibility, context)
  trigger(visibility)
  run_commands(context) if visible?
end

#to_commandObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nuklear/ui/popup.rb', line 15

def to_command
  [:ui_popup,
    type == :dynamic ? NK_POPUP_DYNAMIC : NK_POPUP_STATIC,
    title,
    flags,
    left,
    top,
    width,
    height
  ]
end

#visible?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/nuklear/ui/popup.rb', line 27

def visible?
  @enabled
end