scarpe 0.2.2 → 0.4.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 +7 -1
- data/.yardopts +1 -0
- data/CHANGELOG.md +52 -6
- data/Gemfile +2 -1
- data/Gemfile.lock +20 -6
- data/LICENSE.txt +7 -1
- data/README.md +100 -21
- data/Rakefile +68 -1
- data/examples/Edit_box_Styles.rb +8 -0
- data/examples/Kerning.rb +7 -0
- data/examples/animate.rb +20 -0
- data/examples/arrow.rb +10 -0
- data/examples/border.rb +11 -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/check.rb +2 -0
- data/examples/download_and_show_image.rb +3 -0
- data/examples/flags/finland.rb +15 -0
- data/examples/flags/italy.rb +11 -0
- data/examples/flags/mauritius.rb +14 -0
- data/examples/font_family.rb +17 -0
- data/examples/font_shorthand.rb +9 -0
- data/examples/gen.rb +12 -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/shoes-manual/append.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/background_change.rb +12 -0
- data/examples/legacy/not_checked/shoes-manual/background_pattern.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/basic_app.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/border.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/FONTS.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_color.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_open_file.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/ask_save_folder.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/confirm.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/debug.rb +2 -0
- data/examples/legacy/not_checked/shoes-manual/builtins/info.rb +3 -0
- data/examples/legacy/not_checked/shoes-manual/button.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/clear.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/custom_header.rb +13 -0
- data/examples/legacy/not_checked/shoes-manual/displace.rb +14 -0
- data/examples/legacy/not_checked/shoes-manual/edit_box.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/fill_pattern.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/fonts.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/gutter.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/image_web.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/keypress.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/list_box.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/motion.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/mouse.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/move.rb +14 -0
- data/examples/legacy/not_checked/shoes-manual/nested_ovals.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/oval.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/ovals.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/ovals_image.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/prepend.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/progress_bar.rb +10 -0
- data/examples/legacy/not_checked/shoes-manual/radio.rb +18 -0
- data/examples/legacy/not_checked/shoes-manual/radio_alternative_1.rb +7 -0
- data/examples/legacy/not_checked/shoes-manual/radio_alternative_2.rb +9 -0
- data/examples/legacy/not_checked/shoes-manual/rotate_rectangle.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/shape.rb +11 -0
- data/examples/legacy/not_checked/shoes-manual/static/avatar.png +0 -0
- data/examples/legacy/not_checked/shoes-manual/stroke.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/style.rb +3 -0
- data/examples/legacy/not_checked/shoes-manual/style_alternative_1.rb +4 -0
- data/examples/legacy/not_checked/shoes-manual/style_alternative_2.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/style_length.rb +5 -0
- data/examples/legacy/not_checked/shoes-manual/timer.rb +6 -0
- data/examples/legacy/not_checked/shoes-manual/trigger_window.rb +8 -0
- data/examples/legacy/not_checked/shoes-manual/window_owner.rb +8 -0
- 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/shoes_manual/alert_button.rb +2 -0
- data/examples/legacy/working/shoes_manual/animate.rb +7 -0
- data/examples/legacy/working/shoes_manual/background_para.rb +4 -0
- data/examples/legacy/working/shoes_manual/button_alternative.rb +7 -0
- data/examples/legacy/working/shoes_manual/checkbox.rb +17 -0
- data/examples/legacy/working/shoes_manual/download.rb +12 -0
- data/examples/legacy/working/shoes_manual/edit_box.rb +6 -0
- data/examples/legacy/working/shoes_manual/editline.rb +7 -0
- data/examples/legacy/working/shoes_manual/fixed_height.rb +8 -0
- data/examples/legacy/working/shoes_manual/fixed_width.rb +12 -0
- data/examples/legacy/working/shoes_manual/image.rb +5 -0
- data/examples/legacy/working/shoes_manual/instance_variable_check.rb +10 -0
- data/examples/legacy/working/shoes_manual/message.rb +18 -0
- data/examples/legacy/working/shoes_manual/rectangle.rb +6 -0
- data/examples/legacy/working/shoes_manual/save_download.rb +12 -0
- data/examples/legacy/working/shoes_manual/self_check.rb +10 -0
- data/examples/legacy/working/shoes_manual/stack.rb +7 -0
- data/examples/legacy/working/shoes_manual/style_info.rb +8 -0
- data/examples/legacy/working/shoes_manual/utf8_support.rb +8 -0
- data/examples/legacy/working/shoes_manual/width.rb +4 -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/multi_image.rb +5 -0
- data/examples/local_assets/sample.gif +0 -0
- data/examples/local_assets/sample.mp4 +0 -0
- data/examples/local_assets/small.png +0 -0
- data/examples/local_fonts.rb +5 -2
- data/examples/local_images.rb +2 -3
- data/examples/margin.rb +13 -0
- data/examples/margin_check.rb +27 -0
- data/examples/oval-with-kwargs.rb +3 -0
- data/examples/oval.rb +26 -0
- data/examples/para/para_text.rb +14 -0
- data/examples/para_font_styles.rb +17 -0
- data/examples/para_font_variant.rb +6 -0
- data/examples/para_fontweight.rb +13 -0
- data/examples/parse_xl_funnies.rb +3 -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/scarpe_ext.rb +3 -0
- data/examples/shapes/star.rb +1 -3
- data/examples/simpler-menu.rb +21 -0
- data/examples/spacing.rb +1 -1
- data/examples/span.rb +4 -2
- data/exe/scarpe +2 -1
- data/lacci/Gemfile +2 -0
- data/lacci/Gemfile.lock +8 -1
- data/lacci/lacci.gemspec +2 -2
- data/lacci/lib/lacci/scarpe_cli.rb +2 -2
- 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 +66 -0
- data/lacci/lib/scarpe/niente/drawable.rb +59 -0
- data/lacci/lib/scarpe/niente/shoes_spec.rb +93 -0
- data/lacci/lib/scarpe/niente.rb +32 -0
- data/lacci/lib/shoes/app.rb +111 -72
- 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 +41 -2
- data/lacci/lib/shoes/display_service.rb +80 -18
- data/lacci/lib/shoes/download.rb +2 -2
- data/lacci/lib/shoes/drawable.rb +654 -0
- data/lacci/lib/shoes/drawables/arc.rb +27 -0
- data/lacci/lib/shoes/drawables/arrow.rb +21 -0
- data/lacci/lib/shoes/drawables/border.rb +28 -0
- data/lacci/lib/shoes/drawables/button.rb +57 -0
- data/lacci/lib/shoes/drawables/check.rb +33 -0
- data/lacci/lib/shoes/drawables/document_root.rb +20 -0
- data/lacci/lib/shoes/{widgets → drawables}/edit_box.rb +9 -8
- data/lacci/lib/shoes/{widgets → drawables}/edit_line.rb +8 -7
- data/lacci/lib/shoes/drawables/flow.rb +20 -0
- data/lacci/lib/shoes/drawables/font_helper.rb +62 -0
- data/lacci/lib/shoes/{widgets → drawables}/image.rb +7 -7
- data/lacci/lib/shoes/drawables/line.rb +17 -0
- data/lacci/lib/shoes/drawables/link.rb +31 -0
- data/lacci/lib/shoes/drawables/list_box.rb +59 -0
- data/lacci/lib/shoes/drawables/oval.rb +48 -0
- data/lacci/lib/shoes/drawables/para.rb +206 -0
- data/lacci/lib/shoes/drawables/progress.rb +15 -0
- data/lacci/lib/shoes/drawables/radio.rb +35 -0
- data/lacci/lib/shoes/drawables/rect.rb +18 -0
- data/lacci/lib/shoes/{widgets → drawables}/shape.rb +8 -8
- data/lacci/lib/shoes/drawables/slot.rb +178 -0
- data/lacci/lib/shoes/drawables/stack.rb +21 -0
- data/lacci/lib/shoes/drawables/star.rb +28 -0
- data/lacci/lib/shoes/drawables/subscription_item.rb +93 -0
- data/lacci/lib/shoes/drawables/text_drawable.rb +122 -0
- data/lacci/lib/shoes/drawables/video.rb +17 -0
- data/lacci/lib/shoes/drawables/widget.rb +74 -0
- data/lacci/lib/shoes/drawables.rb +32 -0
- data/lacci/lib/shoes/errors.rb +38 -0
- data/lacci/lib/shoes/log.rb +2 -2
- data/lacci/lib/shoes/margin_helper.rb +79 -0
- data/lacci/lib/shoes/ruby_extensions.rb +15 -0
- data/lacci/lib/shoes-spec.rb +93 -0
- data/lacci/lib/shoes.rb +31 -10
- data/lacci/test/.gitignore +1 -0
- data/lacci/test/test_draw_context.rb +167 -0
- data/lacci/test/test_font_helper.rb +57 -0
- data/lacci/test/test_helper.rb +81 -0
- data/lacci/test/test_lacci.rb +99 -3
- data/lacci/test/test_margin_helper.rb +82 -0
- data/lacci/test/test_niente_test_infra.rb +26 -0
- data/lacci/test/test_oval.rb +82 -0
- data/lacci/test/test_parenting.rb +140 -0
- data/lacci/test/test_shoes_errors.rb +49 -0
- data/lacci/test/test_text_drawables.rb +23 -0
- data/lib/scarpe/assets.rb +18 -0
- data/lib/scarpe/cats_cradle.rb +84 -103
- data/lib/scarpe/errors.rb +77 -0
- data/lib/scarpe/shoes_spec.rb +160 -0
- data/lib/scarpe/version.rb +2 -2
- data/lib/scarpe/wv/app.rb +21 -20
- data/lib/scarpe/wv/arc.rb +4 -51
- data/lib/scarpe/wv/arrow.rb +9 -0
- data/lib/scarpe/wv/border.rb +9 -18
- data/lib/scarpe/wv/button.rb +7 -35
- data/lib/scarpe/wv/check.rb +3 -5
- data/lib/scarpe/wv/control_interface.rb +20 -30
- data/lib/scarpe/wv/document_root.rb +81 -4
- data/lib/scarpe/wv/{widget.rb → drawable.rb} +71 -82
- data/lib/scarpe/wv/edit_box.rb +8 -18
- data/lib/scarpe/wv/edit_line.rb +9 -20
- data/lib/scarpe/wv/flow.rb +2 -18
- data/lib/scarpe/wv/image.rb +7 -30
- data/lib/scarpe/wv/line.rb +3 -25
- data/lib/scarpe/wv/link.rb +6 -17
- data/lib/scarpe/wv/list_box.rb +6 -29
- data/lib/scarpe/wv/oval.rb +13 -0
- data/lib/scarpe/wv/para.rb +12 -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/scarpe_extensions.rb +8 -0
- data/lib/scarpe/wv/shape.rb +13 -13
- data/lib/scarpe/wv/slot.rb +8 -25
- 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 +90 -0
- data/lib/scarpe/wv/video.rb +15 -15
- data/lib/scarpe/wv/web_wrangler.rb +320 -328
- data/lib/scarpe/wv/webview_local_display.rb +52 -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 +52 -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 +4 -1
- data/scarpe-components/Gemfile.lock +85 -0
- data/scarpe-components/README.md +2 -2
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cerulean.css +12229 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cosmo.css +11810 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-cyborg.css +12210 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-darkly.css +12153 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-flatly.css +12126 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-icons.min.css +5 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-journal.css +12099 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-litera.css +12211 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-lumen.css +12369 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-lux.css +11928 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-materia.css +13184 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-minty.css +12177 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-morph.css +12750 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-pulse.css +11890 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-quartz.css +12622 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-sandstone.css +12201 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-simplex.css +12186 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-sketchy.css +12451 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-slate.css +12492 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-solar.css +12149 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-spacelab.css +12266 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-superhero.css +12216 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-united.css +12077 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-vapor.css +12549 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-yeti.css +12325 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap-zephyr.css +12283 -0
- data/scarpe-components/assets/bootstrap-themes/bootstrap.bundle.min.js +7 -0
- data/scarpe-components/lib/scarpe/components/asset_server.rb +219 -0
- data/scarpe-components/lib/scarpe/components/base64.rb +23 -5
- data/scarpe-components/lib/scarpe/components/calzini/alert.rb +49 -0
- data/scarpe-components/lib/scarpe/components/calzini/art_drawables.rb +227 -0
- data/scarpe-components/lib/scarpe/components/calzini/border.rb +38 -0
- data/scarpe-components/lib/scarpe/components/calzini/button.rb +37 -0
- data/scarpe-components/lib/scarpe/components/calzini/misc.rb +136 -0
- data/scarpe-components/lib/scarpe/components/calzini/para.rb +237 -0
- data/scarpe-components/lib/scarpe/components/calzini/slots.rb +109 -0
- data/scarpe-components/lib/scarpe/components/calzini.rb +236 -0
- data/scarpe-components/lib/scarpe/components/errors.rb +24 -0
- data/scarpe-components/lib/scarpe/components/file_helpers.rb +1 -0
- data/scarpe-components/lib/scarpe/components/html.rb +134 -0
- data/scarpe-components/lib/scarpe/components/minitest_export_reporter.rb +83 -0
- data/scarpe-components/lib/scarpe/components/minitest_import_runnable.rb +98 -0
- data/scarpe-components/lib/scarpe/components/minitest_result.rb +127 -0
- data/scarpe-components/lib/scarpe/components/modular_logger.rb +5 -5
- data/scarpe-components/lib/scarpe/components/print_logger.rb +22 -3
- data/scarpe-components/lib/scarpe/components/process_helpers.rb +37 -0
- 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 +167 -0
- data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +48 -6
- data/scarpe-components/lib/scarpe/components/version.rb +2 -2
- data/scarpe-components/test/assets/big-image.png +0 -0
- data/scarpe-components/test/assets/big-stylesheet.css +497 -0
- data/scarpe-components/test/assets/little-image.png +0 -0
- data/scarpe-components/test/assets/little-stylesheet.css +1 -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 +54 -0
- data/scarpe-components/test/calzini/test_calzini_misc.rb +115 -0
- data/scarpe-components/test/calzini/test_calzini_para.rb +34 -0
- data/scarpe-components/test/calzini/test_calzini_slots.rb +85 -0
- data/scarpe-components/test/calzini/test_calzini_text_drawables.rb +106 -0
- data/scarpe-components/test/calzini/test_various.rb +133 -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_asset_server.rb +72 -0
- data/scarpe-components/test/test_components.rb +31 -2
- data/scarpe-components/test/test_dimensions.rb +26 -0
- data/scarpe-components/test/test_helper.rb +20 -1
- data/scarpe-components/test/test_html.rb +65 -0
- data/scarpe-components/test/test_minitest_result.rb +68 -0
- data/scarpe-components/test/test_promises.rb +5 -4
- data/scarpe-components/test/test_segmented_app_files.rb +10 -6
- data/scarpegen.rb +14 -14
- data/sig/scarpe.rbs +1 -1
- data/tasks/check_html_fixtures.rb +140 -0
- data/tasks/regenerate_html_fixtures.rb +104 -0
- 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 -28
- data/templates/example_template.erb +1 -1
- data/templates/module_template.erb +4 -4
- data/templates/webview_template.erb +3 -2
- metadata +286 -80
- data/examples/legacy/not_checked/shoes-contrib/elements/image-icon.rb +0 -3
- data/lacci/lib/shoes/spacing.rb +0 -9
- 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/check.rb +0 -28
- data/lacci/lib/shoes/widgets/document_root.rb +0 -20
- data/lacci/lib/shoes/widgets/flow.rb +0 -22
- data/lacci/lib/shoes/widgets/font.rb +0 -14
- data/lacci/lib/shoes/widgets/line.rb +0 -18
- 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/slot.rb +0 -75
- data/lacci/lib/shoes/widgets/span.rb +0 -26
- data/lacci/lib/shoes/widgets/stack.rb +0 -24
- 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/evented_assertions.rb +0 -88
- data/lib/scarpe/wv/alert.rb +0 -66
- data/lib/scarpe/wv/background.rb +0 -27
- 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/span.rb +0 -68
- 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 → working}/shoes3-tests/editline/editline.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
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class Border < Shoes::Drawable
|
5
|
+
# Shoes style with verification or value mapping:
|
6
|
+
# shoes_style(:left) { |val| convert_to_integer(val, "left") }
|
7
|
+
|
8
|
+
shoes_styles :stroke, :strokewidth # Write your shoes styles here
|
9
|
+
|
10
|
+
shoes_style(:strokewidth) { |val| convert_to_integer(val, "strokewidth") }
|
11
|
+
shoes_style(:curve) { |val| convert_to_integer(val, "curve") }
|
12
|
+
|
13
|
+
Shoes::Drawable.drawable_default_styles[Shoes::Border][:stroke] = :black
|
14
|
+
Shoes::Drawable.drawable_default_styles[Shoes::Border][:strokewidth] = 1
|
15
|
+
Shoes::Drawable.drawable_default_styles[Shoes::Border][:curve] = 0
|
16
|
+
|
17
|
+
opt_init_args :stroke, :strokewidth, :curve
|
18
|
+
def initialize(*args, **kwargs)
|
19
|
+
super
|
20
|
+
@draw_context = Shoes::App.instance.current_draw_context
|
21
|
+
|
22
|
+
create_display_drawable
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class Button < Shoes::Drawable
|
5
|
+
shoes_styles :text, :width, :height, :top, :left, :color, :padding_top, :padding_bottom, :text_color, :size, :font_size, :tooltip
|
6
|
+
shoes_events :click
|
7
|
+
|
8
|
+
init_args :text
|
9
|
+
# Creates a new Button object.
|
10
|
+
#
|
11
|
+
# @param text [String] The text displayed on the button.
|
12
|
+
# @param width [Integer] The requested width of the button in pixels.
|
13
|
+
# @param height [Integer] The requested height of the button in pixels.
|
14
|
+
# @param top [Integer] The position of the top edge of the button relative to its parent widget.
|
15
|
+
# @param left [Integer] The position of the left edge of the button relative to its parent widget.
|
16
|
+
# @param size [Integer] The font size of the button text.
|
17
|
+
# @param color [String] The background color of the button.
|
18
|
+
# @param padding_top [Integer] The padding above the button text.
|
19
|
+
# @param padding_bottom [Integer] The padding below the button text.
|
20
|
+
# @param text_color [String] The color of the button text.
|
21
|
+
# @yield A block of code to be executed when the button is clicked.
|
22
|
+
# @return [Shoes::Button] the button object
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Shoes.app do
|
26
|
+
# @push = button "Push me"
|
27
|
+
# @note = para "Nothing pushed so far"
|
28
|
+
# @push.click {
|
29
|
+
# @note.replace(
|
30
|
+
# "Aha! Click! ",
|
31
|
+
# link("Go back") { @note.replace("Nothing pushed so far") }
|
32
|
+
# )
|
33
|
+
# }
|
34
|
+
# end
|
35
|
+
def initialize(*args, **kwargs, &block)
|
36
|
+
# Properties passed as positional args, not keywords, don't get auto-set
|
37
|
+
@block = block
|
38
|
+
|
39
|
+
super
|
40
|
+
|
41
|
+
# Bind block to a handler named "click"
|
42
|
+
bind_self_event("click") do
|
43
|
+
@log.debug("Button clicked, calling handler") if @block
|
44
|
+
@block&.call
|
45
|
+
end
|
46
|
+
|
47
|
+
create_display_drawable
|
48
|
+
end
|
49
|
+
|
50
|
+
# Set the click handler
|
51
|
+
#
|
52
|
+
# @yield A block to be called when the button is clicked.
|
53
|
+
def click(&block)
|
54
|
+
@block = block
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class Check < Shoes::Drawable
|
5
|
+
shoes_styles :checked
|
6
|
+
shoes_events :click
|
7
|
+
|
8
|
+
init_args
|
9
|
+
opt_init_args :checked
|
10
|
+
def initialize(*args, **kwargs, &block)
|
11
|
+
@block = block
|
12
|
+
super
|
13
|
+
|
14
|
+
bind_self_event("click") do
|
15
|
+
self.checked = !checked?
|
16
|
+
@block.call(self) if @block
|
17
|
+
end
|
18
|
+
create_display_drawable
|
19
|
+
end
|
20
|
+
|
21
|
+
def click(&block)
|
22
|
+
@block = block
|
23
|
+
end
|
24
|
+
|
25
|
+
def checked?
|
26
|
+
@checked ? true : false
|
27
|
+
end
|
28
|
+
|
29
|
+
def checked(value)
|
30
|
+
self.checked = value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class DocumentRoot < Shoes::Flow
|
5
|
+
shoes_events # No DocumentRoot-specific events yet
|
6
|
+
|
7
|
+
Shoes::Drawable.drawable_default_styles[Shoes::DocumentRoot][:height] = "100%"
|
8
|
+
Shoes::Drawable.drawable_default_styles[Shoes::DocumentRoot][:width] = "100%"
|
9
|
+
|
10
|
+
init_args
|
11
|
+
def initialize(**kwargs, &block)
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
# The default inspect string can be absolutely huge in console output, and it's frequently printed.
|
16
|
+
def inspect
|
17
|
+
"<Shoes::DocumentRoot>"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class EditBox < Shoes::
|
5
|
-
|
3
|
+
class Shoes
|
4
|
+
class EditBox < Shoes::Drawable
|
5
|
+
shoes_styles :text, :height, :width ,:tooltip, :font
|
6
|
+
shoes_events :change
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
init_args
|
9
|
+
opt_init_args :text
|
10
|
+
def initialize(*args, **kwargs, &block)
|
9
11
|
@callback = block
|
10
|
-
|
11
12
|
super
|
12
13
|
|
13
14
|
bind_self_event("change") do |new_text|
|
@@ -15,7 +16,7 @@ module Shoes
|
|
15
16
|
@callback&.call(self)
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
+
create_display_drawable
|
19
20
|
end
|
20
21
|
|
21
22
|
def change(&block)
|
@@ -23,7 +24,7 @@ module Shoes
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def append(new_text)
|
26
|
-
self.text = self.text + new_text
|
27
|
+
self.text = (self.text || "") + new_text
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class EditLine < Shoes::
|
5
|
-
|
3
|
+
class Shoes
|
4
|
+
class EditLine < Shoes::Drawable
|
5
|
+
shoes_styles :text, :width, :font, :tooltip, :stroke
|
6
|
+
shoes_events :change
|
6
7
|
|
7
|
-
|
8
|
+
init_args
|
9
|
+
opt_init_args :text
|
10
|
+
def initialize(*args, **kwargs, &block)
|
8
11
|
@block = block
|
9
|
-
@text = text
|
10
|
-
|
11
12
|
super
|
12
13
|
|
13
14
|
bind_self_event("change") do |new_text|
|
@@ -15,7 +16,7 @@ module Shoes
|
|
15
16
|
@block&.call(new_text)
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
+
create_display_drawable
|
19
20
|
end
|
20
21
|
|
21
22
|
def change(&block)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class Flow < Shoes::Slot
|
5
|
+
include Shoes::Background
|
6
|
+
|
7
|
+
Shoes::Drawable.drawable_default_styles[Shoes::Flow][:width] = "100%"
|
8
|
+
|
9
|
+
shoes_events
|
10
|
+
|
11
|
+
def initialize(*args, **kwargs, &block)
|
12
|
+
super
|
13
|
+
|
14
|
+
# Create the display-side drawable *before* instance_eval, which will add child drawables with their display drawables
|
15
|
+
create_display_drawable
|
16
|
+
|
17
|
+
Shoes::App.instance.with_slot(self, &block) if block_given?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module FontHelper
|
2
|
+
|
3
|
+
def parse_font(font)
|
4
|
+
|
5
|
+
input = font
|
6
|
+
regex = /\s+(?=(?:[^']*'[^']*')*[^']*$)(?![^']*,[^']*')/
|
7
|
+
result = input.split(regex)
|
8
|
+
|
9
|
+
fs = nil
|
10
|
+
fv = nil
|
11
|
+
fw = nil
|
12
|
+
fss = nil
|
13
|
+
ff = ""
|
14
|
+
|
15
|
+
fos = ["italic", "oblique"]
|
16
|
+
fov = ["small-caps", "initial", "inherit"]
|
17
|
+
fow = ["bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
|
18
|
+
foss = ["xx-small", "x-small", "small","large", "x-large", "xx-large", "smaller", "larger"]
|
19
|
+
|
20
|
+
result.each do |i|
|
21
|
+
if fos.include?(i)
|
22
|
+
fs = i
|
23
|
+
next
|
24
|
+
elsif fov.include?(i)
|
25
|
+
fv = i
|
26
|
+
next
|
27
|
+
elsif fow.include?(i)
|
28
|
+
fw = i
|
29
|
+
next
|
30
|
+
elsif foss.include?(i)
|
31
|
+
fss = i
|
32
|
+
next
|
33
|
+
else
|
34
|
+
if contains_number?(i)
|
35
|
+
|
36
|
+
fss=i;
|
37
|
+
|
38
|
+
elsif i != "normal" && i != "medium" && i.strip != ""
|
39
|
+
|
40
|
+
if ff == "Arial"
|
41
|
+
|
42
|
+
ff = i
|
43
|
+
|
44
|
+
else
|
45
|
+
|
46
|
+
ff = ff+" "+i
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
[fs, fv , fw , fss , ff.strip]
|
55
|
+
end
|
56
|
+
|
57
|
+
def contains_number?(str)
|
58
|
+
|
59
|
+
!!(str =~ /\d/)
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
class Image < Shoes::
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(url, width: nil, height: nil, top: nil, left: nil, click: nil)
|
8
|
-
@url = url
|
3
|
+
class Shoes
|
4
|
+
class Image < Shoes::Drawable
|
5
|
+
shoes_styles :url, :width, :height, :top, :left, :click
|
6
|
+
shoes_events # No Image-specific events yet
|
9
7
|
|
8
|
+
init_args :url
|
9
|
+
def initialize(*args, **kwargs)
|
10
10
|
super
|
11
11
|
|
12
12
|
# Get the image dimensions
|
13
13
|
# @width, @height = size
|
14
14
|
|
15
|
-
|
15
|
+
create_display_drawable
|
16
16
|
end
|
17
17
|
|
18
18
|
def replace(url)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class Line < Shoes::Drawable
|
5
|
+
shoes_styles :left, :top, :x2, :y2, :draw_context
|
6
|
+
shoes_events # No Line-specific events yet
|
7
|
+
|
8
|
+
init_args :left, :top, :x2, :y2
|
9
|
+
def initialize(*args, **kwargs)
|
10
|
+
@draw_context = Shoes::App.instance.current_draw_context
|
11
|
+
|
12
|
+
super
|
13
|
+
|
14
|
+
create_display_drawable
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class Link < Shoes::TextDrawable
|
5
|
+
shoes_styles :text, :click, :has_block
|
6
|
+
shoes_events :click
|
7
|
+
|
8
|
+
#Shoes::Drawable.drawable_default_styles[Shoes::Link][:click] = "#"
|
9
|
+
|
10
|
+
init_args # Empty by the time it reaches Drawable#initialize
|
11
|
+
def initialize(*args, **kwargs, &block)
|
12
|
+
@block = block
|
13
|
+
# We can't send a block to the display drawable, but we can send a boolean
|
14
|
+
@has_block = !block.nil?
|
15
|
+
|
16
|
+
super
|
17
|
+
|
18
|
+
bind_self_event("click") do
|
19
|
+
@block&.call
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# In Shoes, the LinkHover pseudo-class is used to set default styles for links when
|
25
|
+
# hovered over. The functionality isn't present in Lacci yet.
|
26
|
+
class LinkHover < Link
|
27
|
+
def initialize
|
28
|
+
raise "This class should never be instantiated directly! Use link, not link_hover!"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
class ListBox < Shoes::Drawable
|
5
|
+
shoes_styles :items, :height, :width
|
6
|
+
|
7
|
+
# Shoes3 uses choose as the initialize arg, and .choose(item) as the setter here,
|
8
|
+
# but queries it with .text. So this is an unusual style, and we've chosen this
|
9
|
+
# name not to conflict with Shoes3.
|
10
|
+
shoes_style :chosen
|
11
|
+
|
12
|
+
shoes_events :change
|
13
|
+
|
14
|
+
init_args # No positional args
|
15
|
+
def initialize(**kwargs, &block)
|
16
|
+
# These aren't being set as styles -- remove them from kwargs before calling super
|
17
|
+
# TODO: set [] as default value for items?
|
18
|
+
@items = kwargs.delete(:items) || []
|
19
|
+
@chosen = kwargs.delete(:choose) || @items&.first
|
20
|
+
|
21
|
+
super(**kwargs, &block)
|
22
|
+
|
23
|
+
bind_self_event("change") do |new_item|
|
24
|
+
self.chosen = new_item
|
25
|
+
@callback&.call(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
create_display_drawable
|
29
|
+
end
|
30
|
+
|
31
|
+
# Select an item. `item` should be a text entry from `items`.
|
32
|
+
#
|
33
|
+
# @param item [String] the item to choose
|
34
|
+
# @return [void]
|
35
|
+
def choose(item)
|
36
|
+
unless self.items.include?(item)
|
37
|
+
raise Shoes::Errors::NoSuchListItemError, "List items (#{self.items.inspect}) do not contain item #{item.inspect}!"
|
38
|
+
end
|
39
|
+
|
40
|
+
@chosen = item
|
41
|
+
end
|
42
|
+
|
43
|
+
# The currently chosen text item or nil.
|
44
|
+
#
|
45
|
+
# @return [String|NilClass] the current text item or nil.
|
46
|
+
def text
|
47
|
+
@chosen
|
48
|
+
end
|
49
|
+
|
50
|
+
# Register a block to be called when the selection changes.
|
51
|
+
#
|
52
|
+
# @yield the block to be called when selection changes
|
53
|
+
# @return [Shoes::ListBox] self
|
54
|
+
def change(&block)
|
55
|
+
@callback = block
|
56
|
+
self # Allow chaining calls
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Shoes
|
4
|
+
# Docs: https://github.com/scarpe-team/scarpe/blob/main/docs/static/manual.md#ovalleft-top-radius--shoesshape
|
5
|
+
class Oval < Shoes::Drawable
|
6
|
+
shoes_styles :center, :draw_context, :stroke, :fill
|
7
|
+
|
8
|
+
shoes_style(:left) { |val| convert_to_integer(val, "left") }
|
9
|
+
shoes_style(:top) { |val| convert_to_integer(val, "top") }
|
10
|
+
shoes_style(:radius) { |val| convert_to_integer(val, "radius") }
|
11
|
+
shoes_style(:height) { |val| convert_to_integer(val, "height") }
|
12
|
+
shoes_style(:width) { |val| convert_to_integer(val, "width") }
|
13
|
+
shoes_style(:strokewidth) { |val| convert_to_integer(val, "strokewidth") }
|
14
|
+
|
15
|
+
Shoes::Drawable.drawable_default_styles[Shoes::Oval][:fill] = "black"
|
16
|
+
Shoes::Drawable.drawable_default_styles[Shoes::Oval][:stroke] = "black"
|
17
|
+
|
18
|
+
init_args :left, :top
|
19
|
+
opt_init_args :radius, :height
|
20
|
+
def initialize(*args, **options)
|
21
|
+
@draw_context = Shoes::App.instance.current_draw_context
|
22
|
+
|
23
|
+
super # Parse any positional or keyword args
|
24
|
+
|
25
|
+
unless @left && @top && (@width || @height || @radius)
|
26
|
+
raise Shoes::Errors::InvalidAttributeValueError, "Oval requires left, top and one of (width, height, radius) to be specified!"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Calzini expects "radius" to mean the x-axis-aligned radius, not y-axis-aligned.
|
30
|
+
# For an axis-aligned oval the two may be different.
|
31
|
+
|
32
|
+
# If we have no width, but a radius, default the width to be the radius * 2
|
33
|
+
@width ||= @radius * 2 if @radius
|
34
|
+
|
35
|
+
# We now know we have width or height, but maybe not both.
|
36
|
+
|
37
|
+
# Default to a circle - set height from width or vice-versa
|
38
|
+
@width ||= @height
|
39
|
+
@height ||= @width
|
40
|
+
|
41
|
+
# If we don't have radius yet, set it from width
|
42
|
+
@radius ||= @width / 2
|
43
|
+
|
44
|
+
create_display_drawable
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'font_helper.rb'
|
3
|
+
class Shoes
|
4
|
+
class Para < Shoes::Drawable
|
5
|
+
include FontHelper
|
6
|
+
shoes_styles :text_items, :size, :family, :font_weight, :font, :font_variant, :emphasis, :kerning
|
7
|
+
shoes_style(:stroke) { |val, _name| Shoes::Colors.to_rgb(val) }
|
8
|
+
shoes_style(:fill) { |val, _name| Shoes::Colors.to_rgb(val) }
|
9
|
+
|
10
|
+
shoes_style(:align) do |val|
|
11
|
+
unless ["left", "center", "right"].include?(val)
|
12
|
+
raise(Shoes::Errors::InvalidAttributeValueError, "Align must be one of left, center or right!")
|
13
|
+
end
|
14
|
+
val
|
15
|
+
end
|
16
|
+
|
17
|
+
Shoes::Drawable.drawable_default_styles[Shoes::Para][:size] = :para
|
18
|
+
|
19
|
+
shoes_events # No Para-specific events yet
|
20
|
+
|
21
|
+
# Initializes a new instance of the `Para` drawable. There are different
|
22
|
+
# methods to instantiate slightly different styles of Para, such as
|
23
|
+
# `tagline`, `caption` and `subtitle`. These will always be different
|
24
|
+
# sizes, but may be generally styled differently for some display services.
|
25
|
+
#
|
26
|
+
# @param args The text content of the paragraph.
|
27
|
+
# @param kwargs [Hash] the various Shoes styles for this paragraph.
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# Shoes.app do
|
31
|
+
# p = para "Hello, This is at the top!", stroke: red, size: :title, font: "Arial"
|
32
|
+
#
|
33
|
+
# banner("Welcome to Shoes!")
|
34
|
+
# title("Shoes Examples")
|
35
|
+
# subtitle("Explore the Features")
|
36
|
+
# tagline("Step into a World of Shoes")
|
37
|
+
# caption("A GUI Framework for Ruby")
|
38
|
+
# inscription("Designed for Easy Development")
|
39
|
+
#
|
40
|
+
# p.replace "On top we'll switch to ", strong("bold"), "!"
|
41
|
+
# end
|
42
|
+
|
43
|
+
def initialize(*args, **kwargs)
|
44
|
+
|
45
|
+
if kwargs[:font]
|
46
|
+
arr= parse_font(kwargs[:font])
|
47
|
+
|
48
|
+
if arr[0] != nil
|
49
|
+
|
50
|
+
kwargs[:emphasis] = arr[0]
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
if arr[1] != nil
|
55
|
+
|
56
|
+
kwargs[:font_variant] = arr[1]
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
if arr[2] != nil
|
61
|
+
|
62
|
+
kwargs[:font_weight] = arr[2]
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
if arr[3] != nil
|
67
|
+
|
68
|
+
kwargs[:size] = arr[3]
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
if arr[4] != ""
|
73
|
+
|
74
|
+
kwargs[:family] = arr[4]
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
# Don't pass text_children args to Drawable#initialize
|
81
|
+
super(*[], **kwargs)
|
82
|
+
|
83
|
+
# Text_children alternates strings and TextDrawables, so we can't just pass
|
84
|
+
# it as a Shoes style. It won't serialize.
|
85
|
+
update_text_children(args)
|
86
|
+
|
87
|
+
create_display_drawable
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def text_children_to_items(text_children)
|
95
|
+
text_children.map { |arg| arg.is_a?(TextDrawable) ? arg.linkable_id : arg.to_s }
|
96
|
+
end
|
97
|
+
|
98
|
+
public
|
99
|
+
|
100
|
+
# Sets the paragraph text to a new value, which can
|
101
|
+
# include {TextDrawable}s like em(), strong(), etc.
|
102
|
+
#
|
103
|
+
# @param children [Array] the arguments can be Strings and/or TextDrawables
|
104
|
+
# @return [void]
|
105
|
+
def replace(*children)
|
106
|
+
update_text_children(children)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Set the paragraph text to a single String.
|
110
|
+
# To use bold, italics, etc. use {Para#replace} instead.
|
111
|
+
#
|
112
|
+
# @param child [String] the new text to use for this Para
|
113
|
+
# @return [void]
|
114
|
+
def text=(*children)
|
115
|
+
update_text_children(children)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Return the text, but not the styling, of the para's
|
119
|
+
# contents. For example, if the contents had strong
|
120
|
+
# and emphasized text, the bold and emphasized would
|
121
|
+
# be removed but the text would be returned.
|
122
|
+
#
|
123
|
+
# @return [String] the text from this para
|
124
|
+
def text
|
125
|
+
@text_children.map(&:to_s).join
|
126
|
+
end
|
127
|
+
|
128
|
+
# Return the text but not styling from the para. This
|
129
|
+
# is the same as #text.
|
130
|
+
#
|
131
|
+
# @return [String] the text from this para
|
132
|
+
def to_s
|
133
|
+
self.text
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
# Text_children alternates strings and TextDrawables, so we can't just pass
|
139
|
+
# it as a Shoes style. It won't serialize.
|
140
|
+
def update_text_children(children)
|
141
|
+
@text_children = children.flatten
|
142
|
+
# This should signal the display drawable to change
|
143
|
+
self.text_items = text_children_to_items(@text_children)
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
class Shoes
|
151
|
+
class Drawable
|
152
|
+
# Return a banner-sized para. This can use all the normal
|
153
|
+
# Para styles and arguments. See {Para#initialize} for
|
154
|
+
# details.
|
155
|
+
#
|
156
|
+
# @return [Shoes::Para] the new para drawable
|
157
|
+
def banner(*args, **kwargs)
|
158
|
+
para(*args, **{ size: :banner }.merge(kwargs))
|
159
|
+
end
|
160
|
+
|
161
|
+
# Return a title-sized para. This can use all the normal
|
162
|
+
# Para styles and arguments. See {Para#initialize} for
|
163
|
+
# details.
|
164
|
+
#
|
165
|
+
# @return [Shoes::Para] the new para drawable
|
166
|
+
def title(*args, **kwargs)
|
167
|
+
para(*args, **{ size: :title }.merge(kwargs))
|
168
|
+
end
|
169
|
+
|
170
|
+
# Return a subtitle-sized para. This can use all the normal
|
171
|
+
# Para styles and arguments. See {Para#initialize} for
|
172
|
+
# details.
|
173
|
+
#
|
174
|
+
# @return [Shoes::Para] the new para drawable
|
175
|
+
def subtitle(*args, **kwargs)
|
176
|
+
para(*args, **{ size: :subtitle }.merge(kwargs))
|
177
|
+
end
|
178
|
+
|
179
|
+
# Return a tagline-sized para. This can use all the normal
|
180
|
+
# Para styles and arguments. See {Para#initialize} for
|
181
|
+
# details.
|
182
|
+
#
|
183
|
+
# @return [Shoes::Para] the new para drawable
|
184
|
+
def tagline(*args, **kwargs)
|
185
|
+
para(*args, **{ size: :tagline }.merge(kwargs))
|
186
|
+
end
|
187
|
+
|
188
|
+
# Return a caption-sized para. This can use all the normal
|
189
|
+
# Para styles and arguments. See {Para#initialize} for
|
190
|
+
# details.
|
191
|
+
#
|
192
|
+
# @return [Shoes::Para] the new para drawable
|
193
|
+
def caption(*args, **kwargs)
|
194
|
+
para(*args, **{ size: :caption }.merge(kwargs))
|
195
|
+
end
|
196
|
+
|
197
|
+
# Return an inscription-sized para. This can use all the normal
|
198
|
+
# Para styles and arguments. See {Para#initialize} for
|
199
|
+
# details.
|
200
|
+
#
|
201
|
+
# @return [Shoes::Para] the new para drawable
|
202
|
+
def inscription(*args, **kwargs)
|
203
|
+
para(*args, **{ size: :inscription }.merge(kwargs))
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|