lacci 0.3.0 → 0.5.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.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/Gemfile.lock +4 -32
- data/lib/lacci/scarpe_cli.rb +0 -1
- data/lib/lacci/version.rb +1 -1
- data/lib/scarpe/niente/app.rb +12 -1
- data/lib/scarpe/niente/display_service.rb +5 -1
- data/lib/scarpe/niente/drawable.rb +2 -0
- data/lib/scarpe/niente/shoes_spec.rb +10 -5
- data/lib/scarpe/niente.rb +15 -2
- data/lib/shoes/app.rb +204 -105
- data/lib/shoes/constants.rb +24 -2
- data/lib/shoes/display_service.rb +43 -4
- data/lib/shoes/drawable.rb +326 -36
- data/lib/shoes/drawables/arc.rb +4 -26
- data/lib/shoes/drawables/arrow.rb +3 -23
- data/lib/shoes/drawables/border.rb +28 -0
- data/lib/shoes/drawables/button.rb +5 -21
- data/lib/shoes/drawables/check.rb +7 -3
- data/lib/shoes/drawables/document_root.rb +4 -4
- data/lib/shoes/drawables/edit_box.rb +6 -5
- data/lib/shoes/drawables/edit_line.rb +5 -4
- data/lib/shoes/drawables/flow.rb +4 -6
- data/lib/shoes/drawables/font_helper.rb +62 -0
- data/lib/shoes/drawables/image.rb +2 -2
- data/lib/shoes/drawables/line.rb +3 -6
- data/lib/shoes/drawables/link.rb +16 -9
- data/lib/shoes/drawables/list_box.rb +8 -5
- data/lib/shoes/drawables/oval.rb +48 -0
- data/lib/shoes/drawables/para.rb +106 -18
- data/lib/shoes/drawables/progress.rb +2 -1
- data/lib/shoes/drawables/radio.rb +5 -3
- data/lib/shoes/drawables/rect.rb +7 -6
- data/lib/shoes/drawables/shape.rb +4 -3
- data/lib/shoes/drawables/slot.rb +102 -9
- data/lib/shoes/drawables/stack.rb +7 -12
- data/lib/shoes/drawables/star.rb +9 -31
- data/lib/shoes/drawables/text_drawable.rb +93 -34
- data/lib/shoes/drawables/video.rb +3 -2
- data/lib/shoes/drawables/widget.rb +9 -4
- data/lib/shoes/drawables.rb +2 -1
- data/lib/shoes/errors.rb +13 -3
- data/lib/shoes/margin_helper.rb +79 -0
- data/lib/shoes.rb +98 -20
- metadata +11 -15
- data/lib/scarpe/niente/logger.rb +0 -29
- data/lib/shoes/drawables/span.rb +0 -27
- data/lib/shoes/spacing.rb +0 -9
data/lib/shoes.rb
CHANGED
|
@@ -7,49 +7,47 @@
|
|
|
7
7
|
# to handle the DSL and command-line parts of Shoes without knowing anything about how the
|
|
8
8
|
# display side works at all.
|
|
9
9
|
|
|
10
|
-
if RUBY_VERSION[0..2] <
|
|
11
|
-
Shoes::Log.logger(
|
|
10
|
+
if RUBY_VERSION[0..2] < '3.2'
|
|
11
|
+
Shoes::Log.logger('Shoes').error('Lacci (Scarpe, Shoes) requires Ruby 3.2 or higher!')
|
|
12
12
|
exit(-1)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
class Shoes; end
|
|
16
16
|
class Shoes::Error < StandardError; end
|
|
17
|
-
require_relative
|
|
17
|
+
require_relative 'shoes/errors'
|
|
18
18
|
|
|
19
|
-
require_relative
|
|
20
|
-
require_relative
|
|
19
|
+
require_relative 'shoes/constants'
|
|
20
|
+
require_relative 'shoes/ruby_extensions'
|
|
21
21
|
|
|
22
22
|
# Shoes adds some top-level methods and constants that can be used everywhere. Kernel is where they go.
|
|
23
23
|
module Kernel
|
|
24
24
|
include Shoes::Constants
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
require_relative
|
|
27
|
+
require_relative 'shoes/display_service'
|
|
28
28
|
|
|
29
29
|
# Pre-declare classes that get referenced outside their own require file
|
|
30
30
|
class Shoes::Drawable < Shoes::Linkable; end
|
|
31
31
|
class Shoes::Slot < Shoes::Drawable; end
|
|
32
32
|
class Shoes::Widget < Shoes::Slot; end
|
|
33
33
|
|
|
34
|
-
require_relative
|
|
35
|
-
require_relative
|
|
34
|
+
require_relative 'shoes/log'
|
|
35
|
+
require_relative 'shoes/colors'
|
|
36
36
|
|
|
37
|
-
require_relative
|
|
37
|
+
require_relative 'shoes/builtins'
|
|
38
38
|
|
|
39
|
-
require_relative
|
|
40
|
-
require_relative "shoes/border"
|
|
41
|
-
require_relative "shoes/spacing"
|
|
39
|
+
require_relative 'shoes/background'
|
|
42
40
|
|
|
43
|
-
require_relative
|
|
44
|
-
require_relative
|
|
45
|
-
require_relative
|
|
41
|
+
require_relative 'shoes/drawable'
|
|
42
|
+
require_relative 'shoes/app'
|
|
43
|
+
require_relative 'shoes/drawables'
|
|
46
44
|
|
|
47
|
-
require_relative
|
|
45
|
+
require_relative 'shoes/download'
|
|
48
46
|
|
|
49
47
|
# No easy way to tell at this point whether
|
|
50
48
|
# we will later load Shoes-Spec code, e.g.
|
|
51
49
|
# by running a segmented app with test code.
|
|
52
|
-
require_relative
|
|
50
|
+
require_relative 'shoes-spec'
|
|
53
51
|
|
|
54
52
|
# The module containing Shoes in all its glory.
|
|
55
53
|
# Shoes is a platform-independent GUI library, designed to create
|
|
@@ -57,6 +55,40 @@ require_relative "shoes-spec"
|
|
|
57
55
|
#
|
|
58
56
|
class Shoes
|
|
59
57
|
class << self
|
|
58
|
+
attr_accessor :APPS
|
|
59
|
+
|
|
60
|
+
# Track the most recently defined Shoes subclass for the inheritance pattern
|
|
61
|
+
# e.g., class Book < Shoes; end; Shoes.app
|
|
62
|
+
attr_accessor :pending_app_class
|
|
63
|
+
|
|
64
|
+
# When someone does `class MyApp < Shoes`, track it
|
|
65
|
+
def inherited(subclass)
|
|
66
|
+
# Only track direct subclasses of Shoes, not Shoes::App, Shoes::Drawable, etc.
|
|
67
|
+
# Those have their own inheritance tracking
|
|
68
|
+
if self == ::Shoes
|
|
69
|
+
Shoes.pending_app_class = subclass
|
|
70
|
+
end
|
|
71
|
+
super
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Class-level url method for defining routes in Shoes subclasses
|
|
75
|
+
# e.g., class Book < Shoes; url '/', :index; end
|
|
76
|
+
def url(path, method_name)
|
|
77
|
+
@class_routes ||= {}
|
|
78
|
+
if path.is_a?(String) && path.include?('(')
|
|
79
|
+
# Convert string patterns like '/page/(\d+)' to regex
|
|
80
|
+
regex = Regexp.new("^#{path.gsub(/\(.*?\)/, '(.*?)')}$")
|
|
81
|
+
@class_routes[regex] = method_name
|
|
82
|
+
else
|
|
83
|
+
@class_routes[path] = method_name
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Get the routes defined on this class
|
|
88
|
+
def class_routes
|
|
89
|
+
@class_routes ||= {}
|
|
90
|
+
end
|
|
91
|
+
|
|
60
92
|
# Creates a Shoes app with a new window. The block parameter is used to create
|
|
61
93
|
# drawables and set up handlers. Arguments are passed to Shoes::App.new internally.
|
|
62
94
|
#
|
|
@@ -76,16 +108,60 @@ class Shoes
|
|
|
76
108
|
# @param width [Integer] The new app window width
|
|
77
109
|
# @param height [Integer] The new app window height
|
|
78
110
|
# @param resizable [Boolean] Whether the app window should be resizeable
|
|
111
|
+
# @param features [Symbol,Array<Symbol>] Additional Shoes extensions requested by the app
|
|
79
112
|
# @return [void]
|
|
80
113
|
# @see Shoes::App#new
|
|
81
114
|
def app(
|
|
82
|
-
title:
|
|
115
|
+
title: 'Shoes!',
|
|
83
116
|
width: 480,
|
|
84
117
|
height: 420,
|
|
85
118
|
resizable: true,
|
|
119
|
+
features: [],
|
|
86
120
|
&app_code_body
|
|
87
121
|
)
|
|
88
|
-
|
|
122
|
+
f = [features].flatten # Make sure this is a list, not a single symbol
|
|
123
|
+
app = Shoes::App.new(title:, width:, height:, resizable:, features: f, &app_code_body)
|
|
124
|
+
|
|
125
|
+
# If there's a pending Shoes subclass (e.g., class Book < Shoes), use it
|
|
126
|
+
if Shoes.pending_app_class
|
|
127
|
+
subclass = Shoes.pending_app_class
|
|
128
|
+
Shoes.pending_app_class = nil # Clear it so it doesn't affect future apps
|
|
129
|
+
|
|
130
|
+
# Include the subclass as a module to get its instance methods
|
|
131
|
+
# This works because we're extending the singleton class
|
|
132
|
+
methods_to_copy = subclass.instance_methods(false)
|
|
133
|
+
|
|
134
|
+
methods_to_copy.each do |method_name|
|
|
135
|
+
# Get source location and use eval to redefine - but that's fragile
|
|
136
|
+
# Instead, let's use a delegation pattern with the app as context
|
|
137
|
+
|
|
138
|
+
# Read the method's arity and create a proper wrapper
|
|
139
|
+
um = subclass.instance_method(method_name)
|
|
140
|
+
|
|
141
|
+
# Define a wrapper that will eval the original method body in app's context
|
|
142
|
+
# This is a bit hacky but works: we store the subclass and call via instance_eval
|
|
143
|
+
app.define_singleton_method(method_name) do |*args, &block|
|
|
144
|
+
# Create a temporary subclass instance that delegates to app for Shoes methods
|
|
145
|
+
temp = subclass.allocate
|
|
146
|
+
temp.instance_variable_set(:@__shoes_app__, self)
|
|
147
|
+
|
|
148
|
+
# Define method_missing on the temp to delegate Shoes DSL calls to the app
|
|
149
|
+
temp.define_singleton_method(:method_missing) do |name, *a, **kw, &b|
|
|
150
|
+
@__shoes_app__.send(name, *a, **kw, &b)
|
|
151
|
+
end
|
|
152
|
+
temp.define_singleton_method(:respond_to_missing?) { |*| true }
|
|
153
|
+
|
|
154
|
+
# Call the original method on temp (which delegates DSL calls to app)
|
|
155
|
+
temp.send(method_name, *args, &block)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Copy routes from the subclass to the app
|
|
160
|
+
subclass.class_routes.each do |path, method_name|
|
|
161
|
+
app.url(path, method_name)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
89
165
|
app.init
|
|
90
166
|
app.run
|
|
91
167
|
nil
|
|
@@ -124,7 +200,7 @@ class Shoes
|
|
|
124
200
|
proc do |path|
|
|
125
201
|
load path
|
|
126
202
|
true
|
|
127
|
-
end
|
|
203
|
+
end
|
|
128
204
|
]
|
|
129
205
|
end
|
|
130
206
|
|
|
@@ -144,4 +220,6 @@ class Shoes
|
|
|
144
220
|
@file_loaders = loaders
|
|
145
221
|
end
|
|
146
222
|
end
|
|
223
|
+
|
|
224
|
+
Shoes.APPS ||= []
|
|
147
225
|
end
|
metadata
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lacci
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Concetto Rudilosso
|
|
8
8
|
- Noah Gibbs
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: exe
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: scarpe-components
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
16
|
requirements:
|
|
18
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
19
18
|
- !ruby/object:Gem::Version
|
|
20
|
-
version:
|
|
19
|
+
version: 0.4.0
|
|
21
20
|
type: :runtime
|
|
22
21
|
prerelease: false
|
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
23
|
requirements:
|
|
25
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
26
25
|
- !ruby/object:Gem::Version
|
|
27
|
-
version:
|
|
28
|
-
description:
|
|
26
|
+
version: 0.4.0
|
|
29
27
|
email:
|
|
30
28
|
- marcoc.r@outlook.com
|
|
31
29
|
- the.codefolio.guy@gmail.com
|
|
@@ -43,7 +41,6 @@ files:
|
|
|
43
41
|
- lib/scarpe/niente/app.rb
|
|
44
42
|
- lib/scarpe/niente/display_service.rb
|
|
45
43
|
- lib/scarpe/niente/drawable.rb
|
|
46
|
-
- lib/scarpe/niente/logger.rb
|
|
47
44
|
- lib/scarpe/niente/shoes_spec.rb
|
|
48
45
|
- lib/shoes-spec.rb
|
|
49
46
|
- lib/shoes.rb
|
|
@@ -60,23 +57,25 @@ files:
|
|
|
60
57
|
- lib/shoes/drawables.rb
|
|
61
58
|
- lib/shoes/drawables/arc.rb
|
|
62
59
|
- lib/shoes/drawables/arrow.rb
|
|
60
|
+
- lib/shoes/drawables/border.rb
|
|
63
61
|
- lib/shoes/drawables/button.rb
|
|
64
62
|
- lib/shoes/drawables/check.rb
|
|
65
63
|
- lib/shoes/drawables/document_root.rb
|
|
66
64
|
- lib/shoes/drawables/edit_box.rb
|
|
67
65
|
- lib/shoes/drawables/edit_line.rb
|
|
68
66
|
- lib/shoes/drawables/flow.rb
|
|
67
|
+
- lib/shoes/drawables/font_helper.rb
|
|
69
68
|
- lib/shoes/drawables/image.rb
|
|
70
69
|
- lib/shoes/drawables/line.rb
|
|
71
70
|
- lib/shoes/drawables/link.rb
|
|
72
71
|
- lib/shoes/drawables/list_box.rb
|
|
72
|
+
- lib/shoes/drawables/oval.rb
|
|
73
73
|
- lib/shoes/drawables/para.rb
|
|
74
74
|
- lib/shoes/drawables/progress.rb
|
|
75
75
|
- lib/shoes/drawables/radio.rb
|
|
76
76
|
- lib/shoes/drawables/rect.rb
|
|
77
77
|
- lib/shoes/drawables/shape.rb
|
|
78
78
|
- lib/shoes/drawables/slot.rb
|
|
79
|
-
- lib/shoes/drawables/span.rb
|
|
80
79
|
- lib/shoes/drawables/stack.rb
|
|
81
80
|
- lib/shoes/drawables/star.rb
|
|
82
81
|
- lib/shoes/drawables/subscription_item.rb
|
|
@@ -85,16 +84,14 @@ files:
|
|
|
85
84
|
- lib/shoes/drawables/widget.rb
|
|
86
85
|
- lib/shoes/errors.rb
|
|
87
86
|
- lib/shoes/log.rb
|
|
87
|
+
- lib/shoes/margin_helper.rb
|
|
88
88
|
- lib/shoes/ruby_extensions.rb
|
|
89
|
-
- lib/shoes/spacing.rb
|
|
90
89
|
homepage: https://github.com/scarpe-team/scarpe
|
|
91
90
|
licenses:
|
|
92
91
|
- MIT
|
|
93
92
|
metadata:
|
|
94
93
|
homepage_uri: https://github.com/scarpe-team/scarpe
|
|
95
|
-
source_code_uri: https://github.com/scarpe-team/scarpe
|
|
96
94
|
changelog_uri: https://github.com/scarpe-team/scarpe/blob/main/CHANGELOG.md
|
|
97
|
-
post_install_message:
|
|
98
95
|
rdoc_options: []
|
|
99
96
|
require_paths:
|
|
100
97
|
- lib
|
|
@@ -109,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
106
|
- !ruby/object:Gem::Version
|
|
110
107
|
version: '0'
|
|
111
108
|
requirements: []
|
|
112
|
-
rubygems_version: 3.
|
|
113
|
-
signing_key:
|
|
109
|
+
rubygems_version: 3.6.9
|
|
114
110
|
specification_version: 4
|
|
115
111
|
summary: Lacci - a portable Shoes DSL with switchable display backends, part of Scarpe
|
|
116
112
|
test_files: []
|
data/lib/scarpe/niente/logger.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "shoes/log"
|
|
4
|
-
require "json"
|
|
5
|
-
|
|
6
|
-
module Niente; end
|
|
7
|
-
class Niente::LogImpl
|
|
8
|
-
include Shoes::Log # for constants
|
|
9
|
-
|
|
10
|
-
class PrintLogger
|
|
11
|
-
def initialize(_)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
[:error, :warn, :debug, :info].each do |level|
|
|
15
|
-
define_method(level) do |msg|
|
|
16
|
-
puts "#{level}: #{msg}"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def logger_for_component(component)
|
|
22
|
-
PrintLogger.new(component.to_s)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def configure_logger(log_config)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
#Shoes::Log.instance = Niente::LogImpl.new
|
data/lib/shoes/drawables/span.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Shoes
|
|
4
|
-
class Span < Shoes::Drawable
|
|
5
|
-
shoes_styles :text, :stroke, :size, :font, :html_attributes
|
|
6
|
-
shoes_events # No Span-specific events yet
|
|
7
|
-
|
|
8
|
-
def initialize(text, stroke: nil, size: :span, font: nil, **html_attributes)
|
|
9
|
-
super
|
|
10
|
-
|
|
11
|
-
@text = text
|
|
12
|
-
@stroke = stroke
|
|
13
|
-
@size = size
|
|
14
|
-
@font = font
|
|
15
|
-
@html_attributes = html_attributes
|
|
16
|
-
|
|
17
|
-
create_display_drawable
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def replace(text)
|
|
21
|
-
@text = text
|
|
22
|
-
|
|
23
|
-
# This should signal the display drawable to change
|
|
24
|
-
self.text = @text
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|