Class: Shoes::Widget
- Includes:
- Background
- Defined in:
- lib/shoes/drawables/widget.rb,
lib/shoes.rb
Overview
TODO: when this is subclassed, grab :initialize out of the subclass, put it into :initialize_widget, and replace with an initialize that creates the display widget propertly, sets the linkable_id, etc.
Constant Summary
Constants inherited from Drawable
Constants included from Log
Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG
Instance Attribute Summary
Attributes inherited from Slot
Attributes inherited from Drawable
#debug_id, #destroyed, #parent
Attributes inherited from Linkable
Class Method Summary collapse
Methods included from Background
Methods inherited from Slot
#add_child, #append, #clear, #contents, #current_draw_context, #fill, #initialize, #method_missing, #nofill, #nostroke, #remove_child, #respond_to_missing?, #rotate, #stroke, #strokewidth
Methods inherited from Drawable
allocate_drawable_id, #app, #banner, #caption, convert_to_float, convert_to_integer, #destroy, #download, drawable_by_id, drawable_class_by_name, dsl_name, #event, expects_parent?, feature_for_shoes_style, get_shoes_events, #hide, #hover, init_args, #initialize, #inscription, #inspect, is_widget_class?, #leave, #method_missing, #motion, opt_init_args, optional_init_args, register_drawable_id, registered_shoes_events?, required_init_args, #respond_to_missing?, #set_parent, shoes_events, shoes_style, shoes_style_hashes, shoes_style_name?, shoes_style_names, #shoes_style_values, shoes_styles, #show, #style, #subtitle, #tagline, #title, #toggle, unregister_drawable_id, validate_as
Methods included from MarginHelper
Methods included from Colors
#gray, included, #rgb, #to_rgb
Methods included from Log
configure_logger, #log_init, logger
Methods inherited from Linkable
#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event
Constructor Details
This class inherits a constructor from Shoes::Slot
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Shoes::Slot
Class Method Details
.inherited(subclass) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/shoes/drawables/widget.rb', line 43 def self.inherited(subclass) super # Widgets are special - we can't know in advance what sort of initialize args they take subclass.init_args :any end |
.method_added(name) ⇒ Object
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/shoes/drawables/widget.rb', line 50 def self.method_added(name) # We're only looking for the initialize() method, and only on subclasses # of Shoes::Widget, not Shoes::Widget itself. return if self == ::Shoes::Widget || name != :initialize # Need to avoid infinite adding of initialize() if we're re-adding the default initialize return if @midway_through_adding_initialize # Take the user-provided initialize method and save a copy named __widget_initialize alias_method :__widget_initialize, :initialize # And add the default initialize back where it belongs @midway_through_adding_initialize = true define_method(:initialize) do |*args, **kwargs, &block| super(*args, **kwargs, &block) = kwargs # Get rid of options? create_display_drawable (*args, **kwargs, &block) # Do Widgets do this? Shoes::App.instance.with_slot(self, &block) if block end @midway_through_adding_initialize = false end |