scarpe 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +16 -2
- data/Gemfile.lock +7 -3
- data/README.md +24 -8
- data/Rakefile +1 -1
- data/examples/animate.rb +20 -0
- data/examples/arrow.rb +10 -0
- data/examples/btn_tooltip.rb +7 -0
- data/examples/button_style_changed.rb +7 -0
- data/examples/button_styles_default.rb +6 -0
- data/examples/gen.rb +8 -8
- data/examples/highlander.rb +3 -3
- data/examples/legacy/README.md +6 -0
- data/examples/legacy/not_checked/shoes-contrib/basic/shoes-notes.rb +1 -1
- data/examples/legacy/not_checked/simple/anim-shapes.rb +1 -1
- data/examples/legacy/not_checked/speedometer_app.rb +55 -0
- data/examples/legacy/working/simple/image-icon.rb +3 -0
- data/examples/legacy/{not_checked → working}/simple/image.rb +1 -1
- data/examples/list_box_choose.rb +17 -0
- data/examples/local_assets/local_file_server.rb +82 -0
- data/examples/local_assets/sample.gif +0 -0
- data/examples/local_assets/sample.mp4 +0 -0
- data/examples/local_fonts.rb +2 -2
- data/examples/local_images.rb +2 -3
- data/examples/para/para_text.rb +14 -0
- data/examples/progress.rb +31 -0
- data/examples/radio/radio_groups.rb +2 -2
- data/examples/rect.rb +4 -0
- data/examples/rotate_shapes.rb +17 -0
- data/examples/simpler-menu.rb +21 -0
- data/exe/scarpe +2 -1
- data/lacci/Gemfile +2 -0
- data/lacci/Gemfile.lock +8 -1
- data/lacci/lacci.gemspec +1 -1
- data/lacci/lib/lacci/scarpe_cli.rb +2 -1
- data/lacci/lib/lacci/scarpe_core.rb +2 -1
- data/lacci/lib/lacci/version.rb +1 -1
- data/lacci/lib/scarpe/niente/app.rb +23 -0
- data/lacci/lib/scarpe/niente/display_service.rb +62 -0
- data/lacci/lib/scarpe/niente/drawable.rb +57 -0
- data/lacci/lib/scarpe/niente/logger.rb +29 -0
- data/lacci/lib/scarpe/niente/shoes_spec.rb +87 -0
- data/lacci/lib/scarpe/niente.rb +20 -0
- data/lacci/lib/shoes/app.rb +88 -43
- data/lacci/lib/shoes/background.rb +2 -2
- data/lacci/lib/shoes/border.rb +2 -2
- data/lacci/lib/shoes/builtins.rb +63 -0
- data/lacci/lib/shoes/changelog.rb +52 -0
- data/lacci/lib/shoes/colors.rb +3 -1
- data/lacci/lib/shoes/constants.rb +19 -1
- data/lacci/lib/shoes/display_service.rb +39 -16
- data/lacci/lib/shoes/download.rb +2 -2
- data/lacci/lib/shoes/drawable.rb +380 -0
- data/lacci/lib/shoes/drawables/arc.rb +49 -0
- data/lacci/lib/shoes/drawables/arrow.rb +41 -0
- data/lacci/lib/shoes/drawables/button.rb +73 -0
- data/lacci/lib/shoes/{widgets → drawables}/check.rb +5 -4
- data/lacci/lib/shoes/{widgets → drawables}/document_root.rb +3 -3
- data/lacci/lib/shoes/{widgets → drawables}/edit_box.rb +6 -6
- data/lacci/lib/shoes/{widgets → drawables}/edit_line.rb +6 -6
- data/lacci/lib/shoes/{widgets → drawables}/flow.rb +6 -6
- data/lacci/lib/shoes/{widgets → drawables}/image.rb +6 -6
- data/lacci/lib/shoes/{widgets → drawables}/line.rb +7 -5
- data/lacci/lib/shoes/drawables/link.rb +34 -0
- data/lacci/lib/shoes/drawables/list_box.rb +56 -0
- data/lacci/lib/shoes/drawables/para.rb +118 -0
- data/lacci/lib/shoes/drawables/progress.rb +14 -0
- data/lacci/lib/shoes/drawables/radio.rb +33 -0
- data/lacci/lib/shoes/drawables/rect.rb +17 -0
- data/lacci/lib/shoes/{widgets → drawables}/shape.rb +6 -7
- data/lacci/lib/shoes/{widgets → drawables}/slot.rb +32 -20
- data/lacci/lib/shoes/{widgets → drawables}/span.rb +8 -7
- data/lacci/lib/shoes/{widgets → drawables}/stack.rb +6 -4
- data/lacci/lib/shoes/drawables/star.rb +50 -0
- data/lacci/lib/shoes/drawables/subscription_item.rb +93 -0
- data/lacci/lib/shoes/drawables/text_drawable.rb +63 -0
- data/lacci/lib/shoes/drawables/video.rb +16 -0
- data/lacci/lib/shoes/drawables/widget.rb +69 -0
- data/lacci/lib/shoes/drawables.rb +31 -0
- data/lacci/lib/shoes/errors.rb +28 -0
- data/lacci/lib/shoes/log.rb +2 -2
- data/lacci/lib/shoes/ruby_extensions.rb +15 -0
- data/lacci/lib/shoes/spacing.rb +2 -2
- data/lacci/lib/shoes-spec.rb +93 -0
- data/lacci/lib/shoes.rb +27 -7
- data/lacci/test/test_helper.rb +54 -0
- data/lacci/test/test_lacci.rb +12 -3
- data/lacci/test/test_shoes_errors.rb +49 -0
- data/lib/scarpe/cats_cradle.rb +81 -59
- data/lib/scarpe/errors.rb +77 -0
- data/lib/scarpe/evented_assertions.rb +50 -17
- data/lib/scarpe/shoes_spec.rb +181 -0
- data/lib/scarpe/version.rb +2 -2
- data/lib/scarpe/wv/app.rb +20 -20
- data/lib/scarpe/wv/arc.rb +4 -47
- data/lib/scarpe/wv/arrow.rb +9 -0
- data/lib/scarpe/wv/button.rb +7 -35
- data/lib/scarpe/wv/check.rb +3 -5
- data/lib/scarpe/wv/control_interface.rb +18 -20
- data/lib/scarpe/wv/document_root.rb +81 -4
- data/lib/scarpe/wv/{widget.rb → drawable.rb} +66 -43
- data/lib/scarpe/wv/edit_box.rb +4 -17
- data/lib/scarpe/wv/edit_line.rb +4 -18
- data/lib/scarpe/wv/flow.rb +2 -18
- data/lib/scarpe/wv/image.rb +8 -28
- data/lib/scarpe/wv/line.rb +3 -25
- data/lib/scarpe/wv/link.rb +3 -16
- data/lib/scarpe/wv/list_box.rb +6 -29
- data/lib/scarpe/wv/para.rb +11 -30
- data/lib/scarpe/wv/progress.rb +19 -0
- data/lib/scarpe/wv/radio.rb +9 -10
- data/lib/scarpe/wv/rect.rb +13 -0
- data/lib/scarpe/wv/shape.rb +3 -8
- data/lib/scarpe/wv/slot.rb +8 -25
- data/lib/scarpe/wv/span.rb +3 -27
- data/lib/scarpe/wv/stack.rb +2 -18
- data/lib/scarpe/wv/star.rb +3 -53
- data/lib/scarpe/wv/subscription_item.rb +38 -4
- data/lib/scarpe/wv/text_drawable.rb +32 -0
- data/lib/scarpe/wv/video.rb +15 -15
- data/lib/scarpe/wv/web_wrangler.rb +299 -329
- data/lib/scarpe/wv/webview_local_display.rb +48 -33
- data/lib/scarpe/wv/webview_relay_display.rb +12 -12
- data/lib/scarpe/wv/webview_relay_util.rb +7 -10
- data/lib/scarpe/wv/wv_display_worker.rb +2 -2
- data/lib/scarpe/wv.rb +45 -12
- data/lib/scarpe/wv_local.rb +1 -1
- data/lib/scarpe/wv_relay.rb +1 -1
- data/lib/scarpe.rb +1 -0
- data/logger/debug_web_wrangler.json +1 -1
- data/logger/scarpe_wv_test.json +1 -1
- data/scarpe-components/Gemfile.lock +86 -0
- data/scarpe-components/lib/scarpe/components/base64.rb +3 -7
- data/scarpe-components/lib/scarpe/components/calzini/alert.rb +49 -0
- data/scarpe-components/lib/scarpe/components/calzini/art_widgets.rb +203 -0
- data/scarpe-components/lib/scarpe/components/calzini/button.rb +39 -0
- data/scarpe-components/lib/scarpe/components/calzini/misc.rb +146 -0
- data/scarpe-components/lib/scarpe/components/calzini/para.rb +35 -0
- data/scarpe-components/lib/scarpe/components/calzini/slots.rb +155 -0
- data/scarpe-components/lib/scarpe/components/calzini/text_widgets.rb +65 -0
- data/scarpe-components/lib/scarpe/components/calzini.rb +149 -0
- data/scarpe-components/lib/scarpe/components/errors.rb +20 -0
- data/scarpe-components/lib/scarpe/components/file_helpers.rb +1 -0
- data/scarpe-components/lib/scarpe/components/html.rb +131 -0
- data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +75 -0
- data/scarpe-components/lib/scarpe/components/minitest_import_runnable.rb +98 -0
- data/scarpe-components/lib/scarpe/components/minitest_result.rb +86 -0
- data/scarpe-components/lib/scarpe/components/modular_logger.rb +5 -5
- data/scarpe-components/lib/scarpe/components/print_logger.rb +9 -5
- data/scarpe-components/lib/scarpe/components/promises.rb +14 -14
- data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +36 -17
- data/scarpe-components/lib/scarpe/components/string_helpers.rb +10 -0
- data/scarpe-components/lib/scarpe/components/tiranti.rb +225 -0
- data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +45 -5
- data/scarpe-components/lib/scarpe/components/version.rb +2 -2
- data/scarpe-components/test/calzini/test_calzini_alert.rb +30 -0
- data/scarpe-components/test/calzini/test_calzini_art_drawables.rb +105 -0
- data/scarpe-components/test/calzini/test_calzini_button.rb +52 -0
- data/scarpe-components/test/calzini/test_calzini_misc.rb +115 -0
- data/scarpe-components/test/calzini/test_calzini_para.rb +37 -0
- data/scarpe-components/test/calzini/test_calzini_slots.rb +130 -0
- data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +41 -0
- data/scarpe-components/test/mtr_data/exception.json +1 -0
- data/scarpe-components/test/mtr_data/fail_with_message.json +1 -0
- data/scarpe-components/test/mtr_data/skipped_no_message.json +1 -0
- data/scarpe-components/test/mtr_data/skipped_w_msg.json +1 -0
- data/scarpe-components/test/mtr_data/succeed_2_asserts.json +1 -0
- data/scarpe-components/test/test_dimensions.rb +26 -0
- data/scarpe-components/test/test_helper.rb +20 -0
- data/scarpe-components/test/test_html.rb +65 -0
- data/scarpe-components/test/test_minitest_result.rb +61 -0
- data/scarpe-components/test/test_promises.rb +5 -4
- data/scarpe-components/test/test_segmented_app_files.rb +8 -6
- data/scarpegen.rb +14 -14
- data/sig/scarpe.rbs +1 -1
- data/templates/basic_class_template.erb +13 -14
- data/templates/class_template_with_event_bind.erb +4 -4
- data/templates/class_template_with_shapes.erb +8 -17
- data/templates/example_template.erb +1 -1
- data/templates/module_template.erb +4 -4
- data/templates/webview_template.erb +3 -2
- metadata +113 -55
- data/examples/legacy/not_checked/shoes-contrib/elements/image-icon.rb +0 -3
- data/lacci/lib/shoes/widget.rb +0 -218
- data/lacci/lib/shoes/widgets/alert.rb +0 -19
- data/lacci/lib/shoes/widgets/arc.rb +0 -51
- data/lacci/lib/shoes/widgets/button.rb +0 -35
- data/lacci/lib/shoes/widgets/font.rb +0 -14
- data/lacci/lib/shoes/widgets/link.rb +0 -25
- data/lacci/lib/shoes/widgets/list_box.rb +0 -25
- data/lacci/lib/shoes/widgets/para.rb +0 -68
- data/lacci/lib/shoes/widgets/radio.rb +0 -35
- data/lacci/lib/shoes/widgets/star.rb +0 -44
- data/lacci/lib/shoes/widgets/subscription_item.rb +0 -60
- data/lacci/lib/shoes/widgets/text_widget.rb +0 -51
- data/lacci/lib/shoes/widgets/video.rb +0 -15
- data/lacci/lib/shoes/widgets.rb +0 -29
- data/lib/scarpe/wv/alert.rb +0 -66
- data/lib/scarpe/wv/background.rb +0 -27
- data/lib/scarpe/wv/border.rb +0 -24
- data/lib/scarpe/wv/control_interface_test.rb +0 -238
- data/lib/scarpe/wv/dimensions.rb +0 -22
- data/lib/scarpe/wv/font.rb +0 -36
- data/lib/scarpe/wv/html.rb +0 -108
- data/lib/scarpe/wv/spacing.rb +0 -41
- data/lib/scarpe/wv/text_widget.rb +0 -30
- /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/definr.rb +0 -0
- /data/examples/legacy/not_checked/{expert → shoes-contrib/basic}/funnies.rb +0 -0
- /data/examples/legacy/not_checked/shoes-contrib/{elements → basic}/list_box-select-class.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/basic-edit-box.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/basic-fps.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/border-cat.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/check-mate.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/manipulation → working/simple}/clear-slot.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/clock.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/gradient-shoes.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/basic → working/simple}/list_box-shape-report.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/list_box.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/phat-button.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib → working}/simple/simple-calc.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/position → working/simple}/stack-width.rb +0 -0
- /data/examples/legacy/{not_checked/shoes-contrib/elements → working/simple}/width-introspec.rb +0 -0
data/lib/scarpe/wv/edit_box.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class EditBox < Drawable
|
|
5
5
|
attr_reader :text, :height, :width
|
|
6
6
|
|
|
7
7
|
def initialize(properties)
|
|
8
8
|
super
|
|
9
9
|
|
|
10
|
-
# The JS handler sends a "change" event, which we forward to the Shoes
|
|
10
|
+
# The JS handler sends a "change" event, which we forward to the Shoes drawable tree
|
|
11
11
|
bind("change") do |new_text|
|
|
12
12
|
send_self_event(new_text, event_name: "change")
|
|
13
13
|
end
|
|
@@ -23,20 +23,7 @@ class Scarpe
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def element
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
HTML.render do |h|
|
|
29
|
-
h.textarea(id: html_id, oninput: oninput, style: style) { text }
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
protected
|
|
34
|
-
|
|
35
|
-
def style
|
|
36
|
-
super.merge({
|
|
37
|
-
height: Dimensions.length(height),
|
|
38
|
-
width: Dimensions.length(width),
|
|
39
|
-
}.compact)
|
|
26
|
+
render("edit_box")
|
|
40
27
|
end
|
|
41
28
|
end
|
|
42
29
|
end
|
data/lib/scarpe/wv/edit_line.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class EditLine < Drawable
|
|
5
5
|
attr_reader :text, :width
|
|
6
6
|
|
|
7
7
|
def initialize(properties)
|
|
8
8
|
super
|
|
9
9
|
|
|
10
|
-
# The JS handler sends a "change" event, which we forward to the Shoes
|
|
10
|
+
# The JS handler sends a "change" event, which we forward to the Shoes drawable tree
|
|
11
11
|
bind("change") do |new_text|
|
|
12
12
|
send_self_event(new_text, event_name: "change")
|
|
13
13
|
end
|
|
@@ -23,21 +23,7 @@ class Scarpe
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def element
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
HTML.render do |h|
|
|
29
|
-
h.input(id: html_id, oninput: oninput, value: @text, style: style)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
protected
|
|
34
|
-
|
|
35
|
-
def style
|
|
36
|
-
styles = super
|
|
37
|
-
|
|
38
|
-
styles[:width] = Dimensions.length(@width) if @width
|
|
39
|
-
|
|
40
|
-
styles
|
|
26
|
+
render("edit_line")
|
|
41
27
|
end
|
|
42
28
|
end
|
|
43
29
|
end
|
data/lib/scarpe/wv/flow.rb
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
5
|
-
def initialize(properties)
|
|
6
|
-
super
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
protected
|
|
10
|
-
|
|
11
|
-
def style
|
|
12
|
-
{
|
|
13
|
-
display: "flex",
|
|
14
|
-
"flex-direction": "row",
|
|
15
|
-
"flex-wrap": "wrap",
|
|
16
|
-
"align-content": "flex-start",
|
|
17
|
-
"justify-content": "flex-start",
|
|
18
|
-
"align-items": "flex-start",
|
|
19
|
-
}.merge(super)
|
|
20
|
-
end
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Flow < Slot
|
|
21
5
|
end
|
|
22
6
|
end
|
data/lib/scarpe/wv/image.rb
CHANGED
|
@@ -2,40 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
require "scarpe/components/base64"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
class
|
|
7
|
-
include Components::Base64
|
|
5
|
+
module Scarpe::Webview
|
|
6
|
+
class Image < Drawable
|
|
7
|
+
include Scarpe::Components::Base64
|
|
8
|
+
|
|
8
9
|
def initialize(properties)
|
|
9
10
|
super
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def element
|
|
15
|
-
if @click
|
|
16
|
-
HTML.render do |h|
|
|
17
|
-
h.a(id: html_id, href: @click) { h.img(id: html_id, src: @url, style:) }
|
|
18
|
-
end
|
|
19
|
-
else
|
|
20
|
-
HTML.render do |h|
|
|
21
|
-
h.img(id: html_id, src: @url, style:)
|
|
22
|
-
end
|
|
12
|
+
unless valid_url?(@url)
|
|
13
|
+
@url = "data:image/png;base64,#{encode_file_to_base64(@url)}"
|
|
23
14
|
end
|
|
24
15
|
end
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def style
|
|
29
|
-
styles = super
|
|
30
|
-
|
|
31
|
-
styles[:width] = Dimensions.length(@width) if @width
|
|
32
|
-
styles[:height] = Dimensions.length(@height) if @height
|
|
33
|
-
|
|
34
|
-
styles[:top] = Dimensions.length(@top) if @top
|
|
35
|
-
styles[:left] = Dimensions.length(@left) if @left
|
|
36
|
-
styles[:position] = "absolute" if @top || @left
|
|
37
|
-
|
|
38
|
-
styles
|
|
17
|
+
def element
|
|
18
|
+
render("image")
|
|
39
19
|
end
|
|
40
20
|
end
|
|
41
21
|
end
|
data/lib/scarpe/wv/line.rb
CHANGED
|
@@ -1,35 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Line < Drawable
|
|
5
5
|
def initialize(properties)
|
|
6
6
|
super(properties)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def element
|
|
10
|
-
|
|
11
|
-
h.div(id: html_id, style: style) do
|
|
12
|
-
h.svg(width: @x2, height: @y2) do
|
|
13
|
-
h.line(x1: @left, y1: @top, x2: @x2, y2: @y2, style: line_style)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
protected
|
|
20
|
-
|
|
21
|
-
def style
|
|
22
|
-
super.merge({
|
|
23
|
-
left: "#{@left}px",
|
|
24
|
-
top: "#{@top}px",
|
|
25
|
-
})
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def line_style
|
|
29
|
-
{
|
|
30
|
-
stroke: @draw_context["stroke"],
|
|
31
|
-
"stroke-width": "4",
|
|
32
|
-
}
|
|
10
|
+
render("line")
|
|
33
11
|
end
|
|
34
12
|
end
|
|
35
13
|
end
|
data/lib/scarpe/wv/link.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Link < TextDrawable
|
|
5
5
|
def initialize(properties)
|
|
6
6
|
super
|
|
7
7
|
|
|
@@ -11,20 +11,7 @@ class Scarpe
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def element
|
|
14
|
-
|
|
15
|
-
h.a(**attributes) do
|
|
16
|
-
@text
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def attributes
|
|
22
|
-
{
|
|
23
|
-
id: html_id,
|
|
24
|
-
href: @click,
|
|
25
|
-
onclick: (handler_js_code("click") if @has_block),
|
|
26
|
-
style: style,
|
|
27
|
-
}.compact
|
|
14
|
+
render "link"
|
|
28
15
|
end
|
|
29
16
|
end
|
|
30
17
|
end
|
data/lib/scarpe/wv/list_box.rb
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
5
|
-
attr_reader :
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class ListBox < Drawable
|
|
5
|
+
attr_reader :items, :height, :width, :chosen
|
|
6
6
|
|
|
7
7
|
def initialize(properties)
|
|
8
|
-
super
|
|
8
|
+
super
|
|
9
9
|
|
|
10
|
-
# The JS handler sends a "change" event, which we forward to the Shoes widget tree
|
|
11
10
|
bind("change") do |new_item|
|
|
12
11
|
send_self_event(new_item, event_name: "change")
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
def properties_changed(changes)
|
|
17
|
-
selected = changes.delete("
|
|
16
|
+
selected = changes.delete("chosen")
|
|
18
17
|
if selected
|
|
19
18
|
html_element.value = selected
|
|
20
19
|
end
|
|
@@ -22,29 +21,7 @@ class Scarpe
|
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def element
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
select_attrs = { id: html_id, onchange: onchange, style: style }
|
|
28
|
-
option_attrs = { value: nil, selected: false }
|
|
29
|
-
|
|
30
|
-
HTML.render do |h|
|
|
31
|
-
h.select(**select_attrs) do
|
|
32
|
-
items.each do |item|
|
|
33
|
-
h.option(**option_attrs, value: item, selected: (item == selected_item)) { item }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
protected
|
|
40
|
-
|
|
41
|
-
def style
|
|
42
|
-
styles = super
|
|
43
|
-
|
|
44
|
-
styles[:height] = Dimensions.length(height) if height
|
|
45
|
-
styles[:width] = Dimensions.length(width) if width
|
|
46
|
-
|
|
47
|
-
styles
|
|
24
|
+
render("list_box")
|
|
48
25
|
end
|
|
49
26
|
end
|
|
50
27
|
end
|
data/lib/scarpe/wv/para.rb
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Para < Drawable
|
|
5
|
+
# Currently this is duplicated in Calzini. How to refactor?
|
|
6
|
+
# Similarly, we make some assumptions about when size is a symbol
|
|
7
|
+
# versus string that may not survive JSON deserialization.
|
|
8
|
+
# Do we want to hardcode these sizes in Lacci and have it always
|
|
9
|
+
# pass numbers?
|
|
5
10
|
SIZES = {
|
|
6
11
|
inscription: 10,
|
|
7
12
|
ins: 10,
|
|
@@ -14,10 +19,6 @@ class Scarpe
|
|
|
14
19
|
}.freeze
|
|
15
20
|
private_constant :SIZES
|
|
16
21
|
|
|
17
|
-
def initialize(properties)
|
|
18
|
-
super
|
|
19
|
-
end
|
|
20
|
-
|
|
21
22
|
def properties_changed(changes)
|
|
22
23
|
items = changes.delete("text_items")
|
|
23
24
|
if items
|
|
@@ -40,39 +41,23 @@ class Scarpe
|
|
|
40
41
|
if item.is_a?(String)
|
|
41
42
|
item
|
|
42
43
|
else
|
|
43
|
-
|
|
44
|
+
Scarpe::Webview::DisplayService.instance.query_display_drawable_for(item)
|
|
44
45
|
end
|
|
45
46
|
end
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
def element(&block)
|
|
49
|
-
|
|
50
|
-
h.p(**options, &block)
|
|
51
|
-
end
|
|
50
|
+
render("para", &block)
|
|
52
51
|
end
|
|
53
52
|
|
|
53
|
+
# Because para's to_html takes a block, and it needs to convert IDs into display
|
|
54
|
+
# drawables, it needs to also override to_html
|
|
54
55
|
def to_html
|
|
55
56
|
@children ||= []
|
|
56
57
|
|
|
57
58
|
element { child_markup }
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
protected
|
|
61
|
-
|
|
62
|
-
def style
|
|
63
|
-
super.merge({
|
|
64
|
-
color: rgb_to_hex(@stroke),
|
|
65
|
-
"font-size": font_size,
|
|
66
|
-
"font-family": @font,
|
|
67
|
-
}.compact)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def font_size
|
|
71
|
-
font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size
|
|
72
|
-
|
|
73
|
-
Dimensions.length(font_size)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
61
|
private
|
|
77
62
|
|
|
78
63
|
def child_markup
|
|
@@ -84,9 +69,5 @@ class Scarpe
|
|
|
84
69
|
end
|
|
85
70
|
end.join
|
|
86
71
|
end
|
|
87
|
-
|
|
88
|
-
def options
|
|
89
|
-
@html_attributes.merge(id: html_id, style: style)
|
|
90
|
-
end
|
|
91
72
|
end
|
|
92
73
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Progress < Drawable
|
|
5
|
+
def initialize(properties)
|
|
6
|
+
super
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# For now do *not* catch properties_changed and do a small update.
|
|
10
|
+
# Tiranti updates some additional fields (e.g. aria-valuenow) that
|
|
11
|
+
# Calzini does not. We'll want Calzini and Tiranti to handle the
|
|
12
|
+
# updates more for themselves. See issue #419 for updates on how
|
|
13
|
+
# we'll handle this. But for right now we re-render the whole
|
|
14
|
+
# drawable every time we change the progress fraction.
|
|
15
|
+
def element
|
|
16
|
+
render("progress")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/scarpe/wv/radio.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Radio < Drawable
|
|
5
|
+
# TODO: is this needed?
|
|
5
6
|
attr_reader :text
|
|
6
7
|
|
|
7
8
|
def initialize(properties)
|
|
@@ -20,15 +21,13 @@ class Scarpe
|
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def element
|
|
23
|
-
|
|
24
|
-
h.input(type: :radio, id: html_id, onclick: handler_js_code("click"), name: group_name, value: "hmm #{text}", checked: @checked, style: style)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
24
|
+
props = shoes_styles
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
# If a group isn't set, default to the linkable ID of the parent slot
|
|
27
|
+
unless @group
|
|
28
|
+
props["group"] = @parent ? @parent.shoes_linkable_id : "no_group"
|
|
29
|
+
end
|
|
30
|
+
render("radio", props)
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
end
|
data/lib/scarpe/wv/shape.rb
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class WebviewShape < Scarpe::WebviewWidget
|
|
6
|
-
def initialize(properties)
|
|
7
|
-
super(properties)
|
|
8
|
-
end
|
|
9
|
-
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Shape < Drawable
|
|
10
5
|
def to_html
|
|
11
6
|
@children ||= []
|
|
12
7
|
child_markup = @children.map(&:to_html).join
|
|
@@ -51,7 +46,7 @@ class Scarpe
|
|
|
51
46
|
x, y = *args
|
|
52
47
|
current_path += "L #{x} #{y} "
|
|
53
48
|
else
|
|
54
|
-
raise "Unknown shape command! #{cmd.inspect}"
|
|
49
|
+
raise Scarpe::UnknownShapeCommandError, "Unknown shape command! #{cmd.inspect}"
|
|
55
50
|
end
|
|
56
51
|
end
|
|
57
52
|
|
data/lib/scarpe/wv/slot.rb
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
5
|
-
include Scarpe::WebviewBackground
|
|
6
|
-
include Scarpe::WebviewBorder
|
|
7
|
-
include Scarpe::WebviewSpacing
|
|
8
|
-
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Slot < Drawable
|
|
9
5
|
def initialize(properties)
|
|
10
6
|
@event_callbacks = {}
|
|
11
7
|
|
|
@@ -13,16 +9,16 @@ class Scarpe
|
|
|
13
9
|
end
|
|
14
10
|
|
|
15
11
|
def element(&block)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
props = shoes_styles.merge("html_attributes" => html_attributes)
|
|
13
|
+
render_name = self.class.name.split("::")[-1].downcase # usually "stack" or "flow" or "documentroot"
|
|
14
|
+
render(render_name, props, &block)
|
|
19
15
|
end
|
|
20
16
|
|
|
21
17
|
def set_event_callback(obj, event_name, js_code)
|
|
22
18
|
event_name = event_name.to_s
|
|
23
19
|
@event_callbacks[event_name] ||= {}
|
|
24
20
|
if @event_callbacks[event_name][obj]
|
|
25
|
-
raise "Can't have two callbacks on the same event, from the same object, on the same parent!"
|
|
21
|
+
raise Scarpe::DuplicateCallbackError, "Can't have two callbacks on the same event, from the same object, on the same parent!"
|
|
26
22
|
end
|
|
27
23
|
|
|
28
24
|
@event_callbacks[event_name][obj] = js_code
|
|
@@ -54,7 +50,8 @@ class Scarpe
|
|
|
54
50
|
html_element.set_attribute(event_name, @event_callbacks[event_name].values.join(";"))
|
|
55
51
|
end
|
|
56
52
|
|
|
57
|
-
|
|
53
|
+
# These get added for event handlers and passed to Calzini
|
|
54
|
+
def html_attributes
|
|
58
55
|
attr = {}
|
|
59
56
|
|
|
60
57
|
@event_callbacks.each do |event_name, handlers|
|
|
@@ -63,19 +60,5 @@ class Scarpe
|
|
|
63
60
|
|
|
64
61
|
attr
|
|
65
62
|
end
|
|
66
|
-
|
|
67
|
-
def style
|
|
68
|
-
styles = super
|
|
69
|
-
|
|
70
|
-
styles[:"margin-top"] = @margin_top if @margin_top
|
|
71
|
-
styles[:"margin-bottom"] = @margin_bottom if @margin_bottom
|
|
72
|
-
styles[:"margin-left"] = @margin_left if @margin_left
|
|
73
|
-
styles[:"margin-right"] = @margin_right if @margin_right
|
|
74
|
-
|
|
75
|
-
styles[:width] = Dimensions.length(@width) if @width
|
|
76
|
-
styles[:height] = Dimensions.length(@height) if @height
|
|
77
|
-
|
|
78
|
-
styles
|
|
79
|
-
end
|
|
80
63
|
end
|
|
81
64
|
end
|
data/lib/scarpe/wv/span.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Span < TextDrawable
|
|
5
5
|
SIZES = {
|
|
6
6
|
inscription: 10,
|
|
7
7
|
ins: 10,
|
|
@@ -34,35 +34,11 @@ class Scarpe
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def element(&block)
|
|
37
|
-
|
|
38
|
-
h.span(**options, &block)
|
|
39
|
-
end
|
|
37
|
+
render("span", &block)
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
def to_html
|
|
43
41
|
element { @text }
|
|
44
42
|
end
|
|
45
|
-
|
|
46
|
-
protected
|
|
47
|
-
|
|
48
|
-
def style
|
|
49
|
-
{
|
|
50
|
-
color: @stroke,
|
|
51
|
-
"font-size": font_size,
|
|
52
|
-
"font-family": @font,
|
|
53
|
-
}.compact
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
private
|
|
57
|
-
|
|
58
|
-
def options
|
|
59
|
-
@html_attributes.merge(id: html_id, style: style)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def font_size
|
|
63
|
-
font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size
|
|
64
|
-
|
|
65
|
-
Dimensions.length(font_size)
|
|
66
|
-
end
|
|
67
43
|
end
|
|
68
44
|
end
|
data/lib/scarpe/wv/stack.rb
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
5
|
-
def get_style
|
|
6
|
-
style
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
protected
|
|
10
|
-
|
|
11
|
-
def style
|
|
12
|
-
{
|
|
13
|
-
display: "flex",
|
|
14
|
-
"flex-direction": "column",
|
|
15
|
-
"align-content": "flex-start",
|
|
16
|
-
"justify-content": "flex-start",
|
|
17
|
-
"align-items": "flex-start",
|
|
18
|
-
overflow: @scroll ? "auto" : nil,
|
|
19
|
-
}.compact.merge(super)
|
|
20
|
-
end
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Stack < Slot
|
|
21
5
|
end
|
|
22
6
|
end
|
data/lib/scarpe/wv/star.rb
CHANGED
|
@@ -1,63 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class
|
|
3
|
+
module Scarpe::Webview
|
|
4
|
+
class Star < Drawable
|
|
5
5
|
def initialize(properties)
|
|
6
6
|
super(properties)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def element(&block)
|
|
10
|
-
|
|
11
|
-
stroke = @draw_context["stroke"]
|
|
12
|
-
fill = "black" if fill == ""
|
|
13
|
-
stroke = "black" if stroke == ""
|
|
14
|
-
HTML.render do |h|
|
|
15
|
-
h.div(id: html_id, style: style) do
|
|
16
|
-
h.svg(width: @outer, height: @outer, style: "fill:#{fill};") do
|
|
17
|
-
h.polygon(points: star_points, style: "stroke:#{stroke};stroke-width:2")
|
|
18
|
-
end
|
|
19
|
-
block.call(h) if block_given?
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
protected
|
|
25
|
-
|
|
26
|
-
def style
|
|
27
|
-
super.merge({
|
|
28
|
-
width: Dimensions.length(@width),
|
|
29
|
-
height: Dimensions.length(@height),
|
|
30
|
-
})
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def star_points
|
|
36
|
-
get_star_points.join(",")
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def get_star_points
|
|
40
|
-
angle = 2 * Math::PI / @points
|
|
41
|
-
coordinates = []
|
|
42
|
-
|
|
43
|
-
@points.times do |i|
|
|
44
|
-
outer_angle = i * angle
|
|
45
|
-
inner_angle = outer_angle + angle / 2
|
|
46
|
-
|
|
47
|
-
coordinates.concat(get_coordinates(outer_angle, inner_angle))
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
coordinates
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def get_coordinates(outer_angle, inner_angle)
|
|
54
|
-
outer_x = @outer / 2 + Math.cos(outer_angle) * @outer / 2
|
|
55
|
-
outer_y = @outer / 2 + Math.sin(outer_angle) * @outer / 2
|
|
56
|
-
|
|
57
|
-
inner_x = @outer / 2 + Math.cos(inner_angle) * @inner / 2
|
|
58
|
-
inner_y = @outer / 2 + Math.sin(inner_angle) * @inner / 2
|
|
59
|
-
|
|
60
|
-
[outer_x, outer_y, inner_x, inner_y]
|
|
10
|
+
render("star", &block)
|
|
61
11
|
end
|
|
62
12
|
end
|
|
63
13
|
end
|