Class: Shoes::Shape

Inherits:
Slot show all
Defined in:
lacci/lib/shoes/widgets/shape.rb

Overview

A Shape acts as a sort of union type for drawn shapes. In Shoes you can use it to merge multiple ovals, arcs, stars, etc. into a single drawn shape.

In Shoes3, a Shape isn't really a Slot. It's a kind of DSL with drawing commands that happen to have the same name as the Art widgets like star, arc, etc. Here we're treating it as a slot containing those widgets, which is wrong but not too wrong.

Incompatibilities with Shoes:

  • A Shoes3 Shape is not a slot; Scarpe does not do union shapes

Constant Summary

Constants included from Log

Log::DEFAULT_COMPONENT, Log::DEFAULT_DEBUG_LOG_CONFIG, Log::DEFAULT_LOG_CONFIG

Instance Attribute Summary

Attributes inherited from Slot

#children

Attributes inherited from Widget

#parent

Attributes inherited from Linkable

#linkable_id

Instance Method Summary collapse

Methods inherited from Slot

#add_child, #app, #append, #clear, #contents, #remove_child

Methods inherited from Widget

#banner, #caption, #destroy, display_properties, display_property, display_property_name?, display_property_names, #display_property_values, #download, dsl_name, #hide, #inscription, #inspect, #method_missing, #respond_to_missing?, #set_parent, #show, #subtitle, #tagline, #title, #toggle, widget_class_by_name

Methods included from Colors

#gray, #rgb, #to_rgb

Methods included from Log

configure_logger, #log_init, logger

Methods inherited from Linkable

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

Constructor Details

#initialize(left: nil, top: nil, &block) ⇒ Shape

Returns a new instance of Shape.



15
16
17
18
19
20
21
22
23
24
25
# File 'lacci/lib/shoes/widgets/shape.rb', line 15

def initialize(left: nil, top: nil, &block)
  @left = left
  @top = top
  @shape_commands = []
  @draw_context = Shoes::App.instance.current_draw_context

  super
  create_display_widget

  Shoes::App.instance.with_slot(self, &block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Shoes::Widget

Instance Method Details

#add_shape_command(cmd) ⇒ Object

The cmd should be an array of the form:

[cmd_name, *args]

such as ["move_to", 50, 50]. Note that these must be JSON-serializable.



33
34
35
# File 'lacci/lib/shoes/widgets/shape.rb', line 33

def add_shape_command(cmd)
  @shape_commands << cmd
end