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_x, #scroll_y, #stroke_color
Attributes inherited from CyberarmEngine::Element
#background_canvas, #border_canvas, #enabled, #event_handler, #options, #parent, #style, #x, #y, #z
Instance Method Summary collapse
- #define_label_singletons ⇒ Object
-
#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 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, #show_cursor, #show_cursor=, #window
Methods inherited from Container
#add, #build, #clear, #fits_on_line?, #hit_element?, #layout, #max_width, #move_to_next_line, #position_on_current_line, #position_on_next_line, #recalculate, #render, #tallest_neighbor, #update
Methods inherited from CyberarmEngine::Element
#background=, #button_down, #button_up, #content_height, #content_width, #default_events, #draw, #enabled?, #height, #hide, #hit?, #inner_height, #inner_width, #is_root?, #noncontent_height, #noncontent_width, #outer_height, #outer_width, #recalculate, #render, #reposition, #root, #set_background, #set_border_color, #set_border_thickness, #set_margin, #set_padding, #show, #stylize, #toggle, #update, #update_background, #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 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 4 def initialize(text, , block = nil) super({}, block = nil) [:toggled] = [:checked] = ToggleButton.new() @label = Label.new(text, ) define_label_singletons add() add(@label) end |
Instance Method Details
#define_label_singletons ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 30 def define_label_singletons @label.define_singleton_method(:_toggle_button) do || = end @label.() @label.define_singleton_method(:holding_left_mouse_button) do |sender, x, y| .(sender, x, y) end @label.define_singleton_method(:released_left_mouse_button) do |sender, x, y| .(sender, x, y) end @label.define_singleton_method(:clicked_left_mouse_button) do |sender, x, y| .(sender, x, y) end @label.define_singleton_method(:enter) do |sender| .enter(sender) end @label.define_singleton_method(:leave) do |sender| .leave(sender) end end |
#text=(text) ⇒ Object
17 18 19 20 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 17 def text=(text) @label.text = text recalculate end |
#value ⇒ Object
22 23 24 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 22 def value .value end |
#value=(bool) ⇒ Object
26 27 28 |
# File 'lib/cyberarm_engine/ui/elements/check_box.rb', line 26 def value=(bool) .vlaue = bool end |