lacci 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +8 -1
  4. data/lib/lacci/scarpe_cli.rb +2 -2
  5. data/lib/lacci/scarpe_core.rb +2 -1
  6. data/lib/lacci/version.rb +1 -1
  7. data/lib/scarpe/niente/app.rb +23 -0
  8. data/lib/scarpe/niente/display_service.rb +66 -0
  9. data/lib/scarpe/niente/drawable.rb +59 -0
  10. data/lib/scarpe/niente/shoes_spec.rb +93 -0
  11. data/lib/scarpe/niente.rb +32 -0
  12. data/lib/shoes/app.rb +111 -72
  13. data/lib/shoes/background.rb +2 -2
  14. data/lib/shoes/border.rb +2 -2
  15. data/lib/shoes/builtins.rb +63 -0
  16. data/lib/shoes/changelog.rb +52 -0
  17. data/lib/shoes/colors.rb +3 -1
  18. data/lib/shoes/constants.rb +41 -2
  19. data/lib/shoes/display_service.rb +80 -18
  20. data/lib/shoes/download.rb +2 -2
  21. data/lib/shoes/drawable.rb +654 -0
  22. data/lib/shoes/drawables/arc.rb +27 -0
  23. data/lib/shoes/drawables/arrow.rb +21 -0
  24. data/lib/shoes/drawables/border.rb +28 -0
  25. data/lib/shoes/drawables/button.rb +57 -0
  26. data/lib/shoes/drawables/check.rb +33 -0
  27. data/lib/shoes/drawables/document_root.rb +20 -0
  28. data/lib/shoes/{widgets → drawables}/edit_box.rb +9 -8
  29. data/lib/shoes/{widgets → drawables}/edit_line.rb +8 -7
  30. data/lib/shoes/drawables/flow.rb +20 -0
  31. data/lib/shoes/drawables/font_helper.rb +62 -0
  32. data/lib/shoes/{widgets → drawables}/image.rb +7 -7
  33. data/lib/shoes/drawables/line.rb +17 -0
  34. data/lib/shoes/drawables/link.rb +31 -0
  35. data/lib/shoes/drawables/list_box.rb +59 -0
  36. data/lib/shoes/drawables/oval.rb +48 -0
  37. data/lib/shoes/drawables/para.rb +206 -0
  38. data/lib/shoes/drawables/progress.rb +15 -0
  39. data/lib/shoes/drawables/radio.rb +35 -0
  40. data/lib/shoes/drawables/rect.rb +18 -0
  41. data/lib/shoes/{widgets → drawables}/shape.rb +8 -8
  42. data/lib/shoes/drawables/slot.rb +178 -0
  43. data/lib/shoes/drawables/stack.rb +21 -0
  44. data/lib/shoes/drawables/star.rb +28 -0
  45. data/lib/shoes/drawables/subscription_item.rb +93 -0
  46. data/lib/shoes/drawables/text_drawable.rb +122 -0
  47. data/lib/shoes/drawables/video.rb +17 -0
  48. data/lib/shoes/drawables/widget.rb +74 -0
  49. data/lib/shoes/drawables.rb +32 -0
  50. data/lib/shoes/errors.rb +38 -0
  51. data/lib/shoes/log.rb +2 -2
  52. data/lib/shoes/margin_helper.rb +79 -0
  53. data/lib/shoes/ruby_extensions.rb +15 -0
  54. data/lib/shoes-spec.rb +93 -0
  55. data/lib/shoes.rb +31 -10
  56. metadata +58 -31
  57. data/lib/shoes/spacing.rb +0 -9
  58. data/lib/shoes/widget.rb +0 -218
  59. data/lib/shoes/widgets/alert.rb +0 -19
  60. data/lib/shoes/widgets/arc.rb +0 -51
  61. data/lib/shoes/widgets/button.rb +0 -35
  62. data/lib/shoes/widgets/check.rb +0 -28
  63. data/lib/shoes/widgets/document_root.rb +0 -20
  64. data/lib/shoes/widgets/flow.rb +0 -22
  65. data/lib/shoes/widgets/font.rb +0 -14
  66. data/lib/shoes/widgets/line.rb +0 -18
  67. data/lib/shoes/widgets/link.rb +0 -25
  68. data/lib/shoes/widgets/list_box.rb +0 -25
  69. data/lib/shoes/widgets/para.rb +0 -68
  70. data/lib/shoes/widgets/radio.rb +0 -35
  71. data/lib/shoes/widgets/slot.rb +0 -75
  72. data/lib/shoes/widgets/span.rb +0 -26
  73. data/lib/shoes/widgets/stack.rb +0 -24
  74. data/lib/shoes/widgets/star.rb +0 -44
  75. data/lib/shoes/widgets/subscription_item.rb +0 -60
  76. data/lib/shoes/widgets/text_widget.rb +0 -51
  77. data/lib/shoes/widgets/video.rb +0 -15
  78. data/lib/shoes/widgets.rb +0 -29
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Shoes
4
- class Stack < Shoes::Slot
5
- include Shoes::Background
6
- include Shoes::Border
7
- include Shoes::Spacing
8
-
9
- # TODO: sort out various margin and padding properties, including putting stuff into spacing
10
- display_properties :width, :height, :scroll
11
-
12
- def initialize(width: nil, height: nil, margin: nil, padding: nil, scroll: false, margin_top: nil, margin_bottom: nil, margin_left: nil,
13
- margin_right: nil, **options, &block)
14
-
15
- @options = options
16
-
17
- super
18
-
19
- create_display_widget
20
- # Create the display-side widget *before* running the block, which will add child widgets with their display widgets
21
- Shoes::App.instance.with_slot(self, &block) if block_given?
22
- end
23
- end
24
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Shoes
4
- class Star < Shoes::Widget
5
- display_properties :left, :top, :points, :outer, :inner, :draw_context
6
-
7
- def initialize(left, top, points = 10, outer = 100, inner = 50)
8
- @points = convert_to_integer(points, "points", 10)
9
- @outer = convert_to_float(outer, "outer", 100.0)
10
- @inner = convert_to_float(inner, "inner", 50.0)
11
-
12
- @draw_context = Shoes::App.instance.current_draw_context
13
-
14
- super
15
- create_display_widget
16
- end
17
-
18
- private
19
-
20
- def convert_to_integer(value, attribute_name, default = 0)
21
- begin
22
- value = Integer(value)
23
- raise InvalidAttributeValueError, "Negative num '#{value}' not allowed for attribute '#{attribute_name}'" if value < 0
24
-
25
- value
26
- rescue ArgumentError
27
- error_message = "Invalid value '#{value}' provided for attribute '#{attribute_name}'. The value should be a number."
28
- raise InvalidAttributeValueError, error_message
29
- end
30
- end
31
-
32
- def convert_to_float(value, attribute_name, default = 0.0)
33
- begin
34
- value = Float(value)
35
- raise InvalidAttributeValueError, "Negative num '#{value}' not allowed for attribute '#{attribute_name}'" if value < 0
36
-
37
- value
38
- rescue ArgumentError
39
- error_message = "Invalid value '#{value}' provided for attribute '#{attribute_name}'. The value should be a number."
40
- raise InvalidAttributeValueError, error_message
41
- end
42
- end
43
- end
44
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Certain Shoes calls like motion and keydown are basically an
4
- # event subscription, with no other visible presence. However,
5
- # they have a place in the widget tree and can be deleted.
6
- #
7
- # Depending on the display library they may not have any
8
- # direct visual (or similar) presence there either.
9
- #
10
- # Inheriting from Widget gives these a parent slot and a
11
- # linkable_id automatically.
12
- class Shoes::SubscriptionItem < Shoes::Widget
13
- display_property :shoes_api_name
14
-
15
- def initialize(shoes_api_name:, &block)
16
- super
17
-
18
- @callback = block
19
-
20
- case shoes_api_name
21
- when "hover"
22
- # Hover passes the Shoes widget as the block param
23
- @unsub_id = bind_self_event("hover") do
24
- @callback&.call(self)
25
- end
26
- when "motion"
27
- # Shoes sends back x, y, mods as the args.
28
- # Shoes3 uses the strings "control" "shift" and
29
- # "control_shift" as the mods arg.
30
- @unsub_id = bind_self_event("motion") do |x, y, ctrl_key, shift_key, **_kwargs|
31
- mods = [ctrl_key ? "control" : nil, shift_key ? "shift" : nil].compact.join("_")
32
- @callback&.call(x, y, mods)
33
- end
34
- when "click"
35
- # Click has block params button, left, top
36
- # button is the button number, left and top are coords
37
- @unsub_id = bind_self_event("click") do |button, x, y, **_kwargs|
38
- @callback&.call(button, x, y)
39
- end
40
- else
41
- raise "Unknown Shoes API call #{shoes_api_name.inspect} passed to SubscriptionItem!"
42
- end
43
-
44
- @unsub_id = bind_self_event(shoes_api_name) do |*args|
45
- @callback&.call(*args)
46
- end
47
-
48
- # This won't create a visible display widget, but will turn into
49
- # an invisible widget and a stream of events.
50
- create_display_widget
51
- end
52
-
53
- def destroy
54
- # TODO: we need a better way to do this automatically. See https://github.com/scarpe-team/scarpe/issues/291
55
- unsub_shoes_event(@unsub_id) if @unsub_id
56
- @unsub_id = nil
57
-
58
- super
59
- end
60
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Shoes::TextWidget
4
-
5
- module Shoes
6
- class TextWidget < Shoes::Widget
7
- class << self
8
- # rubocop:disable Lint/MissingSuper
9
- def inherited(subclass)
10
- Shoes::Widget.widget_classes ||= []
11
- Shoes::Widget.widget_classes << subclass
12
- end
13
- # rubocop:enable Lint/MissingSuper
14
- end
15
- end
16
-
17
- class << self
18
- def default_text_widget_with(element)
19
- class_name = element.capitalize
20
-
21
- widget_class = Class.new(Shoes::TextWidget) do
22
- # Can we just change content to text to match the Shoes API?
23
- display_property :content
24
-
25
- def initialize(content)
26
- @content = content
27
-
28
- super
29
-
30
- create_display_widget
31
- end
32
-
33
- def text
34
- self.content
35
- end
36
-
37
- def text=(new_text)
38
- self.content = new_text
39
- end
40
- end
41
- Shoes.const_set class_name, widget_class
42
- widget_class.class_eval do
43
- display_property :content
44
- end
45
- end
46
- end
47
- end
48
-
49
- Shoes.default_text_widget_with(:code)
50
- Shoes.default_text_widget_with(:em)
51
- Shoes.default_text_widget_with(:strong)
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Shoes
4
- class Video < Shoes::Widget
5
- display_properties :url
6
-
7
- def initialize(url)
8
- @url = url
9
- super
10
- create_display_widget
11
- end
12
-
13
- # other methods
14
- end
15
- end
data/lib/shoes/widgets.rb DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "shoes/widgets/slot"
4
- require "shoes/widgets/stack"
5
- require "shoes/widgets/flow"
6
- require "shoes/widgets/document_root"
7
-
8
- require "shoes/widgets/text_widget"
9
-
10
- require "shoes/widgets/font"
11
- require "shoes/widgets/subscription_item"
12
-
13
- require "shoes/widgets/arc"
14
- require "shoes/widgets/line"
15
- require "shoes/widgets/shape"
16
- require "shoes/widgets/star"
17
-
18
- require "shoes/widgets/alert"
19
- require "shoes/widgets/button"
20
- require "shoes/widgets/check"
21
- require "shoes/widgets/edit_box"
22
- require "shoes/widgets/edit_line"
23
- require "shoes/widgets/image"
24
- require "shoes/widgets/link"
25
- require "shoes/widgets/list_box"
26
- require "shoes/widgets/para"
27
- require "shoes/widgets/radio"
28
- require "shoes/widgets/span"
29
- require "shoes/widgets/video"