lacci 0.2.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -1
- data/lib/lacci/scarpe_cli.rb +2 -2
- data/lib/lacci/scarpe_core.rb +2 -1
- data/lib/lacci/version.rb +1 -1
- data/lib/scarpe/niente/app.rb +23 -0
- data/lib/scarpe/niente/display_service.rb +66 -0
- data/lib/scarpe/niente/drawable.rb +59 -0
- data/lib/scarpe/niente/shoes_spec.rb +93 -0
- data/lib/scarpe/niente.rb +32 -0
- data/lib/shoes/app.rb +111 -72
- data/lib/shoes/background.rb +2 -2
- data/lib/shoes/border.rb +2 -2
- data/lib/shoes/builtins.rb +63 -0
- data/lib/shoes/changelog.rb +52 -0
- data/lib/shoes/colors.rb +3 -1
- data/lib/shoes/constants.rb +41 -2
- data/lib/shoes/display_service.rb +80 -18
- data/lib/shoes/download.rb +2 -2
- data/lib/shoes/drawable.rb +654 -0
- data/lib/shoes/drawables/arc.rb +27 -0
- data/lib/shoes/drawables/arrow.rb +21 -0
- data/lib/shoes/drawables/border.rb +28 -0
- data/lib/shoes/drawables/button.rb +57 -0
- data/lib/shoes/drawables/check.rb +33 -0
- data/lib/shoes/drawables/document_root.rb +20 -0
- data/lib/shoes/{widgets → drawables}/edit_box.rb +9 -8
- data/lib/shoes/{widgets → drawables}/edit_line.rb +8 -7
- data/lib/shoes/drawables/flow.rb +20 -0
- data/lib/shoes/drawables/font_helper.rb +62 -0
- data/lib/shoes/{widgets → drawables}/image.rb +7 -7
- data/lib/shoes/drawables/line.rb +17 -0
- data/lib/shoes/drawables/link.rb +31 -0
- data/lib/shoes/drawables/list_box.rb +59 -0
- data/lib/shoes/drawables/oval.rb +48 -0
- data/lib/shoes/drawables/para.rb +206 -0
- data/lib/shoes/drawables/progress.rb +15 -0
- data/lib/shoes/drawables/radio.rb +35 -0
- data/lib/shoes/drawables/rect.rb +18 -0
- data/lib/shoes/{widgets → drawables}/shape.rb +8 -8
- data/lib/shoes/drawables/slot.rb +178 -0
- data/lib/shoes/drawables/stack.rb +21 -0
- data/lib/shoes/drawables/star.rb +28 -0
- data/lib/shoes/drawables/subscription_item.rb +93 -0
- data/lib/shoes/drawables/text_drawable.rb +122 -0
- data/lib/shoes/drawables/video.rb +17 -0
- data/lib/shoes/drawables/widget.rb +74 -0
- data/lib/shoes/drawables.rb +32 -0
- data/lib/shoes/errors.rb +38 -0
- data/lib/shoes/log.rb +2 -2
- data/lib/shoes/margin_helper.rb +79 -0
- data/lib/shoes/ruby_extensions.rb +15 -0
- data/lib/shoes-spec.rb +93 -0
- data/lib/shoes.rb +31 -10
- metadata +58 -31
- data/lib/shoes/spacing.rb +0 -9
- data/lib/shoes/widget.rb +0 -218
- data/lib/shoes/widgets/alert.rb +0 -19
- data/lib/shoes/widgets/arc.rb +0 -51
- data/lib/shoes/widgets/button.rb +0 -35
- data/lib/shoes/widgets/check.rb +0 -28
- data/lib/shoes/widgets/document_root.rb +0 -20
- data/lib/shoes/widgets/flow.rb +0 -22
- data/lib/shoes/widgets/font.rb +0 -14
- data/lib/shoes/widgets/line.rb +0 -18
- data/lib/shoes/widgets/link.rb +0 -25
- data/lib/shoes/widgets/list_box.rb +0 -25
- data/lib/shoes/widgets/para.rb +0 -68
- data/lib/shoes/widgets/radio.rb +0 -35
- data/lib/shoes/widgets/slot.rb +0 -75
- data/lib/shoes/widgets/span.rb +0 -26
- data/lib/shoes/widgets/stack.rb +0 -24
- data/lib/shoes/widgets/star.rb +0 -44
- data/lib/shoes/widgets/subscription_item.rb +0 -60
- data/lib/shoes/widgets/text_widget.rb +0 -51
- data/lib/shoes/widgets/video.rb +0 -15
- data/lib/shoes/widgets.rb +0 -29
data/lib/shoes/widgets/stack.rb
DELETED
@@ -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
|
data/lib/shoes/widgets/star.rb
DELETED
@@ -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)
|
data/lib/shoes/widgets/video.rb
DELETED
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"
|