Class: Glimmer::LibUI::ControlProxy::ColorButtonProxy
- Inherits:
 - 
      Glimmer::LibUI::ControlProxy
      
        
- Object
 - Glimmer::LibUI::ControlProxy
 - Glimmer::LibUI::ControlProxy::ColorButtonProxy
 
 
- Defined in:
 - lib/glimmer/libui/control_proxy/color_button_proxy.rb
 
Overview
Proxy for LibUI color button objects
Follows the Proxy Design Pattern
Constant Summary
Constants inherited from Glimmer::LibUI::ControlProxy
BOOLEAN_PROPERTIES, KEYWORD_ALIASES, STRING_PROPERTIES, TransformProxy
Instance Attribute Summary
Attributes inherited from Glimmer::LibUI::ControlProxy
#args, #block, #content_added, #custom_control, #keyword, #libui, #options, #parent_custom_control, #parent_proxy, #slot
Instance Method Summary collapse
- #alpha(value = nil) ⇒ Object (also: #alpha=, #set_alpha, #a, #a=, #set_a)
 - #blue(value = nil) ⇒ Object (also: #blue=, #set_blue, #b, #b=, #set_b)
 - #color(value = nil) ⇒ Object (also: #color=, #set_color)
 - #data_bind_write(property, model_binding) ⇒ Object
 - #destroy ⇒ Object
 - #green(value = nil) ⇒ Object (also: #green=, #set_green, #g, #g=, #set_g)
 - #red(value = nil) ⇒ Object (also: #red=, #set_red, #r, #r=, #set_r)
 
Methods inherited from Glimmer::LibUI::ControlProxy
#append_properties, #append_property, #bind_content, #can_handle_listener?, constant_symbol, #content, control_proxies, control_proxy_class, create, #custom_listener_name_aliases, #custom_listener_names, #default_destroy, #deregister_all_custom_listeners, #deregister_custom_listeners, descendant_keyword_constant_map, #destroy_child, #enabled, exists?, #handle_custom_listener, #handle_listener, #has_custom_listener?, image_proxies, #initialize, keyword, #libui_api_keyword, #listeners, #listeners_for, main_window_proxy, map_descendant_keyword_constants_for, menu_proxies, #method_missing, new_control, #notify_custom_listeners, #post_add_content, #post_initialize_child, reset_descendant_keyword_constant_map, #respond_to?, #respond_to_libui?, #send_to_libui, #visible, #window_proxy
Methods included from DataBindable
#data_bind, #data_bind_read, #data_binding_model_attribute_observer_registrations
Methods included from Parent
#children, #post_initialize_child
Constructor Details
This class inherits a constructor from Glimmer::LibUI::ControlProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer::LibUI::ControlProxy
Instance Method Details
#alpha(value = nil) ⇒ Object Also known as: alpha=, set_alpha, a, a=, set_a
      96 97 98 99 100 101 102  | 
    
      # File 'lib/glimmer/libui/control_proxy/color_button_proxy.rb', line 96 def alpha(value = nil) if value.nil? color[:a] else self.color = {a: value} end end  | 
  
#blue(value = nil) ⇒ Object Also known as: blue=, set_blue, b, b=, set_b
      83 84 85 86 87 88 89  | 
    
      # File 'lib/glimmer/libui/control_proxy/color_button_proxy.rb', line 83 def blue(value = nil) if value.nil? color[:b] else self.color = {b: value} end end  | 
  
#color(value = nil) ⇒ Object Also known as: color=, set_color
      31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53  | 
    
      # File 'lib/glimmer/libui/control_proxy/color_button_proxy.rb', line 31 def color(value = nil) if value.nil? @red ||= Fiddle::Pointer.malloc(8) # double @green ||= Fiddle::Pointer.malloc(8) # double @blue ||= Fiddle::Pointer.malloc(8) # double @alpha ||= Fiddle::Pointer.malloc(8) # double ::LibUI.(@libui, @red, @green, @blue, @alpha) { r: @red[0, 8].unpack1('d') * 255.0, g: @green[0, 8].unpack1('d') * 255.0, b: @blue[0, 8].unpack1('d') * 255.0, a: @alpha[0, 8].unpack1('d') } else current_color = color value = Glimmer::LibUI.interpret_color(value) value[:r] ||= current_color[:r] value[:g] ||= current_color[:g] value[:b] ||= current_color[:b] value[:a] ||= current_color[:a] ::LibUI.(@libui, value[:r].to_f / 255.0, value[:g].to_f / 255.0, value[:b].to_f / 255.0, value[:a]) end end  | 
  
#data_bind_write(property, model_binding) ⇒ Object
      117 118 119  | 
    
      # File 'lib/glimmer/libui/control_proxy/color_button_proxy.rb', line 117 def data_bind_write(property, model_binding) handle_listener('on_changed') { model_binding.call(color) } if property == 'color' end  | 
  
#destroy ⇒ Object
      109 110 111 112 113 114 115  | 
    
      # File 'lib/glimmer/libui/control_proxy/color_button_proxy.rb', line 109 def destroy Fiddle.free @red unless @red.nil? Fiddle.free @green unless @green.nil? Fiddle.free @blue unless @blue.nil? Fiddle.free @alpha unless @alpha.nil? super end  | 
  
#green(value = nil) ⇒ Object Also known as: green=, set_green, g, g=, set_g
      70 71 72 73 74 75 76  | 
    
      # File 'lib/glimmer/libui/control_proxy/color_button_proxy.rb', line 70 def green(value = nil) if value.nil? color[:g] else self.color = {g: value} end end  | 
  
#red(value = nil) ⇒ Object Also known as: red=, set_red, r, r=, set_r
      57 58 59 60 61 62 63  | 
    
      # File 'lib/glimmer/libui/control_proxy/color_button_proxy.rb', line 57 def red(value = nil) if value.nil? color[:r] else self.color = {r: value} end end  |