glimmer-dsl-libui 0.5.16 → 0.5.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +48 -9005
- data/VERSION +1 -1
- data/docs/examples/GLIMMER-DSL-LIBUI-ADVANCED-EXAMPLES.md +6265 -0
- data/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md +2604 -0
- data/examples/paginated_refined_table.rb +11 -136
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/custom_control/refined_table.rb +73 -34
- data/lib/glimmer/libui/custom_window.rb +11 -2
- metadata +4 -2
@@ -6,148 +6,21 @@ class PaginatedRefinedTable
|
|
6
6
|
include Glimmer::LibUI::Application
|
7
7
|
|
8
8
|
NAMES_FIRST = %w[
|
9
|
-
Liam
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Elijah
|
16
|
-
Lucas
|
17
|
-
Mason
|
18
|
-
Logan
|
19
|
-
Alexander
|
20
|
-
Ethan
|
21
|
-
Jacob
|
22
|
-
Michael
|
23
|
-
Daniel
|
24
|
-
Henry
|
25
|
-
Jackson
|
26
|
-
Sebastian
|
27
|
-
Aiden
|
28
|
-
Matthew
|
29
|
-
Samuel
|
30
|
-
David
|
31
|
-
Joseph
|
32
|
-
Carter
|
33
|
-
Owen
|
34
|
-
Wyatt
|
35
|
-
John
|
36
|
-
Jack
|
37
|
-
Luke
|
38
|
-
Jayden
|
39
|
-
Dylan
|
40
|
-
Grayson
|
41
|
-
Levi
|
42
|
-
Isaac
|
43
|
-
Gabriel
|
44
|
-
Julian
|
45
|
-
Mateo
|
46
|
-
Anthony
|
47
|
-
Jaxon
|
48
|
-
Lincoln
|
49
|
-
Joshua
|
50
|
-
Christopher
|
51
|
-
Andrew
|
52
|
-
Theodore
|
53
|
-
Caleb
|
54
|
-
Ryan
|
55
|
-
Asher
|
56
|
-
Nathan
|
57
|
-
Thomas
|
58
|
-
Leo
|
59
|
-
Isaiah
|
60
|
-
Charles
|
61
|
-
Josiah
|
62
|
-
Hudson
|
63
|
-
Christian
|
64
|
-
Hunter
|
65
|
-
Connor
|
66
|
-
Eli
|
67
|
-
Ezra
|
68
|
-
Aaron
|
69
|
-
Landon
|
70
|
-
Adrian
|
71
|
-
Jonathan
|
72
|
-
Nolan
|
73
|
-
Jeremiah
|
74
|
-
Easton
|
75
|
-
Elias
|
76
|
-
Colton
|
77
|
-
Cameron
|
78
|
-
Carson
|
79
|
-
Robert
|
80
|
-
Angel
|
81
|
-
Maverick
|
82
|
-
Nicholas
|
83
|
-
Dominic
|
84
|
-
Jaxson
|
85
|
-
Greyson
|
86
|
-
Adam
|
87
|
-
Ian
|
88
|
-
Austin
|
89
|
-
Santiago
|
90
|
-
Jordan
|
91
|
-
Cooper
|
92
|
-
Brayden
|
93
|
-
Roman
|
94
|
-
Evan
|
95
|
-
Ezekiel
|
96
|
-
Xaviar
|
97
|
-
Jose
|
98
|
-
Jace
|
99
|
-
Jameson
|
100
|
-
Leonardo
|
101
|
-
Axel
|
102
|
-
Everett
|
103
|
-
Kayden
|
104
|
-
Miles
|
105
|
-
Sawyer
|
106
|
-
Jason
|
107
|
-
Emma
|
108
|
-
Olivia
|
109
|
-
Bartholomew
|
110
|
-
Corey
|
111
|
-
Danielle
|
112
|
-
Eva
|
113
|
-
Felicity
|
9
|
+
Liam Noah William James Oliver Benjamin Elijah Lucas Mason Logan Alexander Ethan Jacob Michael Daniel Henry Jackson Sebastian
|
10
|
+
Aiden Matthew Samuel David Joseph Carter Owen Wyatt John Jack Luke Jayden Dylan Grayson Levi Isaac Gabriel Julian Mateo
|
11
|
+
Anthony Jaxon Lincoln Joshua Christopher Andrew Theodore Caleb Ryan Asher Nathan Thomas Leo Isaiah Charles Josiah Hudson
|
12
|
+
Christian Hunter Connor Eli Ezra Aaron Landon Adrian Jonathan Nolan Jeremiah Easton Elias Colton Cameron Carson Robert Angel
|
13
|
+
Maverick Nicholas Dominic Jaxson Greyson Adam Ian Austin Santiago Jordan Cooper Brayden Roman Evan Ezekiel Xaviar Jose Jace
|
14
|
+
Jameson Leonardo Axel Everett Kayden Miles Sawyer Jason Emma Olivia Bartholomew Corey Danielle Eva Felicity
|
114
15
|
]
|
115
16
|
|
116
17
|
NAMES_LAST = %w[
|
117
|
-
Smith
|
118
|
-
Johnson
|
119
|
-
Williams
|
120
|
-
Brown
|
121
|
-
Jones
|
122
|
-
Miller
|
123
|
-
Davis
|
124
|
-
Wilson
|
125
|
-
Anderson
|
126
|
-
Taylor
|
127
|
-
George
|
128
|
-
Harrington
|
129
|
-
Iverson
|
130
|
-
Jackson
|
131
|
-
Korby
|
132
|
-
Levinson
|
18
|
+
Smith Johnson Williams Brown Jones Miller Davis Wilson Anderson Taylor George Harrington Iverson Jackson Korby Levinson
|
133
19
|
]
|
134
20
|
|
135
21
|
CITIES = [
|
136
|
-
'Bellesville',
|
137
|
-
'
|
138
|
-
'Steepleton',
|
139
|
-
'Deerenstein',
|
140
|
-
'Schwartz',
|
141
|
-
'Hollandia',
|
142
|
-
'Saint Pete',
|
143
|
-
'Grandville',
|
144
|
-
'London',
|
145
|
-
'Berlin',
|
146
|
-
'Elktown',
|
147
|
-
'Paris',
|
148
|
-
'Garrison',
|
149
|
-
'Muncy',
|
150
|
-
'St Louis',
|
22
|
+
'Bellesville', 'Lombardia', 'Steepleton', 'Deerenstein', 'Schwartz', 'Hollandia', 'Saint Pete', 'Grandville', 'London',
|
23
|
+
'Berlin', 'Elktown', 'Paris', 'Garrison', 'Muncy', 'St Louis',
|
151
24
|
]
|
152
25
|
|
153
26
|
STATES = [ 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA',
|
@@ -233,6 +106,8 @@ class PaginatedRefinedTable
|
|
233
106
|
},
|
234
107
|
table_editable: true,
|
235
108
|
per_page: 20,
|
109
|
+
# page: 1, # initial page is 1
|
110
|
+
# visible_page_count: true, # page count can be hidden if preferred
|
236
111
|
)
|
237
112
|
}
|
238
113
|
}
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -6,24 +6,36 @@ class RefinedTable
|
|
6
6
|
option :table_editable, default: false
|
7
7
|
option :per_page, default: 10
|
8
8
|
option :page, default: 1
|
9
|
+
option :visible_page_count, default: false
|
10
|
+
option :filter_query, default: ''
|
9
11
|
|
10
|
-
attr_accessor :filtered_model_array
|
12
|
+
attr_accessor :filtered_model_array # filtered model array (intermediary, non-paginated)
|
13
|
+
attr_accessor :refined_model_array # paginated filtered model array
|
14
|
+
attr_reader :table_proxy
|
11
15
|
|
12
16
|
before_body do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
init_model_array
|
18
|
+
end
|
19
|
+
|
20
|
+
after_body do
|
21
|
+
filter_model_array
|
22
|
+
|
23
|
+
observe(self, :model_array) do
|
24
|
+
init_model_array
|
25
|
+
end
|
26
|
+
|
27
|
+
observe(self, :filter_query) do
|
28
|
+
filter_model_array
|
29
|
+
end
|
18
30
|
end
|
19
31
|
|
20
32
|
body {
|
21
33
|
vertical_box {
|
22
34
|
table_filter
|
23
35
|
|
24
|
-
table_paginator
|
36
|
+
table_paginator if page_count > 1
|
25
37
|
|
26
|
-
@
|
38
|
+
@table_proxy = table {
|
27
39
|
table_columns.each do |column_name, column_details|
|
28
40
|
editable_value = on_clicked_value = nil
|
29
41
|
if column_details.is_a?(Symbol) || column_details.is_a?(String)
|
@@ -41,7 +53,7 @@ class RefinedTable
|
|
41
53
|
end
|
42
54
|
|
43
55
|
editable table_editable
|
44
|
-
cell_rows <=> [self, :
|
56
|
+
cell_rows <=> [self, :refined_model_array]
|
45
57
|
}
|
46
58
|
}
|
47
59
|
}
|
@@ -49,33 +61,17 @@ class RefinedTable
|
|
49
61
|
def table_filter
|
50
62
|
search_entry {
|
51
63
|
stretchy false
|
52
|
-
text <=> [self, :filter_query
|
53
|
-
before_write: ->(new_filter_query) {
|
54
|
-
if new_filter_query != filter_query
|
55
|
-
if !@filtered_model_array_stack.key?(new_filter_query)
|
56
|
-
@filtered_model_array_stack[new_filter_query] = model_array.dup.filter do |model|
|
57
|
-
@table.expand([model])[0].any? do |attribute_value|
|
58
|
-
attribute_value.to_s.downcase.include?(new_filter_query.downcase)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
@filtered_model_array = @filtered_model_array_stack[new_filter_query]
|
63
|
-
if new_filter_query.size > filter_query.size
|
64
|
-
@filter_query_page_stack[filter_query] = page
|
65
|
-
end
|
66
|
-
self.page = @filter_query_page_stack[new_filter_query] || correct_page(page)
|
67
|
-
paginate_model_array
|
68
|
-
end
|
69
|
-
}
|
70
|
-
]
|
64
|
+
text <=> [self, :filter_query]
|
71
65
|
}
|
72
66
|
end
|
73
67
|
|
74
68
|
def table_paginator
|
75
69
|
horizontal_box {
|
76
70
|
stretchy false
|
77
|
-
|
71
|
+
|
78
72
|
button('<<') {
|
73
|
+
enabled <= [self, :page, on_read: ->(val) {val > 1}]
|
74
|
+
|
79
75
|
on_clicked do
|
80
76
|
unless self.page == 0
|
81
77
|
self.page = 1
|
@@ -83,7 +79,10 @@ class RefinedTable
|
|
83
79
|
end
|
84
80
|
end
|
85
81
|
}
|
82
|
+
|
86
83
|
button('<') {
|
84
|
+
enabled <= [self, :page, on_read: ->(val) {val > 1}]
|
85
|
+
|
87
86
|
on_clicked do
|
88
87
|
unless self.page == 0
|
89
88
|
self.page = [page - 1, 1].max
|
@@ -91,6 +90,7 @@ class RefinedTable
|
|
91
90
|
end
|
92
91
|
end
|
93
92
|
}
|
93
|
+
|
94
94
|
entry {
|
95
95
|
text <=> [self, :page,
|
96
96
|
on_read: :to_s,
|
@@ -98,7 +98,16 @@ class RefinedTable
|
|
98
98
|
after_write: ->(val) { paginate_model_array },
|
99
99
|
]
|
100
100
|
}
|
101
|
+
|
102
|
+
if visible_page_count
|
103
|
+
label {
|
104
|
+
text <= [self, :refined_model_array, on_read: ->(val) {"of #{page_count} pages"}]
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
101
108
|
button('>') {
|
109
|
+
enabled <= [self, :page, on_read: ->(val) {val < page_count}]
|
110
|
+
|
102
111
|
on_clicked do
|
103
112
|
unless self.page == 0
|
104
113
|
self.page = [page + 1, page_count].min
|
@@ -106,7 +115,10 @@ class RefinedTable
|
|
106
115
|
end
|
107
116
|
end
|
108
117
|
}
|
118
|
+
|
109
119
|
button('>>') {
|
120
|
+
enabled <= [self, :page, on_read: ->(val) {val < page_count}]
|
121
|
+
|
110
122
|
on_clicked do
|
111
123
|
unless self.page == 0
|
112
124
|
self.page = page_count
|
@@ -117,8 +129,35 @@ class RefinedTable
|
|
117
129
|
}
|
118
130
|
end
|
119
131
|
|
132
|
+
def init_model_array
|
133
|
+
@last_filter_query = nil
|
134
|
+
@filter_query_page_stack = {}
|
135
|
+
@filtered_model_array = model_array.dup
|
136
|
+
@filtered_model_array_stack = {'' => @filtered_model_array}
|
137
|
+
self.page = correct_page(page)
|
138
|
+
filter_model_array if @table_proxy
|
139
|
+
end
|
140
|
+
|
141
|
+
def filter_model_array
|
142
|
+
return unless (@last_filter_query.nil? || filter_query != @last_filter_query)
|
143
|
+
if !@filtered_model_array_stack.key?(filter_query)
|
144
|
+
@filtered_model_array_stack[filter_query] = model_array.dup.filter do |model|
|
145
|
+
@table_proxy.expand([model])[0].any? do |attribute_value|
|
146
|
+
attribute_value.to_s.downcase.include?(filter_query.downcase)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
@filtered_model_array = @filtered_model_array_stack[filter_query]
|
151
|
+
if @last_filter_query.nil? || filter_query.size > @last_filter_query.size
|
152
|
+
@filter_query_page_stack[filter_query] = correct_page(page)
|
153
|
+
end
|
154
|
+
self.page = @filter_query_page_stack[filter_query] || correct_page(page)
|
155
|
+
paginate_model_array
|
156
|
+
@last_filter_query = filter_query
|
157
|
+
end
|
158
|
+
|
120
159
|
def paginate_model_array
|
121
|
-
self.
|
160
|
+
self.refined_model_array = filtered_model_array[index, limit]
|
122
161
|
end
|
123
162
|
|
124
163
|
def index
|
@@ -137,15 +176,15 @@ class RefinedTable
|
|
137
176
|
[[page, 1].max, page_count].min
|
138
177
|
end
|
139
178
|
|
140
|
-
# Ensure proxying properties to @
|
179
|
+
# Ensure proxying properties to @table_proxy if body_root (vertical_box) doesn't support them
|
141
180
|
|
142
181
|
def respond_to?(method_name, *args, &block)
|
143
|
-
super || @
|
182
|
+
super || @table_proxy&.respond_to?(method_name, *args, &block)
|
144
183
|
end
|
145
184
|
|
146
185
|
def method_missing(method_name, *args, &block)
|
147
|
-
if @
|
148
|
-
@
|
186
|
+
if @table_proxy&.respond_to?(method_name, *args, &block)
|
187
|
+
@table_proxy&.send(method_name, *args, &block)
|
149
188
|
else
|
150
189
|
super
|
151
190
|
end
|
@@ -31,8 +31,17 @@ module Glimmer
|
|
31
31
|
|
32
32
|
class << self
|
33
33
|
def launch(*args, &content)
|
34
|
-
|
35
|
-
|
34
|
+
@@launched_custom_window = send(keyword, *args, &content)
|
35
|
+
@@launched_custom_window.show
|
36
|
+
@@launched_custom_window
|
37
|
+
end
|
38
|
+
|
39
|
+
def launched_custom_window
|
40
|
+
@@launched_custom_window if defined?(@@launched_custom_window)
|
41
|
+
end
|
42
|
+
|
43
|
+
def launched_application
|
44
|
+
launched_custom_window
|
36
45
|
end
|
37
46
|
end
|
38
47
|
|
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.5.
|
4
|
+
version: 0.5.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -275,6 +275,8 @@ files:
|
|
275
275
|
- VERSION
|
276
276
|
- bin/girb
|
277
277
|
- bin/girb_runner.rb
|
278
|
+
- docs/examples/GLIMMER-DSL-LIBUI-ADVANCED-EXAMPLES.md
|
279
|
+
- docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md
|
278
280
|
- examples/area_based_custom_controls.rb
|
279
281
|
- examples/area_gallery.rb
|
280
282
|
- examples/area_gallery2.rb
|