scarpe 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.yardopts +12 -0
- data/CHANGELOG.md +16 -2
- data/Gemfile +3 -0
- data/Gemfile.lock +116 -0
- data/README.md +53 -30
- data/Rakefile +13 -1
- data/docs/yard/catscradle.md +44 -0
- data/docs/yard/template/default/fulldoc/html/setup.rb +13 -0
- data/docs/yard/template/default/layout/html/setup.rb +9 -0
- data/examples/animate.rb +20 -0
- data/examples/arrow.rb +10 -0
- data/examples/background_with_image.rb +16 -0
- data/examples/bloopsaphone/working/bronx_army_knife.rb +66 -0
- data/examples/bloopsaphone/working/morning_serenity.rb +21 -0
- data/examples/bloopsaphone/working/simpsons_theme_song_by_why.rb +6 -4
- data/examples/btn_tooltip.rb +7 -0
- data/examples/button_go_away.rb +1 -1
- data/examples/button_style_changed.rb +7 -0
- data/examples/button_styles_default.rb +6 -0
- data/examples/check.rb +18 -0
- data/examples/clear_and_append.rb +24 -0
- data/examples/download_and_show_image.rb +28 -0
- data/examples/edit_box.rb +3 -5
- data/examples/fonts.rb +2 -2
- data/examples/gen.rb +8 -8
- data/examples/get_headers.rb +10 -0
- data/examples/highlander.rb +4 -2
- 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/link.rb +2 -2
- 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 +4 -0
- data/examples/local_images.rb +3 -0
- data/examples/motion_events.rb +20 -0
- data/examples/para/para_text.rb +14 -0
- data/examples/parse_xl_funnies.rb +58 -0
- data/examples/progress.rb +31 -0
- data/examples/radio/radio.rb +16 -0
- data/examples/radio/radio_groups.rb +18 -0
- data/examples/radio/radio_same_slot.rb +6 -0
- data/examples/rect.rb +4 -0
- data/examples/rotate_shapes.rb +17 -0
- data/examples/ruby_racer.rb +13 -15
- data/examples/selfitude.rb +18 -0
- data/examples/shapes/shapes_fill.rb +4 -3
- data/examples/shoes_school.rb +2 -4
- data/examples/show_hide.rb +6 -0
- data/examples/simpler-menu.rb +21 -0
- data/examples/skip_ci/change_my_audio_source.rb +21 -0
- data/examples/skip_ci/guitar_fretboard.rb +137 -0
- data/examples/video.rb +10 -0
- data/exe/scarpe +43 -66
- data/fonts/Pacifico.ttf +0 -0
- data/lacci/Gemfile +24 -0
- data/lacci/Gemfile.lock +79 -0
- data/lacci/Rakefile +12 -0
- data/lacci/lacci.gemspec +37 -0
- data/lacci/lib/lacci/scarpe_cli.rb +71 -0
- data/lacci/lib/lacci/scarpe_core.rb +22 -0
- data/lacci/lib/lacci/version.rb +13 -0
- 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 +309 -0
- data/{lib/scarpe → lacci/lib/shoes}/background.rb +2 -2
- data/{lib/scarpe → lacci/lib/shoes}/border.rb +2 -2
- data/lacci/lib/shoes/builtins.rb +63 -0
- data/lacci/lib/shoes/changelog.rb +52 -0
- data/{lib/scarpe → lacci/lib/shoes}/colors.rb +3 -1
- data/lacci/lib/shoes/constants.rb +47 -0
- data/{lib/scarpe → lacci/lib/shoes}/display_service.rb +71 -53
- data/lacci/lib/shoes/download.rb +123 -0
- 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/drawables/check.rb +29 -0
- data/lacci/lib/shoes/drawables/document_root.rb +20 -0
- data/lacci/lib/shoes/drawables/edit_box.rb +29 -0
- data/{lib/scarpe → lacci/lib/shoes/drawables}/edit_line.rb +6 -6
- data/lacci/lib/shoes/drawables/flow.rb +22 -0
- data/{lib/scarpe → lacci/lib/shoes/drawables}/image.rb +7 -11
- data/lacci/lib/shoes/drawables/line.rb +20 -0
- 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/drawables/shape.rb +36 -0
- data/lacci/lib/shoes/drawables/slot.rb +87 -0
- data/{lib/scarpe → lacci/lib/shoes/drawables}/span.rb +8 -7
- data/lacci/lib/shoes/drawables/stack.rb +26 -0
- 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 +71 -0
- data/lacci/lib/shoes/ruby_extensions.rb +15 -0
- data/lacci/lib/shoes/spacing.rb +9 -0
- data/lacci/lib/shoes-spec.rb +93 -0
- data/lacci/lib/shoes.rb +147 -0
- data/lacci/test/test_colors.rb +39 -0
- data/lacci/test/test_helper.rb +63 -0
- data/lacci/test/test_lacci.rb +18 -0
- data/lacci/test/test_shoes_errors.rb +49 -0
- data/lib/scarpe/cats_cradle.rb +271 -0
- data/lib/scarpe/errors.rb +77 -0
- data/lib/scarpe/evented_assertions.rb +121 -0
- data/lib/scarpe/shoes_spec.rb +181 -0
- data/lib/scarpe/version.rb +2 -2
- data/lib/scarpe/wv/app.rb +45 -23
- data/lib/scarpe/wv/arc.rb +4 -48
- data/lib/scarpe/wv/arrow.rb +9 -0
- data/lib/scarpe/wv/button.rb +7 -33
- data/lib/scarpe/wv/check.rb +27 -0
- data/lib/scarpe/wv/control_interface.rb +32 -40
- data/lib/scarpe/wv/document_root.rb +66 -31
- data/lib/scarpe/wv/drawable.rb +273 -0
- data/lib/scarpe/wv/edit_box.rb +4 -19
- data/lib/scarpe/wv/edit_line.rb +4 -18
- data/lib/scarpe/wv/flow.rb +2 -28
- data/lib/scarpe/wv/image.rb +10 -25
- data/lib/scarpe/wv/line.rb +3 -28
- data/lib/scarpe/wv/link.rb +3 -15
- data/lib/scarpe/wv/list_box.rb +6 -29
- data/lib/scarpe/wv/para.rb +11 -28
- data/lib/scarpe/wv/progress.rb +19 -0
- data/lib/scarpe/wv/radio.rb +33 -0
- data/lib/scarpe/wv/rect.rb +13 -0
- data/lib/scarpe/wv/shape.rb +41 -10
- data/lib/scarpe/wv/slot.rb +64 -0
- data/lib/scarpe/wv/span.rb +3 -25
- data/lib/scarpe/wv/stack.rb +2 -38
- data/lib/scarpe/wv/star.rb +3 -54
- data/lib/scarpe/wv/subscription_item.rb +84 -0
- data/lib/scarpe/wv/text_drawable.rb +32 -0
- data/lib/scarpe/wv/video.rb +34 -0
- data/lib/scarpe/wv/web_wrangler.rb +449 -299
- data/lib/scarpe/wv/webview_local_display.rb +63 -26
- data/lib/scarpe/wv/webview_relay_display.rb +24 -125
- data/lib/scarpe/wv/webview_relay_util.rb +140 -0
- data/lib/scarpe/wv/wv_display_worker.rb +19 -6
- data/lib/scarpe/wv.rb +76 -14
- data/lib/scarpe/wv_local.rb +1 -1
- data/lib/scarpe/wv_relay.rb +1 -1
- data/lib/scarpe.rb +4 -32
- data/logger/debug_web_wrangler.json +1 -1
- data/logger/scarpe_wv_test.json +1 -1
- data/scarpe-components/.gitignore +1 -0
- data/scarpe-components/Gemfile +22 -0
- data/scarpe-components/Gemfile.lock +86 -0
- data/scarpe-components/README.md +35 -0
- data/scarpe-components/Rakefile +12 -0
- data/scarpe-components/lib/scarpe/components/base64.rb +25 -0
- 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 +66 -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 +113 -0
- data/scarpe-components/lib/scarpe/components/print_logger.rb +47 -0
- data/{lib/scarpe → scarpe-components/lib/scarpe/components}/promises.rb +115 -48
- data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +189 -0
- 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 +257 -0
- data/scarpe-components/lib/scarpe/components/version.rb +7 -0
- data/scarpe-components/scarpe-components.gemspec +38 -0
- 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_components.rb +9 -0
- data/scarpe-components/test/test_dimensions.rb +26 -0
- data/scarpe-components/test/test_helper.rb +43 -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 +261 -0
- data/scarpe-components/test/test_segmented_app_files.rb +184 -0
- data/scarpegen.rb +14 -14
- data/sig/scarpe.rbs +1 -1
- data/{lib/scarpe → spikes}/glibui/widget.rb +2 -2
- data/{lib/scarpe → spikes}/glibui.rb +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 -5
- metadata +236 -145
- data/examples/fill.rb +0 -25
- data/examples/legacy/not_checked/shoes-contrib/basic/class-book.yaml +0 -387
- data/examples/legacy/not_checked/shoes-contrib/elements/image-icon.rb +0 -3
- data/examples/legacy/not_checked/shoes-contrib/good/good-clock.rb +0 -51
- data/examples/legacy/not_checked/shoes-contrib/good/good-follow.rb +0 -26
- data/examples/legacy/not_checked/shoes-contrib/good/good-reminder.rb +0 -174
- data/examples/legacy/not_checked/shoes-contrib/good/good-vjot.rb +0 -56
- data/examples/legacy/not_checked/shoes-contrib/simple/simple-timer.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/good-clock.rb +0 -51
- data/examples/legacy/not_checked/shoes-dep-samples/good-follow.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/good-reminder.rb +0 -174
- data/examples/legacy/not_checked/shoes-dep-samples/good-vjot.rb +0 -56
- data/examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb +0 -75
- data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-shapes.rb +0 -17
- data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-text.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-arc.rb +0 -23
- data/examples/legacy/not_checked/shoes-dep-samples/simple-bounce.rb +0 -24
- data/examples/legacy/not_checked/shoes-dep-samples/simple-calc.rb +0 -70
- data/examples/legacy/not_checked/shoes-dep-samples/simple-chipmunk.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/simple-control-sizes.rb +0 -24
- data/examples/legacy/not_checked/shoes-dep-samples/simple-curve.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/simple-dialogs.rb +0 -29
- data/examples/legacy/not_checked/shoes-dep-samples/simple-draw.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-editor.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-form.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-form.shy +0 -0
- data/examples/legacy/not_checked/shoes-dep-samples/simple-mask.rb +0 -21
- data/examples/legacy/not_checked/shoes-dep-samples/simple-menu.rb +0 -31
- data/examples/legacy/not_checked/shoes-dep-samples/simple-menu1.rb +0 -35
- data/examples/legacy/not_checked/shoes-dep-samples/simple-rubygems.rb +0 -29
- data/examples/legacy/not_checked/shoes-dep-samples/simple-slide.rb +0 -45
- data/examples/legacy/not_checked/shoes-dep-samples/simple-sphere.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-sqlite3.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-timer.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-video.rb +0 -13
- data/examples/legacy/not_checked/simple/anim-text.rb +0 -13
- data/examples/legacy/not_checked/simple/arc.rb +0 -23
- data/examples/legacy/not_checked/simple/bounce.rb +0 -24
- data/examples/legacy/not_checked/simple/chipmunk.rb +0 -26
- data/examples/legacy/not_checked/simple/curve.rb +0 -26
- data/examples/legacy/not_checked/simple/dialogs.rb +0 -29
- data/examples/legacy/not_checked/simple/downloader.rb +0 -40
- data/examples/legacy/not_checked/simple/draw.rb +0 -13
- data/examples/legacy/not_checked/simple/mask.rb +0 -21
- data/examples/legacy/not_checked/simple/slide.rb +0 -45
- data/examples/legacy/not_checked/simple/sphere.rb +0 -28
- data/lib/constants.rb +0 -5
- data/lib/scarpe/alert.rb +0 -19
- data/lib/scarpe/app.rb +0 -78
- data/lib/scarpe/arc.rb +0 -49
- data/lib/scarpe/button.rb +0 -35
- data/lib/scarpe/document_root.rb +0 -20
- data/lib/scarpe/edit_box.rb +0 -24
- data/lib/scarpe/fill.rb +0 -23
- data/lib/scarpe/flow.rb +0 -19
- data/lib/scarpe/line.rb +0 -25
- data/lib/scarpe/link.rb +0 -25
- data/lib/scarpe/list_box.rb +0 -25
- data/lib/scarpe/logger.rb +0 -155
- data/lib/scarpe/para.rb +0 -90
- data/lib/scarpe/shape.rb +0 -19
- data/lib/scarpe/spacing.rb +0 -9
- data/lib/scarpe/stack.rb +0 -70
- data/lib/scarpe/star.rb +0 -47
- data/lib/scarpe/text_widget.rb +0 -42
- data/lib/scarpe/unit_test_helpers.rb +0 -163
- data/lib/scarpe/widget.rb +0 -198
- data/lib/scarpe/widgets.rb +0 -30
- data/lib/scarpe/wv/alert.rb +0 -65
- data/lib/scarpe/wv/background.rb +0 -18
- data/lib/scarpe/wv/border.rb +0 -22
- data/lib/scarpe/wv/control_interface_test.rb +0 -253
- data/lib/scarpe/wv/dimensions.rb +0 -22
- data/lib/scarpe/wv/fill.rb +0 -30
- data/lib/scarpe/wv/html.rb +0 -107
- data/lib/scarpe/wv/shape_helper.rb +0 -44
- data/lib/scarpe/wv/spacing.rb +0 -41
- data/lib/scarpe/wv/text_widget.rb +0 -30
- data/lib/scarpe/wv/widget.rb +0 -181
- data/scarpe-0.2.0.gem +0 -0
- /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 → spikes}/glibui/README.md +0 -0
- /data/{lib/scarpe → spikes}/glibui/alert.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/app.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/background.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/border.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/button.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/dimensions.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/document_root.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/edit_box.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/edit_line.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/flow.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/html.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/image.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/link.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/local_display.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/para.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/spacing.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/stack.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/text_widget.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/alert.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/button.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/colors.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/core.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/flow.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/libui.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/notepad.md +0 -0
- /data/{lib/scarpe → spikes}/libui/para.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/stack.rb +0 -0
data/lib/scarpe/wv/app.rb
CHANGED
@@ -1,38 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# Scarpe::
|
5
|
-
class
|
6
|
-
attr_reader :debug
|
3
|
+
module Scarpe::Webview
|
4
|
+
# Scarpe::Webview::App must only be used from the main thread, due to GTK+ limitations.
|
5
|
+
class App < Drawable # App inherits from Drawable to set up linkable IDs and event methods
|
7
6
|
attr_reader :control_interface
|
8
7
|
|
9
8
|
attr_writer :shoes_linkable_id
|
10
9
|
|
11
10
|
def initialize(properties)
|
12
|
-
# Is this a thing? Do we care about this?
|
13
|
-
# opts = @control_interface.app_opts_get_override(opts)
|
14
|
-
|
15
11
|
super
|
16
12
|
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# The control interface is what lets these files see
|
24
|
-
# events, specify overrides and so on.
|
13
|
+
# Scarpe's ControlInterface sets up event handlers
|
14
|
+
# for the display service that aren't sent to
|
15
|
+
# Lacci (Shoes). In general it's used for setup
|
16
|
+
# and additional control or testing, outside the
|
17
|
+
# Shoes app. This is how CatsCradle and Shoes-Spec
|
18
|
+
# set up testing, for instance.
|
25
19
|
@control_interface = ControlInterface.new
|
26
|
-
if ENV["SCARPE_TEST_CONTROL"]
|
27
|
-
@control_interface.instance_eval File.read(ENV["SCARPE_TEST_CONTROL"])
|
28
|
-
end
|
29
20
|
|
30
21
|
# TODO: rename @view
|
31
|
-
@view = Scarpe::WebWrangler.new title: @title,
|
22
|
+
@view = Scarpe::Webview::WebWrangler.new title: @title,
|
32
23
|
width: @width,
|
33
24
|
height: @height,
|
34
|
-
resizable: @resizable
|
35
|
-
|
25
|
+
resizable: @resizable
|
26
|
+
|
27
|
+
@callbacks = {}
|
36
28
|
|
37
29
|
# The control interface has to exist to get callbacks like "override Scarpe app opts".
|
38
30
|
# But the Scarpe App needs those options to be created. So we can't pass these to
|
@@ -50,11 +42,11 @@ class Scarpe
|
|
50
42
|
scarpe_app = self
|
51
43
|
|
52
44
|
@view.init_code("scarpeInit") do
|
53
|
-
|
45
|
+
request_redraw!
|
54
46
|
end
|
55
47
|
|
56
48
|
@view.bind("scarpeHandler") do |*args|
|
57
|
-
|
49
|
+
handle_callback(*args)
|
58
50
|
end
|
59
51
|
|
60
52
|
@view.bind("scarpeExit") do
|
@@ -65,6 +57,8 @@ class Scarpe
|
|
65
57
|
def run
|
66
58
|
@control_interface.dispatch_event(:init)
|
67
59
|
|
60
|
+
@view.empty_page = empty_page_element
|
61
|
+
|
68
62
|
# This takes control of the main thread and never returns. And it *must* be run from
|
69
63
|
# the main thread. And it stops any Ruby background threads.
|
70
64
|
# That's totally cool and normal, right?
|
@@ -81,5 +75,33 @@ class Scarpe
|
|
81
75
|
@view = nil
|
82
76
|
end
|
83
77
|
end
|
78
|
+
|
79
|
+
# All JS callbacks to Scarpe drawables are dispatched
|
80
|
+
# via this handler
|
81
|
+
def handle_callback(name, *args)
|
82
|
+
if @callbacks.key?(name)
|
83
|
+
@callbacks[name].call(*args)
|
84
|
+
else
|
85
|
+
raise Scarpe::UnknownEventTypeError, "No such Webview callback: #{name.inspect}!"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Bind a Scarpe callback name; see handle_callback above.
|
90
|
+
# See Scarpe::Drawable for how the naming is set up
|
91
|
+
def bind(name, &block)
|
92
|
+
@callbacks[name] = block
|
93
|
+
end
|
94
|
+
|
95
|
+
# Request a full redraw if Webview is running. Otherwise
|
96
|
+
# this is a no-op.
|
97
|
+
#
|
98
|
+
# @return [void]
|
99
|
+
def request_redraw!
|
100
|
+
wrangler = DisplayService.instance.wrangler
|
101
|
+
if wrangler.is_running
|
102
|
+
wrangler.replace(@document_root.to_html)
|
103
|
+
end
|
104
|
+
nil
|
105
|
+
end
|
84
106
|
end
|
85
107
|
end
|
data/lib/scarpe/wv/arc.rb
CHANGED
@@ -1,57 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
class Scarpe
|
6
|
-
class WebviewArc < Scarpe::WebviewWidget
|
7
|
-
include ShapeHelper
|
3
|
+
module Scarpe::Webview
|
4
|
+
class Arc < Drawable
|
8
5
|
def initialize(properties)
|
9
6
|
super(properties)
|
10
7
|
end
|
11
8
|
|
12
|
-
def element
|
13
|
-
|
14
|
-
h.div(id: html_id, style: style) do
|
15
|
-
h.svg(width: @width, height: @height) do
|
16
|
-
h.path(d: arc_path)
|
17
|
-
end
|
18
|
-
block.call(h) if block_given?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def style
|
26
|
-
{
|
27
|
-
left: "#{@left}px",
|
28
|
-
top: "#{@top}px",
|
29
|
-
width: "#{@width}px",
|
30
|
-
height: "#{@height}px",
|
31
|
-
}
|
32
|
-
end
|
33
|
-
|
34
|
-
def arc_path
|
35
|
-
center_x = @width / 2
|
36
|
-
center_y = @height / 2
|
37
|
-
radius_x = @width / 2
|
38
|
-
radius_y = @height / 2
|
39
|
-
start_angle_degrees = radians_to_degrees(@angle1) % 360
|
40
|
-
end_angle_degrees = radians_to_degrees(@angle2) % 360
|
41
|
-
large_arc_flag = (end_angle_degrees - start_angle_degrees) % 360 > 180 ? 1 : 0
|
42
|
-
|
43
|
-
"M#{center_x} #{center_y} L#{@width} #{center_y} " \
|
44
|
-
"A#{radius_x} #{radius_y} 0 #{large_arc_flag} 0 " \
|
45
|
-
"#{center_x + radius_x * Math.cos(degrees_to_radians(end_angle_degrees))} " \
|
46
|
-
"#{center_y + radius_y * Math.sin(degrees_to_radians(end_angle_degrees))} Z"
|
47
|
-
end
|
48
|
-
|
49
|
-
def degrees_to_radians(degrees)
|
50
|
-
degrees * Math::PI / 180
|
51
|
-
end
|
52
|
-
|
53
|
-
def radians_to_degrees(radians)
|
54
|
-
radians * (180.0 / Math::PI)
|
9
|
+
def element
|
10
|
+
render("arc")
|
55
11
|
end
|
56
12
|
end
|
57
13
|
end
|
data/lib/scarpe/wv/button.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class
|
3
|
+
module Scarpe::Webview
|
4
|
+
class Button < Drawable
|
5
5
|
def initialize(properties)
|
6
6
|
super
|
7
7
|
|
@@ -10,41 +10,15 @@ class Scarpe
|
|
10
10
|
# This will be sent to the bind_self_event in Button
|
11
11
|
send_self_event(event_name: "click")
|
12
12
|
end
|
13
|
-
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@text
|
19
|
-
end
|
14
|
+
bind("hover") do
|
15
|
+
# This will be sent to the bind_self_event in Button
|
16
|
+
send_self_event(event_name: "hover")
|
20
17
|
end
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
def style
|
26
|
-
styles = {}
|
27
|
-
styles["background-color"] = @color
|
28
|
-
styles["padding-top"] = @padding_top
|
29
|
-
styles["padding-bottom"] = @padding_bottom
|
30
|
-
styles[:color] = @text_color
|
31
|
-
styles[:width] = Dimensions.length(@width) if @width
|
32
|
-
styles[:height] = Dimensions.length(@height) if @height
|
33
|
-
styles["font-size"] = @font_size
|
34
|
-
|
35
|
-
styles[:top] = Dimensions.length(@top) if @top
|
36
|
-
styles[:left] = Dimensions.length(@left) if @left
|
37
|
-
styles[:position] = "absolute" if @top || @left
|
38
|
-
styles["font-size"] = Dimensions.length(font_size) if @size
|
39
|
-
styles["font-family"] = @font if @font
|
40
|
-
styles["color"] = rgb_to_hex(@stroke) if @stroke
|
41
|
-
styles
|
42
|
-
end
|
43
|
-
|
44
|
-
def font_size
|
45
|
-
font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size
|
46
|
-
|
47
|
-
Dimensions.length(font_size)
|
20
|
+
def element
|
21
|
+
render("button")
|
48
22
|
end
|
49
23
|
end
|
50
24
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Scarpe::Webview
|
4
|
+
class Check < Drawable
|
5
|
+
attr_reader :text
|
6
|
+
|
7
|
+
def initialize(properties)
|
8
|
+
super
|
9
|
+
|
10
|
+
bind("click") do
|
11
|
+
send_self_event(event_name: "click", target: shoes_linkable_id)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def properties_changed(changes)
|
16
|
+
checked = changes.delete("checked")
|
17
|
+
|
18
|
+
html_element.toggle_input_button(checked)
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def element
|
24
|
+
render("check")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,28 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# The ControlInterface is used for testing. It's a way to register interest
|
4
|
-
# in important events like redraw, init and shutdown, and to
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
4
|
+
# in important events like redraw, init and shutdown, and to configure a
|
5
|
+
# Shoes app for testing. Note that no part of the Scarpe framework should
|
6
|
+
# ever *depend* on ControlInterface. It's for testing, not normal operation.
|
7
|
+
# If no ControlInterface were ever created or called, Scarpe apps should run
|
8
|
+
# fine with no modifications.
|
9
9
|
#
|
10
10
|
# And if you depend on this from the framework, I'll add a check-mode that
|
11
11
|
# never dispatches any events to any handlers. Do NOT test me on this.
|
12
12
|
|
13
|
-
|
13
|
+
module Scarpe::Webview
|
14
14
|
class ControlInterface
|
15
|
-
include
|
15
|
+
include Shoes::Log
|
16
16
|
|
17
17
|
SUBSCRIBE_EVENTS = [:init, :shutdown, :next_redraw, :every_redraw, :next_heartbeat, :every_heartbeat]
|
18
18
|
DISPATCH_EVENTS = [:init, :shutdown, :redraw, :heartbeat]
|
19
|
+
INVALID_SYSTEM_COMPONENTS_MESSAGE = "Must pass non-nil app and wrangler to ControlInterface#set_system_components!"
|
20
|
+
CONTROL_INTERFACE_INIT_MESSAGE = "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
|
21
|
+
"to make sure they have access to app, doc_root, wrangler, etc!"
|
19
22
|
|
20
23
|
attr_writer :doc_root
|
21
24
|
attr_reader :do_shutdown
|
22
25
|
|
23
26
|
# The control interface needs to see major system components to hook into their events
|
24
27
|
def initialize
|
25
|
-
log_init("
|
28
|
+
log_init("Webview::ControlInterface")
|
26
29
|
|
27
30
|
@do_shutdown = false
|
28
31
|
@event_handlers = {}
|
@@ -33,13 +36,17 @@ class Scarpe
|
|
33
36
|
"<#ControlInterface>"
|
34
37
|
end
|
35
38
|
|
36
|
-
# This should get called once, from
|
39
|
+
# This should get called once, from Shoes::App
|
37
40
|
def set_system_components(app:, doc_root:, wrangler:)
|
38
|
-
unless app
|
39
|
-
@log.error("False app passed to set_system_components!")
|
40
|
-
|
41
|
-
raise "Must pass non-nil app and wrangler to ControlInterface#set_system_components!"
|
41
|
+
unless app
|
42
|
+
@log.error("False app passed to set_system_components!")
|
43
|
+
raise Scarpe::MissingAppError, INVALID_SYSTEM_COMPONENTS_MESSAGE
|
42
44
|
end
|
45
|
+
unless wrangler
|
46
|
+
@log.error("False wrangler passed to set_system_components!")
|
47
|
+
raise Scarpe::MissingWranglerError, INVALID_SYSTEM_COMPONENTS_MESSAGE
|
48
|
+
end
|
49
|
+
|
43
50
|
@app = app
|
44
51
|
@doc_root = doc_root # May be nil at this point
|
45
52
|
@wrangler = wrangler
|
@@ -50,28 +57,19 @@ class Scarpe
|
|
50
57
|
end
|
51
58
|
|
52
59
|
def app
|
53
|
-
unless @app
|
54
|
-
raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
|
55
|
-
"to make sure they have access to app, doc_root, wrangler, etc!"
|
56
|
-
end
|
60
|
+
raise Scarpe::MissingAppError, CONTROL_INTERFACE_INIT_MESSAGE unless @app
|
57
61
|
|
58
62
|
@app
|
59
63
|
end
|
60
64
|
|
61
65
|
def doc_root
|
62
|
-
unless @doc_root
|
63
|
-
raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
|
64
|
-
"to make sure they have access to app, doc_root, wrangler, etc!"
|
65
|
-
end
|
66
|
+
raise Scarpe::MissingDocRootError, CONTROL_INTERFACE_INIT_MESSAGE unless @doc_root
|
66
67
|
|
67
68
|
@doc_root
|
68
69
|
end
|
69
70
|
|
70
71
|
def wrangler
|
71
|
-
unless @wrangler
|
72
|
-
raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
|
73
|
-
"to make sure they have access to app, doc_root, wrangler, etc!"
|
74
|
-
end
|
72
|
+
raise Scarpe::MissingWranglerError, CONTROL_INTERFACE_INIT_MESSAGE unless @wrangler
|
75
73
|
|
76
74
|
@wrangler
|
77
75
|
end
|
@@ -79,23 +77,17 @@ class Scarpe
|
|
79
77
|
# The control interface has overrides for certain settings. If the override has been specified,
|
80
78
|
# those settings will be overridden.
|
81
79
|
|
82
|
-
# Override the Shoes app opts like "debug:" and "die_after:" with new ones.
|
83
|
-
def override_app_opts(new_opts)
|
84
|
-
@new_app_opts = new_opts
|
85
|
-
end
|
86
|
-
|
87
|
-
# Called by Scarpe::App to get the override options
|
88
|
-
def app_opts_get_override(opts)
|
89
|
-
@new_app_opts || opts
|
90
|
-
end
|
91
|
-
|
92
80
|
# On recognised events, this sets a handler for that event
|
93
81
|
def on_event(event, &block)
|
94
82
|
unless SUBSCRIBE_EVENTS.include?(event)
|
95
|
-
raise "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
|
83
|
+
raise Scarpe::IllegalSubscribeEventError, "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
|
96
84
|
end
|
97
85
|
|
98
|
-
@
|
86
|
+
@unsub_id ||= 0
|
87
|
+
@unsub_id += 1
|
88
|
+
|
89
|
+
@event_handlers[event] << { handler: block, unsub: @unsub_id }
|
90
|
+
@unsub_id
|
99
91
|
end
|
100
92
|
|
101
93
|
# Send out the specified event
|
@@ -103,7 +95,7 @@ class Scarpe
|
|
103
95
|
@log.debug("CTL event #{event.inspect} #{args.inspect} #{keywords.inspect}")
|
104
96
|
|
105
97
|
unless DISPATCH_EVENTS.include?(event)
|
106
|
-
raise "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
|
98
|
+
raise Scarpe::IllegalDispatchEventError, "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
|
107
99
|
end
|
108
100
|
|
109
101
|
if @do_shutdown
|
@@ -145,8 +137,8 @@ class Scarpe
|
|
145
137
|
private
|
146
138
|
|
147
139
|
def dumb_dispatch_event(event, *args, **keywords)
|
148
|
-
@event_handlers[event].each do |
|
149
|
-
instance_eval(*args, **keywords, &handler)
|
140
|
+
@event_handlers[event].each do |data|
|
141
|
+
instance_eval(*args, **keywords, &data[:handler])
|
150
142
|
end
|
151
143
|
end
|
152
144
|
end
|
@@ -1,50 +1,85 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Scarpe::Webview
|
4
|
+
# A DocumentRoot is a {Scarpe::Webview::Flow}, with all the same properties
|
5
|
+
# and basic behavior. It also reserves space for Builtins like fonts, alerts,
|
6
|
+
# etc. which don't have individual {Shoes::Drawable} objects.
|
7
|
+
class DocumentRoot < Flow
|
7
8
|
def initialize(properties)
|
8
|
-
@callbacks = {}
|
9
|
-
|
10
9
|
super
|
11
|
-
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
@fonts = []
|
12
|
+
@alerts = []
|
13
|
+
|
14
|
+
bind_shoes_event(event_name: "builtin") do |cmd_name, args|
|
15
|
+
case cmd_name
|
16
|
+
when "font"
|
17
|
+
@fonts << args[0]
|
18
|
+
# Can't just create font_updater and alert_updater on initialize - not everything is set up
|
19
|
+
@font_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new("root-fonts")
|
20
|
+
@font_updater.inner_html = font_contents
|
21
|
+
when "alert"
|
22
|
+
bind_ok_event
|
23
|
+
@alerts << args[0]
|
24
|
+
@alert_updater ||= Scarpe::Webview::WebWrangler::ElementWrangler.new("root-alerts")
|
25
|
+
@alert_updater.inner_html = alert_contents
|
26
|
+
else
|
27
|
+
raise Scarpe::UnknownBuiltinCommandError, "Unexpected builtin command: #{cmd_name.inspect}!"
|
28
|
+
end
|
16
29
|
end
|
17
30
|
end
|
18
31
|
|
19
|
-
|
20
|
-
|
21
|
-
|
32
|
+
def element(&block)
|
33
|
+
contents = block ? block.call : ""
|
34
|
+
super do
|
35
|
+
contents + HTML.render do |h|
|
36
|
+
h.div(id: "root-fonts") do
|
37
|
+
font_contents
|
38
|
+
end
|
39
|
+
h.div(id: "root-alerts") do
|
40
|
+
alert_contents
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
22
44
|
end
|
23
45
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
46
|
+
private
|
47
|
+
|
48
|
+
# This needs to occur after initialize() because the app isn't yet allocated initially,
|
49
|
+
# so we can't call bind() for app events yet.
|
50
|
+
def bind_ok_event
|
51
|
+
return if @ok_event_setup_done
|
29
52
|
|
30
|
-
|
31
|
-
# when requested. It also tracks when a redraw has been requested. Note that often frames will be
|
32
|
-
# very rare if nothing is changing, with seconds or minutes passing in between them.
|
53
|
+
@ok_event_setup_done = true
|
33
54
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
55
|
+
# Done with the alert(s), delete them
|
56
|
+
bind("OK") do
|
57
|
+
@alerts = []
|
58
|
+
needs_update!
|
38
59
|
end
|
39
60
|
end
|
40
61
|
|
41
|
-
|
42
|
-
|
43
|
-
|
62
|
+
def font_contents
|
63
|
+
HTML.render do |h|
|
64
|
+
@fonts.each do |font|
|
65
|
+
h.link(href: font, rel: "stylesheet")
|
66
|
+
h.style do
|
67
|
+
font_name = File.basename(font, ".*")
|
68
|
+
<<~CSS
|
69
|
+
@font-face {
|
70
|
+
font-family: #{font_name};
|
71
|
+
src: url("data:font/truetype;base64,#{encode_file_to_base64(font)}") format('truetype');
|
72
|
+
}
|
73
|
+
CSS
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
44
78
|
|
45
|
-
|
46
|
-
|
47
|
-
|
79
|
+
def alert_contents
|
80
|
+
@alerts.map do |alert_text|
|
81
|
+
render("alert", { "text" => alert_text, "event_name" => "OK" })
|
82
|
+
end.join + " "
|
48
83
|
end
|
49
84
|
end
|
50
85
|
end
|