Class: CyberarmEngine::Element::ListBox
- Inherits:
-
Button
- Object
- CyberarmEngine::Element
- TextBlock
- Button
- CyberarmEngine::Element::ListBox
- Defined in:
- lib/cyberarm_engine/ui/elements/list_box.rb
Constant Summary
Constants included from Theme
Instance Attribute Summary collapse
-
#choose ⇒ Object
Returns the value of attribute choose.
-
#items ⇒ Object
Returns the value of attribute items.
Attributes inherited from CyberarmEngine::Element
#background_canvas, #border_canvas, #enabled, #event_handler, #options, #parent, #style, #tip, #x, #y, #z
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}, block = nil) ⇒ ListBox
constructor
A new instance of ListBox.
- #recalculate ⇒ Object
- #released_left_mouse_button(_sender, _x, _y) ⇒ Object
- #show_menu ⇒ Object
Methods inherited from Button
#draw_image, #draw_text, #render, #value, #value=
Methods inherited from TextBlock
#handle_text_wrapping, #line_width, #render, #value, #value=
Methods inherited from CyberarmEngine::Element
#background=, #blur, #button_down, #button_up, #clicked_left_mouse_button, #content_height, #content_width, #debug_draw, #default_events, #dimensional_size, #draggable?, #draw, #enabled?, #enter, #focus, #height, #hide, #hit?, #inner_height, #inner_width, #inspect, #is_root?, #leave, #left_mouse_button, #max_scroll_height, #max_scroll_width, #noncontent_height, #noncontent_width, #outer_height, #outer_width, #render, #reposition, #root, #safe_style_fetch, #scroll_height, #scroll_width, #set_background, #set_border_color, #set_border_thickness, #set_margin, #set_padding, #set_static_position, #show, #stylize, #to_s, #toggle, #update, #update_background, #update_styles, #value, #value=, #visible?, #width
Methods included from Common
#current_state, #darken, #draw_rect, #fill, #get_asset, #get_image, #get_sample, #get_song, #lighten, #opacity, #pop_state, #previous_state, #push_state, #shift_state, #show_cursor, #show_cursor=, #window
Methods included from CyberarmEngine::Event
#event, #publish, #subscribe, #unsubscribe
Methods included from Theme
#deep_merge, #default, #theme_defaults
Constructor Details
#initialize(options = {}, block = nil) ⇒ ListBox
Returns a new instance of ListBox.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cyberarm_engine/ui/elements/list_box.rb', line 7 def initialize( = {}, block = nil) @items = [:items] || [] @choose = [:choose] || @items.first super(@choose, , block) @style.background_canvas.background = default(:background) # TODO: "Clean Up" into own class? = Stack.new(parent: parent, width: [:width], theme: [:theme]) .define_singleton_method(:recalculate_menu) do @x = @__list_box.x @y = @__list_box.y + @__list_box.height end .instance_variable_set(:"@__list_box", self) def .recalculate super end self.choose = @choose end |
Instance Attribute Details
#choose ⇒ Object
Returns the value of attribute choose.
5 6 7 |
# File 'lib/cyberarm_engine/ui/elements/list_box.rb', line 5 def choose @choose end |
#items ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/cyberarm_engine/ui/elements/list_box.rb', line 4 def items @items end |
Class Method Details
.recalculate ⇒ Object
23 24 25 26 27 |
# File 'lib/cyberarm_engine/ui/elements/list_box.rb', line 23 def .recalculate super end |
Instance Method Details
#recalculate ⇒ Object
75 76 77 78 79 |
# File 'lib/cyberarm_engine/ui/elements/list_box.rb', line 75 def recalculate super .recalculate end |
#released_left_mouse_button(_sender, _x, _y) ⇒ Object
43 44 45 46 47 |
# File 'lib/cyberarm_engine/ui/elements/list_box.rb', line 43 def (_sender, _x, _y) :handled end |
#show_menu ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cyberarm_engine/ui/elements/list_box.rb', line 49 def .clear @items.each do |item| btn = Button.new( item, { parent: , width: 1.0, theme: [:theme], margin: 0, border_color: 0x00ffffff }, proc do self.choose = item @block&.call(item) end ) .add(btn) end recalculate root.gui_state.() end |