glimmer-dsl-libui 0.4.16 → 0.4.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/README.md +451 -68
- data/VERSION +1 -1
- data/examples/area_based_custom_controls.rb +278 -0
- data/examples/basic_table.rb +1 -1
- data/examples/cpu_percentage.rb +1 -1
- data/examples/custom_draw_text.rb +14 -7
- data/examples/custom_draw_text2.rb +15 -8
- data/examples/method_based_custom_keyword.rb +9 -9
- data/examples/method_based_custom_keyword2.rb +9 -9
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/dsl.rb +1 -0
- data/lib/glimmer/dsl/libui/observe_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/operation_expression.rb +47 -0
- data/lib/glimmer/dsl/libui/property_expression.rb +2 -2
- data/lib/glimmer/libui/control_proxy/box.rb +1 -0
- data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/image_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +6 -0
- data/lib/glimmer/libui/control_proxy/column.rb +7 -0
- data/lib/glimmer/libui/control_proxy/form_proxy.rb +1 -0
- data/lib/glimmer/libui/control_proxy/image_proxy.rb +1 -0
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +0 -1
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +6 -4
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +51 -28
- data/lib/glimmer/libui/control_proxy.rb +1 -0
- data/lib/glimmer/libui/data_bindable.rb +1 -1
- data/lib/glimmer/libui/shape/bezier.rb +20 -3
- data/lib/glimmer/libui/shape/line.rb +23 -3
- data/lib/glimmer-dsl-libui.rb +6 -0
- metadata +23 -6
@@ -24,6 +24,13 @@ module Glimmer
|
|
24
24
|
class ControlProxy
|
25
25
|
# Common logic for all column proxy objects
|
26
26
|
module Column
|
27
|
+
class << self
|
28
|
+
# subclasses may override to provide a valid default value like a blank image for image columns and false for checkbox
|
29
|
+
def default_value
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
27
34
|
def initialize(keyword, parent, args, &block)
|
28
35
|
@keyword = keyword
|
29
36
|
@parent_proxy = parent
|
@@ -70,7 +70,8 @@ module Glimmer
|
|
70
70
|
else
|
71
71
|
new_color = Glimmer::LibUI.interpret_color(args)
|
72
72
|
if new_color != @fill
|
73
|
-
|
73
|
+
# TODO consider replacing unobserve with observer_registration.deregister
|
74
|
+
@fill_observer&.unobserve(@fill, attribute_writer_type: [:attribute=, :set_attribute]) if @fill
|
74
75
|
@fill = new_color
|
75
76
|
request_auto_redraw
|
76
77
|
end
|
@@ -79,7 +80,7 @@ module Glimmer
|
|
79
80
|
@fill_observer ||= Glimmer::DataBinding::Observer.proc do
|
80
81
|
request_auto_redraw
|
81
82
|
end
|
82
|
-
@fill_observer.observe(@fill)
|
83
|
+
@fill_observer.observe(@fill, attribute_writer_type: [:attribute=, :set_attribute])
|
83
84
|
end
|
84
85
|
end
|
85
86
|
alias fill= fill
|
@@ -98,7 +99,8 @@ module Glimmer
|
|
98
99
|
else
|
99
100
|
new_color = Glimmer::LibUI.interpret_color(args)
|
100
101
|
if new_color != @stroke
|
101
|
-
|
102
|
+
# TODO consider replacing unobserve with observer_registration.deregister
|
103
|
+
@stroke_observer&.unobserve(@stroke, attribute_writer_type: [:attribute=, :set_attribute]) if @stroke
|
102
104
|
@stroke = Glimmer::LibUI.interpret_color(args)
|
103
105
|
request_auto_redraw
|
104
106
|
end
|
@@ -107,7 +109,7 @@ module Glimmer
|
|
107
109
|
@stroke_observer ||= Glimmer::DataBinding::Observer.proc do
|
108
110
|
request_auto_redraw
|
109
111
|
end
|
110
|
-
@stroke_observer.observe(@stroke)
|
112
|
+
@stroke_observer.observe(@stroke, attribute_writer_type: [:attribute=, :set_attribute])
|
111
113
|
end
|
112
114
|
end
|
113
115
|
alias stroke= stroke
|
@@ -48,6 +48,8 @@ module Glimmer
|
|
48
48
|
@enabled = true
|
49
49
|
@columns = []
|
50
50
|
@cell_rows = []
|
51
|
+
@last_cell_rows = []
|
52
|
+
register_cell_rows_observer
|
51
53
|
window_proxy.on_destroy do
|
52
54
|
# the following unless condition is an exceptional condition stumbled upon that fails freeing the table model
|
53
55
|
::LibUI.free_table_model(@model) unless @destroyed && parent_proxy.is_a?(Box)
|
@@ -75,7 +77,8 @@ module Glimmer
|
|
75
77
|
|
76
78
|
def destroy
|
77
79
|
super
|
78
|
-
|
80
|
+
# TODO consider replacing unobserve with observer_registration.deregister
|
81
|
+
@cell_rows_observer&.unobserve(self, :cell_rows, recursive: true, ignore_frozen: true, attribute_writer_type: [:attribute=, :set_attribute])
|
79
82
|
@destroyed = true
|
80
83
|
end
|
81
84
|
|
@@ -86,31 +89,6 @@ module Glimmer
|
|
86
89
|
if rows != @cell_rows
|
87
90
|
@cell_rows = rows
|
88
91
|
@cell_rows = @cell_rows.to_a if @cell_rows.is_a?(Enumerator)
|
89
|
-
@last_cell_rows ||= array_deep_clone(@cell_rows)
|
90
|
-
@cell_rows_observer ||= Glimmer::DataBinding::Observer.proc do |new_cell_rows|
|
91
|
-
if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
|
92
|
-
@last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
|
93
|
-
::LibUI.table_model_row_deleted(model, row)
|
94
|
-
notify_custom_listeners('on_changed', row, :deleted, @last_cell_rows[row])
|
95
|
-
end
|
96
|
-
elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
|
97
|
-
@cell_rows.array_diff_indexes(@last_cell_rows).each do |row|
|
98
|
-
::LibUI.table_model_row_inserted(model, row)
|
99
|
-
notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
|
100
|
-
end
|
101
|
-
else
|
102
|
-
@cell_rows.each_with_index do |new_row_data, row|
|
103
|
-
if new_row_data != @last_cell_rows[row]
|
104
|
-
::LibUI.table_model_row_changed(model, row)
|
105
|
-
notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
@last_last_cell_rows = array_deep_clone(@last_cell_rows)
|
110
|
-
@last_cell_rows = array_deep_clone(@cell_rows)
|
111
|
-
end.tap do |cell_rows_observer|
|
112
|
-
cell_rows_observer.observe(self, :cell_rows, recursive: true)
|
113
|
-
end
|
114
92
|
end
|
115
93
|
@cell_rows
|
116
94
|
end
|
@@ -153,13 +131,13 @@ module Glimmer
|
|
153
131
|
new_value = new_value.to_a if new_value.is_a?(Enumerator)
|
154
132
|
if model_binding.binding_options[:column_attributes] || (!new_value.empty? && !new_value.first.is_a?(Array))
|
155
133
|
@model_attribute_array_observer_registration&.deregister
|
156
|
-
@model_attribute_array_observer_registration = model_attribute_observer.observe(new_value, @column_attributes)
|
134
|
+
@model_attribute_array_observer_registration = model_attribute_observer.observe(new_value, @column_attributes, ignore_frozen: true, attribute_writer_type: [:attribute=, :set_attribute])
|
157
135
|
model_attribute_observer.add_dependent(model_attribute_observer_registration => @model_attribute_array_observer_registration)
|
158
136
|
end
|
159
137
|
# TODO look if multiple notifications are happening as a result of observing array and observing model binding
|
160
138
|
send("#{property}=", new_value) unless @last_cell_rows == new_value
|
161
139
|
end
|
162
|
-
model_attribute_observer_registration = model_attribute_observer.observe(model_binding)
|
140
|
+
model_attribute_observer_registration = model_attribute_observer.observe(model_binding, attribute_writer_type: [:attribute=, :set_attribute])
|
163
141
|
model_attribute_observer.call # initial update
|
164
142
|
data_binding_model_attribute_observer_registrations << model_attribute_observer_registration
|
165
143
|
model_attribute_observer
|
@@ -310,12 +288,57 @@ module Glimmer
|
|
310
288
|
@libui.tap do
|
311
289
|
@columns.each {|column| column.respond_to?(:build_control, true) && column.send(:build_control) }
|
312
290
|
end
|
291
|
+
|
292
|
+
if !@applied_windows_fix && OS.windows?
|
293
|
+
@applied_windows_fix = true
|
294
|
+
apply_windows_fix
|
295
|
+
end
|
313
296
|
end
|
314
297
|
|
315
298
|
def next_column_index
|
316
299
|
@next_column_index ||= -1
|
317
300
|
@next_column_index += 1
|
318
301
|
end
|
302
|
+
|
303
|
+
def register_cell_rows_observer
|
304
|
+
@cell_rows_observer = Glimmer::DataBinding::Observer.proc do |new_cell_rows|
|
305
|
+
if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
|
306
|
+
@last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
|
307
|
+
::LibUI.table_model_row_deleted(model, row) if model && row
|
308
|
+
notify_custom_listeners('on_changed', row, :deleted, @last_cell_rows[row])
|
309
|
+
end
|
310
|
+
elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
|
311
|
+
@cell_rows.array_diff_indexes(@last_cell_rows).each do |row|
|
312
|
+
::LibUI.table_model_row_inserted(model, row) if model && row
|
313
|
+
notify_custom_listeners('on_changed', row, :inserted, @cell_rows[row])
|
314
|
+
end
|
315
|
+
else
|
316
|
+
@cell_rows.each_with_index do |new_row_data, row|
|
317
|
+
if new_row_data != @last_cell_rows[row]
|
318
|
+
::LibUI.table_model_row_changed(model, row) if model && row
|
319
|
+
notify_custom_listeners('on_changed', row, :changed, @cell_rows[row])
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
@last_last_cell_rows = array_deep_clone(@last_cell_rows)
|
324
|
+
@last_cell_rows = array_deep_clone(@cell_rows)
|
325
|
+
if !@applied_windows_fix_on_first_cell_rows_update && OS.windows?
|
326
|
+
@applied_windows_fix_on_first_cell_rows_update = true
|
327
|
+
apply_windows_fix
|
328
|
+
end
|
329
|
+
end
|
330
|
+
@cell_rows_observer_registration = @cell_rows_observer.observe(self, :cell_rows, recursive: true, ignore_frozen: true, attribute_writer_type: [:attribute=, :set_attribute])
|
331
|
+
end
|
332
|
+
|
333
|
+
def apply_windows_fix
|
334
|
+
Glimmer::LibUI.queue_main do
|
335
|
+
new_row = @columns&.select {|column| column.is_a?(Column)}&.map {|column| column.class.default_value}
|
336
|
+
if new_row
|
337
|
+
@cell_rows << new_row
|
338
|
+
@cell_rows.pop
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
319
342
|
end
|
320
343
|
end
|
321
344
|
end
|
@@ -46,7 +46,7 @@ module Glimmer
|
|
46
46
|
new_value = model_binding.evaluate_property
|
47
47
|
send("#{property}=", new_value) unless send(property) == new_value
|
48
48
|
end
|
49
|
-
observer_registration = model_attribute_observer.observe(model_binding)
|
49
|
+
observer_registration = model_attribute_observer.observe(model_binding, attribute_writer_type: [:attribute=, :set_attribute])
|
50
50
|
model_attribute_observer.call # initial update
|
51
51
|
data_binding_model_attribute_observer_registrations << observer_registration
|
52
52
|
observer_registration
|
@@ -25,13 +25,30 @@ module Glimmer
|
|
25
25
|
module LibUI
|
26
26
|
class Shape
|
27
27
|
class Bezier < Shape
|
28
|
-
parameters :c1_x, :c1_y, :c2_x, :c2_y, :end_x, :end_y
|
29
|
-
parameter_defaults 0, 0, 0, 0, 0, 0
|
28
|
+
parameters :x, :y, :c1_x, :c1_y, :c2_x, :c2_y, :end_x, :end_y
|
29
|
+
parameter_defaults nil, nil, 0, 0, 0, 0, 0, 0
|
30
|
+
|
31
|
+
def initialize(keyword, parent, args, &block)
|
32
|
+
args.prepend nil until args.size == 8
|
33
|
+
super(keyword, parent, args, &block)
|
34
|
+
end
|
30
35
|
|
31
36
|
def draw(area_draw_params)
|
32
|
-
|
37
|
+
if !parent.is_a?(Figure)
|
38
|
+
if include_start_point?
|
39
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, x, y)
|
40
|
+
else
|
41
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, 0, 0)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
::LibUI.draw_path_bezier_to(path_proxy.libui, c1_x, c1_y, c2_x, c2_y, end_x, end_y)
|
33
45
|
super
|
34
46
|
end
|
47
|
+
|
48
|
+
# Indicates if bezier is not part of a figure and yet it includes the start point in addition to other points
|
49
|
+
def include_start_point?
|
50
|
+
x && y
|
51
|
+
end
|
35
52
|
end
|
36
53
|
end
|
37
54
|
end
|
@@ -24,14 +24,34 @@ require 'glimmer/libui/shape'
|
|
24
24
|
module Glimmer
|
25
25
|
module LibUI
|
26
26
|
class Shape
|
27
|
+
# Line to use as part of a figure (when having 2 args)
|
28
|
+
# or independently (when having 4 args representing start point x/y and end point x/y)
|
27
29
|
class Line < Shape
|
28
|
-
parameters :x, :y
|
29
|
-
parameter_defaults 0, 0
|
30
|
+
parameters :x, :y, :end_x, :end_y
|
31
|
+
parameter_defaults 0, 0, nil, nil
|
30
32
|
|
31
33
|
def draw(area_draw_params)
|
32
|
-
|
34
|
+
if parent.is_a?(Figure)
|
35
|
+
::LibUI.draw_path_line_to(path_proxy.libui, x, y)
|
36
|
+
else
|
37
|
+
if include_start_point?
|
38
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, x, y)
|
39
|
+
::LibUI.draw_path_line_to(path_proxy.libui, end_x, end_y)
|
40
|
+
else
|
41
|
+
::LibUI.draw_path_new_figure(path_proxy.libui, 0, 0)
|
42
|
+
::LibUI.draw_path_line_to(path_proxy.libui, x, y)
|
43
|
+
end
|
44
|
+
end
|
33
45
|
super
|
34
46
|
end
|
47
|
+
|
48
|
+
# Indicates if line is not part of a figure and yet it includes the start point in addition to end point
|
49
|
+
def include_start_point?
|
50
|
+
# if the last 2 args are available, it means that the first 2 args represent the start point
|
51
|
+
# if line is part of a figure, then the last 2 args are ignored and it is never assumed to include
|
52
|
+
# start point
|
53
|
+
!parent.is_a?(Figure) && end_x && end_y
|
54
|
+
end
|
35
55
|
end
|
36
56
|
end
|
37
57
|
end
|
data/lib/glimmer-dsl-libui.rb
CHANGED
@@ -28,6 +28,7 @@ require 'glimmer'
|
|
28
28
|
# require 'super_module'
|
29
29
|
require 'color'
|
30
30
|
require 'os'
|
31
|
+
require 'equalizer'
|
31
32
|
require 'array_include_methods'
|
32
33
|
require 'facets/hash/stringify_keys'
|
33
34
|
require 'facets/string/underscore'
|
@@ -46,3 +47,8 @@ Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
|
|
46
47
|
end
|
47
48
|
|
48
49
|
::LibUI.init
|
50
|
+
# begin
|
51
|
+
# PutsDebuggerer.printer = lambda { |m| puts m; $stdout.flush}
|
52
|
+
# rescue
|
53
|
+
##### No Op if puts_debuggerer is not loaded
|
54
|
+
# end
|
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.
|
4
|
+
version: 0.4.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.5.
|
19
|
+
version: 2.5.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.5.
|
26
|
+
version: 2.5.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: os
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 1.4.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: equalizer
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.0.11
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.0.11
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
name: juwelier
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,7 +209,8 @@ description: Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development G
|
|
195
209
|
platform-independent native GUI that just works! Glimmer DSL for LibUI aims to provide
|
196
210
|
declarative DSL syntax that visually maps to GUI control hierarchy, convention over
|
197
211
|
configuration via smart defaults, automation of low-level details, requiring the
|
198
|
-
least amount of syntax possible to build GUI, and custom
|
212
|
+
least amount of syntax possible to build GUI, bidirectional data-binding, and custom
|
213
|
+
keyword support.
|
199
214
|
email: andy.am@gmail.com
|
200
215
|
executables:
|
201
216
|
- girb
|
@@ -211,6 +226,7 @@ files:
|
|
211
226
|
- VERSION
|
212
227
|
- bin/girb
|
213
228
|
- bin/girb_runner.rb
|
229
|
+
- examples/area_based_custom_controls.rb
|
214
230
|
- examples/area_gallery.rb
|
215
231
|
- examples/area_gallery2.rb
|
216
232
|
- examples/area_gallery3.rb
|
@@ -320,6 +336,7 @@ files:
|
|
320
336
|
- lib/glimmer/dsl/libui/listener_expression.rb
|
321
337
|
- lib/glimmer/dsl/libui/observe_expression.rb
|
322
338
|
- lib/glimmer/dsl/libui/open_file_expression.rb
|
339
|
+
- lib/glimmer/dsl/libui/operation_expression.rb
|
323
340
|
- lib/glimmer/dsl/libui/property_expression.rb
|
324
341
|
- lib/glimmer/dsl/libui/save_file_expression.rb
|
325
342
|
- lib/glimmer/dsl/libui/shape_expression.rb
|
@@ -434,7 +451,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
434
451
|
- !ruby/object:Gem::Version
|
435
452
|
version: '0'
|
436
453
|
requirements: []
|
437
|
-
rubygems_version: 3.
|
454
|
+
rubygems_version: 3.3.1
|
438
455
|
signing_key:
|
439
456
|
specification_version: 4
|
440
457
|
summary: Glimmer DSL for LibUI
|