Class: Nuklear::UI::Tree
- Includes:
- Container
- Defined in:
- lib/nuklear/ui/tree.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
Returns the value of attribute image.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title, image: nil, type: :tab, state: :minimized, **options) ⇒ Tree
constructor
A new instance of Tree.
- #result(new_state, context) ⇒ Object
- #state ⇒ Object
- #state=(state) ⇒ Object
- #to_command ⇒ Object
- #type ⇒ Object
- #type=(type) ⇒ Object
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
Methods included from Enableable
#disable, #disabled=, #disabled?, #enable, #enabled=, #enabled?
Methods included from Events
#event_listeners_for, #on, #trigger
Constructor Details
#initialize(title, image: nil, type: :tab, state: :minimized, **options) ⇒ Tree
Returns a new instance of Tree.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/nuklear/ui/tree.rb', line 9 def initialize(title, image: nil, type: :tab, state: :minimized, **) super(**) self.title = title self.image = image self.type = type self.state = state on(Nuklear::NK_MINIMIZED, Nuklear::NK_MAXIMIZED) { |new_state| @state = new_state } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Nuklear::UI::Container
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
7 8 9 |
# File 'lib/nuklear/ui/tree.rb', line 7 def image @image end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/nuklear/ui/tree.rb', line 6 def title @title end |
Instance Method Details
#result(new_state, context) ⇒ Object
56 57 58 59 |
# File 'lib/nuklear/ui/tree.rb', line 56 def result(new_state, context) trigger(new_state) run_commands(context) if @state == Nuklear::NK_MAXIMIZED end |
#state ⇒ Object
36 37 38 39 40 41 |
# File 'lib/nuklear/ui/tree.rb', line 36 def state case type when Nuklear::NK_MAXIMIZED then :maximized when Nuklear::NK_MINIMIZED then :minimized end end |
#state=(state) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/nuklear/ui/tree.rb', line 43 def state=(state) case state when :maximized then @state = Nuklear::NK_MAXIMIZED when :minimized then @state = Nuklear::NK_MINIMIZED when Nuklear::NK_MAXIMIZED, Nuklear::NK_MINIMIZED then @state = state else raise ArgumentError, "state must be one of NK_MAXIMIZED, NK_MINIMIZED" end end |
#to_command ⇒ Object
52 53 54 |
# File 'lib/nuklear/ui/tree.rb', line 52 def to_command [ :ui_tree, @type, image, title, @state ] end |
#type ⇒ Object
20 21 22 23 24 25 |
# File 'lib/nuklear/ui/tree.rb', line 20 def type case type when Nuklear::NK_TREE_TAB then :tab when Nuklear::NK_TREE_NODE then :node end end |
#type=(type) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/nuklear/ui/tree.rb', line 27 def type=(type) case type when :tab then @type = Nuklear::NK_TREE_TAB when :node then @type = Nuklear::NK_TREE_NODE when Nuklear::NK_TREE_TAB, Nuklear::NK_TREE_NODE then @type = type else raise ArgumentError, "type must be one of NK_TREE_TAB, NK_TREE_NODE" end end |