From d01d74e3ea464bb338d694c087e6efe1353a01d7 Mon Sep 17 00:00:00 2001 From: Docs Builder Date: Wed, 30 Aug 2023 10:05:38 +0000 Subject: [PATCH] New docs build --- .nojekyll | 0 Kernel.html | 137 + Lacci.html | 138 + Scarpe.html | 271 ++ Scarpe/AppShutdownError.html | 142 + Scarpe/CLI.html | 522 ++++ Scarpe/ControlInterface.html | 2145 ++++++++++++++ Scarpe/Dimensions.html | 212 ++ Scarpe/Error.html | 138 + Scarpe/HTML.html | 794 +++++ Scarpe/Test.html | 119 + Scarpe/Test/CCInstance.html | 1236 ++++++++ Scarpe/Test/CCProxy.html | 521 ++++ Scarpe/Test/CatsCradle.html | 248 ++ Scarpe/Test/EventedAssertions.html | 696 +++++ Scarpe/TestPromise.html | 454 +++ Scarpe/WVRelayDisplayService.html | 618 ++++ Scarpe/WVRelayUtil.html | 734 +++++ Scarpe/WebWrangler.html | 2382 +++++++++++++++ Scarpe/WebWrangler/DOMWrangler.html | 1186 ++++++++ Scarpe/WebWrangler/ElementWrangler.html | 1069 +++++++ Scarpe/WebWrangler/InternalError.html | 161 + Scarpe/WebWrangler/JSEvalError.html | 228 ++ Scarpe/WebWrangler/JSRuntimeError.html | 161 + Scarpe/WebWrangler/JSTimeoutError.html | 161 + Scarpe/Webview.html | 125 + Scarpe/Webview/ContainedService.html | 441 +++ Scarpe/WebviewAlert.html | 599 ++++ Scarpe/WebviewApp.html | 994 +++++++ Scarpe/WebviewArc.html | 388 +++ Scarpe/WebviewBackground.html | 213 ++ Scarpe/WebviewBorder.html | 209 ++ Scarpe/WebviewButton.html | 474 +++ Scarpe/WebviewCheck.html | 464 +++ Scarpe/WebviewDisplayService.html | 898 ++++++ Scarpe/WebviewDocumentRoot.html | 257 ++ Scarpe/WebviewEditBox.html | 670 +++++ Scarpe/WebviewEditLine.html | 602 ++++ Scarpe/WebviewFlow.html | 373 +++ Scarpe/WebviewFont.html | 476 +++ Scarpe/WebviewImage.html | 408 +++ Scarpe/WebviewLine.html | 440 +++ Scarpe/WebviewLink.html | 390 +++ Scarpe/WebviewListBox.html | 756 +++++ Scarpe/WebviewPara.html | 630 ++++ Scarpe/WebviewRadio.html | 462 +++ Scarpe/WebviewShape.html | 474 +++ Scarpe/WebviewSlot.html | 739 +++++ Scarpe/WebviewSpacing.html | 343 +++ Scarpe/WebviewSpan.html | 502 ++++ Scarpe/WebviewStack.html | 358 +++ Scarpe/WebviewStar.html | 392 +++ Scarpe/WebviewSubscriptionItem.html | 486 ++++ Scarpe/WebviewTextWidget.html | 180 ++ Scarpe/WebviewVideo.html | 348 +++ Scarpe/WebviewWidget.html | 1922 ++++++++++++ Shoes.html | 851 ++++++ Shoes/Alert.html | 291 ++ Shoes/App.html | 1903 ++++++++++++ Shoes/Arc.html | 299 ++ Shoes/Background.html | 190 ++ Shoes/Border.html | 193 ++ Shoes/Button.html | 385 +++ Shoes/Check.html | 469 +++ Shoes/Colors.html | 391 +++ Shoes/Constants.html | 249 ++ Shoes/DisplayService.html | 877 ++++++ Shoes/DocumentRoot.html | 410 +++ Shoes/EditBox.html | 405 +++ Shoes/EditLine.html | 353 +++ Shoes/Error.html | 128 + Shoes/Flow.html | 344 +++ Shoes/Font.html | 281 ++ Shoes/Image.html | 405 +++ Shoes/InvalidAttributeValueError.html | 132 + Shoes/Line.html | 289 ++ Shoes/Link.html | 316 ++ Shoes/Linkable.html | 515 ++++ Shoes/ListBox.html | 353 +++ Shoes/Log.html | 497 ++++ Shoes/LoggedWrapper.html | 377 +++ Shoes/Para.html | 423 +++ Shoes/Radio.html | 471 +++ Shoes/Shape.html | 414 +++ Shoes/Slot.html | 843 ++++++ Shoes/Spacing.html | 110 + Shoes/Span.html | 355 +++ Shoes/Stack.html | 342 +++ Shoes/Star.html | 289 ++ Shoes/SubscriptionItem.html | 427 +++ Shoes/TextWidget.html | 287 ++ Shoes/Video.html | 279 ++ Shoes/Widget.html | 1951 +++++++++++++ Shoes/Widget/ResponseWrapper.html | 391 +++ _index.html | 885 ++++++ class_list.html | 55 + css/common.css | 1 + css/full_list.css | 58 + css/style.css | 497 ++++ file.README.html | 254 ++ file.catscradle.html | 109 + file.manual.html | 3547 +++++++++++++++++++++++ file_list.html | 70 + frames.html | 17 + index.html | 254 ++ js/app.js | 314 ++ js/full_list.js | 216 ++ js/jquery.js | 4 + method_list.html | 3271 +++++++++++++++++++++ top-level-namespace.html | 143 + 110 files changed, 57666 insertions(+) create mode 100644 .nojekyll create mode 100644 Kernel.html create mode 100644 Lacci.html create mode 100644 Scarpe.html create mode 100644 Scarpe/AppShutdownError.html create mode 100644 Scarpe/CLI.html create mode 100644 Scarpe/ControlInterface.html create mode 100644 Scarpe/Dimensions.html create mode 100644 Scarpe/Error.html create mode 100644 Scarpe/HTML.html create mode 100644 Scarpe/Test.html create mode 100644 Scarpe/Test/CCInstance.html create mode 100644 Scarpe/Test/CCProxy.html create mode 100644 Scarpe/Test/CatsCradle.html create mode 100644 Scarpe/Test/EventedAssertions.html create mode 100644 Scarpe/TestPromise.html create mode 100644 Scarpe/WVRelayDisplayService.html create mode 100644 Scarpe/WVRelayUtil.html create mode 100644 Scarpe/WebWrangler.html create mode 100644 Scarpe/WebWrangler/DOMWrangler.html create mode 100644 Scarpe/WebWrangler/ElementWrangler.html create mode 100644 Scarpe/WebWrangler/InternalError.html create mode 100644 Scarpe/WebWrangler/JSEvalError.html create mode 100644 Scarpe/WebWrangler/JSRuntimeError.html create mode 100644 Scarpe/WebWrangler/JSTimeoutError.html create mode 100644 Scarpe/Webview.html create mode 100644 Scarpe/Webview/ContainedService.html create mode 100644 Scarpe/WebviewAlert.html create mode 100644 Scarpe/WebviewApp.html create mode 100644 Scarpe/WebviewArc.html create mode 100644 Scarpe/WebviewBackground.html create mode 100644 Scarpe/WebviewBorder.html create mode 100644 Scarpe/WebviewButton.html create mode 100644 Scarpe/WebviewCheck.html create mode 100644 Scarpe/WebviewDisplayService.html create mode 100644 Scarpe/WebviewDocumentRoot.html create mode 100644 Scarpe/WebviewEditBox.html create mode 100644 Scarpe/WebviewEditLine.html create mode 100644 Scarpe/WebviewFlow.html create mode 100644 Scarpe/WebviewFont.html create mode 100644 Scarpe/WebviewImage.html create mode 100644 Scarpe/WebviewLine.html create mode 100644 Scarpe/WebviewLink.html create mode 100644 Scarpe/WebviewListBox.html create mode 100644 Scarpe/WebviewPara.html create mode 100644 Scarpe/WebviewRadio.html create mode 100644 Scarpe/WebviewShape.html create mode 100644 Scarpe/WebviewSlot.html create mode 100644 Scarpe/WebviewSpacing.html create mode 100644 Scarpe/WebviewSpan.html create mode 100644 Scarpe/WebviewStack.html create mode 100644 Scarpe/WebviewStar.html create mode 100644 Scarpe/WebviewSubscriptionItem.html create mode 100644 Scarpe/WebviewTextWidget.html create mode 100644 Scarpe/WebviewVideo.html create mode 100644 Scarpe/WebviewWidget.html create mode 100644 Shoes.html create mode 100644 Shoes/Alert.html create mode 100644 Shoes/App.html create mode 100644 Shoes/Arc.html create mode 100644 Shoes/Background.html create mode 100644 Shoes/Border.html create mode 100644 Shoes/Button.html create mode 100644 Shoes/Check.html create mode 100644 Shoes/Colors.html create mode 100644 Shoes/Constants.html create mode 100644 Shoes/DisplayService.html create mode 100644 Shoes/DocumentRoot.html create mode 100644 Shoes/EditBox.html create mode 100644 Shoes/EditLine.html create mode 100644 Shoes/Error.html create mode 100644 Shoes/Flow.html create mode 100644 Shoes/Font.html create mode 100644 Shoes/Image.html create mode 100644 Shoes/InvalidAttributeValueError.html create mode 100644 Shoes/Line.html create mode 100644 Shoes/Link.html create mode 100644 Shoes/Linkable.html create mode 100644 Shoes/ListBox.html create mode 100644 Shoes/Log.html create mode 100644 Shoes/LoggedWrapper.html create mode 100644 Shoes/Para.html create mode 100644 Shoes/Radio.html create mode 100644 Shoes/Shape.html create mode 100644 Shoes/Slot.html create mode 100644 Shoes/Spacing.html create mode 100644 Shoes/Span.html create mode 100644 Shoes/Stack.html create mode 100644 Shoes/Star.html create mode 100644 Shoes/SubscriptionItem.html create mode 100644 Shoes/TextWidget.html create mode 100644 Shoes/Video.html create mode 100644 Shoes/Widget.html create mode 100644 Shoes/Widget/ResponseWrapper.html create mode 100644 _index.html create mode 100644 class_list.html create mode 100644 css/common.css create mode 100644 css/full_list.css create mode 100644 css/style.css create mode 100644 file.README.html create mode 100644 file.catscradle.html create mode 100644 file.manual.html create mode 100644 file_list.html create mode 100644 frames.html create mode 100644 index.html create mode 100644 js/app.js create mode 100644 js/full_list.js create mode 100644 js/jquery.js create mode 100644 method_list.html create mode 100644 top-level-namespace.html diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/Kernel.html b/Kernel.html new file mode 100644 index 000000000..4b02b82d2 --- /dev/null +++ b/Kernel.html @@ -0,0 +1,137 @@ + + + + + + + Module: Kernel + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Kernel + + + +

+
+ + + + + + +
+
Includes:
+
Shoes::Constants
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes.rb
+
+ +
+ +

Overview

+
+

Shoes adds some top-level methods and constants that can be used everywhere. Kernel is where they go.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Constants

+

Shoes::Constants::HALF_PI, Shoes::Constants::LIB_DIR, Shoes::Constants::PI, Shoes::Constants::RAD2PI, Shoes::Constants::TWO_PI

+ + + + + + + + + + + + +

Method Summary

+ +

Methods included from Shoes::Constants

+

find_lib_dir

+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Lacci.html b/Lacci.html new file mode 100644 index 000000000..4ca0498a3 --- /dev/null +++ b/Lacci.html @@ -0,0 +1,138 @@ + + + + + + + Module: Lacci + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Lacci + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/lacci/version.rb
+
+ +
+ +

Overview

+
+

The name "scarpe" means "shoes" in Italian. "Lacci" +means "laces." Lacci is the display-independent part +of Scarpe, tying the Shoes API to the display service +of your choice.

+ +

Almost nothing is called Lacci in your program. It's +mostly invisible. Instead, look at the Shoes module +to see what's in Lacci.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
VERSION = + +
+
"0.2.2"
+ +
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe.html b/Scarpe.html new file mode 100644 index 000000000..52e6db527 --- /dev/null +++ b/Scarpe.html @@ -0,0 +1,271 @@ + + + + + + + Class: Scarpe + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb,
+ lib/scarpe/wv/app.rb,
lib/scarpe/wv/arc.rb,
lib/scarpe/version.rb,
lib/scarpe/wv/flow.rb,
lib/scarpe/wv/font.rb,
lib/scarpe/wv/html.rb,
lib/scarpe/wv/line.rb,
lib/scarpe/wv/link.rb,
lib/scarpe/wv/para.rb,
lib/scarpe/wv/slot.rb,
lib/scarpe/wv/span.rb,
lib/scarpe/wv/star.rb,
lib/scarpe/wv/alert.rb,
lib/scarpe/wv/check.rb,
lib/scarpe/wv/image.rb,
lib/scarpe/wv/radio.rb,
lib/scarpe/wv/shape.rb,
lib/scarpe/wv/stack.rb,
lib/scarpe/wv/video.rb,
lib/scarpe/wv/border.rb,
lib/scarpe/wv/button.rb,
lib/scarpe/wv/widget.rb,
lib/scarpe/wv/spacing.rb,
lib/scarpe/wv/edit_box.rb,
lib/scarpe/wv/list_box.rb,
lib/scarpe/wv/edit_line.rb,
lib/scarpe/wv/background.rb,
lib/scarpe/wv/dimensions.rb,
lib/scarpe/wv/text_widget.rb,
lib/scarpe/wv/web_wrangler.rb,
lib/scarpe/wv/web_wrangler.rb,
lib/scarpe/wv/document_root.rb,
lib/scarpe/wv/control_interface.rb,
lib/scarpe/wv/webview_relay_util.rb,
lib/scarpe/wv/webview_local_display.rb,
lib/scarpe/wv/webview_relay_display.rb,
lib/scarpe/wv/control_interface_test.rb,
lacci/lib/lacci/scarpe_cli.rb,
lacci/lib/lacci/scarpe_core.rb
+
+
+ +
+ +

Overview

+
+

The ControlInterface is used for testing. It's a way to register interest +in important events like redraw, init and shutdown, and to configure a +Shoes app for testing. Note that no part of the Scarpe framework should +ever depend on ControlInterface. It's for testing, not normal operation. +If no ControlInterface were ever created or called, Scarpe apps should run +fine with no modifications.

+ +

And if you depend on this from the framework, I'll add a check-mode that +never dispatches any events to any handlers. Do NOT test me on this.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: CLI, Test, WVRelayUtil, Webview, WebviewBackground, WebviewBorder, WebviewSpacing + + + + Classes: AppShutdownError, ControlInterface, Dimensions, Error, HTML, TestPromise, WVRelayDisplayService, WebWrangler, WebviewAlert, WebviewApp, WebviewArc, WebviewButton, WebviewCheck, WebviewDisplayService, WebviewDocumentRoot, WebviewEditBox, WebviewEditLine, WebviewFlow, WebviewFont, WebviewImage, WebviewLine, WebviewLink, WebviewListBox, WebviewPara, WebviewRadio, WebviewShape, WebviewSlot, WebviewSpan, WebviewStack, WebviewStar, WebviewSubscriptionItem, WebviewTextWidget, WebviewVideo, WebviewWidget + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
VERSION = + +
+
"0.2.2"
+ +
DEFAULT_ASSERTION_TIMEOUT = + +
+
1.0
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .default_wv_text_widget_with(element) ⇒ Object + + + + + +

+ + + + +
+
+
+
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+
+
# File 'lib/scarpe/wv/text_widget.rb', line 8
+
+def default_wv_text_widget_with(element)
+  webview_class_name = "Webview#{element.capitalize}"
+  webview_widget_class = Class.new(Scarpe::WebviewTextWidget) do
+    def initialize(properties)
+      class_name = self.class.name.split("::")[-1]
+      @html_tag = class_name.delete_prefix("Webview").downcase
+      super
+    end
+
+    def element
+      HTML.render do |h|
+        h.send(@html_tag) { @content.to_s }
+      end
+    end
+  end
+  Scarpe.const_set webview_class_name, webview_widget_class
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/AppShutdownError.html b/Scarpe/AppShutdownError.html new file mode 100644 index 000000000..168b731db --- /dev/null +++ b/Scarpe/AppShutdownError.html @@ -0,0 +1,142 @@ + + + + + + + Exception: Scarpe::AppShutdownError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::AppShutdownError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/webview_relay_util.rb
+
+ +
+ +

Overview

+
+

An error occurred which would normally be handled by shutting down the app

+ + +
+
+
+ + +
+ + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/CLI.html b/Scarpe/CLI.html new file mode 100644 index 000000000..cd6634352 --- /dev/null +++ b/Scarpe/CLI.html @@ -0,0 +1,522 @@ + + + + + + + Module: Scarpe::CLI + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::CLI + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/lacci/scarpe_cli.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
DEFAULT_USAGE = + +
+
<<~'USAGE'
+  Usage: scarpe_core [OPTIONS] <scarpe app file>           # Same as "scarpe run"
+         scarpe_core [OPTIONS] run <scarpe app file>
+         scarpe_core [OPTIONS] env                         # print Scarpe environment settings
+         scarpe_core -v                                    # print the Scarpe gem version and exit
+    Options:
+        --dev                          Use development local scarpe, not an installed gem
+        --debug                        Turn on application debug mode
+USAGE
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #add_env_categories(categories) ⇒ Object + + + + + +

+ + + + +
+
+
+
+53
+54
+55
+56
+57
+58
+59
+60
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 53
+
+def add_env_categories(categories)
+  unless categories.is_a?(Hash)
+    raise("Please supply a hash with categories names as keys and an array of two-elt arrays as values!")
+  end
+
+  # Try to get categories into the *start* of the hash, insertion-order-wise
+  @env_categories = categories.merge(env_categories)
+end
+
+
+ +
+

+ + #default_env_categoriesObject + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 25
+
+def default_env_categories
+  require "shoes"
+  {
+    "Lacci" => [
+      env_or_default("SCARPE_DISPLAY_SERVICE", "(none)"),
+      env_or_default("SCARPE_LOG_CONFIG", "(default)#{Shoes::Log::DEFAULT_LOG_CONFIG.inspect}"),
+      env_or_default("SCARPE_APP_TEST", "(none)"),
+    ],
+    "Ruby and Shell" => [
+      ["RUBY_DESCRIPTION", RUBY_DESCRIPTION],
+      ["RUBY_PLATFORM", RUBY_PLATFORM],
+      ["RUBY_ENGINE", RUBY_ENGINE],
+      env_or_default("SHELL", "(none)"),
+      env_or_default("PATH", "(none)"),
+      env_or_default("LD_LIBRARY_PATH", "(none)"),
+      env_or_default("DYLD_LIBRARY_PATH", "(none)"),
+      env_or_default("GEM_ROOT", "(none)"),
+      env_or_default("GEM_HOME", "(none)"),
+      env_or_default("GEM_PATH", "(none)"),
+    ],
+  }
+end
+
+
+ +
+

+ + #env_categoriesObject + + + + + +

+ + + + +
+
+
+
+48
+49
+50
+51
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 48
+
+def env_categories
+  @env_categories ||= default_env_categories
+  @env_categories
+end
+
+
+ +
+

+ + #env_or_default(env_var, default_val) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 21
+
+def env_or_default(env_var, default_val)
+  [env_var, ENV[env_var] ? ENV[env_var].inspect : default_val]
+end
+
+
+ +
+ + + + + +
+
+
+
+62
+63
+64
+65
+66
+67
+68
+69
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 62
+
+def print_env
+  env_categories.each do |category, entries|
+    puts "#{category} environment:"
+    entries.each do |name, val|
+      puts "  #{name}: #{val}"
+    end
+  end
+end
+
+
+ +
+

+ + #version_checkObject + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/lacci/scarpe_cli.rb', line 15
+
+def version_check
+  if RUBY_VERSION[0..2] < "3.2"
+    raise "Scarpe and Lacci require Ruby 3.2 or higher!"
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/ControlInterface.html b/Scarpe/ControlInterface.html new file mode 100644 index 000000000..c20067cd3 --- /dev/null +++ b/Scarpe/ControlInterface.html @@ -0,0 +1,2145 @@ + + + + + + + Class: Scarpe::ControlInterface + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::ControlInterface + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Test::EventedAssertions, Test::Helpers, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/control_interface.rb,
+ lib/scarpe/wv/control_interface_test.rb
+
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
SUBSCRIBE_EVENTS = + +
+
[:init, :shutdown, :next_redraw, :every_redraw, :next_heartbeat, :every_heartbeat]
+ +
DISPATCH_EVENTS = + +
+
[:init, :shutdown, :redraw, :heartbeat]
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + +

Methods included from Test::EventedAssertions

+

#assert_html, #assert_include, #assert_not_include, #return_results

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initializeControlInterface + + + + + +

+
+

The control interface needs to see major system components to hook into their events

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+29
+30
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 24
+
+def initialize
+  log_init("WV::ControlInterface")
+
+  @do_shutdown = false
+  @event_handlers = {}
+  (SUBSCRIBE_EVENTS | DISPATCH_EVENTS).each { |e| @event_handlers[e] = [] }
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #do_shutdownObject (readonly) + + + + + +

+
+

Returns the value of attribute do_shutdown.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 21
+
+def do_shutdown
+  @do_shutdown
+end
+
+
+ + + +
+

+ + #doc_rootObject + + + + + +

+ + + + +
+
+
+
+61
+62
+63
+64
+65
+66
+67
+68
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 61
+
+def doc_root
+  unless @doc_root
+    raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
+      "to make sure they have access to app, doc_root, wrangler, etc!"
+  end
+
+  @doc_root
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #all_wv_widgetsObject + + + + + +

+
+

Need to be able to query widgets in test code

+ + +
+
+
+ + +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 55
+
+def all_wv_widgets
+  known = [doc_root]
+  to_check = [doc_root]
+
+  until to_check.empty?
+    next_layer = to_check.flat_map(&:children)
+    known += next_layer
+    to_check = next_layer
+  end
+
+  # I don't *think* we'll ever have widget trees that merge back together, but just in case we'll de-dup
+  known.uniq
+end
+
+
+ +
+

+ + #appObject + + + + + +

+ + + + +
+
+
+
+52
+53
+54
+55
+56
+57
+58
+59
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 52
+
+def app
+  unless @app
+    raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
+      "to make sure they have access to app, doc_root, wrangler, etc!"
+  end
+
+  @app
+end
+
+
+ +
+

+ + #assert(value, msg = nil) ⇒ Object + + + + + +

+ + + + +
+
+
+
+173
+174
+175
+176
+177
+178
+179
+180
+181
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 173
+
+def assert(value, msg = nil)
+  id = start_assertion("#{caller[0]}: #{msg || "Value should be true!"}")
+
+  if value
+    pass_assertion(id)
+  else
+    fail_assertion(id, "Expected true Ruby value: #{value.inspect}")
+  end
+end
+
+
+ +
+

+ + #assert_equal(val1, val2, msg = nil) ⇒ Object + + + + + +

+ + + + +
+
+
+
+183
+184
+185
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 183
+
+def assert_equal(val1, val2, msg = nil)
+  assert val1 == val2, (msg || "Expected #{val2.inspect} to equal #{val1.inspect}!")
+end
+
+
+ +
+

+ + #assert_js(js_code, wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT) ⇒ Object + + + + + +

+
+

Create a promise to do a JS assertion, normally after other ops have finished.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 152
+
+def assert_js(js_code, wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT)
+  id = start_assertion(js_code)
+
+  # this isn't a TestPromise, so it doesn't have the additional DSL entries
+  promise = wrangler.eval_js_async(js_code, wait_for: wait_for, timeout: timeout)
+  promise.on_rejected do
+    fail_assertion(id, "JS Eval failed: #{promise.reason.inspect}")
+  end
+  promise.on_fulfilled do
+    ret_val = promise.returned_value
+    if ret_val
+      pass_assertion(id)
+    else
+      fail_assertion(id, "Expected true JS value: #{ret_val.inspect}")
+    end
+  end
+
+  # So we wrap it in a no-op TestPromise, to get the DSL entries.
+  TestPromise.new(iface: self, wait_for: [promise]).to_execute {}
+end
+
+
+ +
+

+ + #assertion_data_as_a_structObject + + + + + +

+ + + + +
+
+
+
+142
+143
+144
+145
+146
+147
+148
+149
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 142
+
+def assertion_data_as_a_struct
+  {
+    still_pending: @assertions_pending.size,
+    succeeded: @assertions_passed,
+    failed: @assertions_failed.size,
+    failures: @assertions_failed.values.map { |item| [item[:code], item[:failure_reason]] },
+  }
+end
+
+
+ +
+

+ + #assertions_may_existObject + + + + + +

+ + + + +
+
+
+
+106
+107
+108
+109
+110
+111
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 106
+
+def assertions_may_exist
+  @assertions_pending ||= {}
+  @assertions_failed ||= {}
+  @assertions_passed ||= 0
+  @assertion_counter ||= 0
+end
+
+
+ +
+

+ + #assertions_pending?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+138
+139
+140
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 138
+
+def assertions_pending?
+  !@assertions_pending.empty?
+end
+
+
+ +
+

+ + #die_after(time) ⇒ Object + + + + + +

+ + + + +
+
+
+
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 24
+
+def die_after(time)
+  t_start = Time.now
+  @die_after = [t_start, time]
+
+  wrangler.periodic_code("scarpeTestTimeout") do |*_args|
+    t_delta = (Time.now - t_start).to_f
+    if t_delta > time
+      @did_time_out = true
+      @log.warn("die_after - timed out after #{t_delta.inspect} (threshold: #{time.inspect})")
+      return_results(false, "Timed out!")
+      app.destroy
+    end
+  end
+end
+
+
+ +
+

+ + #dispatch_event(event, *args, **keywords) ⇒ Object + + + + + +

+
+

Send out the specified event

+ + +
+
+
+ + +
+ + + + +
+
+
+
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 96
+
+def dispatch_event(event, *args, **keywords)
+  @log.debug("CTL event #{event.inspect} #{args.inspect} #{keywords.inspect}")
+
+  unless DISPATCH_EVENTS.include?(event)
+    raise "Illegal dispatch of event #{event.inspect}! Valid values are: #{DISPATCH_EVENTS.inspect}"
+  end
+
+  if @do_shutdown
+    @log.debug("CTL: Shutting down - not dispatching #{event}!")
+    return
+  end
+
+  if event == :redraw
+    dumb_dispatch_event(:every_redraw, *args, **keywords)
+
+    # Next redraw is interesting. We can add new handlers
+    # when dispatching a next_redraw handler. But we want
+    # each handler to run only once.
+    handlers = @event_handlers[:next_redraw]
+    dumb_dispatch_event(:next_redraw, *args, **keywords)
+    @event_handlers[:next_redraw] -= handlers
+    return
+  end
+
+  if event == :heartbeat
+    dumb_dispatch_event(:every_heartbeat, *args, **keywords)
+
+    # Next heartbeat is interesting. We can add new handlers
+    # when dispatching a next_heartbeat handler. But we want
+    # each handler to run only once.
+    handlers = @event_handlers[:next_heartbeat]
+    dumb_dispatch_event(:next_heartbeat, *args, **keywords)
+    @event_handlers[:next_heartbeat] -= handlers
+    return
+  end
+
+  if event == :shutdown
+    @do_shutdown = true
+  end
+
+  dumb_dispatch_event(event, *args, **keywords)
+end
+
+
+ +
+

+ + #fail_assertion(id, fail_message) ⇒ Object + + + + + +

+ + + + +
+
+
+
+132
+133
+134
+135
+136
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 132
+
+def fail_assertion(id, fail_message)
+  item = @assertions_pending.delete(id)
+  item[:fail_message] = fail_message
+  @assertions_failed[id] = item
+end
+
+
+ +
+

+ + #find_wv_widgets(*specifiers) ⇒ Object + + + + + +

+
+

Shoes doesn't name widgets. We aren't guaranteed that the Shoes widgets are even in the same +process, since we have the Relay display service for Webview. So mostly we can look by +display service class.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 72
+
+def find_wv_widgets(*specifiers)
+  widgets = all_wv_widgets
+
+  specifiers.each do |spec|
+    if spec.is_a?(Class)
+      widgets.select! { |w| spec === w }
+    else
+      raise "I don't know how to search for widgets by #{spec.inspect}!"
+    end
+  end
+
+  widgets
+end
+
+
+ +
+

+ + #fully_updated(wait_for: []) ⇒ Object + + + + + +

+ + + + +
+
+
+
+201
+202
+203
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 201
+
+def fully_updated(wait_for: [])
+  wrangler.promise_dom_fully_updated
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+ + + + +
+
+
+
+32
+33
+34
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 32
+
+def inspect
+  "<#ControlInterface>"
+end
+
+
+ +
+

+ + #on_event(event, &block) ⇒ Object + + + + + +

+
+

On recognised events, this sets a handler for that event

+ + +
+
+
+ + +
+ + + + +
+
+
+
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 83
+
+def on_event(event, &block)
+  unless SUBSCRIBE_EVENTS.include?(event)
+    raise "Illegal subscribe to event #{event.inspect}! Valid values are: #{SUBSCRIBE_EVENTS.inspect}"
+  end
+
+  @unsub_id ||= 0
+  @unsub_id += 1
+
+  @event_handlers[event] << { handler: block, unsub: @unsub_id }
+  @unsub_id
+end
+
+
+ +
+

+ + #pass_assertion(id) ⇒ Object + + + + + +

+ + + + +
+
+
+
+127
+128
+129
+130
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 127
+
+def pass_assertion(id)
+  @assertions_pending.delete(id)
+  @assertions_passed += 1
+end
+
+
+ +
+

+ + #return_when_assertions_doneObject + + + + + +

+
+

Note that we do not extract this assertions library to use elsewhere +because it's very focused on evented assertions that start and stop +over a period of time. Instantaneous procedural asserts don't want to +use this API.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 94
+
+def return_when_assertions_done
+  assertions_may_exist
+
+  wrangler.periodic_code("scarpeReturnWhenAssertionsDone") do |*_args|
+    if @assertions_pending.empty?
+      success = @assertions_failed.empty?
+      return_results success, "Assertions #{success ? "succeeded" : "failed"}", assertion_data_as_a_struct
+      app.destroy
+    end
+  end
+end
+
+
+ +
+

+ + #set_system_components(app:, doc_root:, wrangler:) ⇒ Object + + + + + +

+
+

This should get called once, from Shoes::App

+ + +
+
+
+ + +
+ + + + +
+
+
+
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 37
+
+def set_system_components(app:, doc_root:, wrangler:)
+  unless app && wrangler
+    @log.error("False app passed to set_system_components!") unless app
+    @log.error("False wrangler passed to set_system_components!") unless wrangler
+    raise "Must pass non-nil app and wrangler to ControlInterface#set_system_components!"
+  end
+  @app = app
+  @doc_root = doc_root # May be nil at this point
+  @wrangler = wrangler
+
+  @wrangler.control_interface = self
+
+  @wrangler.on_every_redraw { self.dispatch_event(:redraw) }
+end
+
+
+ +
+

+ + #start_assertion(code) ⇒ Object + + + + + +

+ + + + +
+
+
+
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 113
+
+def start_assertion(code)
+  assertions_may_exist
+
+  this_assertion = @assertion_counter
+  @assertion_counter += 1
+
+  @assertions_pending[this_assertion] = {
+    id: this_assertion,
+    code: code,
+  }
+
+  this_assertion
+end
+
+
+ +
+

+ + #test_metadataObject + + + + + +

+
+

This is returned alongside the actual results automatically

+ + +
+
+
+ + +
+ + + + +
+
+
+
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 40
+
+def 
+  data = {}
+  if @die_after
+    t_delta = (Time.now - @die_after[0]).to_f
+    data["die_after"] = {
+      t_start: @die_after[0].to_s,
+      threshold: @die_after[1],
+      passed: t_delta,
+    }
+  end
+  data
+end
+
+
+ +
+

+ + #timed_out?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+20
+21
+22
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 20
+
+def timed_out?
+  @did_time_out
+end
+
+
+ +
+

+ + #with_js_dom_html(wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+197
+198
+199
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 197
+
+def with_js_dom_html(wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block)
+  with_js_value("document.getElementById('wrapper-wvroot').innerHTML", wait_for: wait_for, timeout: timeout, &block)
+end
+
+
+ +
+

+ + #with_js_value(js_code, wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block) ⇒ Object + + + + + +

+
+

How do we signal an error?

+ + +
+
+
+ + +
+ + + + +
+
+
+
+188
+189
+190
+191
+192
+193
+194
+195
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 188
+
+def with_js_value(js_code, wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block)
+  raise "Must give a block to with_js_value!" unless block
+
+  js_promise = wrangler.eval_js_async(js_code, wait_for: wait_for, timeout: timeout)
+  ruby_promise = TestPromise.new(iface: self, wait_for: [js_promise])
+  ruby_promise.to_execute(&block)
+  ruby_promise
+end
+
+
+ +
+

+ + #wranglerObject + + + + + +

+ + + + +
+
+
+
+70
+71
+72
+73
+74
+75
+76
+77
+
+
# File 'lib/scarpe/wv/control_interface.rb', line 70
+
+def wrangler
+  unless @wrangler
+    raise "ControlInterface code needs to be wrapped in handlers like on_event(:init) " +
+      "to make sure they have access to app, doc_root, wrangler, etc!"
+  end
+
+  @wrangler
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Dimensions.html b/Scarpe/Dimensions.html new file mode 100644 index 000000000..645014c61 --- /dev/null +++ b/Scarpe/Dimensions.html @@ -0,0 +1,212 @@ + + + + + + + Class: Scarpe::Dimensions + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Dimensions + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/dimensions.rb
+
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .length(value) ⇒ Object + + + + + +

+ + + + +
+
+
+
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lib/scarpe/wv/dimensions.rb', line 6
+
+def length(value)
+  case value
+  when Integer
+    if value < 0
+      "calc(100% - #{value.abs}px)"
+    else
+      "#{value}px"
+    end
+  when Float
+    "#{value * 100}%"
+  else
+    value
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Error.html b/Scarpe/Error.html new file mode 100644 index 000000000..73a8daa9a --- /dev/null +++ b/Scarpe/Error.html @@ -0,0 +1,138 @@ + + + + + + + Exception: Scarpe::Error + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::Error + + + +

+
+ +
+
Inherits:
+
+ StandardError + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/lacci/scarpe_core.rb
+
+ +
+ +

Overview

+
+

The base error class for Scarpe errors, but not necessarily Shoes::Errors

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

AppShutdownError, WebWrangler::JSEvalError

+
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/HTML.html b/Scarpe/HTML.html new file mode 100644 index 000000000..40c6f5f18 --- /dev/null +++ b/Scarpe/HTML.html @@ -0,0 +1,794 @@ + + + + + + + Class: Scarpe::HTML + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::HTML + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/html.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
CONTENT_TAGS = + +
+
[:div, :p, :button, :ul, :li, :textarea, :a, :video, :strong, :style, :em, :code, :u, :line, :span, :svg].freeze
+ +
VOID_TAGS = + +
+
[:input, :img, :polygon, :source, :link, :path].freeze
+ +
TAGS = + +
+
(CONTENT_TAGS + VOID_TAGS).freeze
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(&block) ⇒ HTML + + + + + +

+
+

Returns a new instance of HTML.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+19
+
+
# File 'lib/scarpe/wv/html.rb', line 16
+
+def initialize(&block)
+  @buffer = ""
+  block.call(self)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(name, *args, &block) ⇒ Object + + + + + +

+
+ + +
+
+
+ +

Raises:

+
    + +
  • + + + (NoMethodError) + + + +
  • + +
+ +
+ + + + +
+
+
+
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+
+
# File 'lib/scarpe/wv/html.rb', line 63
+
+def method_missing(name, *args, &block)
+  raise NoMethodError, "no method #{name} for #{self.class.name}" unless TAGS.include?(name)
+
+  if VOID_TAGS.include?(name)
+    raise ArgumentError, "void tag #{name} cannot have content" if block_given?
+
+    @buffer += "<#{name}#{render_attributes(*args)} />"
+  else
+    @buffer += "<#{name}#{render_attributes(*args)}>"
+
+    if block_given?
+      result = block.call(self)
+    else
+      result = args.first
+      @buffer += result if result.is_a?(String)
+    end
+    @buffer += result if result.is_a?(String)
+
+    @buffer += "</#{name}>"
+  end
+
+  nil
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .render(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lib/scarpe/wv/html.rb', line 11
+
+def render(&block)
+  new(&block).value
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #option(**attrs, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/scarpe/wv/html.rb', line 33
+
+def option(**attrs, &block)
+  tag(:option, **attrs, &block)
+end
+
+
+ +
+

+ + #p(*args, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'lib/scarpe/wv/html.rb', line 29
+
+def p(*args, &block)
+  method_missing(:p, *args, &block)
+end
+
+
+ +
+

+ + #respond_to_missing?(name, include_all = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lib/scarpe/wv/html.rb', line 25
+
+def respond_to_missing?(name, include_all = false)
+  TAGS.include?(name) || super(name, include_all)
+end
+
+
+ +
+

+ + #select(**attrs, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+59
+60
+61
+
+
# File 'lib/scarpe/wv/html.rb', line 59
+
+def select(**attrs, &block)
+  tag(:select, **attrs, &block)
+end
+
+
+ +
+

+ + #tag(name, **attrs, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+
+
# File 'lib/scarpe/wv/html.rb', line 37
+
+def tag(name, **attrs, &block)
+  if VOID_TAGS.include?(name)
+    raise ArgumentError, "void tag #{name} cannot have content" if block_given?
+
+    @buffer += "<#{name}#{render_attributes(attrs)} />"
+  else
+    @buffer += "<#{name}#{render_attributes(attrs)}>"
+
+    if block_given?
+      result = block.call(self)
+    else
+      result = attrs[:content]
+      @buffer += result if result.is_a?(String)
+    end
+    @buffer += result if result.is_a?(String)
+
+    @buffer += "</#{name}>"
+  end
+
+  nil
+end
+
+
+ +
+

+ + #valueObject + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lib/scarpe/wv/html.rb', line 21
+
+def value
+  @buffer
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test.html b/Scarpe/Test.html new file mode 100644 index 000000000..180cb5598 --- /dev/null +++ b/Scarpe/Test.html @@ -0,0 +1,119 @@ + + + + + + + Module: Scarpe::Test + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Test + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/cats_cradle.rb,
+ lib/scarpe/evented_assertions.rb
+
+
+ +
+ +

Defined Under Namespace

+

+ + + Modules: CatsCradle, EventedAssertions + + + + Classes: CCInstance, CCProxy + + +

+ + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test/CCInstance.html b/Scarpe/Test/CCInstance.html new file mode 100644 index 000000000..91683e49d --- /dev/null +++ b/Scarpe/Test/CCInstance.html @@ -0,0 +1,1236 @@ + + + + + + + Class: Scarpe::Test::CCInstance + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Test::CCInstance + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
EventedAssertions, Helpers, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/cats_cradle.rb
+
+ +
+ +

Overview

+
+

This class defines the CatsCradle DSL. It also holds a "bag of fibers" +with promises for when they should next resume.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
EVENT_TYPES = +
+
+

If we add "every" events, that's likely to complicate timing and event_promise handling.

+ + +
+
+
+ + +
+
+
[:next_heartbeat, :next_redraw]
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

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

+ + + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + +

Methods included from EventedAssertions

+

#assert_html, #assert_include, #assert_not_include, #return_results

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initializeCCInstance + + + + + +

+
+

Returns a new instance of CCInstance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+
+
# File 'lib/scarpe/cats_cradle.rb', line 49
+
+def initialize
+  log_init("CatsCradle")
+
+  @assertion_data = []
+  @assertions_passed = 0
+  @assertions_failed = []
+
+  @waiting_fibers = []
+  @event_promises = {}
+
+  @manager_fiber = Fiber.new do
+    loop do
+      # A fiber can run briefly and then exit. It can run and then block on an API call.
+      # These fibers return promises to indicate to CatsCradle when they can run again.
+      # A fiber that is no longer #alive? is assumed to be successfully finished.
+      @waiting_fibers.each do |fiber_data|
+        next unless fiber_data[:promise].fulfilled?
+
+        @log.debug("Resuming fiber with value #{fiber_data[:promise].returned_value.inspect}")
+        result = fiber_data[:fiber].transfer fiber_data[:promise].returned_value
+
+        # Dead fibers will be removed later, just leave it
+        next unless fiber_data[:fiber].alive?
+
+        case result
+        when ::Scarpe::Promise
+          fiber_data[:promise] = result
+        else
+          raise "Unexpected object returned from Fiber#transfer for still-living Fiber! #{result.inspect}"
+        end
+      end
+
+      # Throw out dead fibers or those that will never wake
+      @waiting_fibers.select! do |fiber_data|
+        fiber_data[:fiber].alive? && !fiber_data[:promise].rejected?
+      end
+
+      # Done with this iteration
+      Fiber.yield
+    end
+  end
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .instanceObject + + + + + +

+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lib/scarpe/cats_cradle.rb', line 45
+
+def self.instance
+  @instance ||= CCInstance.new
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #assert(value, msg = nil) ⇒ Object + + + + + +

+ + + + +
+
+
+
+184
+185
+186
+187
+188
+189
+190
+191
+192
+
+
# File 'lib/scarpe/cats_cradle.rb', line 184
+
+def assert(value, msg = nil)
+  msg ||= "Assertion #{value ? "succeeded" : "failed"}"
+  @assertion_data << [value ? true : false, msg]
+  if value
+    @assertions_passed += 1
+  else
+    @assertions_failed << msg
+  end
+end
+
+
+ +
+

+ + #assert_equal(expected, actual, msg = nil) ⇒ Object + + + + + +

+ + + + +
+
+
+
+194
+195
+196
+197
+
+
# File 'lib/scarpe/cats_cradle.rb', line 194
+
+def assert_equal(expected, actual, msg = nil)
+  msg ||= "Expected #{actual.inspect} to equal #{expected.inspect}!"
+  assert actual == expected, msg
+end
+
+
+ +
+

+ + #assertion_data_as_a_structObject + + + + + +

+ + + + +
+
+
+
+199
+200
+201
+202
+203
+204
+205
+206
+
+
# File 'lib/scarpe/cats_cradle.rb', line 199
+
+def assertion_data_as_a_struct
+  {
+    still_pending: 0,
+    succeeded: @assertions_passed,
+    failed: @assertions_failed.size,
+    failures: @assertions_failed,
+  }
+end
+
+
+ +
+

+ + #dom_html(timeout: 1.0) ⇒ Object + + + + + +

+ + + + +
+
+
+
+173
+174
+175
+
+
# File 'lib/scarpe/cats_cradle.rb', line 173
+
+def dom_html(timeout: 1.0)
+  query_js_value("document.getElementById('wrapper-wvroot').innerHTML", timeout:)
+end
+
+
+ +
+

+ + #event_initObject + + + + + +

+
+

This needs to be called after the basic display service objects exist +and we can find the control interface.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+
+
# File 'lib/scarpe/cats_cradle.rb', line 97
+
+def event_init
+  return if @cc_init_done
+
+  @cc_init_done = true
+
+  @control_interface = ::Shoes::DisplayService.display_service.control_interface
+  @wrangler = @control_interface.wrangler
+
+  cc_instance = self # ControlInterface#on_event does an instance eval. We'll reset self with another.
+
+  @control_interface.on_event(:every_heartbeat) do
+    cc_instance.instance_eval do
+      p = @event_promises.delete(:next_heartbeat)
+      p&.fulfilled!
+
+      # Give every ready fiber a chance to run once.
+      @manager_fiber.resume
+    end
+  end
+
+  @control_interface.on_event(:every_redraw) do
+    cc_instance.instance_eval do
+      p = @event_promises.delete(:next_redraw)
+      p&.fulfilled!
+
+      # Give every ready fiber a chance to run once.
+      @manager_fiber.resume
+    end
+  end
+end
+
+
+ +
+

+ + #event_promise(event) ⇒ Object + + + + + +

+ + + + +
+
+
+
+128
+129
+130
+
+
# File 'lib/scarpe/cats_cradle.rb', line 128
+
+def event_promise(event)
+  @event_promises[event] ||= ::Scarpe::Promise.new
+end
+
+
+ +
+

+ + #fully_updatedObject + + + + + +

+
+

This returns a promise, which can be waited on using wait()

+ + +
+
+
+ + +
+ + + + +
+
+
+
+169
+170
+171
+
+
# File 'lib/scarpe/cats_cradle.rb', line 169
+
+def fully_updated
+  @wrangler.promise_dom_fully_updated
+end
+
+
+ +
+

+ + #on_event(event, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+132
+133
+134
+135
+136
+137
+138
+139
+
+
# File 'lib/scarpe/cats_cradle.rb', line 132
+
+def on_event(event, &block)
+  raise "Unknown event type: #{event.inspect}!" unless EVENT_TYPES.include?(event)
+
+  f = Fiber.new do
+    CCInstance.instance.instance_eval(&block)
+  end
+  @waiting_fibers << { promise: event_promise(event), fiber: f }
+end
+
+
+ +
+

+ + #proxy_for(shoes_widget) ⇒ Object + + + + + +

+ + + + +
+
+
+
+157
+158
+159
+
+
# File 'lib/scarpe/cats_cradle.rb', line 157
+
+def proxy_for(shoes_widget)
+  CCProxy.new(shoes_widget)
+end
+
+
+ +
+

+ + #query_js_value(js_code, timeout: 1.0) ⇒ Object + + + + + +

+ + + + +
+
+
+
+177
+178
+179
+180
+181
+182
+
+
# File 'lib/scarpe/cats_cradle.rb', line 177
+
+def query_js_value(js_code, timeout: 1.0)
+  js_promise = @wrangler.eval_js_async(js_code, timeout:)
+
+  # This promise will return the string, so we can just pass it to #transfer
+  @manager_fiber.transfer(js_promise)
+end
+
+
+ +
+

+ + #test_finishedObject + + + + + +

+ + + + +
+
+
+
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+
+
# File 'lib/scarpe/cats_cradle.rb', line 212
+
+def test_finished
+  if !@assertions_failed.empty?
+    return_results(false, "Assertions failed", assertion_data_as_a_struct)
+  elsif @assertions_passed > 0
+    return_results(true, "All assertions passed", assertion_data_as_a_struct)
+  else
+    return_results(true, "Test finished successfully")
+  end
+  ::Shoes::DisplayService.dispatch_event("destroy", nil)
+end
+
+
+ +
+

+ + #test_metadataObject + + + + + +

+ + + + +
+
+
+
+208
+209
+210
+
+
# File 'lib/scarpe/cats_cradle.rb', line 208
+
+def 
+  {}
+end
+
+
+ +
+

+ + #wait(promise) ⇒ Object + + + + + +

+ + + + +
+
+
+
+161
+162
+163
+164
+165
+166
+
+
# File 'lib/scarpe/cats_cradle.rb', line 161
+
+def wait(promise)
+  raise("Must supply a promise to wait!") unless promise.is_a?(::Scarpe::Promise)
+
+  # Wait until this promise is complete before running again
+  @manager_fiber.transfer(promise)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test/CCProxy.html b/Scarpe/Test/CCProxy.html new file mode 100644 index 000000000..289162b99 --- /dev/null +++ b/Scarpe/Test/CCProxy.html @@ -0,0 +1,521 @@ + + + + + + + Class: Scarpe::Test::CCProxy + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Test::CCProxy + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/cats_cradle.rb
+
+ +
+ +

Overview

+
+

We'd like something we can call Shoes widget methods on, such as para.replace. +But we'd also like to be able to grab the corresponding display widget and +call some of those methods.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #display ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute display.

    +
    + +
  • + + +
  • + + + #obj ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute obj.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(obj) ⇒ CCProxy + + + + + +

+
+

Returns a new instance of CCProxy.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+19
+20
+
+
# File 'lib/scarpe/cats_cradle.rb', line 16
+
+def initialize(obj)
+  @obj = obj
+  # TODO: how to do this with Webview relay? Proxy object to send a message, maybe?
+  @display = ::Shoes::DisplayService.display_service.query_display_widget_for(obj.linkable_id)
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(method) ⇒ Object + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/scarpe/cats_cradle.rb', line 22
+
+def method_missing(method, ...)
+  if @obj.respond_to?(method)
+    self.singleton_class.define_method(method) do |*args, **kwargs, &block|
+      @obj.send(method, *args, **kwargs, &block)
+    end
+    send(method, ...)
+  else
+    super # raise an exception
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #displayObject (readonly) + + + + + +

+
+

Returns the value of attribute display.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+
+
# File 'lib/scarpe/cats_cradle.rb', line 13
+
+def display
+  @display
+end
+
+
+ + + +
+

+ + #objObject (readonly) + + + + + +

+
+

Returns the value of attribute obj.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+14
+15
+16
+
+
# File 'lib/scarpe/cats_cradle.rb', line 14
+
+def obj
+  @obj
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #respond_to_missing?(method_name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/scarpe/cats_cradle.rb', line 33
+
+def respond_to_missing?(method_name, include_private = false)
+  @obj.respond_to_missing?(method_name, include_private)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test/CatsCradle.html b/Scarpe/Test/CatsCradle.html new file mode 100644 index 000000000..f5bd683bf --- /dev/null +++ b/Scarpe/Test/CatsCradle.html @@ -0,0 +1,248 @@ + + + + + + + Module: Scarpe::Test::CatsCradle + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Test::CatsCradle + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/cats_cradle.rb
+
+ +
+ +

Overview

+
+

An attempt at an experimental Fiber-based testing system to deal with +Shoes, Display and JS all at the same time.

+ +

In general, we'll use Fiber.transfer to bounce control back and forth +between the evented implementations (e.g. waiting for redraw) that +need to return control to Webview, and the procedural test flows +that look far better if we don't do that explicitly.

+ +

Ruby Fiber basic docs: https://ruby-doc.org/core-3.0.0/Fiber.html

+ +

This module is mixed into Shoes::App if we're running CatsCradle-based tests

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #event_initObject + + + + + +

+ + + + +
+
+
+
+240
+241
+242
+243
+
+
# File 'lib/scarpe/cats_cradle.rb', line 240
+
+def event_init
+  @cc_instance = CCInstance.instance
+  @cc_instance.event_init
+end
+
+
+ +
+

+ + #on_heartbeat(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+245
+246
+247
+
+
# File 'lib/scarpe/cats_cradle.rb', line 245
+
+def on_heartbeat(&block)
+  @cc_instance.on_event(:next_heartbeat, &block)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Test/EventedAssertions.html b/Scarpe/Test/EventedAssertions.html new file mode 100644 index 000000000..9e3fbf1b4 --- /dev/null +++ b/Scarpe/Test/EventedAssertions.html @@ -0,0 +1,696 @@ + + + + + + + Module: Scarpe::Test::EventedAssertions + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Test::EventedAssertions + + + +

+
+ + + + + + + + + +
+
Included in:
+
ControlInterface, CCInstance
+
+ + + +
+
Defined in:
+
lib/scarpe/evented_assertions.rb
+
+ +
+ +

Overview

+
+

We need a separate assertion system for the kind of Scarpe +testing where we start a subprocess, perform the assertion +logic in the subprocess, and then run Minitest in the parent. +It's an unusual setup.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #assert_html(actual_html, expected_tag, **opts) { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

Assert that actual_html is the same as expected_tag with opts. +This uses Scarpe's HTML tag-based renderer to render the tag and options +into text, and valides that the text is the same.

+ + +
+
+
+

Parameters:

+
    + +
  • + + actual_html + + + (String) + + + + — +

    the html to compare to

    +
    + +
  • + +
  • + + expected_tag + + + (String, Symbol) + + + + — +

    the HTML tag, used to send a method call

    +
    + +
  • + +
  • + + opts + + + + + + + — +

    keyword options passed to the tag method call

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    block passed to the tag method call.

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/scarpe/evented_assertions.rb', line 47
+
+def assert_html(actual_html, expected_tag, **opts, &block)
+  expected_html = Scarpe::HTML.render do |h|
+    h.public_send(expected_tag, opts, &block)
+  end
+
+  assert_equal expected_html, actual_html
+end
+
+
+ +
+

+ + #assert_include(text, subtext, msg = nil) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Assert that text includes subtext.

+ + +
+
+
+

Parameters:

+
    + +
  • + + text + + + (String) + + + + — +

    the longer text

    +
    + +
  • + +
  • + + subtext + + + (String) + + + + — +

    the text that is asserted to be included

    +
    + +
  • + +
  • + + msg + + + (String, nil) + + + (defaults to: nil) + + + — +

    if supplied, the failure message for the assertion

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+20
+21
+22
+23
+
+
# File 'lib/scarpe/evented_assertions.rb', line 20
+
+def assert_include(text, subtext, msg = nil)
+  msg ||= "Expected #{text.inspect} to include #{subtext.inspect}"
+  assert text.include?(subtext), msg
+end
+
+
+ +
+

+ + #assert_not_include(text, subtext, msg = nil) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Assert that text does not include subtext.

+ + +
+
+
+

Parameters:

+
    + +
  • + + text + + + (String) + + + + — +

    the longer text

    +
    + +
  • + +
  • + + subtext + + + (String) + + + + — +

    the text that is asserted to not be included

    +
    + +
  • + +
  • + + msg + + + (String, nil) + + + (defaults to: nil) + + + — +

    if supplied, the failure message for the assertion

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+31
+32
+33
+34
+
+
# File 'lib/scarpe/evented_assertions.rb', line 31
+
+def assert_not_include(text, subtext, msg = nil)
+  msg ||= "Expected #{text.inspect} not to include #{subtext.inspect}"
+  assert !text.include?(subtext), msg
+end
+
+
+ +
+

+ + #return_results(result_bool, msg, data = {}) ⇒ Object + + + + + +

+
+

This does a final return of results. If it gets called +multiple times, the test fails because that's not allowed.

+ + +
+
+
+

Parameters:

+
    + +
  • + + result_bool + + + (Boolean) + + + + — +

    true if the results are success, false if failure

    +
    + +
  • + +
  • + + msg + + + (String) + + + + — +

    the message included with the results

    +
    + +
  • + +
  • + + data + + + (Hash) + + + (defaults to: {}) + + + — +

    any additional data to pass with the results

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + + + + + +

    void

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+
+
# File 'lib/scarpe/evented_assertions.rb', line 62
+
+def return_results(result_bool, msg, data = {})
+  result_file = ENV["SCARPE_TEST_RESULTS"] || "./scarpe_results.txt"
+
+  result_structs = [result_bool, msg, data.merge()]
+  if File.exist?(result_file)
+    results_returned = JSON.parse File.read(result_file)
+  end
+
+  # Multiple different sets of results is bad, even if both are passing.
+  if results_returned && results_returned[0..1] != result_structs[0..1]
+    # Just raising here doesn't reliably fail the test.
+    # See: https://github.com/scarpe-team/scarpe/issues/212
+    Shoes::Log.logger("Test Results").error("Writing multi-result failure file to #{result_file.inspect}!")
+
+    new_res_data = { first_result: results_returned, second_result: result_structs }.merge()
+    bad_result = [false, "Returned two sets of results!", new_res_data]
+    File.write(result_file, JSON.pretty_generate(bad_result))
+
+    return
+  elsif results_returned
+    Shoes::Log.logger("Test Results").warn "Returning identical results twice: #{results_returned.inspect}"
+  end
+
+  Shoes::Log.logger("Test Results").debug("Writing results file #{result_file.inspect} to disk!")
+  File.write(result_file, JSON.pretty_generate(result_structs))
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/TestPromise.html b/Scarpe/TestPromise.html new file mode 100644 index 000000000..c9d4b0c73 --- /dev/null +++ b/Scarpe/TestPromise.html @@ -0,0 +1,454 @@ + + + + + + + Class: Scarpe::TestPromise + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::TestPromise + + + +

+
+ +
+
Inherits:
+
+ Promise + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/control_interface_test.rb
+
+ +
+ +

Overview

+
+

A Promise but with helper functions for Webview testing.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + +
+

Constructor Details

+ +
+

+ + #initialize(iface:, state: nil, wait_for: [], &scheduler) ⇒ TestPromise + + + + + +

+
+

Returns a new instance of TestPromise.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+208
+209
+210
+211
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 208
+
+def initialize(iface:, state: nil, wait_for: [], &scheduler)
+  @iface = iface
+  super(state: state, parents: wait_for, &scheduler)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #inspectObject + + + + + +

+ + + + +
+
+
+
+213
+214
+215
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 213
+
+def inspect
+  "<#TestPromise::#{object_id} state=#{state.inspect} parents=#{parents.inspect} value=#{returned_value.inspect} reason=#{reason.inspect}>"
+end
+
+
+ +
+

+ + #then_ruby_promise(wait_for: [], &block) ⇒ Object + + + + + +

+
+

This method expects to wait for the parent TestPromise and then run a block of Ruby that returns +another promise. This is useful for wrapping Promises like those from replace() that don't have +the test DSL built in. The block will execute when this outer promise is scheduled -- so we don't do +a replace() too early, for instance. And then the outer promise will fulfill when the inner one does.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+221
+222
+223
+224
+225
+226
+227
+228
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 221
+
+def then_ruby_promise(wait_for: [], &block)
+  ruby_wrapper_promise = TestPromise.new iface: @iface, wait_for: ([self] + wait_for)
+
+  ruby_wrapper_promise.on_scheduled do
+    inner_ruby_promise = block.call
+    inner_ruby_promise.on_fulfilled { ruby_wrapper_promise.fulfilled!(inner_ruby_promise.returned_value) }
+  end
+end
+
+
+ +
+

+ + #then_with_js_dom_html(wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+234
+235
+236
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 234
+
+def then_with_js_dom_html(wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block)
+  @iface.with_js_dom_html(wait_for: (wait_for + [self]), timeout:, &block)
+end
+
+
+ +
+

+ + #then_with_js_value(js_code, wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+230
+231
+232
+
+
# File 'lib/scarpe/wv/control_interface_test.rb', line 230
+
+def then_with_js_value(js_code, wait_for: [], timeout: DEFAULT_ASSERTION_TIMEOUT, &block)
+  @iface.with_js_value(js_code, wait_for: (wait_for + [self]), timeout:, &block)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WVRelayDisplayService.html b/Scarpe/WVRelayDisplayService.html new file mode 100644 index 000000000..d63d03cb3 --- /dev/null +++ b/Scarpe/WVRelayDisplayService.html @@ -0,0 +1,618 @@ + + + + + + + Class: Scarpe::WVRelayDisplayService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WVRelayDisplayService + + + +

+
+ +
+
Inherits:
+
+ Shoes::DisplayService + + + show all + +
+
+ + + + + + +
+
Includes:
+
WVRelayUtil, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/webview_relay_display.rb
+
+ +
+ +

Overview

+
+

This display service creates a child process and sends events +back and forth, but creates no widgets of its own. The child +process will spawn a worker with its own WebviewDisplayService +where the real Webview exists. By splitting the Webview +process from the Shoes widgets, it can be easier to return +control to Webview's event handler promptly. Also, the Ruby +process could run background threads if it wanted, and +otherwise behave like a process not containing Webview.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #shutdown ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute shutdown.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from WVRelayUtil

+

#event_loop_for, #ready_to_read?, #receive_datagram, #respond_to_datagram, #send_datagram

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::DisplayService

+

dispatch_event, display_service, full_reset!, #query_display_widget_for, set_display_service_class, #set_widget_pairing, subscribe_to_event, unsub_from_events

+
+

Constructor Details

+ +
+

+ + #initializeWVRelayDisplayService + + + + + +

+
+

Create a Webview Relay Display Service

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 24
+
+def initialize
+  super()
+  log_init("WV::RelayDisplayService")
+
+  @event_subs = []
+  @shutdown = false
+  @i_am = :parent
+
+  server = TCPServer.new("127.0.0.1", 0)
+  port = server.addr[1]
+
+  @pid = spawn(RbConfig.ruby, File.join(__dir__, "wv_display_worker.rb"), port.to_s)
+  @from = @to = server.accept
+
+  # Subscribe to all event notifications and relay them to the worker
+  @event_subs << bind_shoes_event(event_name: :any, target: :any) do |*args, **kwargs|
+    unless kwargs[:relayed]
+      kwargs[:relayed] = true
+      send_datagram({ type: :event, args:, kwargs: })
+    end
+
+    # Forward the run event to the child process before doing this
+    if event_name == "run"
+      run_event_loop
+    end
+  rescue AppShutdownError
+    @shutdown = true
+    @log.info("Attempting to shut down...")
+    self.destroy
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #shutdownObject + + + + + +

+
+

Returns the value of attribute shutdown.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 21
+
+def shutdown
+  @shutdown
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #create_display_widget_for(widget_class_name, widget_id, properties) ⇒ Object + + + + + +

+
+

This method sends a message to the worker process to create a widget. No actual +widget is created or registered with the display service.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+70
+71
+72
+73
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 70
+
+def create_display_widget_for(widget_class_name, widget_id, properties)
+  send_datagram({ type: :create, class_name: widget_class_name, id: widget_id, properties: })
+  # Don't need to return anything. It wouldn't be used anyway.
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+
+

Tell the worker process to quit, and set a flag telling the event loop to shut down.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+76
+77
+78
+79
+80
+81
+82
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 76
+
+def destroy
+  unless @shutdown
+    send_datagram({ type: :destroy })
+  end
+  @shutdown = true
+  (@events_subs || []).each { |unsub_id| DisplayService.unsub_from_events(unsub_id) }
+end
+
+
+ +
+

+ + #run_event_loopObject + + + + + +

+
+

Run, sending and responding to datagrams continuously.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+
+
# File 'lib/scarpe/wv/webview_relay_display.rb', line 57
+
+def run_event_loop
+  until @shutdown
+    respond_to_datagram while ready_to_read?
+    sleep 0.1
+  end
+rescue AppShutdownError
+  @shutdown = true
+  @log.info("Attempting to shut down...")
+  self.destroy
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WVRelayUtil.html b/Scarpe/WVRelayUtil.html new file mode 100644 index 000000000..4f9ae266e --- /dev/null +++ b/Scarpe/WVRelayUtil.html @@ -0,0 +1,734 @@ + + + + + + + Module: Scarpe::WVRelayUtil + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::WVRelayUtil + + + +

+
+ + + + + + + + + +
+
Included in:
+
WVRelayDisplayService, Scarpe::Webview::ContainedService
+
+ + + +
+
Defined in:
+
lib/scarpe/wv/webview_relay_util.rb
+
+ +
+ +

Overview

+
+

WVRelayUtil defines the datagram format for the sockets that connect a parent +Shoes application with a child display server.

+ +

The class including this module should also include Shoes::Log so that it can +be used.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #event_loop_for(t = 1.5) ⇒ Object + + + + + +

+
+

Loop for up to t seconds, reading data and waiting.

+ + +
+
+
+

Parameters:

+
    + +
  • + + t + + + (Float) + + + (defaults to: 1.5) + + + — +

    the number of seconds to loop for

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 130
+
+def event_loop_for(t = 1.5)
+  t_start = Time.now
+  delay_time = t
+
+  while Time.now - t_start < delay_time
+    if ready_to_read?(0.1)
+      respond_to_datagram
+    else
+      sleep 0.1
+    end
+  end
+end
+
+
+ +
+

+ + #ready_to_read?(timeout = 0.0) ⇒ Boolean + + + + + +

+
+

Checks whether the internal socket is ready to be read from. +If timeout is greater than 0, this will block for up to that long.

+ + +
+
+
+

Parameters:

+
    + +
  • + + timeout + + + (Float) + + + (defaults to: 0.0) + + + — +

    the longest to wait for more input to read

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    whether the socket has data ready for reading

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 20
+
+def ready_to_read?(timeout = 0.0)
+  r, _, e = IO.select [@from], [], [@from, @to].uniq, timeout
+
+  # On timeout, select returns nil instead of arrays.
+  return if r.nil?
+
+  unless e.empty?
+    raise "#{@i_am}: Got error on connection(s) from IO.select! Dying!"
+  end
+
+  !r.empty?
+end
+
+
+ +
+

+ + #receive_datagramString + + + + + +

+
+

Read data from the internal socket. Read until a whole datagram +has been received and then return it.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the received datagram

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 59
+
+def receive_datagram
+  @readbuf ||= String.new.encode(Encoding::BINARY)
+  to_read = nil
+
+  loop do
+    # Have we read a packet length already, sitting in @readbuf?
+    a_idx = @readbuf.index("a")
+    if a_idx
+      to_read = @readbuf[0..a_idx].to_i
+      @readbuf = @readbuf[(a_idx + 1)..-1]
+      break
+    end
+
+    # If not, read more bytes
+    new_bytes = @from.read(10)
+    if new_bytes.nil?
+      # This is perfectly normal, if the connection closed
+      raise AppShutdownError, "Got an unexpected EOF reading datagram! " +
+        "Did the #{@i_am == :child ? "parent" : "child"} process die?"
+    end
+    @readbuf << new_bytes
+  end
+
+  loop do
+    if @readbuf.bytesize >= to_read
+      out = @readbuf.byteslice(0, to_read)
+      @readbuf = @readbuf.byteslice(to_read, -1)
+      return out
+    end
+
+    new_bytes = @from.read(to_read - @readbuf.bytesize)
+    @readbuf << new_bytes
+  end
+rescue
+  raise AppShutdownError, "Got exception #{$!.class} when receiving datagram... #{$!.inspect}"
+end
+
+
+ +
+

+ + #respond_to_datagramObject + + + + + +

+
+

Read a datagram from the internal buffer and then dispatch it to the +appropriate handler.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 98
+
+def respond_to_datagram
+  message = receive_datagram
+  m_data = JSON.parse(message)
+
+  if m_data["type"] == "event"
+    kwargs_hash = {}
+    m_data["kwargs"].each { |k, v| kwargs_hash[k.to_sym] = v }
+    send_shoes_event(
+      *m_data["args"],
+      event_name: m_data["kwargs"]["event_name"],
+      target: m_data["kwargs"]["event_target"],
+      **kwargs_hash,
+    )
+  elsif m_data["type"] == "create"
+    raise "Parent process should never receive :create datagram!" if @i_am == :parent
+
+    @wv_display.create_display_widget_for(m_data["class_name"], m_data["id"], m_data["properties"])
+  elsif m_data["type"] == "destroy"
+    if @i_am == :parent
+      @shutdown = true
+    else
+      @log.info("Shutting down...")
+      exit 0
+    end
+  else
+    @log.error("Unrecognized datagram type:event: #{m_data.inspect}!")
+  end
+end
+
+
+ +
+

+ + #send_datagram(contents) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Send bytes on the internal socket to the opposite side.

+ + +
+
+
+

Parameters:

+
    + +
  • + + contents + + + (String) + + + + — +

    data to send

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+
+
# File 'lib/scarpe/wv/webview_relay_util.rb', line 37
+
+def send_datagram(contents)
+  str_data = JSON.dump contents
+  dgram_str = (str_data.length.to_s + "a" + str_data).encode(Encoding::BINARY)
+  to_write = dgram_str.bytesize
+  written = 0
+
+  until written == to_write
+    count = @to.write(dgram_str.byteslice(written..-1))
+    if count.nil? || count == 0
+      raise "Something was wrong in send_datagram! Write returned #{count.inspect}!"
+    end
+
+    written += count
+  end
+
+  nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWrangler.html b/Scarpe/WebWrangler.html new file mode 100644 index 000000000..dcc25ae85 --- /dev/null +++ b/Scarpe/WebWrangler.html @@ -0,0 +1,2382 @@ + + + + + + + Class: Scarpe::WebWrangler + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebWrangler + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb,
+ lib/scarpe/wv/web_wrangler.rb,
lib/scarpe/wv/web_wrangler.rb
+
+
+ +
+ +

Overview

+
+

The Scarpe WebWrangler, for Webview, manages a lot of Webviews quirks. It provides +a simpler underlying abstraction for DOMWrangler and the Webview widgets. +Webview can be picky - if you send it too many messages, it can crash. If the +messages you send it are too large, it can crash. If you don't return control +to its event loop, it can crash. It doesn't save references to all event handlers, +so if you don't save references to them, garbage collection will cause it to +crash.

+ +

As well, Webview only supports asynchronous JS code evaluation with no value +being returned. One of WebWrangler's responsibilities is to make asynchronous +JS calls, detect when they return a value or time out, and make the result clear +to other Scarpe code.

+ +

Some Webview API functions will crash on some platforms if called from a +background thread. Webview will halt all background threads when it runs its +event loop. So it's best to assume no Ruby background threads will be available +while Webview is running. If a Ruby app wants ongoing work to occur, that work +should be registered via a heartbeat handler on the Webview.

+ +

A WebWrangler is initially in Setup mode, where the underlying Webview exists +but does not yet control the event loop. In Setup mode you can bind JS functions, +set up initialization code, but nothing is yet running.

+ +

Once run() is called on WebWrangler, we will hand control of the event loop to +the Webview. This will also stop any background threads in Ruby.

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: DOMWrangler, ElementWrangler, InternalError, JSEvalError, JSRuntimeError, JSTimeoutError + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
EVAL_RESULT = +
+
+

This is the JS function name for eval results (internal-only)

+ + +
+
+
+ + +
+
+
"scarpeAsyncEvalResult"
+ +
EVAL_DEFAULT_TIMEOUT = +
+
+

Allow this many seconds for Webview to finish our JS eval before we decide it's not going to

+ + +
+
+
+ + +
+
+
0.5
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #control_interface ⇒ Object + + + + + + + + + + + + + + + + +

    A reference to the control_interface that manages internal Scarpe Webview events.

    +
    + +
  • + + +
  • + + + #heartbeat ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    This is the time between heartbeats in seconds, usually fractional.

    +
    + +
  • + + +
  • + + + #is_running ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Whether Webview has been started.

    +
    + +
  • + + +
  • + + + #is_terminated ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Once Webview is marked terminated, it's attempting to shut down.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ +
    + +
  • + + + .js_wrapped_code(code, eval_id) ⇒ Object + + + + + + + + + + + + + +

    This method takes a piece of Javascript code and wraps it in the WebWrangler boilerplate to see if it parses successfully, run it, and see if it succeeds.

    +
    + +
  • + + +
+ +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initialize(title:, width:, height:, resizable: false, heartbeat: 0.1) ⇒ WebWrangler + + + + + +

+
+

Create a new WebWrangler.

+ + +
+
+
+

Parameters:

+
    + +
  • + + title + + + (String) + + + + — +

    window title

    +
    + +
  • + +
  • + + width + + + (Integer) + + + + — +

    window width in pixels

    +
    + +
  • + +
  • + + height + + + (Integer) + + + + — +

    window height in pixels

    +
    + +
  • + +
  • + + resizable + + + (Boolean) + + + (defaults to: false) + + + — +

    whether the window should be resizable by the user

    +
    + +
  • + +
  • + + heartbeat + + + (Float) + + + (defaults to: 0.1) + + + — +

    time between heartbeats in seconds

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 87
+
+def initialize(title:, width:, height:, resizable: false, heartbeat: 0.1)
+  log_init("WV::WebWrangler")
+
+  @log.debug("Creating WebWrangler...")
+
+  # For now, always allow inspect element, so pass debug: true
+  @webview = WebviewRuby::Webview.new debug: true
+  @webview = Shoes::LoggedWrapper.new(@webview, "WebviewAPI") if ENV["SCARPE_DEBUG"]
+  @init_refs = {} # Inits don't go away so keep a reference to them to prevent GC
+
+  @title = title
+  @width = width
+  @height = height
+  @resizable = resizable
+  @heartbeat = heartbeat
+
+  # JS setInterval uses RPC and is quite expensive. For many periodic operations
+  # we can group them under a single heartbeat handler and avoid extra JS calls or RPC.
+  @heartbeat_handlers = []
+
+  # Need to keep track of which WebView Javascript evals are still pending,
+  # what handlers to call when they return, etc.
+  @pending_evals = {}
+  @eval_counter = 0
+
+  @dom_wrangler = DOMWrangler.new(self)
+
+  bind("puts") do |*args|
+    puts(*args)
+  end
+
+  @webview.bind(EVAL_RESULT) do |*results|
+    receive_eval_result(*results)
+  end
+
+  # Ruby receives scarpeHeartbeat messages via the window library's main loop.
+  # So this is a way for Ruby to be notified periodically, in time with that loop.
+  @webview.bind("scarpeHeartbeat") do
+    return unless @webview # I think GTK+ may continue to deliver events after shutdown
+
+    periodic_js_callback
+    @heartbeat_handlers.each(&:call)
+    @control_interface.dispatch_event(:heartbeat)
+  end
+  js_interval = (heartbeat.to_f * 1_000.0).to_i
+  @webview.init("setInterval(scarpeHeartbeat,#{js_interval})")
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #control_interfaceObject + + + + + +

+
+

A reference to the control_interface that manages internal Scarpe Webview events.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+52
+53
+54
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 52
+
+def control_interface
+  @control_interface
+end
+
+
+ + + +
+

+ + #heartbeatObject (readonly) + + + + + +

+
+

This is the time between heartbeats in seconds, usually fractional

+ + +
+
+
+ + +
+ + + + +
+
+
+
+49
+50
+51
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 49
+
+def heartbeat
+  @heartbeat
+end
+
+
+ + + +
+

+ + #is_runningObject (readonly) + + + + + +

+
+

Whether Webview has been started. Once Webview is running you can't add new +Javascript bindings. Until it is running, you can't use eval to run Javascript.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 42
+
+def is_running
+  @is_running
+end
+
+
+ + + +
+

+ + #is_terminatedObject (readonly) + + + + + +

+
+

Once Webview is marked terminated, it's attempting to shut down. If we get +events (e.g. heartbeats) after that, we should ignore them.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 46
+
+def is_terminated
+  @is_terminated
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .js_wrapped_code(code, eval_id) ⇒ Object + + + + + +

+
+

This method takes a piece of Javascript code and wraps it in the WebWrangler +boilerplate to see if it parses successfully, run it, and see if it succeeds. +This function would normally be used by testing code, to mock Webview and +watch for code being run. Javascript code containing backticks +could potentially break this abstraction layer, which would cause the resulting +code to fail to parse and Webview would return no error. This should not be +used for random or untrusted code.

+ + +
+
+
+

Parameters:

+
    + +
  • + + code + + + (String) + + + + — +

    the Javascript code to be wrapped

    +
    + +
  • + +
  • + + eval_id + + + (Integer) + + + + — +

    the tracking code to use when calling EVAL_RESULT

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 300
+
+def self.js_wrapped_code(code, eval_id)
+  <<~JS_CODE
+    (function() {
+      var code_string = #{JSON.dump code};
+      try {
+        result = eval(code_string);
+        #{EVAL_RESULT}("success", #{eval_id}, result);
+      } catch(error) {
+        #{EVAL_RESULT}("error", #{eval_id}, error.message);
+      }
+    })();
+  JS_CODE
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #bind(name) { ... } ⇒ Object + + + + + +

+
+

Bind a Javascript-callable function by name. When JS calls the function, +an async message is sent to Ruby via RPC and will eventually cause the +block to be called. This method only works in setup mode, before the +underlying Webview has been told to run.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +

    the Javascript name for the new function

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    The Ruby block to be invoked when JS calls the function

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+151
+152
+153
+154
+155
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 151
+
+def bind(name, &block)
+  raise "App is running, javascript binding no longer works because it uses WebView init!" if @is_running
+
+  @webview.bind(name, &block)
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+
+

Request destruction of WebWrangler, including terminating the underlying +Webview and (when possible) destroying it.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 410
+
+def destroy
+  @log.debug("Destroying WebWrangler...")
+  @log.debug("  (WebWrangler was already terminated)") if @is_terminated
+  @log.debug("  (WebWrangler was already destroyed)") unless @webview
+  if @webview && !@is_terminated
+    @bindings = {}
+    @webview.terminate
+    @is_terminated = true
+  end
+end
+
+
+ +
+

+ + #dom_change(js) ⇒ Scarpe::Promise + + + + + +

+
+

Request a DOM change - return a promise for when this has been done. +If a full replacement (see #replace) is requested, this change may +be lost. Only use it for changes that are preserved by a full update.

+ + +
+
+
+

Parameters:

+
    + +
  • + + js + + + (String) + + + + — +

    the JS to execute to alter the DOM

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the update is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+486
+487
+488
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 486
+
+def dom_change(js)
+  @dom_wrangler.request_change(js)
+end
+
+
+ +
+

+ + #dom_fully_updated?Boolean + + + + + +

+
+

Return whether the DOM is, right this moment, confirmed to be fully +up to date or not.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    true if the window is fully updated, false if changes are pending

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+494
+495
+496
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 494
+
+def dom_fully_updated?
+  @dom_wrangler.fully_updated?
+end
+
+
+ +
+

+ + #dom_promise_redrawScarpe::Promise + + + + + +

+
+

Return a promise that will be fulfilled when all current DOM changes +have committed. If other changes are requested before these +complete, the promise will not wait for them. If you wish to +wait until all changes from all sources have completed, use

+ +

promise_dom_fully_updated.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when all current changes complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+505
+506
+507
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 505
+
+def dom_promise_redraw
+  @dom_wrangler.promise_redraw
+end
+
+
+ +
+

+ + #eval_js_async(code, timeout: EVAL_DEFAULT_TIMEOUT, wait_for: []) ⇒ Object + + + + + +

+
+

Eval a chunk of JS code asynchronously. This method returns a +promise which will be fulfilled or rejected after the JS executes +or times out.

+ +

We both care whether the JS has finished after it was +scheduled and whether it ever got scheduled at all. If it +depends on tasks that never fulfill or reject then it will +raise a timed-out exception.

+ +

Right now we can't/don't pass arguments through from previous fulfilled +promises. To do that, you can schedule the JS to run after the +other promises succeed.

+ +

Webview does not allow interacting with a JS eval once it has +been scheduled. So there is no way to guarantee that a piece of JS has +not executed, or will not execute in the future. A timeout exception +only means that WebWrangler will no longer wait for confirmation or +fulfill the promise if the JS later completes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + code + + + (String) + + + + — +

    the Javascript code to execute

    +
    + +
  • + +
  • + + timeout + + + (Float) + + + (defaults to: EVAL_DEFAULT_TIMEOUT) + + + — +

    how long to allow before raising a timeout exception

    +
    + +
  • + +
  • + + wait_for + + + (Array<Promise>) + + + (defaults to: []) + + + — +

    promises that must complete successfully before this JS is scheduled

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 246
+
+def eval_js_async(code, timeout: EVAL_DEFAULT_TIMEOUT, wait_for: [])
+  unless @is_running
+    raise "WebWrangler isn't running, so evaluating JS won't work!"
+  end
+
+  this_eval_serial = @eval_counter
+  @eval_counter += 1
+
+  @pending_evals[this_eval_serial] = {
+    id: this_eval_serial,
+    code: code,
+    start_time: Time.now,
+    timeout_if_not_scheduled: Time.now + EVAL_DEFAULT_TIMEOUT,
+  }
+
+  # We'll need this inside the promise-scheduling block
+  pending_evals = @pending_evals
+
+  promise = Scarpe::Promise.new(parents: wait_for) do
+    # Are we mid-shutdown?
+    if @webview
+      wrapped_code = WebWrangler.js_wrapped_code(code, this_eval_serial)
+
+      # We've been scheduled!
+      t_now = Time.now
+      # Hard to be sure Webview keeps a proper reference to this, so we will
+      pending_evals[this_eval_serial][:wrapped_code] = wrapped_code
+
+      pending_evals[this_eval_serial][:scheduled_time] = t_now
+      pending_evals[this_eval_serial].delete(:timeout_if_not_scheduled)
+
+      pending_evals[this_eval_serial][:timeout_if_not_finished] = t_now + timeout
+      @webview.eval(wrapped_code)
+      @log.debug("Scheduled JS: (#{this_eval_serial})\n#{wrapped_code}")
+    else
+      # We're mid-shutdown. No more scheduling things.
+    end
+  end
+
+  @pending_evals[this_eval_serial][:promise] = promise
+
+  promise
+end
+
+
+ +
+

+ + #init_code(name) { ... } ⇒ Object + + + + + +

+
+

Request that this block of code be run initially when the Webview is run. +This operates via #init and will not work if Webview is already running.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +

    the Javascript name for the init function

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    The Ruby block to be invoked when Webview runs

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 162
+
+def init_code(name, &block)
+  raise "App is running, javascript init no longer works!" if @is_running
+
+  # Save a reference to the init string so that it doesn't get GC'd
+  code_str = "#{name}();"
+  @init_refs[name] = code_str
+
+  bind(name, &block)
+  @webview.init(code_str)
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+
+

Shorter name for better stack trace messages

+ + +
+
+
+ + +
+ + + + +
+
+
+
+136
+137
+138
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 136
+
+def inspect
+  "Scarpe::WebWrangler:#{object_id}"
+end
+
+
+ +
+

+ + #js_eventually(code) ⇒ void + + + + + +

+
+

This method returns an undefined value.

js_eventually is a native Webview JS evaluation. On syntax error, nothing happens. +On runtime error, execution stops at the error with no further +effect or notification. This is rarely what you want. +The js_eventually code is run asynchronously, returning neither error +nor value.

+ +

This method does not return a promise, and there is no way to track +its progress or its success or failure.

+ + +
+
+
+

Parameters:

+
    + +
  • + + code + + + (String) + + + + — +

    the Javascript code to attempt to execute

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+216
+217
+218
+219
+220
+221
+222
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 216
+
+def js_eventually(code)
+  raise "WebWrangler isn't running, eval doesn't work!" unless @is_running
+
+  @log.warn "Deprecated: please do NOT use js_eventually, it's basically never what you want!" unless ENV["CI"]
+
+  @webview.eval(code)
+end
+
+
+ +
+

+ + #on_every_redraw { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

DOMWrangler will frequently schedule and confirm small JS updates. +A handler registered with on_every_redraw will be called after each +small update.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    Called after each update or batch of updates is verified complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+532
+533
+534
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 532
+
+def on_every_redraw(&block)
+  @dom_wrangler.on_every_redraw(&block)
+end
+
+
+ +
+

+ + #periodic_code(name, interval = heartbeat) { ... } ⇒ Object + + + + + +

+
+

Run the specified code periodically, every "interval" seconds. +If interval is unspecified, run per-heartbeat. This avoids extra +RPC and Javascript overhead. This may use the #init mechanism, +so it should be invoked when the WebWrangler is in setup mode, +before the Webview is running.

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +

    the name of the Javascript init function, if needed

    +
    + +
  • + +
  • + + interval + + + (Float) + + + (defaults to: heartbeat) + + + — +

    the duration between invoking this block

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    the Ruby block to invoke periodically

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 182
+
+def periodic_code(name, interval = heartbeat, &block)
+  if interval == heartbeat
+    @heartbeat_handlers << block
+  else
+    if @is_running
+      # I *think* we need to use init because we want this done for every
+      # new window. But will there ever be a new page/window? Can we just
+      # use eval instead of init to set up a periodic handler and call it
+      # good?
+      raise "App is running, can't set up new periodic handlers with init!"
+    end
+
+    js_interval = (interval.to_f * 1_000.0).to_i
+    code_str = "setInterval(#{name}, #{js_interval});"
+    @init_refs[name] = code_str
+
+    bind(name, &block)
+    @webview.init(code_str)
+  end
+end
+
+
+ +
+

+ + #promise_dom_fully_updatedScarpe::Promise + + + + + +

+
+

Return a promise which will be fulfilled the next time the DOM is +fully up to date. A slow trickle of changes can make this +take a long time, since it includes all current and future changes, +not just changes before this call.

+ +

If you want to know that some specific individual change is done, it's often +easiest to use the promise returned by #dom_change, which will +be fulfilled when that specific change is verified complete.

+ +

If no changes are pending, promise_dom_fully_updated will +return a promise that is already fulfilled.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when all changes are complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+522
+523
+524
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 522
+
+def promise_dom_fully_updated
+  @dom_wrangler.promise_fully_updated
+end
+
+
+ +
+

+ + #replace(html_text) ⇒ Scarpe::Promise + + + + + +

+
+

Replace the entire DOM - return a promise for when this has been done. +This will often get rid of smaller changes in the queue, which is +a good thing since they won't have to be run.

+ + +
+
+
+

Parameters:

+
    + +
  • + + html_text + + + (String) + + + + — +

    The new HTML for the new full DOM

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the update is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+476
+477
+478
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 476
+
+def replace(html_text)
+  @dom_wrangler.request_replace(html_text)
+end
+
+
+ +
+

+ + #runObject + + + + + +

+
+

After setup, we call run to go to "running" mode. +No more setup callbacks should be called, only running callbacks.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 385
+
+def run
+  @log.debug("Run...")
+
+  # From webview:
+  # 0 - Width and height are default size
+  # 1 - Width and height are minimum bonds
+  # 2 - Width and height are maximum bonds
+  # 3 - Window size can not be changed by a user
+  hint = @resizable ? 0 : 3
+
+  @webview.set_title(@title)
+  @webview.set_size(@width, @height, hint)
+  @webview.navigate("data:text/html, #{empty}")
+
+  monkey_patch_console(@webview)
+
+  @is_running = true
+  @webview.run
+  @is_running = false
+  @webview.destroy
+  @webview = nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWrangler/DOMWrangler.html b/Scarpe/WebWrangler/DOMWrangler.html new file mode 100644 index 000000000..3f11cd58a --- /dev/null +++ b/Scarpe/WebWrangler/DOMWrangler.html @@ -0,0 +1,1186 @@ + + + + + + + Class: Scarpe::WebWrangler::DOMWrangler + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebWrangler::DOMWrangler + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

Leaving DOM changes as "meh, async, we'll see when it happens" is terrible for testing. +Instead, we need to track whether particular changes have committed yet or not. +So we add a single gateway for all DOM changes, and we make sure its work is done +before we consider a redraw complete.

+ +

DOMWrangler batches up changes into fewer RPC calls. It's fine to have a redraw +"in flight" and have changes waiting to catch the next bus. But we don't want more +than one in flight, since it seems like having too many pending RPC requests can +crash Webview. So we allow one redraw scheduled and one redraw promise waiting, +at maximum.

+ +

A WebWrangler will create and wrap a DOMWrangler, serving as the interface +for all DOM operations.

+ +

A batch of DOMWrangler changes may be removed if a full update is scheduled. That +update is considered to replace the previous incremental changes. Any changes that +need to execute even if a full update happens should be scheduled through +WebWrangler#eval_js_async, not DOMWrangler.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #pending_redraw_promise ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    A Scarpe::Promise for JS that has been scheduled to execute but is not yet verified complete.

    +
    + +
  • + + +
  • + + + #waiting_changes ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Changes that have not yet been executed.

    +
    + +
  • + + +
  • + + + #waiting_redraw_promise ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    A Scarpe::Promise for waiting changes - it will be fulfilled when all waiting changes have been verified complete, or when a full redraw that removed them has been verified complete.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initialize(web_wrangler) ⇒ DOMWrangler + + + + + +

+
+

Create a DOMWrangler that is paired with a WebWrangler. The WebWrangler is +treated as an underlying abstraction for reliable JS evaluation.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 575
+
+def initialize(web_wrangler)
+  log_init("WV::WebWrangler::DOMWrangler")
+
+  @wrangler = web_wrangler
+
+  @waiting_changes = []
+  @pending_redraw_promise = nil
+  @waiting_redraw_promise = nil
+
+  @fully_up_to_date_promise = nil
+
+  # Initially we're waiting for a full replacement to happen.
+  # It's possible to request updates/changes before we have
+  # a DOM in place and before Webview is running. If we do
+  # that, we should discard those updates.
+  @first_draw_requested = false
+
+  @redraw_handlers = []
+
+  # The "fully up to date" logic is complicated and not
+  # as well tested as I'd like. This makes it far less
+  # likely that the event simply won't fire.
+  # With more comprehensive testing, this should be
+  # removable.
+  web_wrangler.periodic_code("scarpeDOMWranglerHeartbeat") do
+    if @fully_up_to_date_promise && fully_updated?
+      @log.info("Fulfilling up-to-date promise on heartbeat")
+      @fully_up_to_date_promise.fulfilled!
+      @fully_up_to_date_promise = nil
+    end
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #pending_redraw_promiseObject (readonly) + + + + + +

+
+

A Scarpe::Promise for JS that has been scheduled to execute but is not yet verified complete

+ + +
+
+
+ + +
+ + + + +
+
+
+
+565
+566
+567
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 565
+
+def pending_redraw_promise
+  @pending_redraw_promise
+end
+
+
+ + + +
+

+ + #waiting_changesObject (readonly) + + + + + +

+
+

Changes that have not yet been executed

+ + +
+
+
+ + +
+ + + + +
+
+
+
+562
+563
+564
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 562
+
+def waiting_changes
+  @waiting_changes
+end
+
+
+ + + +
+

+ + #waiting_redraw_promiseObject (readonly) + + + + + +

+
+

A Scarpe::Promise for waiting changes - it will be fulfilled when all waiting changes +have been verified complete, or when a full redraw that removed them has been +verified complete. If many small changes are scheduled, the same promise will be +returned for many of them.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+571
+572
+573
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 571
+
+def waiting_redraw_promise
+  @waiting_redraw_promise
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .replacement_code(html_text) ⇒ Object + + + + + +

+ + + + +
+
+
+
+617
+618
+619
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 617
+
+def self.replacement_code(html_text)
+  "document.getElementById('wrapper-wvroot').innerHTML = `#{html_text}`; true"
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #fully_updated?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+736
+737
+738
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 736
+
+def fully_updated?
+  @pending_redraw_promise.nil? && @waiting_redraw_promise.nil? && @waiting_changes.empty?
+end
+
+
+ +
+

+ + #on_every_redraw(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+630
+631
+632
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 630
+
+def on_every_redraw(&block)
+  @redraw_handlers << block
+end
+
+
+ +
+

+ + #promise_fully_updatedObject + + + + + +

+
+

Return a promise which will be fulfilled when the DOM is fully up-to-date

+ + +
+
+
+ + +
+ + + + +
+
+
+
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 741
+
+def promise_fully_updated
+  if fully_updated?
+    # No changes to make, nothing in-process or waiting, so just return a pre-fulfilled promise
+    return Promise.fulfilled
+  end
+
+  # Do we already have a promise for this? Return it. Everybody can share one.
+  if @fully_up_to_date_promise
+    return @fully_up_to_date_promise
+  end
+
+  # We're not fully updated, so we need a promise. Create it, return it.
+  @fully_up_to_date_promise = Promise.new
+end
+
+
+ +
+

+ + #promise_redrawObject + + + + + +

+
+

promise_redraw returns a Scarpe::Promise which will be fulfilled after all current +pending or waiting changes have completed. This may require creating a new +promise.

+ +

What are the states of redraw? +"empty" - no waiting promise, no pending-redraw promise, no pending changes +"pending only" - no waiting promise, but we have a pending redraw with some changes; it hasn't committed yet +"pending and waiting" - we have a waiting promise for our unscheduled changes; we can add more unscheduled + changes since we haven't scheduled them yet.

+ +

This is often called after adding a new waiting change or replacing them, so the state may have just changed. +It can also be called when no changes have been made and no updates need to happen.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 646
+
+def promise_redraw
+  if fully_updated?
+    # No changes to make, nothing in-process or waiting, so just return a pre-fulfilled promise
+    @log.debug("Requesting redraw but there are no pending changes or promises, return pre-fulfilled")
+    return Promise.fulfilled
+  end
+
+  # Already have a redraw requested *and* one on deck? Then all current changes will have committed
+  # when we (eventually) fulfill the waiting_redraw_promise.
+  if @waiting_redraw_promise
+    @log.debug("Promising eventual redraw of #{@waiting_changes.size} waiting unscheduled changes.")
+    return @waiting_redraw_promise
+  end
+
+  if @waiting_changes.empty?
+    # There's no waiting_redraw_promise. There are no waiting changes. But we're not fully updated.
+    # So there must be a redraw in flight, and we don't need to schedule a new waiting_redraw_promise.
+    @log.debug("Returning in-flight redraw promise")
+    return @pending_redraw_promise
+  end
+
+  @log.debug("Requesting redraw with #{@waiting_changes.size} waiting changes and no waiting promise - need to schedule something!")
+
+  # We have at least one waiting change, possibly newly-added. We have no waiting_redraw_promise.
+  # Do we already have a redraw in-flight?
+  if @pending_redraw_promise
+    # Yes we do. Schedule a new waiting promise. When it turns into the pending_redraw_promise it will
+    # grab all waiting changes. In the mean time, it sits here and waits.
+    #
+    # We *could* do a fancy promise thing and have it update @waiting_changes for itself, etc, when it
+    # schedules itself. But we should always be calling promise_redraw or having a redraw fulfilled (see below)
+    # when these things change. I'd rather keep the logic in this method. It's easier to reason through
+    # all the cases.
+    @waiting_redraw_promise = Promise.new
+
+    @log.debug("Creating a new waiting promise since a pending promise is already in place")
+    return @waiting_redraw_promise
+  end
+
+  # We have no redraw in-flight and no pre-existing waiting line. The new change(s) are presumably right
+  # after things were fully up-to-date. We can schedule them for immediate redraw.
+
+  @log.debug("Requesting redraw with #{@waiting_changes.size} waiting changes - scheduling a new redraw for them!")
+  promise = schedule_waiting_changes # This clears the waiting changes
+  @pending_redraw_promise = promise
+
+  promise.on_fulfilled do
+    @redraw_handlers.each(&:call)
+    @pending_redraw_promise = nil
+
+    if @waiting_redraw_promise
+      # While this redraw was in flight, more waiting changes got added and we made a promise
+      # about when they'd complete. Now they get scheduled, and we'll fulfill the waiting
+      # promise when that redraw finishes. Clear the old waiting promise. We'll add a new one
+      # when/if more changes are scheduled during this redraw.
+      old_waiting_promise = @waiting_redraw_promise
+      @waiting_redraw_promise = nil
+
+      @log.debug "Fulfilled redraw with #{@waiting_changes.size} waiting changes - scheduling a new redraw for them!"
+
+      new_promise = promise_redraw
+      new_promise.on_fulfilled { old_waiting_promise.fulfilled! }
+    else
+      # The in-flight redraw completed, and there's still no waiting promise. Good! That means
+      # we should be fully up-to-date.
+      @log.debug "Fulfilled redraw with no waiting changes - marking us as up to date!"
+      if @waiting_changes.empty?
+        # We're fully up to date! Fulfill the promise. Now we don't need it again until somebody asks
+        # us for another.
+        if @fully_up_to_date_promise
+          @fully_up_to_date_promise.fulfilled!
+          @fully_up_to_date_promise = nil
+        end
+      else
+        @log.error "WHOAH, WHAT? My logic must be wrong, because there's " +
+          "no waiting promise, but waiting changes!"
+      end
+    end
+
+    @log.debug("Redraw is now fully up-to-date") if fully_updated?
+  end.on_rejected do
+    @log.error "Could not complete JS redraw! #{promise.reason.full_message}"
+    @log.debug("REDRAW FULLY UP TO DATE BUT JS FAILED") if fully_updated?
+
+    raise "JS Redraw failed! Bailing!"
+
+    # Later we should figure out how to handle this. Clear the promises and queues and request another redraw?
+  end
+end
+
+
+ +
+

+ + #request_change(js_code) ⇒ Object + + + + + +

+ + + + +
+
+
+
+608
+609
+610
+611
+612
+613
+614
+615
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 608
+
+def request_change(js_code)
+  # No updates until there's something to update
+  return unless @first_draw_requested
+
+  @waiting_changes << js_code
+
+  promise_redraw
+end
+
+
+ +
+

+ + #request_replace(html_text) ⇒ Object + + + + + +

+ + + + +
+
+
+
+621
+622
+623
+624
+625
+626
+627
+628
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 621
+
+def request_replace(html_text)
+  # Replace other pending changes, they're not needed any more
+  @waiting_changes = [DOMWrangler.replacement_code(html_text)]
+  @first_draw_requested = true
+
+  @log.debug("Requesting DOM replacement...")
+  promise_redraw
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWrangler/ElementWrangler.html b/Scarpe/WebWrangler/ElementWrangler.html new file mode 100644 index 000000000..62d3a94a5 --- /dev/null +++ b/Scarpe/WebWrangler/ElementWrangler.html @@ -0,0 +1,1069 @@ + + + + + + + Class: Scarpe::WebWrangler::ElementWrangler + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebWrangler::ElementWrangler + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

An ElementWrangler provides a way for a Widget to manipulate is DOM element(s) +via their HTML IDs. The most straightforward Widgets can have a single HTML ID +and use a single ElementWrangler to make any needed changes.

+ +

For now we don't need an ElementWrangler to add DOM elements, just to manipulate them +after initial render. New DOM objects for Widgets are normally added via full +redraws rather than incremental updates.

+ +

Any changes made via ElementWrangler may be cancelled if a full redraw occurs, +since it is assumed that small DOM manipulations are no longer needed. If a +change would need to be made even if a full redraw occurred, it should be +scheduled via WebWrangler#eval_js_async, not via an ElementWrangler.

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #html_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute html_id.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(html_id) ⇒ ElementWrangler + + + + + +

+
+

Create an ElementWrangler for the given HTML ID

+ + +
+
+
+

Parameters:

+
    + +
  • + + html_id + + + (String) + + + + — +

    the HTML ID for the DOM element

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+791
+792
+793
+794
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 791
+
+def initialize(html_id)
+  @webwrangler = WebviewDisplayService.instance.wrangler
+  @html_id = html_id
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #html_idObject (readonly) + + + + + +

+
+

Returns the value of attribute html_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+786
+787
+788
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 786
+
+def html_id
+  @html_id
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #inner_html=(new_html) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's inner_html. The given Ruby value will be converted to string and assigned in backquotes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + new_html + + + (String) + + + + — +

    the new inner_html

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+824
+825
+826
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 824
+
+def inner_html=(new_html)
+  @webwrangler.dom_change("document.getElementById(\"" + html_id + "\").innerHTML = `" + new_html + "`; true")
+end
+
+
+ +
+

+ + #inner_text=(new_text) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's inner_text. The given Ruby value will be converted to string and assigned in single-quotes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + new_text + + + (String) + + + + — +

    the new inner_text

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+816
+817
+818
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 816
+
+def inner_text=(new_text)
+  @webwrangler.dom_change("document.getElementById('" + html_id + "').innerText = '" + new_text + "'; true")
+end
+
+
+ +
+

+ + #promise_updateScarpe::Promise + + + + + +

+
+

Return a promise that will be fulfilled when all changes scheduled via +this ElementWrangler are verified complete.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when scheduled changes are complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+800
+801
+802
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 800
+
+def promise_update
+  @webwrangler.dom_promise_redraw
+end
+
+
+ +
+

+ + #removeScarpe::Promise + + + + + +

+
+

Remove the specified DOM element

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that wil be fulfilled when the element is removed

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+849
+850
+851
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 849
+
+def remove
+  @webwrangler.dom_change("document.getElementById('" + html_id + "').remove(); true")
+end
+
+
+ +
+

+ + #set_attribute(attribute, value) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's inner_html. The given Ruby value will be inspected and assigned.

+ + +
+
+
+

Parameters:

+
    + +
  • + + attribute + + + (String) + + + + — +

    the attribute name

    +
    + +
  • + +
  • + + value + + + (String) + + + + — +

    the new attribute value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+833
+834
+835
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 833
+
+def set_attribute(attribute, value)
+  @webwrangler.dom_change("document.getElementById(\"" + html_id + "\").setAttribute(" + attribute.inspect + "," + value.inspect + "); true")
+end
+
+
+ +
+

+ + #set_style(style_attr, value) ⇒ Scarpe::Promise + + + + + +

+
+

Update an attribute of the JS DOM element's style. The given Ruby value will be inspected and assigned.

+ + +
+
+
+

Parameters:

+
    + +
  • + + style_attr + + + (String) + + + + — +

    the style attribute name

    +
    + +
  • + +
  • + + value + + + (String) + + + + — +

    the new style attribute value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+842
+843
+844
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 842
+
+def set_style(style_attr, value)
+  @webwrangler.dom_change("document.getElementById(\"" + html_id + "\").style.#{style_attr} = " + value.inspect + "; true")
+end
+
+
+ +
+

+ + #toggle_input_button(mark) ⇒ Object + + + + + +

+ + + + +
+
+
+
+853
+854
+855
+856
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 853
+
+def toggle_input_button(mark)
+  checked_value = mark ? "true" : "false"
+  @webwrangler.dom_change("document.getElementById('#{html_id}').checked = #{checked_value};")
+end
+
+
+ +
+

+ + #value=(new_value) ⇒ Scarpe::Promise + + + + + +

+
+

Update the JS DOM element's value. The given Ruby value will be converted to string and assigned in backquotes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + new_value + + + (String) + + + + — +

    the new value

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when the change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+808
+809
+810
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 808
+
+def value=(new_value)
+  @webwrangler.dom_change("document.getElementById('" + html_id + "').value = `" + new_value + "`; true")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWrangler/InternalError.html b/Scarpe/WebWrangler/InternalError.html new file mode 100644 index 000000000..fdb692f99 --- /dev/null +++ b/Scarpe/WebWrangler/InternalError.html @@ -0,0 +1,161 @@ + + + + + + + Exception: Scarpe::WebWrangler::InternalError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::WebWrangler::InternalError + + + +

+
+ +
+
Inherits:
+
+ JSEvalError + +
    +
  • Object
  • + + + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

We got weird or nonsensical results that seem like an error on WebWrangler's part

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from JSEvalError

+

#initialize

+ + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::WebWrangler::JSEvalError

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWrangler/JSEvalError.html b/Scarpe/WebWrangler/JSEvalError.html new file mode 100644 index 000000000..8b81d0d22 --- /dev/null +++ b/Scarpe/WebWrangler/JSEvalError.html @@ -0,0 +1,228 @@ + + + + + + + Exception: Scarpe::WebWrangler::JSEvalError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::WebWrangler::JSEvalError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

This error indicates a problem when running ConfirmedEval

+ + +
+
+
+ + +
+

Direct Known Subclasses

+

InternalError, JSRuntimeError, JSTimeoutError

+
+ + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + +
+

Constructor Details

+ +
+

+ + #initialize(data) ⇒ JSEvalError + + + + + +

+
+

Returns a new instance of JSEvalError.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+56
+57
+58
+59
+
+
# File 'lib/scarpe/wv/web_wrangler.rb', line 56
+
+def initialize(data)
+  @data = data
+  super(data[:msg] || (self.class.name + "!"))
+end
+
+
+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWrangler/JSRuntimeError.html b/Scarpe/WebWrangler/JSRuntimeError.html new file mode 100644 index 000000000..7e9ddadcf --- /dev/null +++ b/Scarpe/WebWrangler/JSRuntimeError.html @@ -0,0 +1,161 @@ + + + + + + + Exception: Scarpe::WebWrangler::JSRuntimeError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::WebWrangler::JSRuntimeError + + + +

+
+ +
+
Inherits:
+
+ JSEvalError + +
    +
  • Object
  • + + + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

An error running the supplied JS code string in confirmed_eval

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from JSEvalError

+

#initialize

+ + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::WebWrangler::JSEvalError

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebWrangler/JSTimeoutError.html b/Scarpe/WebWrangler/JSTimeoutError.html new file mode 100644 index 000000000..890824a88 --- /dev/null +++ b/Scarpe/WebWrangler/JSTimeoutError.html @@ -0,0 +1,161 @@ + + + + + + + Exception: Scarpe::WebWrangler::JSTimeoutError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Scarpe::WebWrangler::JSTimeoutError + + + +

+
+ +
+
Inherits:
+
+ JSEvalError + +
    +
  • Object
  • + + + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/web_wrangler.rb
+
+ +
+ +

Overview

+
+

The code timed out for some reason

+ + +
+
+
+ + +
+ + + + + + + + + + + + + +

Method Summary

+ +

Methods inherited from JSEvalError

+

#initialize

+ + + + + + + +
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::WebWrangler::JSEvalError

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview.html b/Scarpe/Webview.html new file mode 100644 index 000000000..935590242 --- /dev/null +++ b/Scarpe/Webview.html @@ -0,0 +1,125 @@ + + + + + + + Module: Scarpe::Webview + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::Webview + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv.rb
+
+ +
+ +

Overview

+
+

Module to contain the various Scarpe Webview classes

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + + + Classes: ContainedService + + +

+ + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/Webview/ContainedService.html b/Scarpe/Webview/ContainedService.html new file mode 100644 index 000000000..e098f2816 --- /dev/null +++ b/Scarpe/Webview/ContainedService.html @@ -0,0 +1,441 @@ + + + + + + + Class: Scarpe::Webview::ContainedService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::Webview::ContainedService + + + +

+
+ +
+
Inherits:
+
+ Shoes::Linkable + + + show all + +
+
+ + + + + + +
+
Includes:
+
Scarpe::WVRelayUtil, Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/wv_display_worker.rb
+
+ +
+ +

Overview

+
+

This is the implementation of a freestanding Scarpe Webview display server, +which connects via sockets and sends events and properties back and forth +with a display-less Shoes app. The interface is designed to allow fork-based +usage, where a parent process could create a paired sockets and start the +child server. It can also be used via TCP sockets or similar, where a single +socket is both input and output.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #log ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute log.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Scarpe::WVRelayUtil

+

#event_loop_for, #ready_to_read?, #receive_datagram, #respond_to_datagram, #send_datagram

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(from, to) ⇒ ContainedService + + + + + +

+
+

Create a new DisplayService.

+ + +
+
+
+

Parameters:

+
    + +
  • + + from + + + (Socket) + + + + — +

    a readable socket to get input from the Shoes process

    +
    + +
  • + +
  • + + to + + + (Socket) + + + + — +

    a writable socket on which to send output to the Shoes process

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+
+
# File 'lib/scarpe/wv/wv_display_worker.rb', line 39
+
+def initialize(from, to)
+  super()
+  log_init("WV::DisplayWorker")
+
+  @i_am = :child
+  @event_subs = []
+  @wv_display = Scarpe::WebviewDisplayService.new
+
+  @from = from
+  @to = to
+
+  @init_done = false
+
+  # Wait to register our periodic_code until the wrangler exists
+  @event_subs << bind_shoes_event(event_name: "init") do
+    @wv_display.wrangler.periodic_code("datagramProcessor", 0.1) do
+      respond_to_datagram while ready_to_read?(0.0)
+    end
+    @init_done = true
+  end
+
+  # Subscribe to all event notifications and relay them to the opposite side
+  @event_subs << bind_shoes_event(event_name: :any, target: :any) do |*args, **kwargs|
+    unless kwargs[:relayed] || kwargs["relayed"]
+      kwargs[:relayed] = true
+      send_datagram({ type: :event, args:, kwargs: })
+    end
+  end
+
+  # Run for 2.5 seconds to let the app be created and "run" to get called.
+  # Once that happens, Webview will take over the event loop.
+  event_loop_for(2.5)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #logObject (readonly) + + + + + +

+
+

Returns the value of attribute log.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lib/scarpe/wv/wv_display_worker.rb', line 33
+
+def log
+  @log
+end
+
+
+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewAlert.html b/Scarpe/WebviewAlert.html new file mode 100644 index 000000000..6e893ecb0 --- /dev/null +++ b/Scarpe/WebviewAlert.html @@ -0,0 +1,599 @@ + + + + + + + Class: Scarpe::WebviewAlert + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewAlert + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/alert.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewAlert + + + + + +

+
+

Returns a new instance of WebviewAlert.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+
+
# File 'lib/scarpe/wv/alert.rb', line 5
+
+def initialize(properties)
+  super
+
+  bind("click") do
+    send_self_event(event_name: "click")
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #button_styleObject (protected) + + + + + +

+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lib/scarpe/wv/alert.rb', line 62
+
+def button_style
+  {}
+end
+
+
+ +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+
+
# File 'lib/scarpe/wv/alert.rb', line 13
+
+def element
+  onclick = handler_js_code("click")
+
+  HTML.render do |h|
+    h.div(id: html_id, style: overlay_style) do
+      h.div(style: modal_style) do
+        h.div(style: text_style) { @text }
+        h.button(style: button_style, onclick: onclick) { "OK" }
+      end
+    end
+  end
+end
+
+
+ +
+ + + + + +
+
+
+
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+
+
# File 'lib/scarpe/wv/alert.rb', line 45
+
+def modal_style
+  {
+    "min-width": "200px",
+    "min-height": "50px",
+    padding: "10px",
+    display: "flex",
+    background: "#fefefe",
+    "flex-direction": "column",
+    "justify-content": "space-between",
+    "border-radius": "9px",
+  }
+end
+
+
+ +
+

+ + #overlay_styleObject (protected) + + + + + +

+
+

If the whole widget is hidden, the parent style adds display:none

+ + +
+
+
+ + +
+ + + + +
+
+
+
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+
+
# File 'lib/scarpe/wv/alert.rb', line 29
+
+def overlay_style
+  {
+    position: "fixed",
+    top: "0",
+    left: "0",
+    width: "100%",
+    height: "100%",
+    overflow: "auto",
+    "z-index": "1",
+    background: "rgba(0,0,0,0.4)",
+    display: "flex",
+    "align-items": "center",
+    "justify-content": "center",
+  }.merge(style)
+end
+
+
+ +
+

+ + #text_styleObject (protected) + + + + + +

+ + + + +
+
+
+
+58
+59
+60
+
+
# File 'lib/scarpe/wv/alert.rb', line 58
+
+def text_style
+  {}
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewApp.html b/Scarpe/WebviewApp.html new file mode 100644 index 000000000..ba27d2300 --- /dev/null +++ b/Scarpe/WebviewApp.html @@ -0,0 +1,994 @@ + + + + + + + Class: Scarpe::WebviewApp + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewApp + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/app.rb
+
+ +
+ +

Overview

+
+

Scarpe::WebviewApp must only be used from the main thread, due to GTK+ limitations.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+ + + + + + +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewApp + + + + + +

+
+

Returns a new instance of WebviewApp.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+
+
# File 'lib/scarpe/wv/app.rb', line 10
+
+def initialize(properties)
+  super
+
+  # It's possible to provide a Ruby script by setting
+  # SCARPE_TEST_CONTROL to its file path. This can
+  # allow pre-setting test options or otherwise
+  # performing additional actions not written into
+  # the Shoes app itself.
+  #
+  # The control interface is what lets these files see
+  # events, specify overrides and so on.
+  @control_interface = ControlInterface.new
+  if ENV["SCARPE_TEST_CONTROL"]
+    require "scarpe/components/unit_test_helpers"
+    @control_interface.instance_eval File.read(ENV["SCARPE_TEST_CONTROL"])
+  end
+
+  # TODO: rename @view
+  @view = Scarpe::WebWrangler.new title: @title,
+    width: @width,
+    height: @height,
+    resizable: @resizable
+
+  @callbacks = {}
+
+  # The control interface has to exist to get callbacks like "override Scarpe app opts".
+  # But the Scarpe App needs those options to be created. So we can't pass these to
+  # ControlInterface.new.
+  @control_interface.set_system_components app: self, doc_root: nil, wrangler: @view
+
+  bind_shoes_event(event_name: "init") { init }
+  bind_shoes_event(event_name: "run") { run }
+  bind_shoes_event(event_name: "destroy") { destroy }
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #control_interfaceObject (readonly) + + + + + +

+
+

Returns the value of attribute control_interface.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib/scarpe/wv/app.rb', line 6
+
+def control_interface
+  @control_interface
+end
+
+
+ + + +
+

+ + #document_root=(value) ⇒ Object (writeonly) + + + + + +

+
+

Sets the attribute document_root

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + + + + + — +

    the value to set the attribute document_root to.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lib/scarpe/wv/app.rb', line 45
+
+def document_root=(value)
+  @document_root = value
+end
+
+
+ + + +
+

+ + #shoes_linkable_id=(value) ⇒ Object (writeonly) + + + + + +

+
+

Sets the attribute shoes_linkable_id

+ + +
+
+
+

Parameters:

+
    + +
  • + + value + + + + + + + — +

    the value to set the attribute shoes_linkable_id to.

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/scarpe/wv/app.rb', line 8
+
+def shoes_linkable_id=(value)
+  @shoes_linkable_id = value
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #bind(name, &block) ⇒ Object + + + + + +

+
+

Bind a Scarpe callback name; see handle_callback above. +See Scarpe::Widget for how the naming is set up

+ + +
+
+
+ + +
+ + + + +
+
+
+
+91
+92
+93
+
+
# File 'lib/scarpe/wv/app.rb', line 91
+
+def bind(name, &block)
+  @callbacks[name] = block
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+ + + + +
+
+
+
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+
+
# File 'lib/scarpe/wv/app.rb', line 72
+
+def destroy
+  if @document_root || @view
+    @control_interface.dispatch_event :shutdown
+  end
+  @document_root = nil
+  if @view
+    @view.destroy
+    @view = nil
+  end
+end
+
+
+ +
+

+ + #handle_callback(name, *args) ⇒ Object + + + + + +

+
+

All JS callbacks to Scarpe widgets are dispatched +via this handler

+ + +
+
+
+ + +
+ + + + +
+
+
+
+85
+86
+87
+
+
# File 'lib/scarpe/wv/app.rb', line 85
+
+def handle_callback(name, *args)
+  @callbacks[name].call(*args)
+end
+
+
+ +
+

+ + #initObject + + + + + +

+ + + + +
+
+
+
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+
+
# File 'lib/scarpe/wv/app.rb', line 47
+
+def init
+  scarpe_app = self
+
+  @view.init_code("scarpeInit") do
+    request_redraw!
+  end
+
+  @view.bind("scarpeHandler") do |*args|
+    handle_callback(*args)
+  end
+
+  @view.bind("scarpeExit") do
+    scarpe_app.destroy
+  end
+end
+
+
+ +
+

+ + #request_redraw!void + + + + + +

+
+

This method returns an undefined value.

Request a full redraw if Webview is running. Otherwise +this is a no-op.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+99
+100
+101
+102
+103
+104
+105
+
+
# File 'lib/scarpe/wv/app.rb', line 99
+
+def request_redraw!
+  wrangler = WebviewDisplayService.instance.wrangler
+  if wrangler.is_running
+    wrangler.replace(@document_root.to_html)
+  end
+  nil
+end
+
+
+ +
+

+ + #runObject + + + + + +

+ + + + +
+
+
+
+63
+64
+65
+66
+67
+68
+69
+70
+
+
# File 'lib/scarpe/wv/app.rb', line 63
+
+def run
+  @control_interface.dispatch_event(:init)
+
+  # This takes control of the main thread and never returns. And it *must* be run from
+  # the main thread. And it stops any Ruby background threads.
+  # That's totally cool and normal, right?
+  @view.run
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewArc.html b/Scarpe/WebviewArc.html new file mode 100644 index 000000000..062ed4903 --- /dev/null +++ b/Scarpe/WebviewArc.html @@ -0,0 +1,388 @@ + + + + + + + Class: Scarpe::WebviewArc + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewArc + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/arc.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewArc + + + + + +

+
+

Returns a new instance of WebviewArc.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/arc.rb', line 5
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'lib/scarpe/wv/arc.rb', line 9
+
+def element(&block)
+  HTML.render do |h|
+    h.div(id: html_id, style: style) do
+      h.svg(width: @width, height: @height) do
+        h.path(d: arc_path)
+      end
+      block.call(h) if block_given?
+    end
+  end
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+28
+29
+
+
# File 'lib/scarpe/wv/arc.rb', line 22
+
+def style
+  super.merge({
+    left: "#{@left}px",
+    top: "#{@top}px",
+    width: "#{@width}px",
+    height: "#{@height}px",
+  })
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewBackground.html b/Scarpe/WebviewBackground.html new file mode 100644 index 000000000..7fe3eedfc --- /dev/null +++ b/Scarpe/WebviewBackground.html @@ -0,0 +1,213 @@ + + + + + + + Module: Scarpe::WebviewBackground + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::WebviewBackground + + + +

+
+ + + + + + +
+
Includes:
+
Components::Base64
+
+ + + + +
+
Included in:
+
WebviewSlot
+
+ + + +
+
Defined in:
+
lib/scarpe/wv/background.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + +
+

Instance Method Details

+ + +
+

+ + #styleObject + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lib/scarpe/wv/background.rb', line 9
+
+def style
+  styles = (super if defined?(super)) || {}
+  return styles unless @background_color
+
+  color = case @background_color
+  when Array
+    "rgba(#{@background_color.join(", ")})"
+  when Range
+    "linear-gradient(45deg, #{@background_color.first}, #{@background_color.last})"
+  when ->(value) { File.exist?(value) }
+    "url(data:image/png;base64,#{encode_file_to_base64(@background_color)})"
+  else
+    @background_color
+  end
+
+  styles.merge(background: color)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewBorder.html b/Scarpe/WebviewBorder.html new file mode 100644 index 000000000..badf9fde9 --- /dev/null +++ b/Scarpe/WebviewBorder.html @@ -0,0 +1,209 @@ + + + + + + + Module: Scarpe::WebviewBorder + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::WebviewBorder + + + +

+
+ + + + + + + + + +
+
Included in:
+
WebviewSlot
+
+ + + +
+
Defined in:
+
lib/scarpe/wv/border.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #styleObject + + + + + +

+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+
+
# File 'lib/scarpe/wv/border.rb', line 5
+
+def style
+  styles = (super if defined?(super)) || {}
+  return styles unless @border_color
+
+  border_color = case @border_color
+  when Range
+    { "border-image": "linear-gradient(45deg, #{@border_color.first}, #{@border_color.last})" }
+  when Array
+    { "border-color": "rgba(#{@border_color.join(", ")})" }
+  else
+    { "border-color": @border_color }
+  end
+  styles.merge(
+    "border-style": "solid",
+    "border-width": "#{@options[:strokewidth] || 1}px",
+    "border-radius": "#{@options[:curve] || 0}px",
+  ).merge(border_color)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewButton.html b/Scarpe/WebviewButton.html new file mode 100644 index 000000000..e48534374 --- /dev/null +++ b/Scarpe/WebviewButton.html @@ -0,0 +1,474 @@ + + + + + + + Class: Scarpe::WebviewButton + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewButton + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/button.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewButton + + + + + +

+
+

Returns a new instance of WebviewButton.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lib/scarpe/wv/button.rb', line 5
+
+def initialize(properties)
+  super
+
+  # Bind to display-side handler for "click"
+  bind("click") do
+    # This will be sent to the bind_self_event in Button
+    send_self_event(event_name: "click")
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/scarpe/wv/button.rb', line 15
+
+def element
+  HTML.render do |h|
+    h.button(id: html_id, onclick: handler_js_code("click"), style: style) do
+      @text
+    end
+  end
+end
+
+
+ +
+

+ + #font_sizeObject (protected) + + + + + +

+ + + + +
+
+
+
+46
+47
+48
+49
+50
+
+
# File 'lib/scarpe/wv/button.rb', line 46
+
+def font_size
+  font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size
+
+  Dimensions.length(font_size)
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+
+
# File 'lib/scarpe/wv/button.rb', line 25
+
+def style
+  styles = super
+
+  styles[:"background-color"] = @color
+  styles[:"padding-top"] = @padding_top
+  styles[:"padding-bottom"] = @padding_bottom
+  styles[:color] = @text_color
+  styles[:width] = Dimensions.length(@width) if @width
+  styles[:height] = Dimensions.length(@height) if @height
+  styles[:"font-size"] = @font_size
+
+  styles[:top] = Dimensions.length(@top) if @top
+  styles[:left] = Dimensions.length(@left) if @left
+  styles[:position] = "absolute" if @top || @left
+  styles[:"font-size"] = Dimensions.length(font_size) if @size
+  styles[:"font-family"] = @font if @font
+  styles[:color] = rgb_to_hex(@stroke) if @stroke
+
+  styles
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewCheck.html b/Scarpe/WebviewCheck.html new file mode 100644 index 000000000..291365146 --- /dev/null +++ b/Scarpe/WebviewCheck.html @@ -0,0 +1,464 @@ + + + + + + + Class: Scarpe::WebviewCheck + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewCheck + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/check.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute text.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewCheck + + + + + +

+
+

Returns a new instance of WebviewCheck.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lib/scarpe/wv/check.rb', line 7
+
+def initialize(properties)
+  super
+
+  bind("click") do
+    send_self_event(event_name: "click", target: shoes_linkable_id)
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

Returns the value of attribute text.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/check.rb', line 5
+
+def text
+  @text
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+23
+24
+25
+26
+27
+
+
# File 'lib/scarpe/wv/check.rb', line 23
+
+def element
+  HTML.render do |h|
+    h.input(type: :checkbox, id: html_id, onclick: handler_js_code("click"), value: "hmm #{text}", checked: @checked, style:)
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+
+
# File 'lib/scarpe/wv/check.rb', line 15
+
+def properties_changed(changes)
+  checked = changes.delete("checked")
+
+  html_element.toggle_input_button(checked)
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewDisplayService.html b/Scarpe/WebviewDisplayService.html new file mode 100644 index 000000000..343f711f4 --- /dev/null +++ b/Scarpe/WebviewDisplayService.html @@ -0,0 +1,898 @@ + + + + + + + Class: Scarpe::WebviewDisplayService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewDisplayService + + + +

+
+ +
+
Inherits:
+
+ Shoes::DisplayService + + + show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/webview_local_display.rb
+
+ +
+ +

Overview

+
+

This is the simplest type of Webview DisplayService. It creates Webview widgets +corresponding to Shoes widgets, manages the Webview and its DOM tree, and +generally keeps the Shoes/Webview connection working.

+ +

This is an in-process Webview-based display service, with all the limitations that +entails. Slow handlers will crash, ending this display service will end the +process, too many or too large evals can crash the process, etc. +Frequently it's better to use a RelayDisplayService to a second +process containing one of these.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Class Attribute Summary collapse

+
    + +
  • + + + .instance ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute instance.

    +
    + +
  • + + +
+ +

Instance Attribute Summary collapse

+
    + +
  • + + + #app ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    app is the Scarpe::WebviewApp.

    +
    + +
  • + + +
  • + + + #control_interface ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The ControlInterface is used to handle internal events in Webview Scarpe.

    +
    + +
  • + + +
  • + + + #doc_root ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The DocumentRoot is the top widget of the Webview-side widget tree.

    +
    + +
  • + + +
  • + + + #wrangler ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    wrangler is the Scarpe::WebWrangler.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::DisplayService

+

dispatch_event, display_service, full_reset!, #query_display_widget_for, set_display_service_class, #set_widget_pairing, subscribe_to_event, unsub_from_events

+
+

Constructor Details

+ +
+

+ + #initializeWebviewDisplayService + + + + + +

+
+

This is called before any of the various WebviewWidgets are created, to be +able to create them and look them up.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 34
+
+def initialize
+  if WebviewDisplayService.instance
+    raise "ERROR! This is meant to be a singleton!"
+  end
+
+  WebviewDisplayService.instance = self
+
+  super()
+  log_init("WV::WebviewDisplayService")
+
+  @display_widget_for = {}
+end
+
+
+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .instanceObject + + + + + +

+
+

Returns the value of attribute instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 17
+
+def instance
+  @instance
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #appObject (readonly) + + + + + +

+
+

app is the Scarpe::WebviewApp

+ + +
+
+
+ + +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 27
+
+def app
+  @app
+end
+
+
+ + + +
+

+ + #control_interfaceObject (readonly) + + + + + +

+
+

The ControlInterface is used to handle internal events in Webview Scarpe

+ + +
+
+
+ + +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 21
+
+def control_interface
+  @control_interface
+end
+
+
+ + + +
+

+ + #doc_rootObject (readonly) + + + + + +

+
+

The DocumentRoot is the top widget of the Webview-side widget tree

+ + +
+
+
+ + +
+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 24
+
+def doc_root
+  @doc_root
+end
+
+
+ + + +
+

+ + #wranglerObject (readonly) + + + + + +

+
+

wrangler is the Scarpe::WebWrangler

+ + +
+
+
+ + +
+ + + + +
+
+
+
+30
+31
+32
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 30
+
+def wrangler
+  @wrangler
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #create_display_widget_for(widget_class_name, widget_id, properties) ⇒ WebviewWidget + + + + + +

+
+

Create a Webview display widget for a specific Shoes widget, and pair it with +the linkable ID for this Shoes widget.

+ + +
+
+
+

Parameters:

+
    + +
  • + + widget_class_name + + + (String) + + + + — +

    The class name of the Shoes widget, e.g. Shoes::Button

    +
    + +
  • + +
  • + + widget_id + + + (String) + + + + — +

    the linkable ID for widget events

    +
    + +
  • + +
  • + + properties + + + (Hash) + + + + — +

    a JSON-serialisable Hash with the widget's display properties

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (WebviewWidget) + + + + — +

    the newly-created Webview widget

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 54
+
+def create_display_widget_for(widget_class_name, widget_id, properties)
+  if widget_class_name == "App"
+    unless @doc_root
+      raise "WebviewDocumentRoot is supposed to be created before WebviewApp!"
+    end
+
+    display_app = Scarpe::WebviewApp.new(properties)
+    display_app.document_root = @doc_root
+    @control_interface = display_app.control_interface
+    @control_interface.doc_root = @doc_root
+    @app = @control_interface.app
+    @wrangler = @control_interface.wrangler
+
+    set_widget_pairing(widget_id, display_app)
+
+    return display_app
+  end
+
+  # Create a corresponding display widget
+  display_class = Scarpe::WebviewWidget.display_class_for(widget_class_name)
+  display_widget = display_class.new(properties)
+  set_widget_pairing(widget_id, display_widget)
+
+  if widget_class_name == "DocumentRoot"
+    # WebviewDocumentRoot is created before WebviewApp. Mostly doc_root is just like any other widget,
+    # but we'll want a reference to it when we create WebviewApp.
+    @doc_root = display_widget
+  end
+
+  display_widget
+end
+
+
+ +
+

+ + #destroyvoid + + + + + +

+
+

This method returns an undefined value.

Destroy the display service and the app. Quit the process (eventually.)

+ + +
+
+
+ + +
+ + + + +
+
+
+
+89
+90
+91
+92
+
+
# File 'lib/scarpe/wv/webview_local_display.rb', line 89
+
+def destroy
+  @app.destroy
+  WebviewDisplayService.instance = nil
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewDocumentRoot.html b/Scarpe/WebviewDocumentRoot.html new file mode 100644 index 000000000..0c210f523 --- /dev/null +++ b/Scarpe/WebviewDocumentRoot.html @@ -0,0 +1,257 @@ + + + + + + + Class: Scarpe::WebviewDocumentRoot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewDocumentRoot + + + +

+
+ +
+
Inherits:
+
+ WebviewFlow + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/document_root.rb
+
+ +
+ +

Overview

+
+

A WebviewDocumentRoot is a WebviewFlow, with all the same properties +and basic behavior.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from WebviewSpacing

+

Scarpe::WebviewSpacing::SPACING_DIRECTIONS

+ + + +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + + + + + + + +

Method Summary

+ +

Methods inherited from WebviewFlow

+

#initialize, #style

+ + + + + + + + + +

Methods inherited from WebviewSlot

+

#attributes, #element, #initialize, #remove_event_callback, #remove_event_callbacks, #set_event_callback, #style, #update_dom_event

+ + + + + + + + + +

Methods included from WebviewSpacing

+

#extract_spacing_styles_for, #spacing_values_from_options, #style

+ + + + + + + + + +

Methods included from WebviewBorder

+

#style

+ + + + + + + + + +

Methods included from WebviewBackground

+

#style

+ + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::WebviewFlow

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewEditBox.html b/Scarpe/WebviewEditBox.html new file mode 100644 index 000000000..8775a09ad --- /dev/null +++ b/Scarpe/WebviewEditBox.html @@ -0,0 +1,670 @@ + + + + + + + Class: Scarpe::WebviewEditBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewEditBox + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/edit_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #height ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute height.

    +
    + +
  • + + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute text.

    +
    + +
  • + + +
  • + + + #width ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute width.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewEditBox + + + + + +

+
+

Returns a new instance of WebviewEditBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 7
+
+def initialize(properties)
+  super
+
+  # The JS handler sends a "change" event, which we forward to the Shoes widget tree
+  bind("change") do |new_text|
+    send_self_event(new_text, event_name: "change")
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #heightObject (readonly) + + + + + +

+
+

Returns the value of attribute height.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def height
+  @height
+end
+
+
+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

Returns the value of attribute text.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def text
+  @text
+end
+
+
+ + + +
+

+ + #widthObject (readonly) + + + + + +

+
+

Returns the value of attribute width.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 5
+
+def width
+  @width
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 25
+
+def element
+  oninput = handler_js_code("change", "this.value")
+
+  HTML.render do |h|
+    h.textarea(id: html_id, oninput: oninput, style: style) { text }
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 16
+
+def properties_changed(changes)
+  t = changes.delete("text")
+  if t
+    html_element.value = t
+  end
+
+  super
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+35
+36
+37
+38
+39
+40
+
+
# File 'lib/scarpe/wv/edit_box.rb', line 35
+
+def style
+  super.merge({
+    height: Dimensions.length(height),
+    width: Dimensions.length(width),
+  }.compact)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewEditLine.html b/Scarpe/WebviewEditLine.html new file mode 100644 index 000000000..449c2cd26 --- /dev/null +++ b/Scarpe/WebviewEditLine.html @@ -0,0 +1,602 @@ + + + + + + + Class: Scarpe::WebviewEditLine + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewEditLine + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/edit_line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute text.

    +
    + +
  • + + +
  • + + + #width ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute width.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewEditLine + + + + + +

+
+

Returns a new instance of WebviewEditLine.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 7
+
+def initialize(properties)
+  super
+
+  # The JS handler sends a "change" event, which we forward to the Shoes widget tree
+  bind("change") do |new_text|
+    send_self_event(new_text, event_name: "change")
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

Returns the value of attribute text.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 5
+
+def text
+  @text
+end
+
+
+ + + +
+

+ + #widthObject (readonly) + + + + + +

+
+

Returns the value of attribute width.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 5
+
+def width
+  @width
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 25
+
+def element
+  oninput = handler_js_code("change", "this.value")
+
+  HTML.render do |h|
+    h.input(id: html_id, oninput: oninput, value: @text, style: style)
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 16
+
+def properties_changed(changes)
+  t = changes.delete("text")
+  if t
+    html_element.value = t
+  end
+
+  super
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+35
+36
+37
+38
+39
+40
+41
+
+
# File 'lib/scarpe/wv/edit_line.rb', line 35
+
+def style
+  styles = super
+
+  styles[:width] = Dimensions.length(@width) if @width
+
+  styles
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewFlow.html b/Scarpe/WebviewFlow.html new file mode 100644 index 000000000..19d0c5f87 --- /dev/null +++ b/Scarpe/WebviewFlow.html @@ -0,0 +1,373 @@ + + + + + + + Class: Scarpe::WebviewFlow + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewFlow + + + +

+
+ +
+
Inherits:
+
+ WebviewSlot + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/flow.rb
+
+ +
+ +
+

Direct Known Subclasses

+

WebviewDocumentRoot

+
+ + + +

Constant Summary

+ +

Constants included + from WebviewSpacing

+

Scarpe::WebviewSpacing::SPACING_DIRECTIONS

+ + + +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewSlot

+

#attributes, #element, #remove_event_callback, #remove_event_callbacks, #set_event_callback, #update_dom_event

+ + + + + + + + + +

Methods included from WebviewSpacing

+

#extract_spacing_styles_for, #spacing_values_from_options

+ + + + + + + + + + + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewFlow + + + + + +

+
+

Returns a new instance of WebviewFlow.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/flow.rb', line 5
+
+def initialize(properties)
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+
+
# File 'lib/scarpe/wv/flow.rb', line 11
+
+def style
+  {
+    display: "flex",
+    "flex-direction": "row",
+    "flex-wrap": "wrap",
+    "align-content": "flex-start",
+    "justify-content": "flex-start",
+    "align-items": "flex-start",
+  }.merge(super)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewFont.html b/Scarpe/WebviewFont.html new file mode 100644 index 000000000..259c68e03 --- /dev/null +++ b/Scarpe/WebviewFont.html @@ -0,0 +1,476 @@ + + + + + + + Class: Scarpe::WebviewFont + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewFont + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + +
+
Includes:
+
Components::Base64
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/font.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #font ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute font.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewFont + + + + + +

+
+

Returns a new instance of WebviewFont.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+
+
# File 'lib/scarpe/wv/font.rb', line 10
+
+def initialize(properties)
+  @font = properties[:font]
+  super
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #fontObject + + + + + +

+
+

Returns the value of attribute font.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/scarpe/wv/font.rb', line 8
+
+def font
+  @font
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+
+
# File 'lib/scarpe/wv/font.rb', line 19
+
+def element
+  HTML.render do |h|
+    h.link(href: @font, rel: "stylesheet")
+    h.style do
+      <<~CSS
+        @font-face {
+          font-family: #{font_name};
+          src: url("data:font/truetype;base64,#{encode_file_to_base64(@font)}") format('truetype');
+        }
+        * {
+          font-family: #{font_name};
+        }
+      CSS
+    end
+  end
+end
+
+
+ +
+

+ + #font_nameObject + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+
+
# File 'lib/scarpe/wv/font.rb', line 15
+
+def font_name
+  File.basename(@font, ".*")
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewImage.html b/Scarpe/WebviewImage.html new file mode 100644 index 000000000..2aaed8df1 --- /dev/null +++ b/Scarpe/WebviewImage.html @@ -0,0 +1,408 @@ + + + + + + + Class: Scarpe::WebviewImage + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewImage + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + +
+
Includes:
+
Components::Base64
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/image.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewImage + + + + + +

+
+

Returns a new instance of WebviewImage.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+12
+
+
# File 'lib/scarpe/wv/image.rb', line 8
+
+def initialize(properties)
+  super
+
+  @url = valid_url?(@url) ? @url : "data:image/png;base64,#{encode_file_to_base64(@url)}"
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+
+
# File 'lib/scarpe/wv/image.rb', line 14
+
+def element
+  if @click
+    HTML.render do |h|
+      h.a(id: html_id, href: @click) { h.img(id: html_id, src: @url, style:) }
+    end
+  else
+    HTML.render do |h|
+      h.img(id: html_id, src: @url, style:)
+    end
+  end
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
+
# File 'lib/scarpe/wv/image.rb', line 28
+
+def style
+  styles = super
+
+  styles[:width] = Dimensions.length(@width) if @width
+  styles[:height] = Dimensions.length(@height) if @height
+
+  styles[:top] = Dimensions.length(@top) if @top
+  styles[:left] = Dimensions.length(@left) if @left
+  styles[:position] = "absolute" if @top || @left
+
+  styles
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewLine.html b/Scarpe/WebviewLine.html new file mode 100644 index 000000000..9b7db48fb --- /dev/null +++ b/Scarpe/WebviewLine.html @@ -0,0 +1,440 @@ + + + + + + + Class: Scarpe::WebviewLine + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewLine + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewLine + + + + + +

+
+

Returns a new instance of WebviewLine.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/line.rb', line 5
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+
+
# File 'lib/scarpe/wv/line.rb', line 9
+
+def element
+  HTML.render do |h|
+    h.div(id: html_id, style: style) do
+      h.svg(width: @x2, height: @y2) do
+        h.line(x1: @left, y1: @top, x2: @x2, y2: @y2, style: line_style)
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #line_styleObject (protected) + + + + + +

+ + + + +
+
+
+
+28
+29
+30
+31
+32
+33
+
+
# File 'lib/scarpe/wv/line.rb', line 28
+
+def line_style
+  {
+    stroke: @draw_context["stroke"],
+    "stroke-width": "4",
+  }
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+
+
# File 'lib/scarpe/wv/line.rb', line 21
+
+def style
+  super.merge({
+    left: "#{@left}px",
+    top: "#{@top}px",
+  })
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewLink.html b/Scarpe/WebviewLink.html new file mode 100644 index 000000000..2e3451cb5 --- /dev/null +++ b/Scarpe/WebviewLink.html @@ -0,0 +1,390 @@ + + + + + + + Class: Scarpe::WebviewLink + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewLink + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/link.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewLink + + + + + +

+
+

Returns a new instance of WebviewLink.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+
+
# File 'lib/scarpe/wv/link.rb', line 5
+
+def initialize(properties)
+  super
+
+  bind("click") do
+    send_self_event(event_name: "click")
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #attributesObject + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+
+
# File 'lib/scarpe/wv/link.rb', line 21
+
+def attributes
+  {
+    id: html_id,
+    href: @click,
+    onclick: (handler_js_code("click") if @has_block),
+    style: style,
+  }.compact
+end
+
+
+ +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lib/scarpe/wv/link.rb', line 13
+
+def element
+  HTML.render do |h|
+    h.a(**attributes) do
+      @text
+    end
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewListBox.html b/Scarpe/WebviewListBox.html new file mode 100644 index 000000000..a02ba275a --- /dev/null +++ b/Scarpe/WebviewListBox.html @@ -0,0 +1,756 @@ + + + + + + + Class: Scarpe::WebviewListBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewListBox + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/list_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #height ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute height.

    +
    + +
  • + + +
  • + + + #items ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute items.

    +
    + +
  • + + +
  • + + + #selected_item ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute selected_item.

    +
    + +
  • + + +
  • + + + #width ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute width.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewListBox + + + + + +

+
+

Returns a new instance of WebviewListBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+
+
# File 'lib/scarpe/wv/list_box.rb', line 7
+
+def initialize(properties)
+  super(properties)
+
+  # The JS handler sends a "change" event, which we forward to the Shoes widget tree
+  bind("change") do |new_item|
+    send_self_event(new_item, event_name: "change")
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #heightObject (readonly) + + + + + +

+
+

Returns the value of attribute height.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def height
+  @height
+end
+
+
+ + + +
+

+ + #itemsObject (readonly) + + + + + +

+
+

Returns the value of attribute items.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def items
+  @items
+end
+
+
+ + + +
+

+ + #selected_itemObject (readonly) + + + + + +

+
+

Returns the value of attribute selected_item.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def selected_item
+  @selected_item
+end
+
+
+ + + +
+

+ + #widthObject (readonly) + + + + + +

+
+

Returns the value of attribute width.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/list_box.rb', line 5
+
+def width
+  @width
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'lib/scarpe/wv/list_box.rb', line 24
+
+def element
+  onchange = handler_js_code("change", "this.options[this.selectedIndex].value")
+
+  select_attrs = { id: html_id, onchange: onchange, style: style }
+  option_attrs = { value: nil, selected: false }
+
+  HTML.render do |h|
+    h.select(**select_attrs) do
+      items.each do |item|
+        h.option(**option_attrs, value: item, selected: (item == selected_item)) { item }
+      end
+    end
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+
+
# File 'lib/scarpe/wv/list_box.rb', line 16
+
+def properties_changed(changes)
+  selected = changes.delete("selected_item")
+  if selected
+    html_element.value = selected
+  end
+  super
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+41
+42
+43
+44
+45
+46
+47
+48
+
+
# File 'lib/scarpe/wv/list_box.rb', line 41
+
+def style
+  styles = super
+
+  styles[:height] = Dimensions.length(height) if height
+  styles[:width] = Dimensions.length(width) if width
+
+  styles
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewPara.html b/Scarpe/WebviewPara.html new file mode 100644 index 000000000..88e8f154f --- /dev/null +++ b/Scarpe/WebviewPara.html @@ -0,0 +1,630 @@ + + + + + + + Class: Scarpe::WebviewPara + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewPara + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/para.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #rgb_to_hex, #set_parent

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewPara + + + + + +

+
+

Returns a new instance of WebviewPara.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+
+
# File 'lib/scarpe/wv/para.rb', line 17
+
+def initialize(properties)
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+48
+49
+50
+51
+52
+
+
# File 'lib/scarpe/wv/para.rb', line 48
+
+def element(&block)
+  HTML.render do |h|
+    h.p(**options, &block)
+  end
+end
+
+
+ +
+

+ + #font_sizeObject (protected) + + + + + +

+ + + + +
+
+
+
+70
+71
+72
+73
+74
+
+
# File 'lib/scarpe/wv/para.rb', line 70
+
+def font_size
+  font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size
+
+  Dimensions.length(font_size)
+end
+
+
+ +
+

+ + #items_to_display_children(items) ⇒ Object + + + + + +

+ + + + +
+
+
+
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+
+
# File 'lib/scarpe/wv/para.rb', line 36
+
+def items_to_display_children(items)
+  return [] if items.nil?
+
+  items.map do |item|
+    if item.is_a?(String)
+      item
+    else
+      WebviewDisplayService.instance.query_display_widget_for(item)
+    end
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+
+
# File 'lib/scarpe/wv/para.rb', line 21
+
+def properties_changed(changes)
+  items = changes.delete("text_items")
+  if items
+    html_element.inner_html = to_html
+    return
+  end
+
+  # Not deleting, so this will re-render
+  if changes["size"] && SIZES[@size.to_sym]
+    @size = @size.to_sym
+  end
+
+  super
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+62
+63
+64
+65
+66
+67
+68
+
+
# File 'lib/scarpe/wv/para.rb', line 62
+
+def style
+  super.merge({
+    color: rgb_to_hex(@stroke),
+    "font-size": font_size,
+    "font-family": @font,
+  }.compact)
+end
+
+
+ +
+

+ + #to_htmlObject + + + + + +

+ + + + +
+
+
+
+54
+55
+56
+57
+58
+
+
# File 'lib/scarpe/wv/para.rb', line 54
+
+def to_html
+  @children ||= []
+
+  element { child_markup }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewRadio.html b/Scarpe/WebviewRadio.html new file mode 100644 index 000000000..b6696bf4f --- /dev/null +++ b/Scarpe/WebviewRadio.html @@ -0,0 +1,462 @@ + + + + + + + Class: Scarpe::WebviewRadio + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewRadio + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/radio.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #text ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute text.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewRadio + + + + + +

+
+

Returns a new instance of WebviewRadio.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lib/scarpe/wv/radio.rb', line 7
+
+def initialize(properties)
+  super
+
+  bind("click") do
+    send_self_event(event_name: "click", target: shoes_linkable_id)
+  end
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #textObject (readonly) + + + + + +

+
+

Returns the value of attribute text.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/radio.rb', line 5
+
+def text
+  @text
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+26
+
+
# File 'lib/scarpe/wv/radio.rb', line 22
+
+def element
+  HTML.render do |h|
+    h.input(type: :radio, id: html_id, onclick: handler_js_code("click"), name: group_name, value: "hmm #{text}", checked: @checked, style: style)
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+
+
# File 'lib/scarpe/wv/radio.rb', line 15
+
+def properties_changed(changes)
+  items = changes.delete("checked")
+  html_element.toggle_input_button(items)
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewShape.html b/Scarpe/WebviewShape.html new file mode 100644 index 000000000..2b92606dd --- /dev/null +++ b/Scarpe/WebviewShape.html @@ -0,0 +1,474 @@ + + + + + + + Class: Scarpe::WebviewShape + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewShape + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/shape.rb
+
+ +
+ +

Overview

+
+

Should inherit from Slot?

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewShape + + + + + +

+
+

Returns a new instance of WebviewShape.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lib/scarpe/wv/shape.rb', line 6
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
# File 'lib/scarpe/wv/shape.rb', line 27
+
+def element(&block)
+  color = @draw_context["fill"] || "black"
+  HTML.render do |h|
+    h.div(id: html_id, style: style) do
+      h.svg(width: "400", height: "500") do
+        h.path(d: path_from_shape_commands, style: "fill:#{color};stroke-width:2;")
+      end
+      block.call(h) if block_given?
+    end
+  end
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+63
+64
+65
+66
+67
+68
+
+
# File 'lib/scarpe/wv/shape.rb', line 63
+
+def style
+  super.merge({
+    width: "400",
+    height: "900",
+  })
+end
+
+
+ +
+

+ + #to_htmlObject + + + + + +

+ + + + +
+
+
+
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lib/scarpe/wv/shape.rb', line 10
+
+def to_html
+  @children ||= []
+  child_markup = @children.map(&:to_html).join
+
+  color = @draw_context["fill"] || "black"
+  self_markup = HTML.render do |h|
+    h.div(id: html_id, style: style) do
+      h.svg(width: "400", height: "500") do
+        h.path(d: path_from_shape_commands, style: "fill:#{color};stroke-width:2;")
+      end
+    end
+  end
+
+  # Put child markup first for backward compatibility, but I'm pretty sure this is wrong.
+  child_markup + self_markup
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewSlot.html b/Scarpe/WebviewSlot.html new file mode 100644 index 000000000..3e6e54fc0 --- /dev/null +++ b/Scarpe/WebviewSlot.html @@ -0,0 +1,739 @@ + + + + + + + Class: Scarpe::WebviewSlot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewSlot + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + +
+
Includes:
+
WebviewBackground, WebviewBorder, WebviewSpacing
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/slot.rb
+
+ +
+ +
+

Direct Known Subclasses

+

WebviewFlow, WebviewStack

+
+ + + +

Constant Summary

+ +

Constants included + from WebviewSpacing

+

Scarpe::WebviewSpacing::SPACING_DIRECTIONS

+ + + +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from WebviewSpacing

+

#extract_spacing_styles_for, #spacing_values_from_options

+ + + + + + + + + + + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewSlot + + + + + +

+
+

Returns a new instance of WebviewSlot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+
+
# File 'lib/scarpe/wv/slot.rb', line 9
+
+def initialize(properties)
+  @event_callbacks = {}
+
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #attributesObject (protected) + + + + + +

+ + + + +
+
+
+
+57
+58
+59
+60
+61
+62
+63
+64
+65
+
+
# File 'lib/scarpe/wv/slot.rb', line 57
+
+def attributes
+  attr = {}
+
+  @event_callbacks.each do |event_name, handlers|
+    attr[event_name] = handlers.values.join(";")
+  end
+
+  attr
+end
+
+
+ +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+19
+
+
# File 'lib/scarpe/wv/slot.rb', line 15
+
+def element(&block)
+  HTML.render do |h|
+    h.div(attributes.merge(id: html_id, style: style), &block)
+  end
+end
+
+
+ +
+

+ + #remove_event_callback(obj, event_name) ⇒ Object + + + + + +

+ + + + +
+
+
+
+33
+34
+35
+36
+37
+38
+39
+
+
# File 'lib/scarpe/wv/slot.rb', line 33
+
+def remove_event_callback(obj, event_name)
+  event_name = event_name.to_s
+  @event_callbacks[event_name] ||= {}
+  @event_callbacks[event_name].delete(obj)
+
+  update_dom_event(event_name)
+end
+
+
+ +
+

+ + #remove_event_callbacks(obj) ⇒ Object + + + + + +

+ + + + +
+
+
+
+41
+42
+43
+44
+45
+46
+47
+48
+49
+
+
# File 'lib/scarpe/wv/slot.rb', line 41
+
+def remove_event_callbacks(obj)
+  changed = []
+
+  @event_callbacks.each do |event_name, items|
+    changed << event_name if items.delete(obj)
+  end
+
+  changed.each { |event_name| update_dom_event(event_name) }
+end
+
+
+ +
+

+ + #set_event_callback(obj, event_name, js_code) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/scarpe/wv/slot.rb', line 21
+
+def set_event_callback(obj, event_name, js_code)
+  event_name = event_name.to_s
+  @event_callbacks[event_name] ||= {}
+  if @event_callbacks[event_name][obj]
+    raise "Can't have two callbacks on the same event, from the same object, on the same parent!"
+  end
+
+  @event_callbacks[event_name][obj] = js_code
+
+  update_dom_event(event_name)
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+
+
# File 'lib/scarpe/wv/slot.rb', line 67
+
+def style
+  styles = super
+
+  styles[:"margin-top"] = @margin_top if @margin_top
+  styles[:"margin-bottom"] = @margin_bottom if @margin_bottom
+  styles[:"margin-left"] = @margin_left if @margin_left
+  styles[:"margin-right"] = @margin_right if @margin_right
+
+  styles[:width] = Dimensions.length(@width) if @width
+  styles[:height] = Dimensions.length(@height) if @height
+
+  styles
+end
+
+
+ +
+

+ + #update_dom_event(event_name) ⇒ Object (protected) + + + + + +

+ + + + +
+
+
+
+53
+54
+55
+
+
# File 'lib/scarpe/wv/slot.rb', line 53
+
+def update_dom_event(event_name)
+  html_element.set_attribute(event_name, @event_callbacks[event_name].values.join(";"))
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewSpacing.html b/Scarpe/WebviewSpacing.html new file mode 100644 index 000000000..75e1bdbc8 --- /dev/null +++ b/Scarpe/WebviewSpacing.html @@ -0,0 +1,343 @@ + + + + + + + Module: Scarpe::WebviewSpacing + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Scarpe::WebviewSpacing + + + +

+
+ + + + + + + + + +
+
Included in:
+
WebviewSlot
+
+ + + +
+
Defined in:
+
lib/scarpe/wv/spacing.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
SPACING_DIRECTIONS = + +
+
[:left, :right, :top, :bottom]
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #extract_spacing_styles_for(attribute, styles, values) ⇒ Object + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+
+
# File 'lib/scarpe/wv/spacing.rb', line 16
+
+def extract_spacing_styles_for(attribute, styles, values)
+  values ||= spacing_values_from_options(attribute)
+
+  case values
+  when Hash
+    values.each do |direction, value|
+      styles["#{attribute}-#{direction}"] = Dimensions.length(value)
+    end
+  when Array
+    SPACING_DIRECTIONS.zip(values).to_h.compact.each do |direction, value|
+      styles["#{attribute}-#{direction}"] = Dimensions.length(value)
+    end
+  else
+    styles[attribute] = Dimensions.length(values)
+  end
+
+  styles.compact!
+end
+
+
+ +
+

+ + #spacing_values_from_options(attribute) ⇒ Object + + + + + +

+ + + + +
+
+
+
+35
+36
+37
+38
+39
+
+
# File 'lib/scarpe/wv/spacing.rb', line 35
+
+def spacing_values_from_options(attribute)
+  SPACING_DIRECTIONS.map do |direction|
+    @options.delete("#{attribute}_#{direction}".to_sym)
+  end
+end
+
+
+ +
+

+ + #styleObject + + + + + +

+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+
+
# File 'lib/scarpe/wv/spacing.rb', line 7
+
+def style
+  styles = defined?(super) ? super : {}
+
+  extract_spacing_styles_for(:margin, styles, @margin)
+  extract_spacing_styles_for(:padding, styles, @padding)
+
+  styles
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewSpan.html b/Scarpe/WebviewSpan.html new file mode 100644 index 000000000..3128f2086 --- /dev/null +++ b/Scarpe/WebviewSpan.html @@ -0,0 +1,502 @@ + + + + + + + Class: Scarpe::WebviewSpan + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewSpan + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/span.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #remove_child, #rgb_to_hex, #set_parent

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewSpan + + + + + +

+
+

Returns a new instance of WebviewSpan.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+
+
# File 'lib/scarpe/wv/span.rb', line 17
+
+def initialize(properties)
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+36
+37
+38
+39
+40
+
+
# File 'lib/scarpe/wv/span.rb', line 36
+
+def element(&block)
+  HTML.render do |h|
+    h.span(**options, &block)
+  end
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+
+
# File 'lib/scarpe/wv/span.rb', line 21
+
+def properties_changed(changes)
+  text = changes.delete("text")
+  if text
+    html_element.inner_html = text
+    return
+  end
+
+  # Not deleting, so this will re-render
+  if changes["size"] && SIZES[@size.to_sym]
+    @size = @size.to_sym
+  end
+
+  super
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+48
+49
+50
+51
+52
+53
+54
+
+
# File 'lib/scarpe/wv/span.rb', line 48
+
+def style
+  {
+    color: @stroke,
+    "font-size": font_size,
+    "font-family": @font,
+  }.compact
+end
+
+
+ +
+

+ + #to_htmlObject + + + + + +

+ + + + +
+
+
+
+42
+43
+44
+
+
# File 'lib/scarpe/wv/span.rb', line 42
+
+def to_html
+  element { @text }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewStack.html b/Scarpe/WebviewStack.html new file mode 100644 index 000000000..853ef3ef9 --- /dev/null +++ b/Scarpe/WebviewStack.html @@ -0,0 +1,358 @@ + + + + + + + Class: Scarpe::WebviewStack + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewStack + + + +

+
+ +
+
Inherits:
+
+ WebviewSlot + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/stack.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from WebviewSpacing

+

Scarpe::WebviewSpacing::SPACING_DIRECTIONS

+ + + +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewSlot

+

#attributes, #element, #initialize, #remove_event_callback, #remove_event_callbacks, #set_event_callback, #update_dom_event

+ + + + + + + + + +

Methods included from WebviewSpacing

+

#extract_spacing_styles_for, #spacing_values_from_options

+ + + + + + + + + + + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::WebviewSlot

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #get_styleObject + + + + + +

+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/stack.rb', line 5
+
+def get_style
+  style
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+
+
# File 'lib/scarpe/wv/stack.rb', line 11
+
+def style
+  {
+    display: "flex",
+    "flex-direction": "column",
+    "align-content": "flex-start",
+    "justify-content": "flex-start",
+    "align-items": "flex-start",
+    overflow: @scroll ? "auto" : nil,
+  }.compact.merge(super)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewStar.html b/Scarpe/WebviewStar.html new file mode 100644 index 000000000..eea2e245b --- /dev/null +++ b/Scarpe/WebviewStar.html @@ -0,0 +1,392 @@ + + + + + + + Class: Scarpe::WebviewStar + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewStar + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/star.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewStar + + + + + +

+
+

Returns a new instance of WebviewStar.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lib/scarpe/wv/star.rb', line 5
+
+def initialize(properties)
+  super(properties)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #element(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+
+
# File 'lib/scarpe/wv/star.rb', line 9
+
+def element(&block)
+  fill = @draw_context["fill"]
+  stroke = @draw_context["stroke"]
+  fill = "black" if fill == ""
+  stroke = "black" if stroke == ""
+  HTML.render do |h|
+    h.div(id: html_id, style: style) do
+      h.svg(width: @outer, height: @outer, style: "fill:#{fill};") do
+        h.polygon(points: star_points, style: "stroke:#{stroke};stroke-width:2")
+      end
+      block.call(h) if block_given?
+    end
+  end
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+ + + + +
+
+
+
+26
+27
+28
+29
+30
+31
+
+
# File 'lib/scarpe/wv/star.rb', line 26
+
+def style
+  super.merge({
+    width: Dimensions.length(@width),
+    height: Dimensions.length(@height),
+  })
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewSubscriptionItem.html b/Scarpe/WebviewSubscriptionItem.html new file mode 100644 index 000000000..aa17f87f9 --- /dev/null +++ b/Scarpe/WebviewSubscriptionItem.html @@ -0,0 +1,486 @@ + + + + + + + Class: Scarpe::WebviewSubscriptionItem + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewSubscriptionItem + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/subscription_item.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewSubscriptionItem + + + + + +

+
+

Returns a new instance of WebviewSubscriptionItem.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+4
+5
+6
+7
+8
+9
+10
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 4
+
+def initialize(properties)
+  super
+
+  bind(@shoes_api_name) do |*args|
+    send_self_event(*args, event_name: @shoes_api_name)
+  end
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #destroy_selfObject + + + + + +

+ + + + +
+
+
+
+46
+47
+48
+49
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 46
+
+def destroy_self
+  @parent.remove_event_callbacks(self)
+  super
+end
+
+
+ +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 12
+
+def element
+  ""
+end
+
+
+ +
+

+ + #set_parent(new_parent) ⇒ Object + + + + + +

+
+

This will get called once we know the parent, which is useful for events +like hover, where our subscription is likely to depend on what our parent is.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+
+
# File 'lib/scarpe/wv/subscription_item.rb', line 18
+
+def set_parent(new_parent)
+  super
+
+  case @shoes_api_name
+  when "motion"
+    # TODO: what do we do for whole-screen mousemove outside the window?
+    # Those should be set on body, which right now doesn't have a widget.
+    # TODO: figure out how to handle alt and meta keys - does Shoes3 recognise those?
+    new_parent.set_event_callback(
+      self,
+      "onmousemove",
+      handler_js_code(
+        @shoes_api_name,
+        "arguments[0].x",
+        "arguments[0].y",
+        "arguments[0].ctrlKey",
+        "arguments[0].shiftKey",
+      ),
+    )
+  when "hover"
+    new_parent.set_event_callback(self, "onmouseenter", handler_js_code(@shoes_api_name))
+  when "click"
+    new_parent.set_event_callback(self, "onclick", handler_js_code(@shoes_api_name, "arguments[0].button", "arguments[0].x", "arguments[0].y"))
+  else
+    raise "Unknown Shoes event API: #{@shoes_api_name}!"
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewTextWidget.html b/Scarpe/WebviewTextWidget.html new file mode 100644 index 000000000..1deebe482 --- /dev/null +++ b/Scarpe/WebviewTextWidget.html @@ -0,0 +1,180 @@ + + + + + + + Class: Scarpe::WebviewTextWidget + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewTextWidget + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/text_widget.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + + + + + + + +

Method Summary

+ +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #initialize, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Scarpe::WebviewWidget

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewVideo.html b/Scarpe/WebviewVideo.html new file mode 100644 index 000000000..98bcc1f34 --- /dev/null +++ b/Scarpe/WebviewVideo.html @@ -0,0 +1,348 @@ + + + + + + + Class: Scarpe::WebviewVideo + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewVideo + + + +

+
+ +
+
Inherits:
+
+ WebviewWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/scarpe/wv/video.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
SUPPORTED_FORMATS = + +
+
{
+  "video/mp4" => [".mp4"],
+  "video/webp" => [".webp"],
+  "video/quicktime" => [".mov"],
+  "video/x-matroska" => [".mkv"],
+  # Add more formats and their associated file extensions if needed
+}.freeze
+ +
+ + + + + + +

Constants included + from Shoes::Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from WebviewWidget

+

#children, #parent, #shoes_linkable_id

+ + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from WebviewWidget

+

#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html

+ + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewVideo + + + + + +

+
+

Returns a new instance of WebviewVideo.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+13
+14
+15
+16
+
+
# File 'lib/scarpe/wv/video.rb', line 13
+
+def initialize(properties)
+  @url = properties[:url]
+  super
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #elementObject + + + + + +

+ + + + +
+
+
+
+18
+19
+20
+21
+22
+23
+24
+25
+26
+
+
# File 'lib/scarpe/wv/video.rb', line 18
+
+def element
+  HTML.render do |h|
+    h.video(id: html_id, style: style, controls: true) do
+      supported_formats.each do |format|
+        h.source(src: @url, type: format)
+      end
+    end
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Scarpe/WebviewWidget.html b/Scarpe/WebviewWidget.html new file mode 100644 index 000000000..6e8dad4c0 --- /dev/null +++ b/Scarpe/WebviewWidget.html @@ -0,0 +1,1922 @@ + + + + + + + Class: Scarpe::WebviewWidget + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Scarpe::WebviewWidget + + + +

+
+ +
+
Inherits:
+
+ Shoes::Linkable + + + show all + +
+
+ + + + + + +
+
Includes:
+
Shoes::Log
+
+ + + + + + +
+
Defined in:
+
lib/scarpe/wv/widget.rb
+
+ +
+ +

Overview

+
+

The WebviewWidget parent class helps connect a Webview widget with +its Shoes equivalent, render itself to the Webview DOM, handle +Javascript events and generally keep things working in Webview.

+ + +
+
+
+ + +
+ + + +

Constant Summary

+ +

Constants included + from Shoes::Log

+

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

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #children ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    An array of WebviewWidget children (possibly empty) of this widget.

    +
    + +
  • + + +
  • + + + #parent ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The WebviewWidget parent of this widget.

    +
    + +
  • + + +
  • + + + #shoes_linkable_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    The Shoes ID corresponding to the Shoes widget for this Webview widget.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Shoes::Linkable

+

#linkable_id

+ + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Shoes::Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Shoes::Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(properties) ⇒ WebviewWidget + + + + + +

+
+

Set instance variables for the display properties of this widget. Bind Shoes +events for changes of parent widget and changes of property values.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+
+
# File 'lib/scarpe/wv/widget.rb', line 39
+
+def initialize(properties)
+  log_init("WV::Widget")
+
+  # Call method, which looks up the parent
+  @shoes_linkable_id = properties["shoes_linkable_id"] || properties[:shoes_linkable_id]
+  unless @shoes_linkable_id
+    raise "Could not find property shoes_linkable_id in #{properties.inspect}!"
+  end
+
+  # Set the display properties
+  properties.each do |k, v|
+    next if k == "shoes_linkable_id"
+
+    instance_variable_set("@" + k.to_s, v)
+  end
+
+  # The parent field is *almost* simple enough that a typed display property would handle it.
+  bind_shoes_event(event_name: "parent", target: shoes_linkable_id) do |new_parent_id|
+    display_parent = WebviewDisplayService.instance.query_display_widget_for(new_parent_id)
+    if @parent != display_parent
+      set_parent(display_parent)
+    end
+  end
+
+  # When Shoes widgets change properties, we get a change notification here
+  bind_shoes_event(event_name: "prop_change", target: shoes_linkable_id) do |prop_changes|
+    prop_changes.each do |k, v|
+      instance_variable_set("@" + k, v)
+    end
+    properties_changed(prop_changes)
+  end
+
+  bind_shoes_event(event_name: "destroy", target: shoes_linkable_id) do
+    destroy_self
+  end
+
+  super(linkable_id: @shoes_linkable_id)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #childrenObject (readonly) + + + + + +

+
+

An array of WebviewWidget children (possibly empty) of this widget

+ + +
+
+
+ + +
+ + + + +
+
+
+
+35
+36
+37
+
+
# File 'lib/scarpe/wv/widget.rb', line 35
+
+def children
+  @children
+end
+
+
+ + + +
+

+ + #parentObject (readonly) + + + + + +

+
+

The WebviewWidget parent of this widget

+ + +
+
+
+ + +
+ + + + +
+
+
+
+32
+33
+34
+
+
# File 'lib/scarpe/wv/widget.rb', line 32
+
+def parent
+  @parent
+end
+
+
+ + + +
+

+ + #shoes_linkable_idObject (readonly) + + + + + +

+
+

The Shoes ID corresponding to the Shoes widget for this Webview widget

+ + +
+
+
+ + +
+ + + + +
+
+
+
+29
+30
+31
+
+
# File 'lib/scarpe/wv/widget.rb', line 29
+
+def shoes_linkable_id
+  @shoes_linkable_id
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .display_class_for(scarpe_class_name) ⇒ Object + + + + + +

+
+

Return the corresponding Webview class for a particular Shoes class name

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lib/scarpe/wv/widget.rb', line 12
+
+def display_class_for(scarpe_class_name)
+  scarpe_class = Shoes.const_get(scarpe_class_name)
+  unless scarpe_class.ancestors.include?(Shoes::Linkable)
+    raise "Scarpe Webview can only get display classes for Shoes " +
+      "linkable widgets, not #{scarpe_class_name.inspect}!"
+  end
+
+  klass = Scarpe.const_get("Webview" + scarpe_class_name.split("::")[-1])
+  if klass.nil?
+    raise "Couldn't find corresponding Scarpe Webview class for #{scarpe_class_name.inspect}!"
+  end
+
+  klass
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #add_child(child) ⇒ Object (protected) + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+127
+128
+129
+130
+131
+132
+133
+
+
# File 'lib/scarpe/wv/widget.rb', line 127
+
+def add_child(child)
+  @children ||= []
+  @children << child
+
+  # If we add a child, we should redraw ourselves
+  needs_update!
+end
+
+
+ +
+

+ + #bind(event) { ... } ⇒ Object + + + + + +

+
+

This binds a Scarpe JS callback, handled via a single dispatch point in the app

+ + +
+
+
+

Parameters:

+
    + +
  • + + event + + + (String) + + + + — +

    the Scarpe widget event name

    +
    + +
  • + +
+ +

Yields:

+
    + +
  • + + + + + + + +

    the block to call when the event occurs

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+212
+213
+214
+215
+216
+
+
# File 'lib/scarpe/wv/widget.rb', line 212
+
+def bind(event, &block)
+  raise("Widget has no linkable_id! #{inspect}") unless linkable_id
+
+  WebviewDisplayService.instance.app.bind("#{linkable_id}-#{event}", &block)
+end
+
+
+ +
+

+ + #destroy_selfScarpe::Promise + + + + + +

+
+

Removes the element from both the Ruby Widget tree and the HTML DOM. +Return a promise for when that HTML change will be visible.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that is fulfilled when the HTML change is complete

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+222
+223
+224
+225
+
+
# File 'lib/scarpe/wv/widget.rb', line 222
+
+def destroy_self
+  @parent&.remove_child(self)
+  html_element.remove
+end
+
+
+ +
+

+ + #handler_js_code(handler_function_name, *args) ⇒ String + + + + + +

+
+

Generate JS code to trigger a specific event name on this widget with the supplies arguments.

+ + +
+
+
+

Parameters:

+
    + +
  • + + handler_function_name + + + (String) + + + + — +

    the event name - @see #bind

    +
    + +
  • + +
  • + + args + + + (Array) + + + + — +

    additional arguments that will be passed to the event in the generated JS

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the generated JS code

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+243
+244
+245
+246
+247
+248
+
+
# File 'lib/scarpe/wv/widget.rb', line 243
+
+def handler_js_code(handler_function_name, *args)
+  raise("Widget has no linkable_id! #{inspect}") unless linkable_id
+
+  js_args = ["'#{linkable_id}-#{handler_function_name}'", *args].join(", ")
+  "scarpeHandler(#{js_args})"
+end
+
+
+ +
+

+ + #html_elementScarpe::WebWrangler::ElementWrangler + + + + + +

+
+

This gets a mini-webview for just this element and its children, if any. +It is normally called by the widget itself to do its DOM management.

+ + +
+
+
+ +

Returns:

+ + +
+ + + + +
+
+
+
+176
+177
+178
+
+
# File 'lib/scarpe/wv/widget.rb', line 176
+
+def html_element
+  @elt_wrangler ||= Scarpe::WebWrangler::ElementWrangler.new(html_id)
+end
+
+
+ +
+

+ + #html_idString + + + + + +

+
+

Get the object's HTML ID

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the HTML ID

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+190
+191
+192
+
+
# File 'lib/scarpe/wv/widget.rb', line 190
+
+def html_id
+  object_id.to_s
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+
+

A shorter inspect text for prettier irb output

+ + +
+
+
+ + +
+ + + + +
+
+
+
+110
+111
+112
+
+
# File 'lib/scarpe/wv/widget.rb', line 110
+
+def inspect
+  "#<#{self.class}:#{self.object_id} @shoes_linkable_id=#{@shoes_linkable_id} @parent=#{@parent.inspect} @children=#{@children.inspect}>"
+end
+
+
+ +
+

+ + #needs_update!void + + + + + +

+
+

This method returns an undefined value.

Request a full redraw of all widgets.

+ +

It's really hard to do dirty-tracking here because the redraws are fully asynchronous. +And so we can't easily cancel one "in flight," and we can't easily pick up the latest +changes... And we probably don't want to, because we may be halfway through a batch.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+234
+235
+236
+
+
# File 'lib/scarpe/wv/widget.rb', line 234
+
+def needs_update!
+  WebviewDisplayService.instance.app.request_redraw!
+end
+
+
+ +
+

+ + #promise_updateScarpe::Promise + + + + + +

+
+

Return a promise that guarantees all currently-requested changes have completed

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Scarpe::Promise) + + + + — +

    a promise that will be fulfilled when all pending changes have finished

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+183
+184
+185
+
+
# File 'lib/scarpe/wv/widget.rb', line 183
+
+def promise_update
+  html_element.promise_update
+end
+
+
+ +
+

+ + #properties_changed(changes) ⇒ Object + + + + + +

+
+

Properties_changed will be called automatically when properties change. +The widget should delete any changes from the Hash that it knows how +to incrementally handle, and pass the rest to super. If any changes +go entirely un-handled, a full redraw will be scheduled. +This exists to be overridden by children watching for changes.

+ + +
+
+
+

Parameters:

+
    + +
  • + + changes + + + (Hash) + + + + — +

    a Hash of new values for properties that have changed

    +
    + +
  • + +
+ + +
+ + + + +
+
+
+
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+
+
# File 'lib/scarpe/wv/widget.rb', line 85
+
+def properties_changed(changes)
+  # If a widget does something really nonstandard with its html_id or element, it will
+  # need to override to prevent this from happening. That's easy enough, though.
+  if changes.key?("hidden")
+    hidden = changes.delete("hidden")
+    if hidden
+      html_element.set_style("display", "none")
+    else
+      new_style = style # Get current display CSS property, which may vary by subclass
+      disp = new_style[:display]
+      html_element.set_style("display", disp || "block")
+    end
+  end
+
+  needs_update! unless changes.empty?
+end
+
+
+ +
+

+ + #remove_child(child) ⇒ Object (protected) + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+117
+118
+119
+120
+121
+122
+123
+124
+
+
# File 'lib/scarpe/wv/widget.rb', line 117
+
+def remove_child(child)
+  @children ||= []
+  unless @children.include?(child)
+    @log.error("remove_child: no such child(#{child.inspect}) for"\
+      " parent(#{parent.inspect})!")
+  end
+  @children.delete(child)
+end
+
+
+ +
+

+ + #rgb_to_hex(color) ⇒ Object (protected) + + + + + +

+
+

Convert an [r, g, b, a] array to an HTML hex color code +Arrays support alpha. HTML hex does not. So premultiply.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+
+
# File 'lib/scarpe/wv/widget.rb', line 137
+
+def rgb_to_hex(color)
+  return color if color.nil?
+
+  r, g, b, a = *color
+  if r.is_a?(Float)
+    a ||= 1.0
+    r_float = r * a
+    g_float = g * a
+    b_float = b * a
+  else
+    a ||= 255
+    a_float = (a / 255.0)
+    r_float = (r.to_f / 255.0) * a_float
+    g_float = (g.to_f / 255.0) * a_float
+    b_float = (b.to_f / 255.0) * a_float
+  end
+
+  r_int = (r_float * 255.0).to_i.clamp(0, 255)
+  g_int = (g_float * 255.0).to_i.clamp(0, 255)
+  b_int = (b_float * 255.0).to_i.clamp(0, 255)
+
+  "#%0.2X%0.2X%0.2X" % [r_int, g_int, b_int]
+end
+
+
+ +
+

+ + #set_parent(new_parent) ⇒ Object + + + + + +

+
+

Give this widget a new parent, including managing the appropriate child lists for parent widgets.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+103
+104
+105
+106
+107
+
+
# File 'lib/scarpe/wv/widget.rb', line 103
+
+def set_parent(new_parent)
+  @parent&.remove_child(self)
+  new_parent&.add_child(self)
+  @parent = new_parent
+end
+
+
+ +
+

+ + #styleObject (protected) + + + + + +

+
+

CSS styles

+ + +
+
+
+ + +
+ + + + +
+
+
+
+162
+163
+164
+165
+166
+167
+168
+
+
# File 'lib/scarpe/wv/widget.rb', line 162
+
+def style
+  styles = {}
+  if @hidden
+    styles[:display] = "none"
+  end
+  styles
+end
+
+
+ +
+

+ + #to_htmlString + + + + + +

+
+

to_html is intended to get the HTML DOM rendering of this object and its children. +Calling it should be side-effect-free and NOT update the webview.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (String) + + + + — +

    the rendered HTML

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+198
+199
+200
+201
+202
+203
+204
+205
+206
+
+
# File 'lib/scarpe/wv/widget.rb', line 198
+
+def to_html
+  @children ||= []
+  child_markup = @children.map(&:to_html).join
+  if respond_to?(:element)
+    element { child_markup }
+  else
+    child_markup
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes.html b/Shoes.html new file mode 100644 index 000000000..e81ce6552 --- /dev/null +++ b/Shoes.html @@ -0,0 +1,851 @@ + + + + + + + Module: Shoes + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes.rb,
+ lacci/lib/shoes.rb,
lacci/lib/shoes/app.rb,
lacci/lib/shoes/log.rb,
lacci/lib/shoes/border.rb,
lacci/lib/shoes/colors.rb,
lacci/lib/shoes/widget.rb,
lacci/lib/shoes/spacing.rb,
lacci/lib/shoes/download.rb,
lacci/lib/shoes/constants.rb,
lacci/lib/shoes/background.rb,
lacci/lib/shoes/widgets/arc.rb,
lacci/lib/shoes/widgets/flow.rb,
lacci/lib/shoes/widgets/font.rb,
lacci/lib/shoes/widgets/line.rb,
lacci/lib/shoes/widgets/link.rb,
lacci/lib/shoes/widgets/para.rb,
lacci/lib/shoes/widgets/para.rb,
lacci/lib/shoes/widgets/span.rb,
lacci/lib/shoes/widgets/star.rb,
lacci/lib/shoes/widgets/alert.rb,
lacci/lib/shoes/widgets/check.rb,
lacci/lib/shoes/widgets/image.rb,
lacci/lib/shoes/widgets/radio.rb,
lacci/lib/shoes/widgets/shape.rb,
lacci/lib/shoes/widgets/stack.rb,
lacci/lib/shoes/widgets/video.rb,
lacci/lib/shoes/widgets/button.rb,
lacci/lib/shoes/display_service.rb,
lacci/lib/shoes/widgets/edit_box.rb,
lacci/lib/shoes/widgets/list_box.rb,
lacci/lib/shoes/widgets/edit_line.rb,
lacci/lib/shoes/widgets/text_widget.rb,
lacci/lib/shoes/widgets/document_root.rb
+
+
+ +
+ +

Overview

+
+

Shoes::TextWidget

+ + +
+
+
+ + +

Defined Under Namespace

+

+ + + Modules: Background, Border, Colors, Constants, Log, Spacing + + + + Classes: Alert, App, Arc, Button, Check, DisplayService, DocumentRoot, EditBox, EditLine, Error, Flow, Font, Image, InvalidAttributeValueError, Line, Link, Linkable, ListBox, LoggedWrapper, Para, Radio, Shape, Slot, Span, Stack, Star, SubscriptionItem, TextWidget, Video, Widget + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
LOG_LEVELS = + +
+
[:debug, :info, :warn, :error, :fatal].freeze
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .add_file_loader(loader) ⇒ Object + + + + + +

+ + + + +
+
+
+
+115
+116
+117
+
+
# File 'lacci/lib/shoes.rb', line 115
+
+def add_file_loader(loader)
+  file_loaders.prepend(loader)
+end
+
+
+ +
+

+ + .app(title: "Shoes!", width: 480, height: 420, resizable: true, &app_code_body) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Creates a Shoes app with a new window. The block parameter is used to create +widgets and set up handlers. Arguments are passed to Shoes::App.new internally.

+ + +
+
+
+ +
+

Examples:

+ + +

Simple one-button app

+

+ +
Shoes.app(title: "Button!", width: 200, height: 200) do
+  @p = para "Press it NOW!"
+  button("clicky") { @p.replace("You pressed it! CELEBRATION!") }
+end
+ +
+

Parameters:

+
    + +
  • + + title + + + (String) + + + (defaults to: "Shoes!") + + + — +

    The new app window title

    +
    + +
  • + +
  • + + width + + + (Integer) + + + (defaults to: 480) + + + — +

    The new app window width

    +
    + +
  • + +
  • + + height + + + (Integer) + + + (defaults to: 420) + + + — +

    The new app window height

    +
    + +
  • + +
  • + + resizable + + + (Boolean) + + + (defaults to: true) + + + — +

    Whether the app window should be resizeable

    +
    + +
  • + +
+ + +

See Also:

+
    + +
  • Shoes::App#new
  • + +
+

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    In Shoes3, this method will return normally. +In Scarpe, after the block is executed, the method will not return and Scarpe +will retain control of execution until the window is closed and the app quits.

    +
    + +
  • + +
  • + + + + + +

    In Shoes3 the parameters were a hash of options, not keyword arguments.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+
+
# File 'lacci/lib/shoes.rb', line 66
+
+def app(
+  title: "Shoes!",
+  width: 480,
+  height: 420,
+  resizable: true,
+  &app_code_body
+)
+  app = Shoes::App.new(title:, width:, height:, resizable:, &app_code_body)
+  app.init
+  app.run
+  nil
+end
+
+
+ +
+

+ + .default_file_loadersObject + + + + + +

+ + + + +
+
+
+
+101
+102
+103
+104
+105
+106
+107
+108
+109
+
+
# File 'lacci/lib/shoes.rb', line 101
+
+def default_file_loaders
+  [
+    # By default we will always try to load any file, regardless of extension, as a Shoes Ruby file.
+    proc do |path|
+      load path
+      true
+    end,
+  ]
+end
+
+
+ +
+

+ + .default_text_widget_with(element) ⇒ Object + + + + + +

+ + + + +
+
+
+
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+
+
# File 'lacci/lib/shoes/widgets/text_widget.rb', line 18
+
+def default_text_widget_with(element)
+  class_name = element.capitalize
+
+  widget_class = Class.new(Shoes::TextWidget) do
+    # Can we just change content to text to match the Shoes API?
+    display_property :content
+
+    def initialize(content)
+      @content = content
+
+      super
+
+      create_display_widget
+    end
+
+    def text
+      self.content
+    end
+
+    def text=(new_text)
+      self.content = new_text
+    end
+  end
+  Shoes.const_set class_name, widget_class
+  widget_class.class_eval do
+    display_property :content
+  end
+end
+
+
+ +
+

+ + .file_loadersObject + + + + + +

+ + + + +
+
+
+
+111
+112
+113
+
+
# File 'lacci/lib/shoes.rb', line 111
+
+def file_loaders
+  @file_loaders ||= default_file_loaders
+end
+
+
+ +
+

+ + .reset_file_loadersObject + + + + + +

+ + + + +
+
+
+
+119
+120
+121
+
+
# File 'lacci/lib/shoes.rb', line 119
+
+def reset_file_loaders
+  @file_loaders = default_file_loaders
+end
+
+
+ +
+

+ + .run_app(relative_path) ⇒ void + + + + + +

+
+

This method returns an undefined value.

Load a Shoes app from a file. By default, this will load old-style Shoes apps +from a .rb file with all the appropriate libraries loaded. By setting one or +more loaders, a Lacci-based display library can accept new file formats as +well, not just raw Shoes .rb files.

+ + +
+
+
+

Parameters:

+
    + +
  • + + path + + + (String) + + + + — +

    The current-dir-relative path to the file

    +
    + +
  • + +
+ + +

See Also:

+ + +
+ + + + +
+
+
+
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+
+
# File 'lacci/lib/shoes.rb', line 87
+
+def run_app(relative_path)
+  path = File.expand_path relative_path
+  loaded = false
+  file_loaders.each do |loader|
+    if loader.call(path)
+      loaded = true
+      break
+    end
+  end
+  raise "Could not find a file loader for #{path.inspect}!" unless loaded
+
+  nil
+end
+
+
+ +
+

+ + .set_file_loaders(loaders) ⇒ Object + + + + + +

+ + + + +
+
+
+
+123
+124
+125
+
+
# File 'lacci/lib/shoes.rb', line 123
+
+def set_file_loaders(loaders)
+  @file_loaders = loaders
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Alert.html b/Shoes/Alert.html new file mode 100644 index 000000000..9b3fdaa47 --- /dev/null +++ b/Shoes/Alert.html @@ -0,0 +1,291 @@ + + + + + + + Class: Shoes::Alert + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Alert + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/alert.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(text) ⇒ Alert + + + + + +

+
+

Returns a new instance of Alert.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+
+
# File 'lacci/lib/shoes/widgets/alert.rb', line 7
+
+def initialize(text)
+  @text = text
+
+  super
+
+  bind_self_event("click") do
+    remove
+  end
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/App.html b/Shoes/App.html new file mode 100644 index 000000000..72b475a9d --- /dev/null +++ b/Shoes/App.html @@ -0,0 +1,1903 @@ + + + + + + + Class: Shoes::App + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::App + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + +
+
Includes:
+
Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/app.rb,
+ lacci/lib/shoes/app.rb
+
+
+ +
+ +

Overview

+
+

DSL methods

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
CUSTOM_EVENT_LOOP_TYPES = + +
+
["displaylib", "return", "wait"]
+ +
+ + + + + + +

Constants included + from Log

+

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

+ + +

Class Attribute Summary collapse

+
    + +
  • + + + .instance ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute instance.

    +
    + +
  • + + +
+ +

Instance Attribute Summary collapse

+
    + +
  • + + + #document_root ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute document_root.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(title: "Shoes!", width: 480, height: 420, resizable: true, &app_code_body) ⇒ App + + + + + +

+
+

Returns a new instance of App.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+
+
# File 'lacci/lib/shoes/app.rb', line 17
+
+def initialize(
+  title: "Shoes!",
+  width: 480,
+  height: 420,
+  resizable: true,
+  &app_code_body
+)
+  log_init("Shoes::App")
+
+  if Shoes::App.instance
+    @log.error("Trying to create a second Shoes::App in the same process! Fail!")
+    raise "Cannot create multiple Shoes::App objects!"
+  else
+    Shoes::App.instance = self
+  end
+
+  @do_shutdown = false
+  @event_loop_type = "displaylib" # the default
+
+  super
+
+  # The draw context tracks current settings like fill and stroke,
+  # plus potentially other current state that changes from widget
+  # to widget and slot to slot.
+  @draw_context = {
+    "fill" => "",
+    "stroke" => "",
+  }
+
+  # This creates the DocumentRoot, including its corresponding display widget
+  @document_root = Shoes::DocumentRoot.new
+
+  @slots = []
+
+  # Now create the App display widget
+  create_display_widget
+
+  # Set up testing events *after* Display Service basic objects exist
+  if ENV["SCARPE_APP_TEST"]
+    test_code = File.read ENV["SCARPE_APP_TEST"]
+    if test_code != ""
+      self.instance_eval test_code
+    end
+  end
+
+  @app_code_body = app_code_body
+
+  # Try to de-dup as much as possible and not send repeat or multiple
+  # destroy events
+  @watch_for_destroy = bind_shoes_event(event_name: "destroy") do
+    Shoes::DisplayService.unsub_from_events(@watch_for_destroy) if @watch_for_destroy
+    @watch_for_destroy = nil
+    self.destroy(send_event: false)
+  end
+
+  @watch_for_event_loop = bind_shoes_event(event_name: "custom_event_loop") do |loop_type|
+    raise("Unknown event loop type: #{loop_type.inspect}!") unless CUSTOM_EVENT_LOOP_TYPES.include?(loop_type)
+
+    @event_loop_type = loop_type
+  end
+
+  Signal.trap("INT") do
+    @log.warn("App interrupted by signal, stopping...")
+    puts "\nStopping Shoes app..."
+    destroy
+  end
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .instanceObject + + + + + +

+
+

Returns the value of attribute instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lacci/lib/shoes/app.rb', line 8
+
+def instance
+  @instance
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #document_rootObject (readonly) + + + + + +

+
+

Returns the value of attribute document_root.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+
+
# File 'lacci/lib/shoes/app.rb', line 11
+
+def document_root
+  @document_root
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #all_widgetsObject + + + + + +

+ + + + +
+
+
+
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+
+
# File 'lacci/lib/shoes/app.rb', line 156
+
+def all_widgets
+  out = []
+
+  to_add = @document_root.children
+  until to_add.empty?
+    out.concat(to_add)
+    to_add = to_add.flat_map { |w| w.respond_to?(:children) ? w.children : [] }.compact
+  end
+
+  out
+end
+
+
+ +
+

+ + #backgroundObject + + + + + +

+ + + + +
+
+
+
+205
+206
+207
+
+
# File 'lacci/lib/shoes/app.rb', line 205
+
+def background(...)
+  current_slot.background(...)
+end
+
+
+ +
+

+ + #borderObject + + + + + +

+ + + + +
+
+
+
+209
+210
+211
+
+
# File 'lacci/lib/shoes/app.rb', line 209
+
+def border(...)
+  current_slot.border(...)
+end
+
+
+ +
+

+ + #click(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+221
+222
+223
+
+
# File 'lacci/lib/shoes/app.rb', line 221
+
+def click(&block)
+  subscription_item(shoes_api_name: "click", &block)
+end
+
+
+ +
+

+ + #current_draw_contextObject + + + + + +

+ + + + +
+
+
+
+118
+119
+120
+
+
# File 'lacci/lib/shoes/app.rb', line 118
+
+def current_draw_context
+  @draw_context.dup
+end
+
+
+ +
+

+ + #current_slotObject + + + + + +

+ + + + +
+
+
+
+105
+106
+107
+
+
# File 'lacci/lib/shoes/app.rb', line 105
+
+def current_slot
+  @slots[-1]
+end
+
+
+ +
+

+ + #destroy(send_event: true) ⇒ Object + + + + + +

+ + + + +
+
+
+
+151
+152
+153
+154
+
+
# File 'lacci/lib/shoes/app.rb', line 151
+
+def destroy(send_event: true)
+  @do_shutdown = true
+  send_shoes_event(event_name: "destroy") if send_event
+end
+
+
+ +
+

+ + #fill(color) ⇒ Object + + + + + +

+
+

Draw context methods

+ + +
+
+
+ + +
+ + + + +
+
+
+
+227
+228
+229
+
+
# File 'lacci/lib/shoes/app.rb', line 227
+
+def fill(color)
+  @draw_context["fill"] = color
+end
+
+
+ +
+

+ + #find_widgets_by(*specs) ⇒ Object + + + + + +

+
+

We can add various ways to find widgets here. +These are sort of like Shoes selectors, used for testing.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+
+
# File 'lacci/lib/shoes/app.rb', line 170
+
+def find_widgets_by(*specs)
+  widgets = all_widgets
+  specs.each do |spec|
+    if spec.is_a?(Class)
+      widgets.select! { |w| spec === w }
+    elsif spec.is_a?(Symbol) || spec.is_a?(String)
+      s = spec.to_s
+      case s[0]
+      when "$"
+        begin
+          # I'm not finding a global_variable_get or similar...
+          global_value = eval s
+          widgets &= [global_value]
+        rescue
+          raise "Error getting global variable: #{spec.inspect}"
+        end
+      when "@"
+        if Shoes::App.instance.instance_variables.include?(spec.to_sym)
+          widgets &= [self.instance_variable_get(spec)]
+        else
+          raise "Can't find top-level instance variable: #{spec.inspect}!"
+        end
+      else
+      end
+    else
+      raise("Don't know how to find widgets by #{spec.inspect}!")
+    end
+  end
+  widgets
+end
+
+
+ +
+

+ + #hover(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+217
+218
+219
+
+
# File 'lacci/lib/shoes/app.rb', line 217
+
+def hover(&block)
+  subscription_item(shoes_api_name: "hover", &block)
+end
+
+
+ +
+

+ + #initObject + + + + + +

+ + + + +
+
+
+
+85
+86
+87
+88
+89
+90
+
+
# File 'lacci/lib/shoes/app.rb', line 85
+
+def init
+  send_shoes_event(event_name: "init")
+  return if @do_shutdown
+
+  ::Shoes::App.instance.with_slot(@document_root, &@app_code_body)
+end
+
+
+ +
+

+ + #line_to(x, y) ⇒ Object + + + + + +

+ + + + +
+
+
+
+253
+254
+255
+256
+257
+258
+259
+
+
# File 'lacci/lib/shoes/app.rb', line 253
+
+def line_to(x, y)
+  raise("Pass only Numeric arguments to line_to!") unless x.is_a?(Numeric) && y.is_a?(Numeric)
+
+  if current_slot.is_a?(::Shoes::Shape)
+    current_slot.add_shape_command(["line_to", x, y])
+  end
+end
+
+
+ +
+

+ + #motion(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+213
+214
+215
+
+
# File 'lacci/lib/shoes/app.rb', line 213
+
+def motion(&block)
+  subscription_item(shoes_api_name: "motion", &block)
+end
+
+
+ +
+

+ + #move_to(x, y) ⇒ Object + + + + + +

+
+

Shape DSL methods

+ + +
+
+
+ + +
+ + + + +
+
+
+
+245
+246
+247
+248
+249
+250
+251
+
+
# File 'lacci/lib/shoes/app.rb', line 245
+
+def move_to(x, y)
+  raise("Pass only Numeric arguments to move_to!") unless x.is_a?(Numeric) && y.is_a?(Numeric)
+
+  if current_slot.is_a?(::Shoes::Shape)
+    current_slot.add_shape_command(["move_to", x, y])
+  end
+end
+
+
+ +
+

+ + #nofillObject + + + + + +

+ + + + +
+
+
+
+231
+232
+233
+
+
# File 'lacci/lib/shoes/app.rb', line 231
+
+def nofill
+  @draw_context["fill"] = ""
+end
+
+
+ +
+

+ + #nostrokeObject + + + + + +

+ + + + +
+
+
+
+239
+240
+241
+
+
# File 'lacci/lib/shoes/app.rb', line 239
+
+def nostroke
+  @draw_context["stroke"] = ""
+end
+
+
+ +
+

+ + #pop_slotObject + + + + + +

+ + + + +
+
+
+
+99
+100
+101
+102
+103
+
+
# File 'lacci/lib/shoes/app.rb', line 99
+
+def pop_slot
+  return if @slots.size <= 1
+
+  @slots.pop
+end
+
+
+ +
+

+ + #push_slot(slot) ⇒ Object + + + + + +

+
+

"Container" widgets like flows, stacks, masks and the document root +are considered "slots" in Shoes parlance. When a new slot is created, +we push it here in order to track what widgets are found in that slot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+95
+96
+97
+
+
# File 'lacci/lib/shoes/app.rb', line 95
+
+def push_slot(slot)
+  @slots.push(slot)
+end
+
+
+ +
+

+ + #runObject + + + + + +

+
+

This usually doesn't return. The display service may take control +of the main thread. Local Webview even stops any background threads. +However, some display libraries don't want to shut down and don't +want to (and/or can't) take control of the event loop.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+
+
# File 'lacci/lib/shoes/app.rb', line 126
+
+def run
+  if @do_shutdown
+    $stderr.puts "Destroy has already been signaled, but we just called Shoes::App.run!"
+    return
+  end
+
+  # The display lib can send us an event to customise the event loop handling.
+  # But it must do so before the "run" event returns.
+  send_shoes_event(event_name: "run")
+
+  case @event_loop_type
+  when "wait"
+    # Display lib wants us to busy-wait instead of it.
+    sleep 0.1 until @do_shutdown
+  when "displaylib"
+    # If run event returned, that means we're done.
+    destroy
+  when "return"
+    # We can just return to the main event loop. But we shouldn't call destroy.
+    # Presumably some event loop *outside* our event loop is handling things.
+  else
+    raise "Internal error! Incorrect event loop type: #{@event_loop_type.inspect}!"
+  end
+end
+
+
+ +
+

+ + #stroke(color) ⇒ Object + + + + + +

+ + + + +
+
+
+
+235
+236
+237
+
+
# File 'lacci/lib/shoes/app.rb', line 235
+
+def stroke(color)
+  @draw_context["stroke"] = color
+end
+
+
+ +
+

+ + #with_slot(slot_item, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+109
+110
+111
+112
+113
+114
+115
+116
+
+
# File 'lacci/lib/shoes/app.rb', line 109
+
+def with_slot(slot_item, &block)
+  return unless block_given?
+
+  push_slot(slot_item)
+  Shoes::App.instance.instance_eval(&block)
+ensure
+  pop_slot
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Arc.html b/Shoes/Arc.html new file mode 100644 index 000000000..e9d7ee126 --- /dev/null +++ b/Shoes/Arc.html @@ -0,0 +1,299 @@ + + + + + + + Class: Shoes::Arc + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Arc + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/arc.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args) ⇒ Arc + + + + + +

+
+

Returns a new instance of Arc.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lacci/lib/shoes/widgets/arc.rb', line 9
+
+def initialize(*args)
+  @left, @top, @width, @height, @angle1, @angle2 = args
+
+  @left = convert_to_integer(@left, "left")
+  @top = convert_to_integer(@top, "top")
+  @width = convert_to_integer(@width, "width")
+  @height = convert_to_integer(@height, "height")
+  @angle1 = convert_to_float(@angle1, "angle1")
+  @angle2 = convert_to_float(@angle2, "angle2")
+
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Background.html b/Shoes/Background.html new file mode 100644 index 000000000..147dd444d --- /dev/null +++ b/Shoes/Background.html @@ -0,0 +1,190 @@ + + + + + + + Module: Shoes::Background + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Background + + + +

+
+ + + + + + + + + +
+
Included in:
+
Flow, Stack
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/background.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #background(color, options = {}) ⇒ Object + + + + + +

+
+

NOTE: this needs to be passed through in order for the styling to work

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+
+
# File 'lacci/lib/shoes/background.rb', line 10
+
+def background(color, options = {})
+  self.background_color = color
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Border.html b/Shoes/Border.html new file mode 100644 index 000000000..cad4a9039 --- /dev/null +++ b/Shoes/Border.html @@ -0,0 +1,193 @@ + + + + + + + Module: Shoes::Border + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Border + + + +

+
+ + + + + + + + + +
+
Included in:
+
Flow, Stack
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/border.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #border(color, options = {}) ⇒ Object + + + + + +

+
+

Considering a signature like this: +border "#00D0FF", :strokewidth => 3, :curve => 12

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+
+
# File 'lacci/lib/shoes/border.rb', line 11
+
+def border(color, options = {})
+  self.border_color = color
+  self.options = options
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Button.html b/Shoes/Button.html new file mode 100644 index 000000000..db1406d7d --- /dev/null +++ b/Shoes/Button.html @@ -0,0 +1,385 @@ + + + + + + + Class: Shoes::Button + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Button + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + +
+
Includes:
+
Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/button.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(text, width: nil, height: nil, top: nil, left: nil, color: nil, padding_top: nil, padding_bottom: nil, size: 12, text_color: nil, font_size: nil, &block) ⇒ Button + + + + + +

+
+

Returns a new instance of Button.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+
+
# File 'lacci/lib/shoes/widgets/button.rb', line 8
+
+def initialize(text, width: nil, height: nil, top: nil, left: nil, color: nil, padding_top: nil, padding_bottom: nil, size: 12, text_color: nil,
+  font_size: nil, & block)
+
+  log_init("Button")
+
+  # Properties passed as positional args, not keywords, don't get auto-set
+  @text = text
+  @color = color
+
+  @block = block
+
+  super
+
+  # Bind to a handler named "click"
+  bind_self_event("click") do
+    @log.debug("Button clicked, calling handler") if @block
+    @block&.call
+  end
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #click(&block) ⇒ Object + + + + + +

+
+

Set the click handler

+ + +
+
+
+ + +
+ + + + +
+
+
+
+31
+32
+33
+
+
# File 'lacci/lib/shoes/widgets/button.rb', line 31
+
+def click(&block)
+  @block = block
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Check.html b/Shoes/Check.html new file mode 100644 index 000000000..d1a0e27e8 --- /dev/null +++ b/Shoes/Check.html @@ -0,0 +1,469 @@ + + + + + + + Class: Shoes::Check + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Check + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/check.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(checked = nil, &block) ⇒ Check + + + + + +

+
+

Returns a new instance of Check.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lacci/lib/shoes/widgets/check.rb', line 7
+
+def initialize(checked = nil, &block)
+  @block = block
+  super
+
+  bind_self_event("click") { click }
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #checked(value) ⇒ Object + + + + + +

+ + + + +
+
+
+
+24
+25
+26
+
+
# File 'lacci/lib/shoes/widgets/check.rb', line 24
+
+def checked(value)
+  self.checked = value
+end
+
+
+ +
+

+ + #checked?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+20
+21
+22
+
+
# File 'lacci/lib/shoes/widgets/check.rb', line 20
+
+def checked?
+  @checked ? true : false
+end
+
+
+ +
+

+ + #click(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+15
+16
+17
+18
+
+
# File 'lacci/lib/shoes/widgets/check.rb', line 15
+
+def click(&block)
+  @block = block
+  self.checked = !checked?
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Colors.html b/Shoes/Colors.html new file mode 100644 index 000000000..975618716 --- /dev/null +++ b/Shoes/Colors.html @@ -0,0 +1,391 @@ + + + + + + + Module: Shoes::Colors + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Colors + + + +

+
+ + + + + + + + + +
+
Included in:
+
Widget
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/colors.rb
+
+ +
+ + + + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #gray(darkness = 128, alpha = nil) ⇒ Object + + + + + +

+
+ + +
+ + + + +
+
+
+
+159
+160
+161
+162
+
+
# File 'lacci/lib/shoes/colors.rb', line 159
+
+def gray(darkness = 128, alpha = nil)
+  alpha ||= (darkness.is_a?(Integer) ? 255 : 1.0)
+  [darkness, darkness, darkness, alpha]
+end
+
+
+ +
+

+ + #rgb(r, g, b, a = nil) ⇒ Object + + + + + +

+
+

Shoes allows RGB values to be Floats between 0 and 1 or Integers between 0 and 255

+ + +
+
+
+ + +
+ + + + +
+
+
+
+165
+166
+167
+168
+169
+170
+171
+172
+173
+
+
# File 'lacci/lib/shoes/colors.rb', line 165
+
+def rgb(r, g, b, a = nil)
+  if r.is_a?(Float)
+    [r, g, b, a || 1.0]
+  elsif r.is_a?(Integer)
+    [r, g, b, a || 255]
+  else
+    raise("RGB values should be Float or Integer!")
+  end
+end
+
+
+ +
+

+ + #to_rgb(color) ⇒ Object + + + + + +

+ + + + +
+
+
+
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+
+
# File 'lacci/lib/shoes/colors.rb', line 175
+
+def to_rgb(color)
+  case color
+  when nil
+    nil
+  when Array
+    color # Already an RGB array
+  when Symbol
+    if COLORS[color]
+      rgb(*COLORS[color])
+    else
+      raise("Unrecognised color name: #{color}")
+    end
+  when String
+    if color[0] == "#"
+      if color.length == 4
+        r = color[1].to_i(16)
+        g = color[2].to_i(16)
+        b = color[3].to_i(16)
+        rgb(16 * r, 16 * g, 16 * b)
+      elsif color.length == 7
+        r = color[1..2].to_i(16)
+        g = color[3..4].to_i(16)
+        b = color[5..6].to_i(16)
+        rgb(r, g, b)
+      else
+        raise("Don't know how to convert #{color.inspect} to RGB! (wrong number of digits)")
+      end
+    else
+      rgb_value = COLORS[color.to_sym]
+      if rgb_value
+        rgb(*rgb_value)
+      else
+        raise("Unrecognised color name: #{color}")
+      end
+    end
+  else
+    raise("Don't know how to convert #{color.inspect} to RGB!")
+  end
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Constants.html b/Shoes/Constants.html new file mode 100644 index 000000000..fd5f7d731 --- /dev/null +++ b/Shoes/Constants.html @@ -0,0 +1,249 @@ + + + + + + + Module: Shoes::Constants + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Constants + + + +

+
+ + + + + + + + + +
+
Included in:
+
Kernel
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/constants.rb
+
+ +
+ + + +

+ Constant Summary + collapse +

+ +
+ +
LIB_DIR = + +
+
find_lib_dir
+ +
RAD2PI = +
+
+

Math constants from Shoes3

+ + +
+
+
+ + +
+
+
0.01745329251994329577
+ +
TWO_PI = + +
+
6.28318530717958647693
+ +
HALF_PI = + +
+
1.57079632679489661923
+ +
PI = + +
+
3.14159265358979323846
+ +
+ + + + + + + + + +

+ Class Method Summary + collapse +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + .find_lib_dirObject + + + + + +

+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes/constants.rb', line 5
+
+def self.find_lib_dir
+  begin
+    require "tmpdir"
+  rescue LoadError
+    return nil
+  end
+  homes = [
+    [ENV["LOCALAPPDATA"], "Shoes"],
+    [ENV["APPDATA"], "Shoes"],
+    [ENV["HOME"], ".shoes"],
+    [Dir.tmpdir, "shoes"],
+  ]
+  top, file = homes.detect { |home_top, _| home_top && File.exist?(home_top) }
+  File.join(top, file)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/DisplayService.html b/Shoes/DisplayService.html new file mode 100644 index 000000000..5bb728985 --- /dev/null +++ b/Shoes/DisplayService.html @@ -0,0 +1,877 @@ + + + + + + + Class: Shoes::DisplayService + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::DisplayService + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + +
+
Extended by:
+
Log
+
+ + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/display_service.rb
+
+ +
+ + + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Log

+

configure_logger, log_init, logger

+ + +
+

Class Method Details

+ + +
+

+ + .dispatch_event(event_name, event_target, *args, **kwargs) ⇒ Object + + + + + +

+
+

An event_target may be nil, to indicate there is no target.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+
+
# File 'lacci/lib/shoes/display_service.rb', line 36
+
+def dispatch_event(event_name, event_target, *args, **kwargs)
+  @@display_event_handlers ||= {}
+
+  unless @log
+    log_init("DisplayService")
+  end
+
+  raise "Cannot dispatch on event_name :any!" if event_name == :any
+
+  @log.debug("Dispatch event: #{event_name.inspect} T: #{event_target.inspect} A: #{args.inspect} KW: #{kwargs.inspect}")
+
+  # When true, this makes sure all events and properties are 100% strings, no symbols.
+  if ENV["SCARPE_DEBUG"]
+    args = JSON.parse JSON.dump(args)
+    new_kw = {}
+    kwargs.each do |k, v|
+      new_kw[k] = JSON.parse JSON.dump(v)
+    end
+    kwargs = new_kw
+  end
+
+  same_name_handlers = @@display_event_handlers[event_name] || {}
+  any_name_handlers = @@display_event_handlers[:any] || {}
+
+  # Do we have any keys, in same_name_handlers or any_name_handlers, matching the target or :any?
+  # Note that "nil" is a target like any other for these purposes -- subscribing to a nil target
+  # won't get you non-nil-target events and vice-versa.
+  handlers = [
+    same_name_handlers[:any],           # Same name, any target
+    same_name_handlers[event_target],   # Same name, same target
+    any_name_handlers[:any],            # Any name, any target
+    any_name_handlers[event_target],    # Any name, same target
+  ].compact.inject([], &:+)
+  kwargs[:event_name] = event_name
+  kwargs[:event_target] = event_target if event_target
+  handlers.each { |h| h[:handler].call(*args, **kwargs) }
+end
+
+
+ +
+

+ + .display_serviceObject + + + + + +

+ + + + +
+
+
+
+120
+121
+122
+123
+124
+125
+126
+
+
# File 'lacci/lib/shoes/display_service.rb', line 120
+
+def display_service
+  return @service if @service
+
+  raise "No display service was set!" unless @display_service_klass
+
+  @service = @display_service_klass.new
+end
+
+
+ +
+

+ + .full_reset!Object + + + + + +

+ + + + +
+
+
+
+109
+110
+111
+112
+
+
# File 'lacci/lib/shoes/display_service.rb', line 109
+
+def full_reset!
+  @@display_event_handlers = {}
+  @json_debug_serialize = nil
+end
+
+
+ +
+

+ + .set_display_service_class(klass) ⇒ Object + + + + + +

+ + + + +
+
+
+
+114
+115
+116
+117
+118
+
+
# File 'lacci/lib/shoes/display_service.rb', line 114
+
+def set_display_service_class(klass)
+  raise "Can only set a single display service class!" if @display_service_klass
+
+  @display_service_klass = klass
+end
+
+
+ +
+

+ + .subscribe_to_event(event_name, event_target, &handler) ⇒ Object + + + + + +

+
+

It's permitted to subscribe to event_name :any for all event names, and event_target :any for all targets. +An event_target of nil means "no target", and only matches events dispatched with a nil target.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+
+
# File 'lacci/lib/shoes/display_service.rb', line 76
+
+def subscribe_to_event(event_name, event_target, &handler)
+  @@display_event_handlers ||= {}
+  @@display_event_unsub_id ||= 0
+  unless handler
+    raise "Must pass a block as a handler to DisplayService.subscribe_to_event!"
+  end
+
+  unless @log
+    log_init("DisplayService")
+  end
+
+  @log.debug("Subscribe to event: #{event_name.inspect} T: #{event_target.inspect}")
+
+  id = @@display_event_unsub_id
+  @@display_event_unsub_id += 1
+
+  @@display_event_handlers[event_name] ||= {}
+  @@display_event_handlers[event_name][event_target] ||= []
+  @@display_event_handlers[event_name][event_target] << { handler:, unsub_id: id }
+
+  id
+end
+
+
+ +
+

+ + .unsub_from_events(unsub_id) ⇒ Object + + + + + +

+ + + + +
+
+
+
+99
+100
+101
+102
+103
+104
+105
+106
+107
+
+
# File 'lacci/lib/shoes/display_service.rb', line 99
+
+def unsub_from_events(unsub_id)
+  raise "Must provide an unsubscribe ID!" if unsub_id.nil?
+
+  @@display_event_handlers.each do |_e_name, target_hash|
+    target_hash.each do |_target, h_list|
+      h_list.delete_if { |item| item[:unsub_id] == unsub_id }
+    end
+  end
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #create_display_widget_for(widget_class_name, widget_id, properties) ⇒ Object + + + + + +

+
+

These methods are an interface to DisplayService objects.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+131
+132
+133
+
+
# File 'lacci/lib/shoes/display_service.rb', line 131
+
+def create_display_widget_for(widget_class_name, widget_id, properties)
+  raise "Override in DisplayService implementation!"
+end
+
+
+ +
+

+ + #destroyObject + + + + + +

+ + + + +
+
+
+
+149
+150
+151
+
+
# File 'lacci/lib/shoes/display_service.rb', line 149
+
+def destroy
+  raise "Override in DisplayService implementation!"
+end
+
+
+ +
+

+ + #query_display_widget_for(id, nil_ok: false) ⇒ Object + + + + + +

+ + + + +
+
+
+
+140
+141
+142
+143
+144
+145
+146
+147
+
+
# File 'lacci/lib/shoes/display_service.rb', line 140
+
+def query_display_widget_for(id, nil_ok: false)
+  display_widget = @display_widget_for[id]
+  unless display_widget || nil_ok
+    raise "Could not find display widget for linkable ID #{id.inspect}!"
+  end
+
+  display_widget
+end
+
+
+ +
+

+ + #set_widget_pairing(id, display_widget) ⇒ Object + + + + + +

+ + + + +
+
+
+
+135
+136
+137
+138
+
+
# File 'lacci/lib/shoes/display_service.rb', line 135
+
+def set_widget_pairing(id, display_widget)
+  @display_widget_for ||= {}
+  @display_widget_for[id] = display_widget
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/DocumentRoot.html b/Shoes/DocumentRoot.html new file mode 100644 index 000000000..a14e987d6 --- /dev/null +++ b/Shoes/DocumentRoot.html @@ -0,0 +1,410 @@ + + + + + + + Class: Shoes::DocumentRoot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::DocumentRoot + + + +

+
+ +
+
Inherits:
+
+ Flow + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/document_root.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children

+ + + +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ +
    + +
  • + + + #initialize ⇒ DocumentRoot + + + + + + + constructor + + + + + + + + +

    A new instance of DocumentRoot.

    +
    + +
  • + + +
  • + + + #inspect ⇒ Object + + + + + + + + + + + + + +

    The default inspect string can be absolutely huge in console output, and it's frequently printed.

    +
    + +
  • + + +
+ + + + + + + + + + + + + + + + + + + + + + + +

Methods included from Border

+

#border

+ + + + + + + + + +

Methods included from Background

+

#background

+ + + + + + + + + +

Methods inherited from Slot

+

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

+ + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initializeDocumentRoot + + + + + +

+
+

Returns a new instance of DocumentRoot.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+5
+6
+7
+8
+9
+10
+11
+12
+13
+
+
# File 'lacci/lib/shoes/widgets/document_root.rb', line 5
+
+def initialize
+  @height = "100%"
+  @width = @margin = @padding = nil
+  @options = {}
+
+  super
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #inspectObject + + + + + +

+
+

The default inspect string can be absolutely huge in console output, and it's frequently printed.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lacci/lib/shoes/widgets/document_root.rb', line 16
+
+def inspect
+  "<Shoes::DocumentRoot>"
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/EditBox.html b/Shoes/EditBox.html new file mode 100644 index 000000000..4d2ff9438 --- /dev/null +++ b/Shoes/EditBox.html @@ -0,0 +1,405 @@ + + + + + + + Class: Shoes::EditBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::EditBox + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/edit_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(text = "", height: nil, width: nil, &block) ⇒ EditBox + + + + + +

+
+

Returns a new instance of EditBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes/widgets/edit_box.rb', line 7
+
+def initialize(text = "", height: nil, width: nil, &block)
+  @text = text
+  @callback = block
+
+  super
+
+  bind_self_event("change") do |new_text|
+    self.text = new_text
+    @callback&.call(self)
+  end
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #append(new_text) ⇒ Object + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lacci/lib/shoes/widgets/edit_box.rb', line 25
+
+def append(new_text)
+  self.text = self.text + new_text
+end
+
+
+ +
+

+ + #change(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/shoes/widgets/edit_box.rb', line 21
+
+def change(&block)
+  @callback = block
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/EditLine.html b/Shoes/EditLine.html new file mode 100644 index 000000000..50c49dd7a --- /dev/null +++ b/Shoes/EditLine.html @@ -0,0 +1,353 @@ + + + + + + + Class: Shoes::EditLine + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::EditLine + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/edit_line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(text = "", width: nil, &block) ⇒ EditLine + + + + + +

+
+

Returns a new instance of EditLine.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes/widgets/edit_line.rb', line 7
+
+def initialize(text = "", width: nil, &block)
+  @block = block
+  @text = text
+
+  super
+
+  bind_self_event("change") do |new_text|
+    self.text = new_text
+    @block&.call(new_text)
+  end
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #change(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/shoes/widgets/edit_line.rb', line 21
+
+def change(&block)
+  @block = block
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Error.html b/Shoes/Error.html new file mode 100644 index 000000000..ec8a7f9ba --- /dev/null +++ b/Shoes/Error.html @@ -0,0 +1,128 @@ + + + + + + + Exception: Shoes::Error + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::Error + + + +

+
+ +
+
Inherits:
+
+ StandardError + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes.rb
+
+ +
+ +
+

Direct Known Subclasses

+

InvalidAttributeValueError

+
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Flow.html b/Shoes/Flow.html new file mode 100644 index 000000000..1a65f4314 --- /dev/null +++ b/Shoes/Flow.html @@ -0,0 +1,344 @@ + + + + + + + Class: Shoes::Flow + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Flow + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + +
+
Includes:
+
Background, Border, Spacing
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/flow.rb
+
+ +
+ +
+

Direct Known Subclasses

+

DocumentRoot

+
+ + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children

+ + + +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + + + + + +

Methods included from Border

+

#border

+ + + + + + + + + +

Methods included from Background

+

#background

+ + + + + + + + + +

Methods inherited from Slot

+

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

+ + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(width: "100%", height: nil, margin: nil, padding: nil, **options, &block) ⇒ Flow + + + + + +

+
+

Returns a new instance of Flow.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+
+
# File 'lacci/lib/shoes/widgets/flow.rb', line 11
+
+def initialize(width: "100%", height: nil, margin: nil, padding: nil, **options, &block)
+  @options = options
+
+  super
+
+  # Create the display-side widget *before* instance_eval, which will add child widgets with their display widgets
+  create_display_widget
+
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Font.html b/Shoes/Font.html new file mode 100644 index 000000000..5f0b01f4a --- /dev/null +++ b/Shoes/Font.html @@ -0,0 +1,281 @@ + + + + + + + Class: Shoes::Font + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Font + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/font.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(font) ⇒ Font + + + + + +

+
+

Returns a new instance of Font.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+
+
# File 'lacci/lib/shoes/widgets/font.rb', line 7
+
+def initialize(font)
+  @font = font
+  super
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Image.html b/Shoes/Image.html new file mode 100644 index 000000000..def4fa195 --- /dev/null +++ b/Shoes/Image.html @@ -0,0 +1,405 @@ + + + + + + + Class: Shoes::Image + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Image + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/image.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(url, width: nil, height: nil, top: nil, left: nil, click: nil) ⇒ Image + + + + + +

+
+

Returns a new instance of Image.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'lacci/lib/shoes/widgets/image.rb', line 7
+
+def initialize(url, width: nil, height: nil, top: nil, left: nil, click: nil)
+  @url = url
+
+  super
+
+  # Get the image dimensions
+  # @width, @height = size
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #replace(url) ⇒ Object + + + + + +

+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lacci/lib/shoes/widgets/image.rb', line 18
+
+def replace(url)
+  self.url = url
+end
+
+
+ +
+

+ + #sizeObject + + + + + +

+ + + + +
+
+
+
+22
+23
+24
+25
+26
+27
+
+
# File 'lacci/lib/shoes/widgets/image.rb', line 22
+
+def size
+  require "fastimage"
+  width, height = FastImage.size(@url)
+
+  [width, height]
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/InvalidAttributeValueError.html b/Shoes/InvalidAttributeValueError.html new file mode 100644 index 000000000..0e996ffbf --- /dev/null +++ b/Shoes/InvalidAttributeValueError.html @@ -0,0 +1,132 @@ + + + + + + + Exception: Shoes::InvalidAttributeValueError + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: Shoes::InvalidAttributeValueError + + + +

+
+ +
+
Inherits:
+
+ Error + +
    +
  • Object
  • + + + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/arc.rb
+
+ +
+ + + + + + + + + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Line.html b/Shoes/Line.html new file mode 100644 index 000000000..e6968563e --- /dev/null +++ b/Shoes/Line.html @@ -0,0 +1,289 @@ + + + + + + + Class: Shoes::Line + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Line + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/line.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(left, top, x2, y2) ⇒ Line + + + + + +

+
+

Returns a new instance of Line.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'lacci/lib/shoes/widgets/line.rb', line 7
+
+def initialize(left, top, x2, y2)
+  @left = left
+  @top = top
+  @x2 = x2
+  @y2 = y2
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Link.html b/Shoes/Link.html new file mode 100644 index 000000000..dc4662c38 --- /dev/null +++ b/Shoes/Link.html @@ -0,0 +1,316 @@ + + + + + + + Class: Shoes::Link + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Link + + + +

+
+ +
+
Inherits:
+
+ TextWidget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/link.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from TextWidget

+

inherited

+ + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(text, click: nil, &block) ⇒ Link + + + + + +

+
+

Returns a new instance of Link.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+
+
# File 'lacci/lib/shoes/widgets/link.rb', line 7
+
+def initialize(text, click: nil, &block)
+  @text = text
+  @block = block
+  # We can't send a block to the display widget, but we can send a boolean
+  @has_block = !block.nil?
+
+  super
+
+  # The click property should be changed before it gets sent to the display widget
+  @click ||= "#"
+
+  bind_self_event("click") do
+    @block&.call
+  end
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Linkable.html b/Shoes/Linkable.html new file mode 100644 index 000000000..1e75dd2d5 --- /dev/null +++ b/Shoes/Linkable.html @@ -0,0 +1,515 @@ + + + + + + + Class: Shoes::Linkable + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Linkable + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/display_service.rb
+
+ +
+ +

Overview

+
+

This is for objects that can be referred to via events, using their +IDs. There are also convenience functions for binding and sending +events.

+ +

Linkable objects may be event targets. Technically anything, linkable +or not, can be an event subscriber, but linkables get easy convenience +functions for subscription.

+ + +
+
+
+ + +
+ + + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #linkable_id ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute linkable_id.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(linkable_id: object_id) ⇒ Linkable + + + + + +

+
+

Returns a new instance of Linkable.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+164
+165
+166
+
+
# File 'lacci/lib/shoes/display_service.rb', line 164
+
+def initialize(linkable_id: object_id)
+  @linkable_id = linkable_id
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #linkable_idObject (readonly) + + + + + +

+
+

Returns the value of attribute linkable_id.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+162
+163
+164
+
+
# File 'lacci/lib/shoes/display_service.rb', line 162
+
+def linkable_id
+  @linkable_id
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #bind_shoes_event(event_name:, target: nil, &handler) ⇒ Object + + + + + +

+ + + + +
+
+
+
+176
+177
+178
+
+
# File 'lacci/lib/shoes/display_service.rb', line 176
+
+def bind_shoes_event(event_name:, target: nil, &handler)
+  DisplayService.subscribe_to_event(event_name, target, &handler)
+end
+
+
+ +
+

+ + #send_self_event(*args, event_name:, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+168
+169
+170
+
+
# File 'lacci/lib/shoes/display_service.rb', line 168
+
+def send_self_event(*args, event_name:, **kwargs)
+  DisplayService.dispatch_event(event_name, self.linkable_id, *args, **kwargs)
+end
+
+
+ +
+

+ + #send_shoes_event(*args, event_name:, target: nil, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+172
+173
+174
+
+
# File 'lacci/lib/shoes/display_service.rb', line 172
+
+def send_shoes_event(*args, event_name:, target: nil, **kwargs)
+  DisplayService.dispatch_event(event_name, target, *args, **kwargs)
+end
+
+
+ +
+

+ + #unsub_shoes_event(unsub_id) ⇒ Object + + + + + +

+ + + + +
+
+
+
+180
+181
+182
+
+
# File 'lacci/lib/shoes/display_service.rb', line 180
+
+def unsub_shoes_event(unsub_id)
+  DisplayService.unsub_from_events(unsub_id)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/ListBox.html b/Shoes/ListBox.html new file mode 100644 index 000000000..c0404acf9 --- /dev/null +++ b/Shoes/ListBox.html @@ -0,0 +1,353 @@ + + + + + + + Class: Shoes::ListBox + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::ListBox + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/list_box.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(args = {}, &block) ⇒ ListBox + + + + + +

+
+

Returns a new instance of ListBox.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+
+
# File 'lacci/lib/shoes/widgets/list_box.rb', line 7
+
+def initialize(args = {}, &block)
+  @items = args[:items] || []
+  @selected_item = args[:selected_item]
+  super()
+
+  bind_self_event("change") do |new_item|
+    self.selected_item = new_item
+    @callback&.call(new_item)
+  end
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #change(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+20
+21
+22
+23
+
+
# File 'lacci/lib/shoes/widgets/list_box.rb', line 20
+
+def change(&block)
+  @callback = block
+  self # Allow chaining calls
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Log.html b/Shoes/Log.html new file mode 100644 index 000000000..910af5968 --- /dev/null +++ b/Shoes/Log.html @@ -0,0 +1,497 @@ + + + + + + + Module: Shoes::Log + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Log + + + +

+ + +

Overview

+
+

Include this module to get a @log instance variable to log as your +configured component.

+ + +
+
+
+ + +
+ +

+ Constant Summary + collapse +

+ +
+ +
DEFAULT_COMPONENT = +
+
+

These constants will wind up included in a lot of places. Should they move?

+ + +
+
+
+ + +
+
+
"default"
+ +
DEFAULT_LOG_CONFIG = + +
+
{
+  "default" => "info",
+}
+ +
DEFAULT_DEBUG_LOG_CONFIG = + +
+
{
+  "default" => "debug",
+}
+ +
+ + + + + +

Class Attribute Summary collapse

+
    + +
  • + + + .current_log_config ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute current_log_config.

    +
    + +
  • + + +
  • + + + .instance ⇒ Object + + + + + + + + + + + + + + + + +

    Returns the value of attribute instance.

    +
    + +
  • + + +
+ + + + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + +
+

Class Attribute Details

+ + + +
+

+ + .current_log_configObject (readonly) + + + + + +

+
+

Returns the value of attribute current_log_config.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+28
+29
+30
+
+
# File 'lacci/lib/shoes/log.rb', line 28
+
+def current_log_config
+  @current_log_config
+end
+
+
+ + + +
+

+ + .instanceObject + + + + + +

+
+

Returns the value of attribute instance.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lacci/lib/shoes/log.rb', line 27
+
+def instance
+  @instance
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .configure_logger(log_config) ⇒ Object + + + + + +

+ + + + +
+
+
+
+40
+41
+42
+
+
# File 'lacci/lib/shoes/log.rb', line 40
+
+def configure_logger(log_config)
+  @instance.configure_logger(log_config)
+end
+
+
+ +
+

+ + .logger(component = self) ⇒ Object + + + + + +

+ + + + +
+
+
+
+36
+37
+38
+
+
# File 'lacci/lib/shoes/log.rb', line 36
+
+def logger(component = self)
+  @instance.logger_for_component(component)
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+

+ + #log_init(component = self) ⇒ Object + + + + + +

+ + + + +
+
+
+
+45
+46
+47
+
+
# File 'lacci/lib/shoes/log.rb', line 45
+
+def log_init(component = self)
+  @log = Shoes::Log.instance.logger_for_component(component)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/LoggedWrapper.html b/Shoes/LoggedWrapper.html new file mode 100644 index 000000000..fd78e12c4 --- /dev/null +++ b/Shoes/LoggedWrapper.html @@ -0,0 +1,377 @@ + + + + + + + Class: Shoes::LoggedWrapper + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::LoggedWrapper + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/log.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+
+

Constructor Details

+ +
+

+ + #initialize(instance, component = instance) ⇒ LoggedWrapper + + + + + +

+
+

Returns a new instance of LoggedWrapper.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+52
+53
+54
+55
+56
+
+
# File 'lacci/lib/shoes/log.rb', line 52
+
+def initialize(instance, component = instance)
+  log_init(component)
+
+  @instance = instance
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(method) ⇒ Object + + + + + +

+ + + + +
+
+
+
+58
+59
+60
+61
+62
+63
+64
+65
+
+
# File 'lacci/lib/shoes/log.rb', line 58
+
+def method_missing(method, ...)
+  self.singleton_class.define_method(method) do |*args, **kwargs, &block|
+    ret = @instance.send(method, *args, **kwargs, &block)
+    @log.info("Method: #{method} Args: #{args.inspect} KWargs: #{kwargs.inspect} Block: #{block ? "y" : "n"} Return: #{ret.inspect}")
+    ret
+  end
+  send(method, ...)
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #respond_to_missing?(method_name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+67
+68
+69
+
+
# File 'lacci/lib/shoes/log.rb', line 67
+
+def respond_to_missing?(method_name, include_private = false)
+  @instance.respond_to_missing?(method_name, include_private)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Para.html b/Shoes/Para.html new file mode 100644 index 000000000..91aceca82 --- /dev/null +++ b/Shoes/Para.html @@ -0,0 +1,423 @@ + + + + + + + Class: Shoes::Para + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Para + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/para.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, stroke: nil, size: :para, font: nil, hidden: false, **html_attributes) ⇒ Para + + + + + +

+
+

Returns a new instance of Para.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 7
+
+def initialize(*args, stroke: nil, size: :para, font: nil, hidden: false, **html_attributes)
+  @text_children = args || []
+  if hidden
+    @hidden_text_items = text_children_to_items(@text_children)
+    @text_items = []
+  else
+    # Text_children alternates strings and TextWidgets, so we can't just pass
+    # it as a display property. It won't serialize.
+    @text_items = text_children_to_items(@text_children)
+    @hidden_text_items = []
+  end
+  stroke = to_rgb(stroke)
+
+  @html_attributes = html_attributes || {}
+
+  super
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #replace(*children) ⇒ Object + + + + + +

+ + + + +
+
+
+
+31
+32
+33
+34
+35
+36
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 31
+
+def replace(*children)
+  @text_children = children
+
+  # This should signal the display widget to change
+  self.text_items = text_children_to_items(@text_children)
+end
+
+
+ +
+

+ + #text_children_to_items(text_children) ⇒ Object + + + + + +

+ + + + +
+
+
+
+27
+28
+29
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 27
+
+def text_children_to_items(text_children)
+  text_children.map { |arg| arg.is_a?(String) ? arg : arg.linkable_id }
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Radio.html b/Shoes/Radio.html new file mode 100644 index 000000000..d94f89dad --- /dev/null +++ b/Shoes/Radio.html @@ -0,0 +1,471 @@ + + + + + + + Class: Shoes::Radio + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Radio + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/radio.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(group = nil, checked = nil, &block) ⇒ Radio + + + + + +

+
+

Returns a new instance of Radio.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+
+
# File 'lacci/lib/shoes/widgets/radio.rb', line 7
+
+def initialize(group = nil, checked = nil, &block)
+  @group = group
+  @block = block
+  super
+
+  bind_self_event("click") { click }
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #checked(value) ⇒ Object + + + + + +

+ + + + +
+
+
+
+25
+26
+27
+
+
# File 'lacci/lib/shoes/widgets/radio.rb', line 25
+
+def checked(value)
+  self.checked = value
+end
+
+
+ +
+

+ + #checked?Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+21
+22
+23
+
+
# File 'lacci/lib/shoes/widgets/radio.rb', line 21
+
+def checked?
+  @checked ? true : false
+end
+
+
+ +
+

+ + #click(&block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+19
+
+
# File 'lacci/lib/shoes/widgets/radio.rb', line 16
+
+def click(&block)
+  @block = block
+  self.checked = !checked?
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Shape.html b/Shoes/Shape.html new file mode 100644 index 000000000..328005bb7 --- /dev/null +++ b/Shoes/Shape.html @@ -0,0 +1,414 @@ + + + + + + + Class: Shoes::Shape + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Shape + + + +

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

Overview

+
+

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

+ +

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

+ + +
+
+
+ +

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

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

    +
    + +
  • + +
+ +
+ + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children

+ + + +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Slot

+

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

+ + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

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

+
+

Returns a new instance of Shape.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+
+
# File 'lacci/lib/shoes/widgets/shape.rb', line 15
+
+def initialize(left: nil, top: nil, &block)
+  @left = left
+  @top = top
+  @shape_commands = []
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+  create_display_widget
+
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #add_shape_command(cmd) ⇒ Object + + + + + +

+
+

The cmd should be an array of the form:

+ +
[cmd_name, *args]
+
+ +

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

+ + +
+
+
+ + +
+ + + + +
+
+
+
+33
+34
+35
+
+
# File 'lacci/lib/shoes/widgets/shape.rb', line 33
+
+def add_shape_command(cmd)
+  @shape_commands << cmd
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Slot.html b/Shoes/Slot.html new file mode 100644 index 000000000..936169f6e --- /dev/null +++ b/Shoes/Slot.html @@ -0,0 +1,843 @@ + + + + + + + Class: Shoes::Slot + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Slot + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/slot.rb
+
+ +
+ +
+

Direct Known Subclasses

+

Flow, Shape, Stack

+
+ + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + +

Instance Attribute Summary collapse

+ + + + + + +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Shoes::Widget

+ +
+
+

Dynamic Method Handling

+

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

+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #childrenObject (readonly) + + + + + +

+
+ + +
+
+
+ +

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    Shoes uses #content, not #children, for this

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+5
+6
+7
+
+
# File 'lacci/lib/shoes/widgets/slot.rb', line 5
+
+def children
+  @children
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #add_child(child) ⇒ Object + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+17
+18
+19
+20
+
+
# File 'lacci/lib/shoes/widgets/slot.rb', line 17
+
+def add_child(child)
+  @children ||= []
+  @children << child
+end
+
+
+ +
+

+ + #app { ... } ⇒ Shoes::App + + + + + +

+
+

Calling stack.app or flow.app will execute the block +with the Shoes::App as self, and with that stack or +flow as the current slot.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    the block to call with the Shoes App as self

    +
    + +
  • + +
+

Returns:

+
    + +
  • + + + (Shoes::App) + + + + — +

    the Shoes app

    +
    + +
  • + +
+

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    Shoes Classic will only change self +via this method, while Scarpe will also change self +with the other Slot Manipulation methods: #clear,

    + +

    append, #prepend, #before and #after.

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+39
+40
+41
+42
+
+
# File 'lacci/lib/shoes/widgets/slot.rb', line 39
+
+def app(&block)
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+  Shoes::App.instance
+end
+
+
+ +
+

+ + #append { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

Call the block to append new children to a Slot.

+ +

Should only be called on a Slot, since only Slots can have children.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    the block to call to replace children; will be called on the Shoes::App, appending to the called Slot as the current slot

    +
    + +
  • + +
+

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    Shoes Classic calls the append block with current self, while Scarpe uses the Shoes::App as self

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+69
+70
+71
+72
+73
+74
+
+
# File 'lacci/lib/shoes/widgets/slot.rb', line 69
+
+def append(&block)
+  raise("append requires a block!") unless block_given?
+  raise("Don't append to something that isn't a slot!") unless self.is_a?(Shoes::Slot)
+
+  Shoes::App.instance.with_slot(self, &block)
+end
+
+
+ +
+

+ + #clear { ... } ⇒ void + + + + + +

+
+

This method returns an undefined value.

Remove all children from this widget. If a block +is given, call the block to replace the children with +new contents from that block.

+ +

Should only be called on Slots, which can +have children.

+ + +
+
+
+ +

Yields:

+
    + +
  • + + + + + + + +

    The block to call to replace the contents of the widget (optional)

    +
    + +
  • + +
+

Incompatibilities with Shoes:

+
    + +
  • + + + + + +

    Shoes Classic calls the clear block with current self, while Scarpe uses the Shoes::App as self

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+55
+56
+57
+58
+59
+
+
# File 'lacci/lib/shoes/widgets/slot.rb', line 55
+
+def clear(&block)
+  @children.dup.each(&:destroy)
+  append(&block) if block_given?
+  nil
+end
+
+
+ +
+

+ + #contentsObject + + + + + +

+
+

Get a list of child widgets

+ + +
+
+
+ + +
+ + + + +
+
+
+
+23
+24
+25
+26
+
+
# File 'lacci/lib/shoes/widgets/slot.rb', line 23
+
+def contents
+  @children ||= []
+  @children.dup
+end
+
+
+ +
+

+ + #remove_child(child) ⇒ Object + + + + + +

+
+

Do not call directly, use set_parent

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+11
+12
+13
+14
+
+
# File 'lacci/lib/shoes/widgets/slot.rb', line 8
+
+def remove_child(child)
+  @children ||= []
+  unless @children.include?(child)
+    @log.warn("remove_child: no such child(#{child.inspect}) for parent(#{parent.inspect})!")
+  end
+  @children.delete(child)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Spacing.html b/Shoes/Spacing.html new file mode 100644 index 000000000..2982b821c --- /dev/null +++ b/Shoes/Spacing.html @@ -0,0 +1,110 @@ + + + + + + + Module: Shoes::Spacing + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Shoes::Spacing + + + +

+
+ + + + + + + + + +
+
Included in:
+
Flow, Stack
+
+ + + +
+
Defined in:
+
lacci/lib/shoes/spacing.rb
+
+ +
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Span.html b/Shoes/Span.html new file mode 100644 index 000000000..a6b48e43b --- /dev/null +++ b/Shoes/Span.html @@ -0,0 +1,355 @@ + + + + + + + Class: Shoes::Span + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Span + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/span.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(text, stroke: nil, size: :span, font: nil, **html_attributes) ⇒ Span + + + + + +

+
+

Returns a new instance of Span.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+
+
# File 'lacci/lib/shoes/widgets/span.rb', line 7
+
+def initialize(text, stroke: nil, size: :span, font: nil, **html_attributes)
+  @text = text
+  @stroke = stroke
+  @size = size
+  @font = font
+  @html_attributes = html_attributes
+
+  super
+
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #replace(text) ⇒ Object + + + + + +

+ + + + +
+
+
+
+19
+20
+21
+22
+23
+24
+
+
# File 'lacci/lib/shoes/widgets/span.rb', line 19
+
+def replace(text)
+  @text = text
+
+  # This should signal the display widget to change
+  self.text = @text
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Stack.html b/Shoes/Stack.html new file mode 100644 index 000000000..1823b4535 --- /dev/null +++ b/Shoes/Stack.html @@ -0,0 +1,342 @@ + + + + + + + Class: Shoes::Stack + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Stack + + + +

+
+ +
+
Inherits:
+
+ Slot + + + show all + +
+
+ + + + + + +
+
Includes:
+
Background, Border, Spacing
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/stack.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Slot

+

#children

+ + + +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + + + + + + + +

Methods included from Border

+

#border

+ + + + + + + + + +

Methods included from Background

+

#background

+ + + + + + + + + +

Methods inherited from Slot

+

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

+ + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(width: nil, height: nil, margin: nil, padding: nil, scroll: false, margin_top: nil, margin_bottom: nil, margin_left: nil, margin_right: nil, **options, &block) ⇒ Stack + + + + + +

+
+

Returns a new instance of Stack.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+
+
# File 'lacci/lib/shoes/widgets/stack.rb', line 12
+
+def initialize(width: nil, height: nil, margin: nil, padding: nil, scroll: false, margin_top: nil, margin_bottom: nil, margin_left: nil,
+  margin_right: nil, **options, &block)
+
+  @options = options
+
+  super
+
+  create_display_widget
+  # Create the display-side widget *before* running the block, which will add child widgets with their display widgets
+  Shoes::App.instance.with_slot(self, &block) if block_given?
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Star.html b/Shoes/Star.html new file mode 100644 index 000000000..9a6d5aaed --- /dev/null +++ b/Shoes/Star.html @@ -0,0 +1,289 @@ + + + + + + + Class: Shoes::Star + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Star + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/star.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(left, top, points = 10, outer = 100, inner = 50) ⇒ Star + + + + + +

+
+

Returns a new instance of Star.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+
+
# File 'lacci/lib/shoes/widgets/star.rb', line 7
+
+def initialize(left, top, points = 10, outer = 100, inner = 50)
+  @points = convert_to_integer(points, "points", 10)
+  @outer = convert_to_float(outer, "outer", 100.0)
+  @inner = convert_to_float(inner, "inner", 50.0)
+
+  @draw_context = Shoes::App.instance.current_draw_context
+
+  super
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/SubscriptionItem.html b/Shoes/SubscriptionItem.html new file mode 100644 index 000000000..2f524823b --- /dev/null +++ b/Shoes/SubscriptionItem.html @@ -0,0 +1,427 @@ + + + + + + + Class: Shoes::SubscriptionItem + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::SubscriptionItem + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/subscription_item.rb
+
+ +
+ +

Overview

+
+

Certain Shoes calls like motion and keydown are basically an +event subscription, with no other visible presence. However, +they have a place in the widget tree and can be deleted.

+ +

Depending on the display library they may not have any +direct visual (or similar) presence there either.

+ +

Inheriting from Widget gives these a parent slot and a +linkable_id automatically.

+ + +
+
+
+ + +
+ + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(shoes_api_name:, &block) ⇒ SubscriptionItem + + + + + +

+
+

Returns a new instance of SubscriptionItem.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+
+
# File 'lacci/lib/shoes/widgets/subscription_item.rb', line 15
+
+def initialize(shoes_api_name:, &block)
+  super
+
+  @callback = block
+
+  case shoes_api_name
+  when "hover"
+    # Hover passes the Shoes widget as the block param
+    @unsub_id = bind_self_event("hover") do
+      @callback&.call(self)
+    end
+  when "motion"
+    # Shoes sends back x, y, mods as the args.
+    # Shoes3 uses the strings "control" "shift" and
+    # "control_shift" as the mods arg.
+    @unsub_id = bind_self_event("motion") do |x, y, ctrl_key, shift_key, **_kwargs|
+      mods = [ctrl_key ? "control" : nil, shift_key ? "shift" : nil].compact.join("_")
+      @callback&.call(x, y, mods)
+    end
+  when "click"
+    # Click has block params button, left, top
+    # button is the button number, left and top are coords
+    @unsub_id = bind_self_event("click") do |button, x, y, **_kwargs|
+      @callback&.call(button, x, y)
+    end
+  else
+    raise "Unknown Shoes API call #{shoes_api_name.inspect} passed to SubscriptionItem!"
+  end
+
+  @unsub_id = bind_self_event(shoes_api_name) do |*args|
+    @callback&.call(*args)
+  end
+
+  # This won't create a visible display widget, but will turn into
+  # an invisible widget and a stream of events.
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #destroyObject + + + + + +

+ + + + +
+
+
+
+53
+54
+55
+56
+57
+58
+59
+
+
# File 'lacci/lib/shoes/widgets/subscription_item.rb', line 53
+
+def destroy
+  # TODO: we need a better way to do this automatically. See https://github.com/scarpe-team/scarpe/issues/291
+  unsub_shoes_event(@unsub_id) if @unsub_id
+  @unsub_id = nil
+
+  super
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/TextWidget.html b/Shoes/TextWidget.html new file mode 100644 index 000000000..a5bd18fa4 --- /dev/null +++ b/Shoes/TextWidget.html @@ -0,0 +1,287 @@ + + + + + + + Class: Shoes::TextWidget + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::TextWidget + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/text_widget.rb
+
+ +
+ +
+

Direct Known Subclasses

+

Link

+
+ + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Class Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #initialize, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +

This class inherits a constructor from Shoes::Widget

+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+

Class Method Details

+ + +
+

+ + .inherited(subclass) ⇒ Object + + + + + +

+
+

rubocop:disable Lint/MissingSuper

+ + +
+
+
+ + +
+ + + + +
+
+
+
+9
+10
+11
+12
+
+
# File 'lacci/lib/shoes/widgets/text_widget.rb', line 9
+
+def inherited(subclass)
+  Shoes::Widget.widget_classes ||= []
+  Shoes::Widget.widget_classes << subclass
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Video.html b/Shoes/Video.html new file mode 100644 index 000000000..eed3b47ec --- /dev/null +++ b/Shoes/Video.html @@ -0,0 +1,279 @@ + + + + + + + Class: Shoes::Video + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Video + + + +

+
+ +
+
Inherits:
+
+ Widget + + + show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/widgets/video.rb
+
+ +
+ + + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + + + +

Instance Attribute Summary

+ +

Attributes inherited from Widget

+

#parent

+ + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods inherited from Widget

+

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

+ + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(url) ⇒ Video + + + + + +

+
+

Returns a new instance of Video.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+7
+8
+9
+10
+11
+
+
# File 'lacci/lib/shoes/widgets/video.rb', line 7
+
+def initialize(url)
+  @url = url
+  super
+  create_display_widget
+end
+
+
+ +
+
+

Dynamic Method Handling

+

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

+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Widget.html b/Shoes/Widget.html new file mode 100644 index 000000000..f12dccee7 --- /dev/null +++ b/Shoes/Widget.html @@ -0,0 +1,1951 @@ + + + + + + + Class: Shoes::Widget + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Widget + + + +

+
+ +
+
Inherits:
+
+ Linkable + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + +
+
Includes:
+
Colors, Log
+
+ + + + + + +
+
Defined in:
+
lacci/lib/shoes/widget.rb,
+ lacci/lib/shoes/download.rb,
lacci/lib/shoes/widgets/para.rb
+
+
+ +
+ +

Overview

+
+

Shoes::Widget

+ +

This is the display-service portable Shoes Widget interface. Visible Shoes +widgets like buttons inherit from this. Compound widgets made of multiple +different smaller Widgets inherit from it in their various apps or libraries. +The Shoes Widget helps build a Shoes-side widget tree, with parents and +children. Any API that applies to all widgets (e.g. remove) should be +defined here.

+ + +
+
+
+ + +
+

Defined Under Namespace

+

+ + + + + Classes: ResponseWrapper + + +

+ + + +

Constant Summary

+ +

Constants included + from Log

+

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

+ + +

Class Attribute Summary collapse

+ + +

Instance Attribute Summary collapse

+
    + +
  • + + + #parent ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute parent.

    +
    + +
  • + + +
+ + + + + +

Attributes inherited from Linkable

+

#linkable_id

+ + + +

+ Class Method Summary + collapse +

+ + + +

+ Instance Method Summary + collapse +

+ + + + + + + + + + + + + +

Methods included from Colors

+

#gray, #rgb, #to_rgb

+ + + + + + + + + +

Methods included from Log

+

configure_logger, #log_init, logger

+ + + + + + + + + +

Methods inherited from Linkable

+

#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event

+
+

Constructor Details

+ +
+

+ + #initialize(*args, **kwargs) ⇒ Widget + + + + + +

+
+

Returns a new instance of Widget.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+
+
# File 'lacci/lib/shoes/widget.rb', line 78
+
+def initialize(*args, **kwargs)
+  log_init("Widget")
+
+  self.class.display_property_names.each do |prop|
+    if kwargs[prop.to_sym]
+      instance_variable_set("@" + prop, kwargs[prop.to_sym])
+    end
+  end
+
+  super() # linkable_id defaults to object_id
+end
+
+
+ +
+
+

Dynamic Method Handling

+

+ This class handles dynamic methods through the method_missing method + +

+ +
+

+ + #method_missing(name, *args, **kwargs, &block) ⇒ Object + + + + + +

+
+

We use method_missing for widget-creating methods like "button", +and also to auto-create display-property getters and setters.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+
+
# File 'lacci/lib/shoes/widget.rb', line 165
+
+def method_missing(name, *args, **kwargs, &block)
+  name_s = name.to_s
+
+  if name_s[-1] == "="
+    prop_name = name_s[0..-2]
+    if self.class.display_property_name?(prop_name)
+      self.class.define_method(name) do |new_value|
+        raise "Trying to set display properties in an object with no linkable ID!" unless linkable_id
+
+        instance_variable_set("@" + prop_name, new_value)
+        send_shoes_event({ prop_name => new_value }, event_name: "prop_change", target: linkable_id)
+      end
+
+      return self.send(name, *args, **kwargs, &block)
+    end
+  end
+
+  if self.class.display_property_name?(name_s)
+    self.class.define_method(name) do
+      raise "Trying to get display properties in an object with no linkable ID!" unless linkable_id
+
+      instance_variable_get("@" + name_s)
+    end
+
+    return self.send(name, *args, **kwargs, &block)
+  end
+
+  klass = Widget.widget_class_by_name(name)
+  return super unless klass
+
+  ::Shoes::Widget.define_method(name) do |*args, **kwargs, &block|
+    # Look up the Shoes widget and create it...
+    widget_instance = klass.new(*args, **kwargs, &block)
+
+    unless klass.ancestors.include?(Shoes::TextWidget)
+      widget_instance.set_parent Shoes::App.instance.current_slot
+    end
+
+    widget_instance
+  end
+
+  send(name, *args, **kwargs, &block)
+end
+
+
+ +
+ +
+

Class Attribute Details

+ + + +
+

+ + .widget_classesObject + + + + + +

+
+

Returns the value of attribute widget_classes.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+18
+19
+20
+
+
# File 'lacci/lib/shoes/widget.rb', line 18
+
+def widget_classes
+  @widget_classes
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #parentObject (readonly) + + + + + +

+
+

Returns the value of attribute parent.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+132
+133
+134
+
+
# File 'lacci/lib/shoes/widget.rb', line 132
+
+def parent
+  @parent
+end
+
+
+ +
+ + +
+

Class Method Details

+ + +
+

+ + .display_properties(*names) ⇒ Object + + + + + +

+
+

Add these names as display properties

+ + +
+
+
+ + +
+ + + + +
+
+
+
+59
+60
+61
+
+
# File 'lacci/lib/shoes/widget.rb', line 59
+
+def display_properties(*names)
+  names.each { |n| display_property(n) }
+end
+
+
+ +
+

+ + .display_property(name) ⇒ Object + + + + + +

+
+

Display properties in Shoes Linkables are automatically sync'd with the display side objects. +TODO: do we want types or other modifiers on specific properties?

+ + +
+
+
+ + +
+ + + + +
+
+
+
+49
+50
+51
+52
+53
+54
+55
+56
+
+
# File 'lacci/lib/shoes/widget.rb', line 49
+
+def display_property(name)
+  name = name.to_s
+
+  return if linkable_properties_hash[name]
+
+  linkable_properties << { name: name }
+  linkable_properties_hash[name] = true
+end
+
+
+ +
+

+ + .display_property_name?(name) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+69
+70
+71
+72
+
+
# File 'lacci/lib/shoes/widget.rb', line 69
+
+def display_property_name?(name)
+  linkable_properties_hash[name.to_s] ||
+    (self != Shoes::Widget && superclass.display_property_name?(name))
+end
+
+
+ +
+

+ + .display_property_namesObject + + + + + +

+ + + + +
+
+
+
+63
+64
+65
+66
+67
+
+
# File 'lacci/lib/shoes/widget.rb', line 63
+
+def display_property_names
+  parent_prop_names = self != Shoes::Widget ? self.superclass.display_property_names : []
+
+  parent_prop_names | linkable_properties.map { |prop| prop[:name] }
+end
+
+
+ +
+

+ + .dsl_nameObject + + + + + +

+ + + + +
+
+
+
+26
+27
+28
+29
+
+
# File 'lacci/lib/shoes/widget.rb', line 26
+
+def dsl_name
+  n = name.split("::").last.chomp("Widget")
+  n.gsub(/(.)([A-Z])/, '\1_\2').downcase
+end
+
+
+ +
+

+ + .widget_class_by_name(name) ⇒ Object + + + + + +

+ + + + +
+
+
+
+31
+32
+33
+
+
# File 'lacci/lib/shoes/widget.rb', line 31
+
+def widget_class_by_name(name)
+  widget_classes.detect { |k| k.dsl_name == name.to_s }
+end
+
+
+ +
+ +
+

Instance Method Details

+ + +
+ + + + + +
+
+
+
+42
+43
+44
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 42
+
+def banner(*args, **kwargs)
+  para(*args, **{ size: :banner }.merge(kwargs))
+end
+
+
+ +
+

+ + #caption(*args, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+58
+59
+60
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 58
+
+def caption(*args, **kwargs)
+  para(*args, **{ size: :caption }.merge(kwargs))
+end
+
+
+ +
+

+ + #destroyObject + + + + Also known as: + remove + + + + +

+
+

Removes the element from the Shoes::Widget tree

+ + +
+
+
+ + +
+ + + + +
+
+
+
+142
+143
+144
+145
+
+
# File 'lacci/lib/shoes/widget.rb', line 142
+
+def destroy
+  @parent&.remove_child(self)
+  send_shoes_event(event_name: "destroy", target: linkable_id)
+end
+
+
+ +
+

+ + #display_property_valuesObject + + + + + +

+ + + + +
+
+
+
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+
+
# File 'lacci/lib/shoes/widget.rb', line 110
+
+def display_property_values
+  all_property_names = self.class.display_property_names
+
+  properties = {}
+  all_property_names.each do |prop|
+    properties[prop] = instance_variable_get("@" + prop)
+  end
+  properties["shoes_linkable_id"] = self.linkable_id
+  properties
+end
+
+
+ +
+

+ + #download(url, method: "GET", save: nil, styles: {}, &block) ⇒ Object + + + + + +

+ + + + +
+
+
+
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+
+
# File 'lacci/lib/shoes/download.rb', line 21
+
+def download(url, method: "GET", save: nil, styles: {}, &block)
+  require "net/http"
+  require "openssl"
+  require "nokogiri"
+
+  @block = block
+
+  Thread.new do
+    logger = Shoes::Log.logger("Shoes::App#download")
+    begin
+      uri = URI(url)
+      response = perform_request(uri, method, styles)
+
+      if response.is_a?(Net::HTTPRedirection)
+        new_location = response["location"]
+        new_uri = URI(new_location)
+        response = perform_request(new_uri, method, styles)
+      end
+
+      wrapped_response = ResponseWrapper.new(response) # Wrap the response
+      handle_response(wrapped_response, save, styles)
+    rescue Net::HTTPError, Net::OpenTimeout, Net::ReadTimeout => e
+      handle_error(e, logger)
+    rescue StandardError => e
+      handle_error(e.message, logger) # Pass the error message as a string
+    end
+  end
+end
+
+
+ +
+

+ + #hideObject + + + + + +

+
+

Hide the widget.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+149
+150
+151
+
+
# File 'lacci/lib/shoes/widget.rb', line 149
+
+def hide
+  self.hidden = true
+end
+
+
+ +
+

+ + #inscription(*args, **kwargs) ⇒ Object + + + + Also known as: + ins + + + + +

+ + + + +
+
+
+
+62
+63
+64
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 62
+
+def inscription(*args, **kwargs)
+  para(*args, **{ size: :inscription }.merge(kwargs))
+end
+
+
+ +
+

+ + #inspectObject + + + + + +

+ + + + +
+
+
+
+90
+91
+92
+93
+94
+
+
# File 'lacci/lib/shoes/widget.rb', line 90
+
+def inspect
+  "#<#{self.class}:#{self.object_id} " +
+    "@linkable_id=#{@linkable_id.inspect} @parent=#{@parent.inspect} " +
+    "@children=#{@children.inspect} properties=#{display_property_values.inspect}>"
+end
+
+
+ +
+

+ + #respond_to_missing?(name, include_private = false) ⇒ Boolean + + + + + +

+
+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + +
  • + +
+ +
+ + + + +
+
+
+
+209
+210
+211
+212
+213
+214
+215
+216
+
+
# File 'lacci/lib/shoes/widget.rb', line 209
+
+def respond_to_missing?(name, include_private = false)
+  name_s = name.to_s
+  return true if self.class.display_property_name?(name_s)
+  return true if self.class.display_property_name?(name_s[0..-2]) && name_s[-1] == "="
+  return true if Widget.widget_class_by_name(name_s)
+
+  super
+end
+
+
+ +
+

+ + #set_parent(new_parent) ⇒ Object + + + + + +

+ + + + +
+
+
+
+134
+135
+136
+137
+138
+139
+
+
# File 'lacci/lib/shoes/widget.rb', line 134
+
+def set_parent(new_parent)
+  @parent&.remove_child(self)
+  new_parent&.add_child(self)
+  @parent = new_parent
+  send_shoes_event(new_parent.linkable_id, event_name: "parent", target: linkable_id)
+end
+
+
+ +
+

+ + #showObject + + + + + +

+
+

Show the widget.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+154
+155
+156
+
+
# File 'lacci/lib/shoes/widget.rb', line 154
+
+def show
+  self.hidden = false
+end
+
+
+ +
+

+ + #subtitle(*args, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+50
+51
+52
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 50
+
+def subtitle(*args, **kwargs)
+  para(*args, **{ size: :subtitle }.merge(kwargs))
+end
+
+
+ +
+

+ + #tagline(*args, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+54
+55
+56
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 54
+
+def tagline(*args, **kwargs)
+  para(*args, **{ size: :tagline }.merge(kwargs))
+end
+
+
+ +
+

+ + #title(*args, **kwargs) ⇒ Object + + + + + +

+ + + + +
+
+
+
+46
+47
+48
+
+
# File 'lacci/lib/shoes/widgets/para.rb', line 46
+
+def title(*args, **kwargs)
+  para(*args, **{ size: :title }.merge(kwargs))
+end
+
+
+ +
+

+ + #toggleObject + + + + + +

+
+

Hide the widget if it is currently shown. Show it if it is currently hidden.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+159
+160
+161
+
+
# File 'lacci/lib/shoes/widget.rb', line 159
+
+def toggle
+  self.hidden = !self.hidden
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/Shoes/Widget/ResponseWrapper.html b/Shoes/Widget/ResponseWrapper.html new file mode 100644 index 000000000..8a7957893 --- /dev/null +++ b/Shoes/Widget/ResponseWrapper.html @@ -0,0 +1,391 @@ + + + + + + + Class: Shoes::Widget::ResponseWrapper + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Class: Shoes::Widget::ResponseWrapper + + + +

+
+ +
+
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lacci/lib/shoes/download.rb
+
+ +
+ + + + + +

Instance Attribute Summary collapse

+
    + +
  • + + + #response ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

    Returns the value of attribute response.

    +
    + +
  • + + +
+ + + + + +

+ Instance Method Summary + collapse +

+ + + + +
+

Constructor Details

+ +
+

+ + #initialize(response) ⇒ ResponseWrapper + + + + + +

+
+

Returns a new instance of ResponseWrapper.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lacci/lib/shoes/download.rb', line 8
+
+def initialize(response)
+  @response = response
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #responseObject (readonly) + + + + + +

+
+

Returns the value of attribute response.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+6
+7
+8
+
+
# File 'lacci/lib/shoes/download.rb', line 6
+
+def response
+  @response
+end
+
+
+ +
+ + +
+

Instance Method Details

+ + +
+

+ + #bodyObject + + + + + +

+ + + + +
+
+
+
+16
+17
+18
+
+
# File 'lacci/lib/shoes/download.rb', line 16
+
+def body
+  @response.body
+end
+
+
+ +
+

+ + #headersObject + + + + + +

+ + + + +
+
+
+
+12
+13
+14
+
+
# File 'lacci/lib/shoes/download.rb', line 12
+
+def headers
+  @response.each_header.to_h
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/_index.html b/_index.html new file mode 100644 index 000000000..b456c4288 --- /dev/null +++ b/_index.html @@ -0,0 +1,885 @@ + + + + + + + Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Documentation by YARD 0.9.28

+
+

Alphabetic Index

+ +

File Listing

+ + +
+

Namespace Listing A-Z

+ + + + + + + + +
+ + + + + + + + + + + + + + + + + +
    +
  • F
  • +
      + +
    • + Flow + + (Shoes) + +
    • + +
    • + Font + + (Shoes) + +
    • + +
    +
+ + +
    +
  • H
  • +
      + +
    • + HTML + + (Scarpe) + +
    • + +
    +
+ + +
+ + + + + + + + +
    +
  • K
  • + +
+ + + + + +
    +
  • P
  • +
      + +
    • + Para + + (Shoes) + +
    • + +
    +
+ + + + + + + + + + + +
+ + +
    +
  • V
  • +
      + +
    • + Video + + (Shoes) + +
    • + +
    +
+ + + + +
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/class_list.html b/class_list.html new file mode 100644 index 000000000..fcd5039ee --- /dev/null +++ b/class_list.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + Class List + + + +
+
+

Class List

+ + + +
+ + +
+ + diff --git a/css/common.css b/css/common.css new file mode 100644 index 000000000..cf25c4523 --- /dev/null +++ b/css/common.css @@ -0,0 +1 @@ +/* Override this file with custom rules */ \ No newline at end of file diff --git a/css/full_list.css b/css/full_list.css new file mode 100644 index 000000000..fa3598242 --- /dev/null +++ b/css/full_list.css @@ -0,0 +1,58 @@ +body { + margin: 0; + font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + font-size: 13px; + height: 101%; + overflow-x: hidden; + background: #fafafa; +} + +h1 { padding: 12px 10px; padding-bottom: 0; margin: 0; font-size: 1.4em; } +.clear { clear: both; } +.fixed_header { position: fixed; background: #fff; width: 100%; padding-bottom: 10px; margin-top: 0; top: 0; z-index: 9999; height: 70px; } +#search { position: absolute; right: 5px; top: 9px; padding-left: 24px; } +#content.insearch #search, #content.insearch #noresults { background: url(data:image/gif;base64,R0lGODlhEAAQAPYAAP///wAAAPr6+pKSkoiIiO7u7sjIyNjY2J6engAAAI6OjsbGxjIyMlJSUuzs7KamppSUlPLy8oKCghwcHLKysqSkpJqamvT09Pj4+KioqM7OzkRERAwMDGBgYN7e3ujo6Ly8vCoqKjY2NkZGRtTU1MTExDw8PE5OTj4+PkhISNDQ0MrKylpaWrS0tOrq6nBwcKysrLi4uLq6ul5eXlxcXGJiYoaGhuDg4H5+fvz8/KKiohgYGCwsLFZWVgQEBFBQUMzMzDg4OFhYWBoaGvDw8NbW1pycnOLi4ubm5kBAQKqqqiQkJCAgIK6urnJyckpKSjQ0NGpqatLS0sDAwCYmJnx8fEJCQlRUVAoKCggICLCwsOTk5ExMTPb29ra2tmZmZmhoaNzc3KCgoBISEiIiIgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCAAAACwAAAAAEAAQAAAHaIAAgoMgIiYlg4kACxIaACEJCSiKggYMCRselwkpghGJBJEcFgsjJyoAGBmfggcNEx0flBiKDhQFlIoCCA+5lAORFb4AJIihCRbDxQAFChAXw9HSqb60iREZ1omqrIPdJCTe0SWI09GBACH5BAkIAAAALAAAAAAQABAAAAdrgACCgwc0NTeDiYozCQkvOTo9GTmDKy8aFy+NOBA7CTswgywJDTIuEjYFIY0JNYMtKTEFiRU8Pjwygy4ws4owPyCKwsMAJSTEgiQlgsbIAMrO0dKDGMTViREZ14kYGRGK38nHguHEJcvTyIEAIfkECQgAAAAsAAAAABAAEAAAB2iAAIKDAggPg4iJAAMJCRUAJRIqiRGCBI0WQEEJJkWDERkYAAUKEBc4Po1GiKKJHkJDNEeKig4URLS0ICImJZAkuQAhjSi/wQyNKcGDCyMnk8u5rYrTgqDVghgZlYjcACTA1sslvtHRgQAh+QQJCAAAACwAAAAAEAAQAAAHZ4AAgoOEhYaCJSWHgxGDJCQARAtOUoQRGRiFD0kJUYWZhUhKT1OLhR8wBaaFBzQ1NwAlkIszCQkvsbOHL7Y4q4IuEjaqq0ZQD5+GEEsJTDCMmIUhtgk1lo6QFUwJVDKLiYJNUd6/hoEAIfkECQgAAAAsAAAAABAAEAAAB2iAAIKDhIWGgiUlh4MRgyQkjIURGRiGGBmNhJWHm4uen4ICCA+IkIsDCQkVACWmhwSpFqAABQoQF6ALTkWFnYMrVlhWvIKTlSAiJiVVPqlGhJkhqShHV1lCW4cMqSkAR1ofiwsjJyqGgQAh+QQJCAAAACwAAAAAEAAQAAAHZ4AAgoOEhYaCJSWHgxGDJCSMhREZGIYYGY2ElYebi56fhyWQniSKAKKfpaCLFlAPhl0gXYNGEwkhGYREUywag1wJwSkHNDU3D0kJYIMZQwk8MjPBLx9eXwuETVEyAC/BOKsuEjYFhoEAIfkECQgAAAAsAAAAABAAEAAAB2eAAIKDhIWGgiUlh4MRgyQkjIURGRiGGBmNhJWHm4ueICImip6CIQkJKJ4kigynKaqKCyMnKqSEK05StgAGQRxPYZaENqccFgIID4KXmQBhXFkzDgOnFYLNgltaSAAEpxa7BQoQF4aBACH5BAkIAAAALAAAAAAQABAAAAdogACCg4SFggJiPUqCJSWGgkZjCUwZACQkgxGEXAmdT4UYGZqCGWQ+IjKGGIUwPzGPhAc0NTewhDOdL7Ykji+dOLuOLhI2BbaFETICx4MlQitdqoUsCQ2vhKGjglNfU0SWmILaj43M5oEAOwAAAAAAAAAAAA==) no-repeat center left; } +#full_list { padding: 0; list-style: none; margin-left: 0; margin-top: 80px; font-size: 1.1em; } +#full_list ul { padding: 0; } +#full_list li { padding: 0; margin: 0; list-style: none; } +#full_list li .item { padding: 5px 5px 5px 12px; } +#noresults { padding: 7px 12px; background: #fff; } +#content.insearch #noresults { margin-left: 7px; } +li.collapsed ul { display: none; } +li a.toggle { cursor: default; position: relative; left: -5px; top: 4px; text-indent: -999px; width: 10px; height: 9px; margin-left: -10px; display: block; float: left; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK8AAACvABQqw0mAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTM5jWRgMAAAAVdEVYdENyZWF0aW9uIFRpbWUAMy8xNC8wOeNZPpQAAAE2SURBVDiNrZTBccIwEEXfelIAHUA6CZ24BGaWO+FuzZAK4k6gg5QAdGAq+Bxs2Yqx7BzyL7Llp/VfzZeQhCTc/ezuGzKKnKSzpCxXJM8fwNXda3df5RZETlIt6YUzSQDs93sl8w3wBZxCCE10GM1OcWbWjB2mWgEH4Mfdyxm3PSepBHibgQE2wLe7r4HjEidpnXMYdQPKEMJcsZ4zs2POYQOcaPfwMVOo58zsAdMt18BuoVDPxUJRacELbXv3hUIX2vYmOUvi8C8ydz/ThjXrqKqqLbDIAdsCKBd+Wo7GWa7o9qzOQHVVVXeAbs+yHHCH4aTsaCOQqunmUy1yBUAXkdMIfMlgF5EXLo2OpV/c/Up7jG4hhHcYLgWzAZXUc2b2ixsfvc/RmNNfOXD3Q/oeL9axJE1yT9IOoUu6MGUkAAAAAElFTkSuQmCC) no-repeat bottom left; } +li.collapsed a.toggle { opacity: 0.5; cursor: default; background-position: top left; } +li { color: #888; cursor: pointer; } +li.deprecated { text-decoration: line-through; font-style: italic; } +li.odd { background: #f0f0f0; } +li.even { background: #fafafa; } +.item:hover { background: #ddd; } +li small:before { content: "("; } +li small:after { content: ")"; } +li small.search_info { display: none; } +a, a:visited { text-decoration: none; color: #05a; } +li.clicked > .item { background: #05a; color: #ccc; } +li.clicked > .item a, li.clicked > .item a:visited { color: #eee; } +li.clicked > .item a.toggle { opacity: 0.5; background-position: bottom right; } +li.collapsed.clicked a.toggle { background-position: top right; } +#search input { border: 1px solid #bbb; border-radius: 3px; } +#full_list_nav { margin-left: 10px; font-size: 0.9em; display: block; color: #aaa; } +#full_list_nav a, #nav a:visited { color: #358; } +#full_list_nav a:hover { background: transparent; color: #5af; } +#full_list_nav span:after { content: ' | '; } +#full_list_nav span:last-child:after { content: ''; } + +#content h1 { margin-top: 0; } +li { white-space: nowrap; cursor: normal; } +li small { display: block; font-size: 0.8em; } +li small:before { content: ""; } +li small:after { content: ""; } +li small.search_info { display: none; } +#search { width: 170px; position: static; margin: 3px; margin-left: 10px; font-size: 0.9em; color: #888; padding-left: 0; padding-right: 24px; } +#content.insearch #search { background-position: center right; } +#search input { width: 110px; } + +#full_list.insearch ul { display: block; } +#full_list.insearch .item { display: none; } +#full_list.insearch .found { display: block; padding-left: 11px !important; } +#full_list.insearch li a.toggle { display: none; } +#full_list.insearch li small.search_info { display: block; } diff --git a/css/style.css b/css/style.css new file mode 100644 index 000000000..eb0dbc86f --- /dev/null +++ b/css/style.css @@ -0,0 +1,497 @@ +html { + width: 100%; + height: 100%; +} +body { + font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; + font-size: 13px; + width: 100%; + margin: 0; + padding: 0; + display: flex; + display: -webkit-flex; + display: -ms-flexbox; +} + +#nav { + position: relative; + width: 100%; + height: 100%; + border: 0; + border-right: 1px dotted #eee; + overflow: auto; +} +.nav_wrap { + margin: 0; + padding: 0; + width: 20%; + height: 100%; + position: relative; + display: flex; + display: -webkit-flex; + display: -ms-flexbox; + flex-shrink: 0; + -webkit-flex-shrink: 0; + -ms-flex: 1 0; +} +#resizer { + position: absolute; + right: -5px; + top: 0; + width: 10px; + height: 100%; + cursor: col-resize; + z-index: 9999; +} +#main { + flex: 5 1; + -webkit-flex: 5 1; + -ms-flex: 5 1; + outline: none; + position: relative; + background: #fff; + padding: 1.2em; + padding-top: 0.2em; + box-sizing: border-box; +} + +@media (max-width: 920px) { + .nav_wrap { width: 100%; top: 0; right: 0; overflow: visible; position: absolute; } + #resizer { display: none; } + #nav { + z-index: 9999; + background: #fff; + display: none; + position: absolute; + top: 40px; + right: 12px; + width: 500px; + max-width: 80%; + height: 80%; + overflow-y: scroll; + border: 1px solid #999; + border-collapse: collapse; + box-shadow: -7px 5px 25px #aaa; + border-radius: 2px; + } +} + +@media (min-width: 920px) { + body { height: 100%; overflow: hidden; } + #main { height: 100%; overflow: auto; } + #search { display: none; } +} + +#main img { max-width: 100%; } +h1 { font-size: 25px; margin: 1em 0 0.5em; padding-top: 4px; border-top: 1px dotted #d5d5d5; } +h1.noborder { border-top: 0px; margin-top: 0; padding-top: 4px; } +h1.title { margin-bottom: 10px; } +h1.alphaindex { margin-top: 0; font-size: 22px; } +h2 { + padding: 0; + padding-bottom: 3px; + border-bottom: 1px #aaa solid; + font-size: 1.4em; + margin: 1.8em 0 0.5em; + position: relative; +} +h2 small { font-weight: normal; font-size: 0.7em; display: inline; position: absolute; right: 0; } +h2 small a { + display: block; + height: 20px; + border: 1px solid #aaa; + border-bottom: 0; + border-top-left-radius: 5px; + background: #f8f8f8; + position: relative; + padding: 2px 7px; +} +.clear { clear: both; } +.inline { display: inline; } +.inline p:first-child { display: inline; } +.docstring, .tags, #filecontents { font-size: 15px; line-height: 1.5145em; } +.docstring p > code, .docstring p > tt, .tags p > code, .tags p > tt { + color: #c7254e; background: #f9f2f4; padding: 2px 4px; font-size: 1em; + border-radius: 4px; +} +.docstring h1, .docstring h2, .docstring h3, .docstring h4 { padding: 0; border: 0; border-bottom: 1px dotted #bbb; } +.docstring h1 { font-size: 1.2em; } +.docstring h2 { font-size: 1.1em; } +.docstring h3, .docstring h4 { font-size: 1em; border-bottom: 0; padding-top: 10px; } +.summary_desc .object_link a, .docstring .object_link a { + font-family: monospace; font-size: 1.05em; + color: #05a; background: #EDF4FA; padding: 2px 4px; font-size: 1em; + border-radius: 4px; +} +.rdoc-term { padding-right: 25px; font-weight: bold; } +.rdoc-list p { margin: 0; padding: 0; margin-bottom: 4px; } +.summary_desc pre.code .object_link a, .docstring pre.code .object_link a { + padding: 0px; background: inherit; color: inherit; border-radius: inherit; +} + +/* style for */ +#filecontents table, .docstring table { border-collapse: collapse; } +#filecontents table th, #filecontents table td, +.docstring table th, .docstring table td { border: 1px solid #ccc; padding: 8px; padding-right: 17px; } +#filecontents table tr:nth-child(odd), +.docstring table tr:nth-child(odd) { background: #eee; } +#filecontents table tr:nth-child(even), +.docstring table tr:nth-child(even) { background: #fff; } +#filecontents table th, .docstring table th { background: #fff; } + +/* style for
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/method_list.html b/method_list.html new file mode 100644 index 000000000..d5d343d74 --- /dev/null +++ b/method_list.html @@ -0,0 +1,3271 @@ + + + + + + + + + + + + + + + + + + Method List + + + +
+
+

Method List

+ + + +
+ + +
+ + diff --git a/top-level-namespace.html b/top-level-namespace.html new file mode 100644 index 000000000..55bfdc9d0 --- /dev/null +++ b/top-level-namespace.html @@ -0,0 +1,143 @@ + + + + + + + Top Level Namespace + + — Documentation by YARD 0.9.28 + + + + + + + + + + + + + + + + + + + +
+ + +

Top Level Namespace + + + +

+
+ + + + + + + + + + + +
+ +

Defined Under Namespace

+

+ + + Modules: Kernel, Lacci, Shoes + + + + Classes: Scarpe + + +

+ + +

+ Constant Summary + collapse +

+ +
+ +
SCARPE_DIR = +
+
+

Wherever this file is installed, locate Scarpe relative to it. This could be an installed gem or a dev repo.

+ + +
+
+
+ + +
+
+
File.join(__dir__, "../..")
+ +
SERVICE = + +
+
Scarpe::Webview::ContainedService.new(s, s)
+ +
+ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file