glimmer-dsl-libui 0.3.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +3298 -3128
- data/VERSION +1 -1
- data/examples/basic_area.rb +1 -3
- data/examples/basic_area2.rb +1 -3
- data/examples/basic_area3.rb +17 -0
- data/examples/basic_area4.rb +19 -0
- data/examples/basic_scrolling_area.rb +79 -0
- data/examples/color_the_circles.rb +2 -2
- data/examples/method_based_custom_keyword.rb +2 -2
- data/examples/midi_player.rb +2 -6
- data/examples/snake/model/game.rb +2 -2
- data/examples/snake/presenter/grid.rb +5 -3
- data/examples/snake.rb +11 -21
- data/examples/tetris.rb +12 -12
- data/examples/tic_tac_toe.rb +3 -12
- data/examples/timer.rb +2 -6
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/bind_expression.rb +36 -0
- data/lib/glimmer/dsl/libui/data_binding_expression.rb +47 -0
- data/lib/glimmer/dsl/libui/dsl.rb +3 -0
- data/lib/glimmer/dsl/libui/observe_expression.rb +35 -0
- data/lib/glimmer/dsl/libui/shine_data_binding_expression.rb +42 -0
- data/lib/glimmer/dsl/libui/string_expression.rb +4 -5
- data/lib/glimmer/libui/attributed_string.rb +19 -6
- data/lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb +35 -0
- data/lib/glimmer/libui/control_proxy/window_proxy.rb +20 -0
- data/lib/glimmer/libui/shape.rb +6 -1
- metadata +11 -4
@@ -27,7 +27,8 @@ require 'glimmer/libui/control_proxy/transformable'
|
|
27
27
|
module Glimmer
|
28
28
|
module LibUI
|
29
29
|
class AttributedString
|
30
|
-
attr_reader :
|
30
|
+
attr_reader :keyword, :parent_proxy, :args
|
31
|
+
attr_accessor :block
|
31
32
|
|
32
33
|
def initialize(keyword, parent_proxy, args, &block)
|
33
34
|
@keyword = keyword
|
@@ -115,10 +116,14 @@ module Glimmer
|
|
115
116
|
alias open_type_features= open_type_features
|
116
117
|
alias set_open_type_features open_type_features
|
117
118
|
|
118
|
-
def post_add_content
|
119
|
-
|
120
|
-
|
121
|
-
@
|
119
|
+
def post_add_content(block = nil)
|
120
|
+
block ||= @block
|
121
|
+
block_result = block&.call
|
122
|
+
unless @content_added
|
123
|
+
@string = block_result if block_result.is_a?(String)
|
124
|
+
@parent_proxy&.post_initialize_child(self)
|
125
|
+
@content_added = true
|
126
|
+
end
|
122
127
|
end
|
123
128
|
|
124
129
|
def post_initialize_child(child)
|
@@ -185,12 +190,20 @@ module Glimmer
|
|
185
190
|
end
|
186
191
|
|
187
192
|
def redraw
|
188
|
-
area_proxy&.
|
193
|
+
area_proxy&.redraw
|
194
|
+
end
|
195
|
+
|
196
|
+
def request_auto_redraw
|
197
|
+
area_proxy&.request_auto_redraw
|
189
198
|
end
|
190
199
|
|
191
200
|
def area_proxy
|
192
201
|
@parent_proxy.parent_proxy
|
193
202
|
end
|
203
|
+
|
204
|
+
def content(&block)
|
205
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::StringExpression.new, @keyword, &block)
|
206
|
+
end
|
194
207
|
end
|
195
208
|
end
|
196
209
|
end
|
@@ -31,8 +31,43 @@ module Glimmer
|
|
31
31
|
class ScrollingAreaProxy < AreaProxy
|
32
32
|
def build_control
|
33
33
|
@area_handler = ::LibUI::FFI::AreaHandler.malloc
|
34
|
+
@args[0] ||= Glimmer::LibUI::ControlProxy.main_window_proxy.width
|
35
|
+
@args[1] ||= Glimmer::LibUI::ControlProxy.main_window_proxy.height
|
34
36
|
@libui = ::LibUI.new_scrolling_area(@area_handler, *@args)
|
35
37
|
end
|
38
|
+
|
39
|
+
def width(value = nil)
|
40
|
+
if value.nil?
|
41
|
+
@args[0]
|
42
|
+
else
|
43
|
+
@args[0] = value
|
44
|
+
set_size(width, height)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
alias width= width
|
48
|
+
alias set_width width
|
49
|
+
|
50
|
+
def height(value = nil)
|
51
|
+
if value.nil?
|
52
|
+
@args[1]
|
53
|
+
else
|
54
|
+
@args[1] = value
|
55
|
+
set_size(width, height)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
alias height= height
|
59
|
+
alias set_height height
|
60
|
+
|
61
|
+
def set_size(width, height)
|
62
|
+
@args[0] = width
|
63
|
+
@args[1] = height
|
64
|
+
super(width, height)
|
65
|
+
end
|
66
|
+
|
67
|
+
def scroll_to(scroll_x, scroll_y, scroll_width = nil, scroll_height = nil)
|
68
|
+
scroll_width, scroll_height = Glimmer::LibUI::ControlProxy.main_window_proxy.content_size
|
69
|
+
super(scroll_x, scroll_y, scroll_width, scroll_height)
|
70
|
+
end
|
36
71
|
end
|
37
72
|
end
|
38
73
|
end
|
@@ -113,6 +113,26 @@ module Glimmer
|
|
113
113
|
alias content_size= content_size
|
114
114
|
alias set_content_size content_size
|
115
115
|
|
116
|
+
def width(value = nil)
|
117
|
+
if value.nil?
|
118
|
+
content_size.first
|
119
|
+
else
|
120
|
+
set_content_size(value, height)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
alias width= width
|
124
|
+
alias set_width width
|
125
|
+
|
126
|
+
def height(value = nil)
|
127
|
+
if value.nil?
|
128
|
+
content_size.last
|
129
|
+
else
|
130
|
+
set_content_size(width, value)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
alias height= height
|
134
|
+
alias set_height height
|
135
|
+
|
116
136
|
def resizable(value = nil)
|
117
137
|
if value.nil?
|
118
138
|
@resizable = true if @resizable.nil?
|
data/lib/glimmer/libui/shape.rb
CHANGED
@@ -91,13 +91,18 @@ module Glimmer
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
def content(&block)
|
95
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::ShapeExpression.new, @keyword, &block)
|
96
|
+
request_auto_redraw
|
97
|
+
end
|
98
|
+
|
94
99
|
# Subclasses must override to perform draw work and call super afterwards to ensure calling destroy when semi-declarative in an on_draw method
|
95
100
|
def draw(area_draw_params)
|
96
101
|
destroy if area_proxy.nil?
|
97
102
|
end
|
98
103
|
|
99
104
|
def redraw
|
100
|
-
area_proxy&.
|
105
|
+
area_proxy&.redraw
|
101
106
|
end
|
102
107
|
|
103
108
|
def request_auto_redraw
|
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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -64,14 +64,14 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.0.
|
67
|
+
version: 0.0.13
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.0.
|
74
|
+
version: 0.0.13
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: chunky_png
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,6 +217,8 @@ files:
|
|
217
217
|
- examples/area_gallery4.rb
|
218
218
|
- examples/basic_area.rb
|
219
219
|
- examples/basic_area2.rb
|
220
|
+
- examples/basic_area3.rb
|
221
|
+
- examples/basic_area4.rb
|
220
222
|
- examples/basic_button.rb
|
221
223
|
- examples/basic_draw_text.rb
|
222
224
|
- examples/basic_draw_text2.rb
|
@@ -226,6 +228,7 @@ files:
|
|
226
228
|
- examples/basic_image3.rb
|
227
229
|
- examples/basic_image4.rb
|
228
230
|
- examples/basic_image5.rb
|
231
|
+
- examples/basic_scrolling_area.rb
|
229
232
|
- examples/basic_table.rb
|
230
233
|
- examples/basic_table_button.rb
|
231
234
|
- examples/basic_table_checkbox.rb
|
@@ -280,14 +283,18 @@ files:
|
|
280
283
|
- glimmer-dsl-libui.gemspec
|
281
284
|
- icons/glimmer.png
|
282
285
|
- lib/glimmer-dsl-libui.rb
|
286
|
+
- lib/glimmer/dsl/libui/bind_expression.rb
|
283
287
|
- lib/glimmer/dsl/libui/control_expression.rb
|
288
|
+
- lib/glimmer/dsl/libui/data_binding_expression.rb
|
284
289
|
- lib/glimmer/dsl/libui/dsl.rb
|
285
290
|
- lib/glimmer/dsl/libui/file_expression.rb
|
286
291
|
- lib/glimmer/dsl/libui/listener_expression.rb
|
292
|
+
- lib/glimmer/dsl/libui/observe_expression.rb
|
287
293
|
- lib/glimmer/dsl/libui/open_file_expression.rb
|
288
294
|
- lib/glimmer/dsl/libui/property_expression.rb
|
289
295
|
- lib/glimmer/dsl/libui/save_file_expression.rb
|
290
296
|
- lib/glimmer/dsl/libui/shape_expression.rb
|
297
|
+
- lib/glimmer/dsl/libui/shine_data_binding_expression.rb
|
291
298
|
- lib/glimmer/dsl/libui/string_expression.rb
|
292
299
|
- lib/glimmer/dsl/libui/tab_item_expression.rb
|
293
300
|
- lib/glimmer/fiddle_consumer.rb
|