glimmer-dsl-libui 0.2.9 → 0.2.13
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 +42 -0
- data/README.md +599 -189
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/bin/girb_runner.rb +1 -1
- data/examples/area_gallery.rb +24 -14
- data/examples/area_gallery2.rb +37 -21
- data/examples/area_gallery3.rb +22 -12
- data/examples/area_gallery4.rb +37 -21
- data/examples/basic_draw_text2.rb +0 -1
- data/examples/basic_table_button.rb +2 -1
- data/examples/basic_table_checkbox.rb +1 -1
- data/examples/basic_table_image.rb +1 -0
- data/examples/basic_table_image_text.rb +1 -0
- data/examples/color_button.rb +2 -0
- data/examples/{color_the_circles.rb → color_the_shapes.rb} +45 -44
- data/examples/control_gallery.rb +6 -0
- data/examples/editable_table.rb +2 -0
- data/examples/form.rb +12 -2
- data/examples/meta_example.rb +34 -18
- data/examples/method_based_custom_keyword.rb +97 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/string_expression.rb +9 -2
- data/lib/glimmer/libui/attributed_string.rb +32 -12
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +31 -6
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +30 -10
- data/lib/glimmer/libui.rb +1 -1
- metadata +13 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.13
|
data/bin/girb
CHANGED
File without changes
|
data/bin/girb_runner.rb
CHANGED
@@ -27,7 +27,7 @@ require_relative '../lib/glimmer-dsl-libui'
|
|
27
27
|
|
28
28
|
include Glimmer
|
29
29
|
|
30
|
-
GIRB_RUNNER_EXIT_FILE = "#{
|
30
|
+
GIRB_RUNNER_EXIT_FILE = "#{Dir.home}/.girb_runner_exit"
|
31
31
|
FileUtils.rm_rf GIRB_RUNNER_EXIT_FILE
|
32
32
|
|
33
33
|
@exit_method = method(:exit)
|
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
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
unless OS.windows?
|
45
|
+
path { # declarative stable path
|
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
|
+
}
|
52
|
+
path { # declarative stable path
|
53
|
+
circle(200, 200, 90)
|
54
|
+
|
55
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
56
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
57
|
+
}
|
58
|
+
end
|
59
|
+
text(160, 40, 100) { # x, y, width
|
60
|
+
string('Area Gallery') {
|
61
|
+
font family: 'Times', size: 14
|
62
|
+
color :black
|
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,28 +95,43 @@ 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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
unless OS.windows?
|
99
|
+
path { # declarative stable path
|
100
|
+
arc {
|
101
|
+
x_center 400
|
102
|
+
y_center 220
|
103
|
+
radius 180
|
104
|
+
start_angle 90
|
105
|
+
sweep 90
|
106
|
+
is_negative false
|
107
|
+
}
|
108
|
+
|
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}]
|
111
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
102
112
|
}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
113
|
+
path { # declarative stable path
|
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
|
+
end
|
124
|
+
text {
|
125
|
+
x 160
|
126
|
+
y 40
|
127
|
+
width 100
|
128
|
+
|
129
|
+
string {
|
130
|
+
font family: 'Times', size: 14
|
131
|
+
color :black
|
132
|
+
|
133
|
+
'Area Gallery'
|
115
134
|
}
|
116
|
-
|
117
|
-
fill r: 204, g: 102, b: 204, a: 0.5
|
118
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
119
135
|
}
|
120
136
|
|
121
137
|
on_mouse_event do |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
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
45
|
+
unless OS.windows?
|
46
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
47
|
+
arc(400, 220, 180, 90, 90, false)
|
48
|
+
|
49
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
50
|
+
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}]
|
51
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
52
|
+
}
|
53
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
54
|
+
circle(200, 200, 90)
|
55
|
+
|
56
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
57
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
58
|
+
}
|
59
|
+
end
|
60
|
+
text(160, 40, 100) { # x, y, width
|
61
|
+
string('Area Gallery') {
|
62
|
+
font family: 'Times', size: 14
|
63
|
+
color :black
|
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,28 +96,43 @@ 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
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
99
|
+
unless OS.windows?
|
100
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
101
|
+
arc {
|
102
|
+
x_center 400
|
103
|
+
y_center 220
|
104
|
+
radius 180
|
105
|
+
start_angle 90
|
106
|
+
sweep 90
|
107
|
+
is_negative false
|
108
|
+
}
|
109
|
+
|
110
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
111
|
+
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}]
|
112
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
103
113
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
114
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
115
|
+
circle {
|
116
|
+
x_center 200
|
117
|
+
y_center 200
|
118
|
+
radius 90
|
119
|
+
}
|
120
|
+
|
121
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
122
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
123
|
+
}
|
124
|
+
end
|
125
|
+
text {
|
126
|
+
x 160
|
127
|
+
y 40
|
128
|
+
width 100
|
129
|
+
|
130
|
+
string {
|
131
|
+
font family: 'Times', size: 14
|
132
|
+
color :black
|
133
|
+
|
134
|
+
'Area Gallery'
|
116
135
|
}
|
117
|
-
|
118
|
-
fill r: 204, g: 102, b: 204, a: 0.5
|
119
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
120
136
|
}
|
121
137
|
end
|
122
138
|
|
@@ -12,7 +12,7 @@ data = [
|
|
12
12
|
%w[cow moo delete]
|
13
13
|
]
|
14
14
|
|
15
|
-
window('Animal sounds',
|
15
|
+
window('Animal sounds', 400, 200) {
|
16
16
|
horizontal_box {
|
17
17
|
table {
|
18
18
|
text_column('Animal')
|
@@ -27,6 +27,7 @@ window('Animal sounds', 300, 200) {
|
|
27
27
|
|
28
28
|
on_changed do |row, type, row_data|
|
29
29
|
puts "Row #{row} #{type}: #{row_data}"
|
30
|
+
$stdout.flush
|
30
31
|
end
|
31
32
|
}
|
32
33
|
}
|
data/examples/color_button.rb
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
require 'glimmer-dsl-libui'
|
2
2
|
|
3
|
-
class
|
3
|
+
class ColorTheShapes
|
4
4
|
include Glimmer
|
5
5
|
|
6
6
|
WINDOW_WIDTH = 800
|
7
7
|
WINDOW_HEIGHT = 600
|
8
|
-
|
9
|
-
|
8
|
+
SHAPE_MIN_SIZE = 15
|
9
|
+
SHAPE_MAX_SIZE = 100
|
10
10
|
MARGIN_WIDTH = 55
|
11
11
|
MARGIN_HEIGHT = 155
|
12
12
|
TIME_MAX_EASY = 4
|
13
13
|
TIME_MAX_MEDIUM = 3
|
14
14
|
TIME_MAX_HARD = 2
|
15
15
|
TIME_MAX_INSANE = 1
|
16
|
+
SHAPES = ['square'] + (OS.windows? ? [] : ['circle'])
|
16
17
|
|
17
18
|
attr_accessor :score
|
18
19
|
|
19
20
|
def initialize
|
20
|
-
@
|
21
|
+
@shapes_data = []
|
21
22
|
@score = 0
|
22
23
|
@time_max = TIME_MAX_HARD
|
23
24
|
@game_over = false
|
24
25
|
register_observers
|
25
|
-
|
26
|
+
setup_shape_factory
|
26
27
|
end
|
27
28
|
|
28
29
|
def register_observers
|
@@ -41,14 +42,14 @@ class ColorTheCircles
|
|
41
42
|
observer.observe(self, :score) # automatically enhances self to become Glimmer::DataBinding::ObservableModel and notify observer on score attribute changes
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
+
def setup_shape_factory
|
45
46
|
consumer = Proc.new do
|
46
47
|
unless @game_over
|
47
|
-
if @
|
48
|
-
# start with 3
|
49
|
-
|
48
|
+
if @shapes_data.empty?
|
49
|
+
# start with 3 shapes to make more challenging
|
50
|
+
add_shape until @shapes_data.size > 3
|
50
51
|
else
|
51
|
-
|
52
|
+
add_shape
|
52
53
|
end
|
53
54
|
end
|
54
55
|
delay = rand * @time_max
|
@@ -57,13 +58,13 @@ class ColorTheCircles
|
|
57
58
|
Glimmer::LibUI.queue_main(&consumer)
|
58
59
|
end
|
59
60
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
def add_shape
|
62
|
+
shape_x = rand * (WINDOW_WIDTH - MARGIN_WIDTH - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
63
|
+
shape_y = rand * (WINDOW_HEIGHT - MARGIN_HEIGHT - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
64
|
+
shape_size = rand * (SHAPE_MAX_SIZE - SHAPE_MIN_SIZE) + SHAPE_MIN_SIZE
|
64
65
|
stroke_color = Glimmer::LibUI.x11_colors.sample
|
65
|
-
@
|
66
|
-
args: [
|
66
|
+
@shapes_data << {
|
67
|
+
args: [shape_x, shape_y, shape_size],
|
67
68
|
fill: nil,
|
68
69
|
stroke: stroke_color
|
69
70
|
}
|
@@ -73,29 +74,29 @@ class ColorTheCircles
|
|
73
74
|
|
74
75
|
def restart_game
|
75
76
|
@score = 0 # update variable directly to avoid notifying observers
|
76
|
-
@
|
77
|
+
@shapes_data.clear
|
77
78
|
@game_over = false
|
78
79
|
end
|
79
80
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
81
|
+
def color_shape(x, y)
|
82
|
+
clicked_shape_data = @shapes_data.find do |shape_data|
|
83
|
+
shape_data[:fill].nil? && shape_data[:shape]&.include?(x, y)
|
83
84
|
end
|
84
|
-
if
|
85
|
-
|
86
|
-
|
85
|
+
if clicked_shape_data
|
86
|
+
clicked_shape_data[:fill] = clicked_shape_data[:stroke]
|
87
|
+
push_colored_shape_behind_uncolored_shapes(clicked_shape_data)
|
87
88
|
@area.queue_redraw_all
|
88
89
|
self.score += 1 # notifies score observers automatically of change
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
@
|
93
|
+
def push_colored_shape_behind_uncolored_shapes(colored_shape_data)
|
94
|
+
removed_colored_shape_data = @shapes_data.delete(colored_shape_data)
|
95
|
+
last_colored_shape_data = @shapes_data.select {|cd| cd[:fill]}.last
|
96
|
+
last_colored_shape_data_index = @shapes_data.index(last_colored_shape_data) || -1
|
97
|
+
@shapes_data.insert(last_colored_shape_data_index + 1, removed_colored_shape_data)
|
97
98
|
end
|
98
|
-
|
99
|
+
|
99
100
|
def launch
|
100
101
|
menu('Actions') {
|
101
102
|
menu_item('Restart') {
|
@@ -138,12 +139,12 @@ class ColorTheCircles
|
|
138
139
|
menu('Help') {
|
139
140
|
menu_item('Instructions') {
|
140
141
|
on_clicked do
|
141
|
-
msg_box('Instructions', "Score goes down as
|
142
|
+
msg_box('Instructions', "Score goes down as shapes are added.\nIf it reaches -20, you lose!\n\nClick shapes to color and score!\nOnce score reaches 0, you win!\n\nBeware of concealed light-colored shapes!\nThey are revealed once darker shapes intersect them.\n\nThere are four levels of difficulty.\nChange via difficulty menu if the game gets too tough.")
|
142
143
|
end
|
143
144
|
}
|
144
145
|
}
|
145
146
|
|
146
|
-
window('Color The
|
147
|
+
window('Color The Shapes', WINDOW_WIDTH, WINDOW_HEIGHT) {
|
147
148
|
margined true
|
148
149
|
|
149
150
|
grid {
|
@@ -157,13 +158,13 @@ class ColorTheCircles
|
|
157
158
|
end
|
158
159
|
}
|
159
160
|
|
160
|
-
label('Score goes down as
|
161
|
+
label('Score goes down as shapes are added. If it reaches -20, you lose!') {
|
161
162
|
left 0
|
162
163
|
top 1
|
163
164
|
halign :center
|
164
165
|
}
|
165
166
|
|
166
|
-
label('Click
|
167
|
+
label('Click shapes to color and score! Once score reaches 0, you win!') {
|
167
168
|
left 0
|
168
169
|
top 2
|
169
170
|
halign :center
|
@@ -190,26 +191,26 @@ class ColorTheCircles
|
|
190
191
|
vexpand true
|
191
192
|
halign :fill
|
192
193
|
valign :fill
|
193
|
-
|
194
|
+
|
194
195
|
on_draw do |area_draw_params|
|
195
196
|
path {
|
196
197
|
rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT)
|
197
|
-
|
198
|
+
|
198
199
|
fill :white
|
199
200
|
}
|
200
|
-
|
201
|
-
@
|
201
|
+
|
202
|
+
@shapes_data.each do |shape_data|
|
202
203
|
path {
|
203
|
-
|
204
|
-
|
205
|
-
fill
|
206
|
-
stroke
|
204
|
+
shape_data[:shape] = send(SHAPES.sample, *shape_data[:args])
|
205
|
+
|
206
|
+
fill shape_data[:fill]
|
207
|
+
stroke shape_data[:stroke]
|
207
208
|
}
|
208
209
|
end
|
209
210
|
end
|
210
|
-
|
211
|
+
|
211
212
|
on_mouse_down do |area_mouse_event|
|
212
|
-
|
213
|
+
color_shape(area_mouse_event[:x], area_mouse_event[:y])
|
213
214
|
end
|
214
215
|
}
|
215
216
|
}
|
@@ -217,4 +218,4 @@ class ColorTheCircles
|
|
217
218
|
end
|
218
219
|
end
|
219
220
|
|
220
|
-
|
221
|
+
ColorTheShapes.new.launch
|
data/examples/control_gallery.rb
CHANGED
@@ -9,6 +9,7 @@ menu('File') {
|
|
9
9
|
on_clicked do
|
10
10
|
file = open_file
|
11
11
|
puts file unless file.nil?
|
12
|
+
$stdout.flush # for Windows
|
12
13
|
end
|
13
14
|
}
|
14
15
|
|
@@ -16,6 +17,7 @@ menu('File') {
|
|
16
17
|
on_clicked do
|
17
18
|
file = save_file
|
18
19
|
puts file unless file.nil?
|
20
|
+
$stdout.flush # for Windows
|
19
21
|
end
|
20
22
|
}
|
21
23
|
|
@@ -98,6 +100,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
98
100
|
|
99
101
|
on_changed do |s|
|
100
102
|
puts "New Spinbox value: #{s.value}"
|
103
|
+
$stdout.flush # for Windows
|
101
104
|
end
|
102
105
|
}
|
103
106
|
|
@@ -107,6 +110,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
107
110
|
on_changed do |s|
|
108
111
|
v = s.value
|
109
112
|
puts "New Slider value: #{v}"
|
113
|
+
$stdout.flush # for Windows
|
110
114
|
@progress_bar.value = v
|
111
115
|
end
|
112
116
|
}
|
@@ -125,6 +129,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
125
129
|
|
126
130
|
on_selected do |c|
|
127
131
|
puts "New combobox selection: #{c.selected}"
|
132
|
+
$stdout.flush # for Windows
|
128
133
|
end
|
129
134
|
}
|
130
135
|
|
@@ -147,6 +152,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
|
147
152
|
|
148
153
|
on_changed do |e|
|
149
154
|
puts "Current textbox data: '#{e.text}'"
|
155
|
+
$stdout.flush # for Windows
|
150
156
|
end
|
151
157
|
}
|
152
158
|
}
|
data/examples/editable_table.rb
CHANGED
@@ -23,10 +23,12 @@ window('Editable animal sounds', 300, 200) {
|
|
23
23
|
|
24
24
|
on_changed do |row, type, row_data| # fires on all changes (even ones happening through data array)
|
25
25
|
puts "Row #{row} #{type}: #{row_data}"
|
26
|
+
$stdout.flush
|
26
27
|
end
|
27
28
|
|
28
29
|
on_edited do |row, row_data| # only fires on direct table editing
|
29
30
|
puts "Row #{row} edited: #{row_data}"
|
31
|
+
$stdout.flush
|
30
32
|
end
|
31
33
|
}
|
32
34
|
}
|
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
|
}
|