Class: Scarpe::Webview::Shape
- Inherits:
-
Drawable
- Object
- Shoes::Linkable
- Drawable
- Scarpe::Webview::Shape
- Defined in:
- lib/scarpe/wv/shape.rb
Constant Summary
Constants included from Shoes::Log
Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG
Instance Attribute Summary
Attributes inherited from Drawable
#children, #parent, #shoes_linkable_id
Attributes inherited from Shoes::Linkable
Instance Method Summary collapse
- #element(&block) ⇒ Object
- #shape_style ⇒ Object protected
-
#to_html ⇒ Object
Shape is the only (?) remaining drawable that doesn't use Calzini.
Methods inherited from Drawable
#add_child, #bind, #destroy_self, display_class_for, #full_window_redraw!, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #set_parent, #shoes_styles
Methods included from Shoes::Log
configure_logger, #log_init, logger
Methods inherited from Shoes::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 Scarpe::Webview::Drawable
Instance Method Details
#element(&block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/scarpe/wv/shape.rb', line 25 def element(&block) color = @draw_context["fill"] || "black" HTML.render do |h| h.div(id: html_id, style: shape_style) do h.svg(width: "400", height: "500") do h.path(d: path_from_shape_commands, style: "fill:#{color};stroke-width:2;") end block.call(h) if block_given? end end end |
#shape_style ⇒ Object (protected)
61 62 63 64 65 66 67 68 |
# File 'lib/scarpe/wv/shape.rb', line 61 def shape_style s = { width: "400", height: "900", } s[:display] = "none" if @hidden s end |
#to_html ⇒ Object
Shape is the only (?) remaining drawable that doesn't use Calzini. It's also kind of broken - it doesn't do what a Shoes Shape is supposed to do yet. This can really use a rework at some point.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/scarpe/wv/shape.rb', line 8 def to_html @children ||= [] child_markup = @children.map(&:to_html).join color = @draw_context["fill"] || "black" self_markup = HTML.render do |h| h.div(id: html_id, style: shape_style) do h.svg(width: "400", height: "500") do h.path(d: path_from_shape_commands, style: "fill:#{color};stroke-width:2;") end end end # Put child markup first for backward compatibility, but I'm pretty sure this is wrong. child_markup + self_markup end |