glimmer-dsl-libui 0.11.2 → 0.11.4
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/CHANGELOG.md +9 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/examples/dynamic_form.rb +3 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/content_expression.rb +2 -2
- data/lib/glimmer/dsl/libui/control_expression.rb +2 -1
- data/lib/glimmer/dsl/libui/custom_control_expression.rb +2 -1
- data/lib/glimmer/dsl/libui/custom_shape_expression.rb +2 -1
- data/lib/glimmer/dsl/libui/shape_expression.rb +2 -1
- data/lib/glimmer/dsl/libui/shine_data_binding_expression.rb +2 -1
- data/lib/glimmer/dsl/libui/string_expression.rb +2 -1
- data/lib/glimmer/libui/control_proxy/text_proxy.rb +75 -1
- data/lib/glimmer/libui/control_proxy/window_proxy.rb +4 -4
- data/lib/glimmer/libui/control_proxy.rb +4 -1
- data/lib/glimmer/libui/custom_control.rb +22 -11
- data/lib/glimmer/libui/custom_shape.rb +15 -10
- data/lib/glimmer/libui/perfect_shaped.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 587e29f6be24b8a3f01a9872faa7f421531b36a9534fe4b241d52339dbca503c
|
4
|
+
data.tar.gz: d1fe047970b1c482aba434f9c1a3d010099aacca1d9ba320cf0ed07967ac3b83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32da548dc373cef2214ce2af6ca329d01691cfdeeda8d9f6f5d85c6878c2d7b02ad1892d50e9f0a443256ef3e54932208c638635f8167e3906500af1eb328c28
|
7
|
+
data.tar.gz: 206732983531c55d879818e1ec92c3bba276a8430d5c2785dd80349078145dc3b8e961b31f3510cf10a7cdbfc1e57e15688858b03b91a80baa3bbe00a06b15c0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.11.4
|
4
|
+
|
5
|
+
- Fix issue with Content Data-Binding not working
|
6
|
+
- Fix issue with not successfully processing layout properties (e.g. `stretchy`) when nested under custom controls/windows
|
7
|
+
|
8
|
+
## 0.11.3
|
9
|
+
|
10
|
+
- Support nesting `on_mouse_*` listeners under `text`
|
11
|
+
|
3
12
|
## 0.11.2
|
4
13
|
|
5
14
|
- Fix issue with getting error when nesting property content under custom controls/shapes/windows (fixes `examples/basic_custom_shape.rb`)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.11.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.11.4
|
2
2
|
## Prerequisite-Free Ruby Desktop Development Cross-Platform Native GUI Library ([Fukuoka Award Winning](http://www.digitalfukuoka.jp/topics/187?locale=ja))
|
3
3
|
### The Quickest Way From Zero To GUI
|
4
4
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
@@ -431,7 +431,7 @@ gem install glimmer-dsl-libui
|
|
431
431
|
Or install via Bundler `Gemfile`:
|
432
432
|
|
433
433
|
```ruby
|
434
|
-
gem 'glimmer-dsl-libui', '~> 0.11.
|
434
|
+
gem 'glimmer-dsl-libui', '~> 0.11.4'
|
435
435
|
```
|
436
436
|
|
437
437
|
Test that installation worked by running the [Glimmer Meta-Example](#examples):
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.11.
|
1
|
+
0.11.4
|
data/examples/dynamic_form.rb
CHANGED
@@ -59,7 +59,9 @@ class DynamicForm
|
|
59
59
|
|
60
60
|
button('Summarize') {
|
61
61
|
on_clicked do
|
62
|
-
|
62
|
+
user_attribute_values = @user.customizable_attributes.map { |attribute| @user.send(attribute) }
|
63
|
+
non_blank_user_attribute_values = user_attribute_values.map(&:to_s).reject(&:empty?)
|
64
|
+
summary = non_blank_user_attribute_values.join(', ')
|
63
65
|
msg_box('Summary', summary)
|
64
66
|
end
|
65
67
|
}
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -19,12 +19,12 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
require 'glimmer/dsl/
|
22
|
+
require 'glimmer/dsl/expression'
|
23
23
|
|
24
24
|
module Glimmer
|
25
25
|
module DSL
|
26
26
|
module Libui
|
27
|
-
class ContentExpression <
|
27
|
+
class ContentExpression < Expression
|
28
28
|
def can_interpret?(parent, keyword, *args, &block)
|
29
29
|
keyword == 'content' &&
|
30
30
|
block_given? &&
|
@@ -38,7 +38,8 @@ module Glimmer
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def add_content(parent, keyword, *args, &block)
|
41
|
-
options = args.last.is_a?(Hash) ? args.last : {
|
41
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
42
|
+
options[:post_add_content] = true if !options.include?(:post_add_content)
|
42
43
|
super
|
43
44
|
parent&.post_add_content if options[:post_add_content]
|
44
45
|
end
|
@@ -44,7 +44,8 @@ module Glimmer
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def add_content(custom_control, keyword, *args, &block)
|
47
|
-
options = args.last.is_a?(Hash) ? args.last : {
|
47
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
48
|
+
options[:post_add_content] = true if !options.include?(:post_add_content)
|
48
49
|
# TODO consider avoiding source_location
|
49
50
|
if block.source_location == custom_control.content&.__getobj__&.source_location
|
50
51
|
custom_control.content.call(custom_control) unless custom_control.content.called?
|
@@ -43,7 +43,8 @@ module Glimmer
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def add_content(custom_shape, keyword, *args, &block)
|
46
|
-
options = args.last.is_a?(Hash) ? args.last : {
|
46
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
47
|
+
options[:post_add_content] = true if !options.include?(:post_add_content)
|
47
48
|
# TODO consider avoiding source_location
|
48
49
|
if block.source_location == custom_shape.content&.__getobj__&.source_location
|
49
50
|
custom_shape.content.call(custom_shape) unless custom_shape.content.called?
|
@@ -48,7 +48,8 @@ module Glimmer
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def add_content(parent, keyword, *args, &block)
|
51
|
-
options = args.last.is_a?(Hash) ? args.last : {
|
51
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
52
|
+
options[:post_add_content] = true if !options.include?(:post_add_content)
|
52
53
|
super
|
53
54
|
parent&.post_add_content if options[:post_add_content]
|
54
55
|
end
|
@@ -28,7 +28,8 @@ module Glimmer
|
|
28
28
|
module Libui
|
29
29
|
class ShineDataBindingExpression < Expression
|
30
30
|
def can_interpret?(parent, keyword, *args, &block)
|
31
|
-
|
31
|
+
keyword != 'content' and
|
32
|
+
args.size == 0 and
|
32
33
|
block.nil? and
|
33
34
|
parent.respond_to?(keyword, *args, &block)
|
34
35
|
end
|
@@ -46,7 +46,8 @@ module Glimmer
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def add_content(parent, keyword, *args, &block)
|
49
|
-
options = args.last.is_a?(Hash) ? args.last : {
|
49
|
+
options = args.last.is_a?(Hash) ? args.last : {}
|
50
|
+
options[:post_add_content] = true if !options.include?(:post_add_content)
|
50
51
|
parent&.post_add_content(block) if options[:post_add_content]
|
51
52
|
end
|
52
53
|
end
|
@@ -32,8 +32,9 @@ module Glimmer
|
|
32
32
|
# Follows the Proxy Design Pattern
|
33
33
|
class TextProxy < ControlProxy
|
34
34
|
include Parent
|
35
|
+
include PerfectShaped
|
35
36
|
prepend Transformable
|
36
|
-
|
37
|
+
|
37
38
|
def initialize(keyword, parent, args, &block)
|
38
39
|
@keyword = keyword
|
39
40
|
@parent_proxy = parent
|
@@ -156,6 +157,69 @@ module Glimmer
|
|
156
157
|
@draw_text_layout_params
|
157
158
|
end
|
158
159
|
|
160
|
+
def area_proxy
|
161
|
+
# TODO eventually reuse this method from Shape
|
162
|
+
find_parent_in_ancestors { |parent| parent.nil? || parent.is_a?(ControlProxy::AreaProxy) }
|
163
|
+
end
|
164
|
+
|
165
|
+
def find_parent_in_ancestors(&condition)
|
166
|
+
# TODO eventually reuse this method from Shape
|
167
|
+
found = self
|
168
|
+
until condition.call(found)
|
169
|
+
# TODO in the future, support nesting under composite shape where there is parent instead of parent_proxy
|
170
|
+
# found = found.respond_to?(:parent_proxy) ? found.parent_proxy : found.parent
|
171
|
+
found = found.parent_proxy
|
172
|
+
end
|
173
|
+
found
|
174
|
+
end
|
175
|
+
|
176
|
+
def can_handle_listener?(listener_name)
|
177
|
+
area_proxy.can_handle_listener?(listener_name)
|
178
|
+
end
|
179
|
+
|
180
|
+
def handle_listener(listener_name, &listener)
|
181
|
+
area_proxy.handle_listener(listener_name) do |event|
|
182
|
+
listener.call(event) if include?(event[:x], event[:y])
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def perfect_shape
|
187
|
+
the_perfect_shape_dependencies = perfect_shape_dependencies
|
188
|
+
if the_perfect_shape_dependencies != @perfect_shape_dependencies
|
189
|
+
absolute_x, absolute_y, width, height = @perfect_shape_dependencies = the_perfect_shape_dependencies
|
190
|
+
@perfect_shape = PerfectShape::Rectangle.new(x: absolute_x, y: absolute_y, width: width, height: height)
|
191
|
+
end
|
192
|
+
@perfect_shape
|
193
|
+
end
|
194
|
+
|
195
|
+
def perfect_shape_dependencies
|
196
|
+
# TODO support absolute_x and absolute_y with relative positioning in the future
|
197
|
+
absolute_x = x
|
198
|
+
absolute_y = y
|
199
|
+
[absolute_x, absolute_y, extent_width, extent_height]
|
200
|
+
end
|
201
|
+
|
202
|
+
def extent_width
|
203
|
+
if @extent_width.to_f > 0
|
204
|
+
@extent_width
|
205
|
+
else
|
206
|
+
width
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def extent_height
|
211
|
+
if @extent_height.to_f > 0
|
212
|
+
@extent_height
|
213
|
+
else
|
214
|
+
children_max_size = children.map(&:font).map {|font| font[:size] if font.respond_to?(:[]) }.compact.max
|
215
|
+
if children_max_size.to_f > 0
|
216
|
+
children_max_size
|
217
|
+
else
|
218
|
+
@default_font[:size]
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
159
223
|
private
|
160
224
|
|
161
225
|
def build_control
|
@@ -169,6 +233,16 @@ module Glimmer
|
|
169
233
|
draw_brush.B = (draw_brush_args[:b] || draw_brush_args[:blue]).to_f / 255.0
|
170
234
|
draw_brush.A = (draw_brush_args[:a] || draw_brush_args[:alpha])
|
171
235
|
end
|
236
|
+
|
237
|
+
def calculate_extents
|
238
|
+
# TODO fix implementation once libui binding project responds about this
|
239
|
+
# as it always returns 0,0 right now
|
240
|
+
extent_width = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE*8)
|
241
|
+
extent_height = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE*8)
|
242
|
+
::LibUI.draw_text_layout_extents(@libui, extent_width, extent_height)
|
243
|
+
@extent_width = extent_width[0, Fiddle::SIZEOF_DOUBLE*8].unpack1('i')
|
244
|
+
@extent_height = extent_height[0, Fiddle::SIZEOF_DOUBLE*8].unpack1('i')
|
245
|
+
end
|
172
246
|
end
|
173
247
|
end
|
174
248
|
end
|
@@ -104,11 +104,11 @@ module Glimmer
|
|
104
104
|
|
105
105
|
def content_size(*args)
|
106
106
|
if args.empty?
|
107
|
-
width = Fiddle::Pointer.malloc(
|
108
|
-
height = Fiddle::Pointer.malloc(
|
107
|
+
width = Fiddle::Pointer.malloc(64)
|
108
|
+
height = Fiddle::Pointer.malloc(64)
|
109
109
|
::LibUI.window_content_size(@libui, width, height)
|
110
|
-
width = width[0,
|
111
|
-
height = height[0,
|
110
|
+
width = width[0, 64].unpack1('i')
|
111
|
+
height = height[0, 64].unpack1('i')
|
112
112
|
[width, height]
|
113
113
|
else
|
114
114
|
args = args.first if args.size == 1 && args.first.is_a?(Array)
|
@@ -142,7 +142,10 @@ module Glimmer
|
|
142
142
|
# Subclasses may override to perform post add_content work (normally must call super)
|
143
143
|
def post_add_content
|
144
144
|
unless @content_added
|
145
|
-
|
145
|
+
if CustomControl.custom_controls_being_interpreted.last.nil? ||
|
146
|
+
CustomControl.custom_controls_being_interpreted.last.parent_proxy != @parent_proxy
|
147
|
+
@parent_proxy&.post_initialize_child(self)
|
148
|
+
end
|
146
149
|
@content_added = true
|
147
150
|
end
|
148
151
|
end
|
@@ -52,16 +52,6 @@ module Glimmer
|
|
52
52
|
result ||= can_handle_listener?(method_name)
|
53
53
|
result ||= @body_root.respond_to?(method_name, *args, &block)
|
54
54
|
end
|
55
|
-
|
56
|
-
# Returns content block if used as an attribute reader (no args)
|
57
|
-
# Otherwise, if a block is passed, it adds it as content to this custom control
|
58
|
-
def content(&block)
|
59
|
-
if block_given?
|
60
|
-
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomControlExpression.new, self.class.keyword, &block)
|
61
|
-
else
|
62
|
-
@content
|
63
|
-
end
|
64
|
-
end
|
65
55
|
end
|
66
56
|
|
67
57
|
super_module_included do |klass|
|
@@ -193,11 +183,16 @@ module Glimmer
|
|
193
183
|
def after_body(&block)
|
194
184
|
@after_body_block = block
|
195
185
|
end
|
186
|
+
|
187
|
+
def custom_controls_being_interpreted
|
188
|
+
@custom_controls_being_interpreted ||= []
|
189
|
+
end
|
196
190
|
end
|
197
191
|
|
198
192
|
attr_reader :body_root, :libui, :parent, :parent_proxy, :args, :keyword, :content, :options
|
199
193
|
|
200
194
|
def initialize(keyword, parent, args, options, &content)
|
195
|
+
CustomControl.custom_controls_being_interpreted << self
|
201
196
|
@parent_proxy = @parent = parent
|
202
197
|
options ||= {}
|
203
198
|
@options = self.class.options.merge(options)
|
@@ -220,7 +215,8 @@ module Glimmer
|
|
220
215
|
end
|
221
216
|
|
222
217
|
def post_add_content
|
223
|
-
|
218
|
+
@parent_proxy&.post_initialize_child(@body_root)
|
219
|
+
Glimmer::LibUI::CustomControl.custom_controls_being_interpreted.pop
|
224
220
|
end
|
225
221
|
|
226
222
|
def observer_registrations
|
@@ -243,6 +239,21 @@ module Glimmer
|
|
243
239
|
!method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
|
244
240
|
!method(method_name)&.source_location&.first&.include?('glimmer/libui/control_proxy.rb')
|
245
241
|
end
|
242
|
+
|
243
|
+
# Returns content block if used as an attribute reader (no args)
|
244
|
+
# Otherwise, if a block is passed, it adds it as content to this custom control
|
245
|
+
def content(*args, &block)
|
246
|
+
if args.empty?
|
247
|
+
if block_given?
|
248
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomControlExpression.new, self.class.keyword, &block)
|
249
|
+
else
|
250
|
+
@content
|
251
|
+
end
|
252
|
+
else
|
253
|
+
# delegate to GUI DSL ContentExpression
|
254
|
+
super
|
255
|
+
end
|
256
|
+
end
|
246
257
|
|
247
258
|
private
|
248
259
|
|
@@ -52,16 +52,6 @@ module Glimmer
|
|
52
52
|
result ||= can_handle_listener?(method_name)
|
53
53
|
result ||= @body_root.respond_to?(method_name, *args, &block)
|
54
54
|
end
|
55
|
-
|
56
|
-
# Returns content block if used as an attribute reader (no args)
|
57
|
-
# Otherwise, if a block is passed, it adds it as content to this custom shape
|
58
|
-
def content(&block)
|
59
|
-
if block_given?
|
60
|
-
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomShapeExpression.new, self.class.keyword, &block)
|
61
|
-
else
|
62
|
-
@content
|
63
|
-
end
|
64
|
-
end
|
65
55
|
end
|
66
56
|
|
67
57
|
super_module_included do |klass|
|
@@ -240,6 +230,21 @@ module Glimmer
|
|
240
230
|
!method(method_name)&.source_location&.first&.include?('glimmer/dsl/engine.rb') and
|
241
231
|
!method(method_name)&.source_location&.first&.include?('glimmer/libui/shape.rb')
|
242
232
|
end
|
233
|
+
|
234
|
+
# Returns content block if used as an attribute reader (no args)
|
235
|
+
# Otherwise, if a block is passed, it adds it as content to this custom shape
|
236
|
+
def content(*args, &block)
|
237
|
+
if args.empty?
|
238
|
+
if block_given?
|
239
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::CustomShapeExpression.new, self.class.keyword, &block)
|
240
|
+
else
|
241
|
+
@content
|
242
|
+
end
|
243
|
+
else
|
244
|
+
# delegate to GUI DSL ContentExpression
|
245
|
+
super
|
246
|
+
end
|
247
|
+
end
|
243
248
|
|
244
249
|
private
|
245
250
|
|
@@ -15,13 +15,14 @@ module Glimmer
|
|
15
15
|
# determining if a point lies on the outline (e.g. makes it easier to select
|
16
16
|
# a shape by mouse)
|
17
17
|
def contain?(*point, outline: false, distance_tolerance: 0)
|
18
|
+
# TODO inverse transform point with `uiDrawMatrixTransformPoint` before checking containment
|
18
19
|
perfect_shape&.contain?(*point, outline: outline, distance_tolerance: distance_tolerance)
|
19
20
|
end
|
20
21
|
|
21
22
|
# Returns if shape includes point on the inside when filled
|
22
23
|
# or if shape includes point on the outline when stroked
|
23
24
|
def include?(*point)
|
24
|
-
if fill.empty?
|
25
|
+
if respond_to?(:fill) && fill.empty?
|
25
26
|
# TODO check if distance_tolerance should be half the thickness in case it is checked against both sides of out and in
|
26
27
|
contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1))
|
27
28
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|