glimmer-dsl-libui 0.2.6 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +530 -92
- data/VERSION +1 -1
- data/examples/area_gallery.rb +18 -8
- data/examples/area_gallery2.rb +26 -12
- data/examples/area_gallery3.rb +16 -6
- data/examples/area_gallery4.rb +26 -12
- data/examples/basic_table_button.rb +4 -0
- data/examples/basic_table_color.rb +39 -0
- data/examples/basic_table_progress_bar.rb +1 -1
- data/examples/color_button.rb +2 -0
- data/examples/custom_draw_text.rb +1 -1
- data/examples/custom_draw_text2.rb +1 -1
- data/examples/editable_table.rb +8 -0
- data/examples/form.rb +12 -2
- data/examples/form_table.rb +4 -0
- data/examples/meta_example.rb +27 -17
- data/examples/method_based_custom_keyword.rb +87 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/icons/glimmer.png +0 -0
- data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +38 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +82 -0
- data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +50 -0
- data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +50 -0
- data/lib/glimmer/libui/control_proxy/editable_column.rb +1 -0
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +31 -6
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +53 -14
- data/lib/glimmer/libui/control_proxy/text_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/triple_column.rb +45 -0
- data/lib/glimmer/libui.rb +1 -1
- metadata +12 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.10
|
data/examples/area_gallery.rb
CHANGED
@@ -7,14 +7,15 @@ window('Area Gallery', 400, 400) {
|
|
7
7
|
path { # declarative stable path
|
8
8
|
square(0, 0, 100)
|
9
9
|
square(100, 100, 400)
|
10
|
-
|
10
|
+
|
11
11
|
fill r: 102, g: 102, b: 204
|
12
12
|
}
|
13
13
|
path { # declarative stable path
|
14
14
|
rectangle(0, 100, 100, 400)
|
15
15
|
rectangle(100, 0, 400, 100)
|
16
|
-
|
17
|
-
|
16
|
+
|
17
|
+
# linear gradient (has x0, y0, x1, y1, and stops)
|
18
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
18
19
|
}
|
19
20
|
path { # declarative stable path
|
20
21
|
figure(100, 100) {
|
@@ -40,17 +41,26 @@ window('Area Gallery', 400, 400) {
|
|
40
41
|
fill r: 202, g: 102, b: 204, a: 0.5
|
41
42
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
42
43
|
}
|
44
|
+
path { # declarative stable path
|
45
|
+
arc(400, 220, 180, 90, 90, false)
|
46
|
+
|
47
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
48
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
49
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
50
|
+
}
|
43
51
|
path { # declarative stable path
|
44
52
|
circle(200, 200, 90)
|
45
53
|
|
46
54
|
fill r: 202, g: 102, b: 204, a: 0.5
|
47
55
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
48
56
|
}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
57
|
+
text(160, 40, 100) { # x, y, width
|
58
|
+
string {
|
59
|
+
font family: 'Times', size: 14
|
60
|
+
color :black
|
61
|
+
|
62
|
+
'Area Gallery'
|
63
|
+
}
|
54
64
|
}
|
55
65
|
|
56
66
|
on_mouse_event do |area_mouse_event|
|
data/examples/area_gallery2.rb
CHANGED
@@ -32,7 +32,8 @@ window('Area Gallery', 400, 400) {
|
|
32
32
|
height 100
|
33
33
|
}
|
34
34
|
|
35
|
-
|
35
|
+
# linear gradient (has x0, y0, x1, y1, and stops)
|
36
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
36
37
|
}
|
37
38
|
path { # declarative stable path
|
38
39
|
figure {
|
@@ -94,16 +95,6 @@ window('Area Gallery', 400, 400) {
|
|
94
95
|
fill r: 202, g: 102, b: 204, a: 0.5
|
95
96
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
96
97
|
}
|
97
|
-
path { # declarative stable path
|
98
|
-
circle {
|
99
|
-
x_center 200
|
100
|
-
y_center 200
|
101
|
-
radius 90
|
102
|
-
}
|
103
|
-
|
104
|
-
fill r: 202, g: 102, b: 204, a: 0.5
|
105
|
-
stroke r: 0, g: 0, b: 0, thickness: 2
|
106
|
-
}
|
107
98
|
path { # declarative stable path
|
108
99
|
arc {
|
109
100
|
x_center 400
|
@@ -114,9 +105,32 @@ window('Area Gallery', 400, 400) {
|
|
114
105
|
is_negative false
|
115
106
|
}
|
116
107
|
|
117
|
-
|
108
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
109
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
118
110
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
119
111
|
}
|
112
|
+
path { # declarative stable path
|
113
|
+
circle {
|
114
|
+
x_center 200
|
115
|
+
y_center 200
|
116
|
+
radius 90
|
117
|
+
}
|
118
|
+
|
119
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
120
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
121
|
+
}
|
122
|
+
text {
|
123
|
+
x 160
|
124
|
+
y 40
|
125
|
+
width 100
|
126
|
+
|
127
|
+
string {
|
128
|
+
font family: 'Times', size: 14
|
129
|
+
color :black
|
130
|
+
|
131
|
+
'Area Gallery'
|
132
|
+
}
|
133
|
+
}
|
120
134
|
|
121
135
|
on_mouse_event do |area_mouse_event|
|
122
136
|
p area_mouse_event
|
data/examples/area_gallery3.rb
CHANGED
@@ -15,7 +15,8 @@ window('Area Gallery', 400, 400) {
|
|
15
15
|
rectangle(0, 100, 100, 400)
|
16
16
|
rectangle(100, 0, 400, 100)
|
17
17
|
|
18
|
-
|
18
|
+
# linear gradient (has x0, y0, x1, y1, and stops)
|
19
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
19
20
|
}
|
20
21
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
21
22
|
figure(100, 100) {
|
@@ -41,17 +42,26 @@ window('Area Gallery', 400, 400) {
|
|
41
42
|
fill r: 202, g: 102, b: 204, a: 0.5
|
42
43
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
43
44
|
}
|
45
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
46
|
+
arc(400, 220, 180, 90, 90, false)
|
47
|
+
|
48
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
49
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
50
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
51
|
+
}
|
44
52
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
45
53
|
circle(200, 200, 90)
|
46
54
|
|
47
55
|
fill r: 202, g: 102, b: 204, a: 0.5
|
48
56
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
49
57
|
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
text(160, 40, 100) { # x, y, width
|
59
|
+
string {
|
60
|
+
font family: 'Times', size: 14
|
61
|
+
color :black
|
62
|
+
|
63
|
+
'Area Gallery'
|
64
|
+
}
|
55
65
|
}
|
56
66
|
end
|
57
67
|
|
data/examples/area_gallery4.rb
CHANGED
@@ -33,7 +33,8 @@ window('Area Gallery', 400, 400) {
|
|
33
33
|
height 100
|
34
34
|
}
|
35
35
|
|
36
|
-
|
36
|
+
# linear gradient (has x0, y0, x1, y1, and stops)
|
37
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
37
38
|
}
|
38
39
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
39
40
|
figure {
|
@@ -95,16 +96,6 @@ window('Area Gallery', 400, 400) {
|
|
95
96
|
fill r: 202, g: 102, b: 204, a: 0.5
|
96
97
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
97
98
|
}
|
98
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
99
|
-
circle {
|
100
|
-
x_center 200
|
101
|
-
y_center 200
|
102
|
-
radius 90
|
103
|
-
}
|
104
|
-
|
105
|
-
fill r: 202, g: 102, b: 204, a: 0.5
|
106
|
-
stroke r: 0, g: 0, b: 0, thickness: 2
|
107
|
-
}
|
108
99
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
109
100
|
arc {
|
110
101
|
x_center 400
|
@@ -115,9 +106,32 @@ window('Area Gallery', 400, 400) {
|
|
115
106
|
is_negative false
|
116
107
|
}
|
117
108
|
|
118
|
-
|
109
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
110
|
+
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
119
111
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
120
112
|
}
|
113
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
114
|
+
circle {
|
115
|
+
x_center 200
|
116
|
+
y_center 200
|
117
|
+
radius 90
|
118
|
+
}
|
119
|
+
|
120
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
121
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
122
|
+
}
|
123
|
+
text {
|
124
|
+
x 160
|
125
|
+
y 40
|
126
|
+
width 100
|
127
|
+
|
128
|
+
string {
|
129
|
+
font family: 'Times', size: 14
|
130
|
+
color :black
|
131
|
+
|
132
|
+
'Area Gallery'
|
133
|
+
}
|
134
|
+
}
|
121
135
|
end
|
122
136
|
|
123
137
|
on_mouse_event do |area_mouse_event|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
require 'chunky_png'
|
5
|
+
|
6
|
+
include Glimmer
|
7
|
+
|
8
|
+
f = File.open(File.expand_path('../icons/glimmer.png', __dir__))
|
9
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
10
|
+
f.close
|
11
|
+
canvas.resample_nearest_neighbor!(24, 24)
|
12
|
+
data = canvas.to_rgba_stream
|
13
|
+
width = canvas.width
|
14
|
+
height = canvas.height
|
15
|
+
img = image {
|
16
|
+
image_part(data, width, height, width * 4)
|
17
|
+
}
|
18
|
+
|
19
|
+
data = [
|
20
|
+
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
21
|
+
[['dog', :yellow] , ['woof', {r: 240, g: 32, b: 32}] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], :skyblue],
|
22
|
+
[['chicken', :beige], ['cock-a-doodle-doo', :blue] , [false, 'mammal', :red] , [img, 'Glimmer', :beige], {r: 5, g: 120, b: 110}],
|
23
|
+
[['horse', :purple] , ['neigh', {r: 240, g: 32, b: 32}], [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], '13a1fb'],
|
24
|
+
[['cow', :gray] , ['moo', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :brown], 0x12ff02]
|
25
|
+
]
|
26
|
+
|
27
|
+
window('Animals', 500, 200) {
|
28
|
+
horizontal_box {
|
29
|
+
table {
|
30
|
+
text_color_column('Animal')
|
31
|
+
text_color_column('Sound')
|
32
|
+
checkbox_text_color_column('Description')
|
33
|
+
image_text_color_column('GUI')
|
34
|
+
background_color_column('Mammal')
|
35
|
+
|
36
|
+
cell_rows data
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}.show
|
@@ -26,7 +26,7 @@ window('Task Progress', 300, 200) {
|
|
26
26
|
|
27
27
|
on_clicked do
|
28
28
|
data.each_with_index do |row_data, row|
|
29
|
-
data[row] =
|
29
|
+
data[row][1] = 100 # automatically updates table due to implicit data-binding
|
30
30
|
end
|
31
31
|
end
|
32
32
|
}
|
data/examples/color_button.rb
CHANGED
@@ -69,7 +69,7 @@ class CustomDrawText
|
|
69
69
|
}
|
70
70
|
|
71
71
|
area {
|
72
|
-
text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
|
72
|
+
text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width] - 2*x)
|
73
73
|
# align :left # default alignment
|
74
74
|
|
75
75
|
@string = string {
|
@@ -76,7 +76,7 @@ class CustomDrawText
|
|
76
76
|
|
77
77
|
@area = area {
|
78
78
|
on_draw do |area_draw_params|
|
79
|
-
text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width])
|
79
|
+
text { # default arguments for x, y, and width are (0, 0, area_draw_params[:area_width] - 2*x)
|
80
80
|
# align :left # default alignment
|
81
81
|
|
82
82
|
string {
|
data/examples/editable_table.rb
CHANGED
@@ -20,6 +20,14 @@ window('Editable animal sounds', 300, 200) {
|
|
20
20
|
|
21
21
|
cell_rows data
|
22
22
|
editable true
|
23
|
+
|
24
|
+
on_changed do |row, type, row_data| # fires on all changes (even ones happening through data array)
|
25
|
+
puts "Row #{row} #{type}: #{row_data}"
|
26
|
+
end
|
27
|
+
|
28
|
+
on_edited do |row, row_data| # only fires on direct table editing
|
29
|
+
puts "Row #{row} edited: #{row_data}"
|
30
|
+
end
|
23
31
|
}
|
24
32
|
}
|
25
33
|
|
data/examples/form.rb
CHANGED
@@ -16,11 +16,21 @@ window('Form') {
|
|
16
16
|
@last_name_entry = entry {
|
17
17
|
label 'Last Name' # label property is available when control is nested under form
|
18
18
|
}
|
19
|
+
|
20
|
+
@phone_entry = entry {
|
21
|
+
label 'Phone' # label property is available when control is nested under form
|
22
|
+
}
|
23
|
+
|
24
|
+
@email_entry = entry {
|
25
|
+
label 'Email' # label property is available when control is nested under form
|
26
|
+
}
|
19
27
|
}
|
20
28
|
|
21
|
-
button('Display
|
29
|
+
button('Display Info') {
|
30
|
+
stretchy false
|
31
|
+
|
22
32
|
on_clicked do
|
23
|
-
msg_box('
|
33
|
+
msg_box('Info', "#{@first_name_entry.text} #{@last_name_entry.text} has phone #{@phone_entry.text} and email #{@email_entry.text}")
|
24
34
|
end
|
25
35
|
}
|
26
36
|
}
|
data/examples/form_table.rb
CHANGED
data/examples/meta_example.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'glimmer-dsl-libui'
|
4
2
|
require 'facets'
|
5
3
|
|
@@ -42,6 +40,18 @@ class MetaExample
|
|
42
40
|
examples[@selected_example_index]
|
43
41
|
end
|
44
42
|
|
43
|
+
def run_example(example)
|
44
|
+
command = "ruby -r #{glimmer_dsl_libui_file} #{example} 2>&1"
|
45
|
+
result = ''
|
46
|
+
IO.popen(command) do |f|
|
47
|
+
f.each_line do |line|
|
48
|
+
result << line
|
49
|
+
puts line
|
50
|
+
end
|
51
|
+
end
|
52
|
+
msg_box('Error Running Example', result) if result.downcase.include?('error')
|
53
|
+
end
|
54
|
+
|
45
55
|
def launch
|
46
56
|
window('Meta-Example', 700, 500) {
|
47
57
|
margined true
|
@@ -50,16 +60,16 @@ class MetaExample
|
|
50
60
|
vertical_box {
|
51
61
|
stretchy false
|
52
62
|
|
53
|
-
@
|
63
|
+
@example_radio_buttons = radio_buttons {
|
54
64
|
stretchy false
|
55
65
|
items examples_with_versions
|
56
66
|
selected @selected_example_index
|
57
67
|
|
58
68
|
on_selected do
|
59
|
-
@selected_example_index = @
|
69
|
+
@selected_example_index = @example_radio_buttons.selected
|
60
70
|
example = selected_example
|
61
|
-
@
|
62
|
-
@
|
71
|
+
@code_entry.text = File.read(file_path_for(example))
|
72
|
+
@version_spinbox.value = 1
|
63
73
|
end
|
64
74
|
}
|
65
75
|
|
@@ -68,17 +78,17 @@ class MetaExample
|
|
68
78
|
stretchy false
|
69
79
|
}
|
70
80
|
|
71
|
-
@
|
81
|
+
@version_spinbox = spinbox(1, 100) {
|
72
82
|
value 1
|
73
83
|
|
74
84
|
on_changed do
|
75
85
|
example = selected_example
|
76
|
-
if @
|
77
|
-
@
|
86
|
+
if @version_spinbox.value > version_count_for(example)
|
87
|
+
@version_spinbox.value -= 1
|
78
88
|
else
|
79
|
-
version_number = @
|
89
|
+
version_number = @version_spinbox.value == 1 ? '' : @version_spinbox.value
|
80
90
|
example = "#{selected_example}#{version_number}"
|
81
|
-
@
|
91
|
+
@code_entry.text = File.read(file_path_for(example))
|
82
92
|
end
|
83
93
|
end
|
84
94
|
}
|
@@ -91,24 +101,24 @@ class MetaExample
|
|
91
101
|
on_clicked do
|
92
102
|
begin
|
93
103
|
meta_example_file = File.join(Dir.home, '.meta_example.rb')
|
94
|
-
File.write(meta_example_file, @
|
95
|
-
|
96
|
-
msg_box('Error Running Example', result) if result.include?('error')
|
104
|
+
File.write(meta_example_file, @code_entry.text)
|
105
|
+
run_example(meta_example_file)
|
97
106
|
rescue => e
|
107
|
+
puts e.full_message
|
98
108
|
puts 'Unable to write code changes! Running original example...'
|
99
|
-
|
109
|
+
run_example(file_path_for(selected_example))
|
100
110
|
end
|
101
111
|
end
|
102
112
|
}
|
103
113
|
button('Reset') {
|
104
114
|
on_clicked do
|
105
|
-
@
|
115
|
+
@code_entry.text = File.read(file_path_for(selected_example))
|
106
116
|
end
|
107
117
|
}
|
108
118
|
}
|
109
119
|
}
|
110
120
|
|
111
|
-
@
|
121
|
+
@code_entry = non_wrapping_multiline_entry {
|
112
122
|
text File.read(file_path_for(selected_example))
|
113
123
|
}
|
114
124
|
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'glimmer-dsl-libui'
|
2
|
+
require 'facets'
|
3
|
+
|
4
|
+
include Glimmer
|
5
|
+
|
6
|
+
Address = Struct.new(:street, :p_o_box, :city, :state, :zip_code)
|
7
|
+
|
8
|
+
def field(model, property)
|
9
|
+
property = property.to_s
|
10
|
+
entry { |e|
|
11
|
+
label property.underscore.split('_').map(&:capitalize).join(' ')
|
12
|
+
text model.send(property).to_s
|
13
|
+
|
14
|
+
on_changed do
|
15
|
+
model.send("#{property}=", e.text)
|
16
|
+
end
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def address_form(address)
|
21
|
+
form {
|
22
|
+
field(address, :street)
|
23
|
+
field(address, :p_o_box)
|
24
|
+
field(address, :city)
|
25
|
+
field(address, :state)
|
26
|
+
field(address, :zip_code)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def label_pair(model, attribute, value)
|
31
|
+
name_label = nil
|
32
|
+
value_label = nil
|
33
|
+
horizontal_box {
|
34
|
+
name_label = label(attribute.to_s.underscore.split('_').map(&:capitalize).join(' '))
|
35
|
+
value_label = label(value.to_s)
|
36
|
+
}
|
37
|
+
Glimmer::DataBinding::Observer.proc do
|
38
|
+
value_label.text = model.send(attribute)
|
39
|
+
end.observe(model, attribute)
|
40
|
+
end
|
41
|
+
|
42
|
+
def address(address)
|
43
|
+
vertical_box {
|
44
|
+
address.each_pair do |attribute, value|
|
45
|
+
label_pair(address, attribute, value)
|
46
|
+
end
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
address1 = Address.new('123 Main St', '23923', 'Denver', 'Colorado', '80014')
|
51
|
+
address2 = Address.new('2038 Park Ave', '83272', 'Boston', 'Massachusetts', '02101')
|
52
|
+
|
53
|
+
window('Method-Based Custom Keyword') {
|
54
|
+
margined true
|
55
|
+
|
56
|
+
horizontal_box {
|
57
|
+
vertical_box {
|
58
|
+
label('Address 1') {
|
59
|
+
stretchy false
|
60
|
+
}
|
61
|
+
address_form(address1)
|
62
|
+
horizontal_separator {
|
63
|
+
stretchy false
|
64
|
+
}
|
65
|
+
label('Address 1 (Saved)') {
|
66
|
+
stretchy false
|
67
|
+
}
|
68
|
+
address(address1)
|
69
|
+
}
|
70
|
+
vertical_separator {
|
71
|
+
stretchy false
|
72
|
+
}
|
73
|
+
vertical_box {
|
74
|
+
label('Address 2') {
|
75
|
+
stretchy false
|
76
|
+
}
|
77
|
+
address_form(address2)
|
78
|
+
horizontal_separator {
|
79
|
+
stretchy false
|
80
|
+
}
|
81
|
+
label('Address 2 (Saved)') {
|
82
|
+
stretchy false
|
83
|
+
}
|
84
|
+
address(address2)
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}.show
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/icons/glimmer.png
ADDED
Binary file
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
require 'glimmer/libui/control_proxy/column'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module LibUI
|
27
|
+
class ControlProxy
|
28
|
+
module Column
|
29
|
+
# Proxy for LibUI background color column objects
|
30
|
+
#
|
31
|
+
# Follows the Proxy Design Pattern
|
32
|
+
class BackgroundColorColumnProxy < ControlProxy
|
33
|
+
include Column
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
require 'glimmer/libui/control_proxy/column'
|
24
|
+
require 'glimmer/libui/control_proxy/triple_column'
|
25
|
+
require 'glimmer/libui/control_proxy/editable_column'
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module LibUI
|
29
|
+
class ControlProxy
|
30
|
+
module Column
|
31
|
+
# Proxy for LibUI checkbox text color column objects
|
32
|
+
#
|
33
|
+
# Follows the Proxy Design Pattern
|
34
|
+
class CheckboxTextColorColumnProxy < ControlProxy
|
35
|
+
include Column
|
36
|
+
include TripleColumn
|
37
|
+
include EditableColumn
|
38
|
+
|
39
|
+
def editable_checkbox(value = nil)
|
40
|
+
if value.nil?
|
41
|
+
@editable_checkbox = false if @editable_checkbox.nil?
|
42
|
+
@editable_checkbox
|
43
|
+
else
|
44
|
+
@editable_checkbox = !!value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
alias editable_checkbox= editable_checkbox
|
48
|
+
alias set_editable_checkbox editable_checkbox
|
49
|
+
alias editable_checkbox? editable_checkbox
|
50
|
+
|
51
|
+
def editable_text(value = nil)
|
52
|
+
if value.nil?
|
53
|
+
@editable_text = false if @editable_text.nil?
|
54
|
+
@editable_text
|
55
|
+
else
|
56
|
+
@editable_text = !!value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
alias editable_text= editable_text
|
60
|
+
alias set_editable_text editable_text
|
61
|
+
alias editable_text? editable_text
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def build_control
|
66
|
+
table_text_column_optional_params = ::LibUI::FFI::TableTextColumnOptionalParams.malloc
|
67
|
+
table_text_column_optional_params.ColorModelColumn = third_column_index
|
68
|
+
@parent_proxy.append_checkbox_text_column(name, column_index, editable_checkbox_value, second_column_index, editable_text_value, table_text_column_optional_params)
|
69
|
+
end
|
70
|
+
|
71
|
+
def editable_checkbox_value
|
72
|
+
(@parent_proxy.editable? || editable? || editable_checkbox?) ? -2 : -1
|
73
|
+
end
|
74
|
+
|
75
|
+
def editable_text_value
|
76
|
+
(@parent_proxy.editable? || editable? || editable_text?) ? -2 : -1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|