Class: CyberarmEngine::Element::CheckBox
- Inherits:
-
Flow
- Object
- CyberarmEngine::Element
- Container
- Flow
- CyberarmEngine::Element::CheckBox
- Defined in:
- lib/cyberarm_engine/ui/elements/check_box.rb
Constant Summary
Constants included from Theme
Instance Attribute Summary
Attributes inherited from Container
#children, #fill_color, #gui_state, #scroll_position, #scroll_target_position, #stroke_color
Attributes inherited from CyberarmEngine::Element
#background_canvas, #border_canvas, #element_visible, #event_handler, #options, #parent, #style, #tip, #x, #y, #z
Instance Method Summary collapse
-
#initialize(text, options, block = nil) ⇒ CheckBox
constructor
A new instance of CheckBox.
- #text=(text) ⇒ Object
- #value ⇒ Object
- #value=(bool) ⇒ Object
Methods inherited from Flow
Methods inherited from Container
#add, #append, #build, #clear, current_container, current_container=, #debug_draw, #fits_on_line?, #hit_element?, #layout, #max_width, #mouse_wheel_down, #mouse_wheel_up, #move_to_next_line, #position_on_current_line, #position_on_next_line, #recalculate, #remove, #render, #scroll_jump_to_end, #scroll_jump_to_top, #scroll_page_down, #scroll_page_up, #scroll_top, #scroll_top=, #tallest_neighbor, #to_s, #update, #update_child_element_visibity, #update_scroll, #write_tree
Methods included from Common
#alt_down?, #control_down?, #current_state, #darken, #draw_rect, #fill, #find_element_by_tag, #get_asset, #get_image, #get_sample, #get_song, #lighten, #opacity, #pop_state, #previous_state, #push_state, #shift_down?, #shift_state, #show_cursor, #show_cursor=, #window
Methods inherited from CyberarmEngine::Element
#background=, #background_image=, #background_nine_slice=, #blur, #button_down, #button_up, #child_of?, #clicked_left_mouse_button, #content_height, #content_width, #debug_draw, #default_events, #dimensional_size, #draggable?, #draw, #element_visible?, #enabled=, #enabled?, #enter, #focus, #focused?, #height, #hide, #hit?, #inner_height, #inner_width, #inspect, #is_root?, #layout, #leave, #left_mouse_button, #max_scroll_height, #max_scroll_width, #noncontent_height, #noncontent_width, #outer_height, #outer_width, #parent_of?, #recalculate, #recalculate_if_size_changed, #released_left_mouse_button, #render, #reposition, #root, #safe_style_fetch, #scroll_height, #scroll_width, #set_background, #set_background_image, #set_background_nine_slice, #set_border_color, #set_border_thickness, #set_color, #set_font, #set_margin, #set_padding, #set_static_position, #show, #space_available_height, #space_available_width, #stylize, #to_s, #toggle, #update, #update_background, #update_background_image, #update_background_nine_slice, #update_styles, #visible?, #width
Methods included from CyberarmEngine::Event
#event, #publish, #subscribe, #unsubscribe
Methods included from Theme
#deep_merge, #default, #theme_defaults
Constructor Details
#initialize(text, options, block = nil) ⇒ CheckBox
Returns a new instance of CheckBox.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 4 def initialize(text, , block = nil) super(, block) [:toggled] = [:checked] [:parent] = self = ToggleButton.new() [:parent] = self @label = TextBlock.new(text, ) @label.subscribe(:holding_left_mouse_button) do |sender, x, y| .(sender, x, y) end @label.subscribe(:released_left_mouse_button) do |sender, x, y| .(sender, x, y) end @label.subscribe(:clicked_left_mouse_button) do |sender, x, y| .(sender, x, y) publish(:changed, .value) end @label.subscribe(:enter) do |sender| .enter(sender) end @label.subscribe(:leave) do |sender| .leave(sender) end add() add(@label) end |
Instance Method Details
#text=(text) ⇒ Object
39 40 41 42 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 39 def text=(text) @label.text = text recalculate end |
#value ⇒ Object
44 45 46 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 44 def value .value end |
#value=(bool) ⇒ Object
48 49 50 51 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 48 def value=(bool) .value = bool publish(:changed, .value) end |