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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.9
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 = "#{Etc.getpwuid.dir}/.girb_runner_exit"
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)
@@ -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
- fill r: 204, g: 102, b: 204
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
- path { # declarative stable path
44
- circle(200, 200, 90)
45
-
46
- fill r: 202, g: 102, b: 204, a: 0.5
47
- stroke r: 0, g: 0, b: 0, thickness: 2
48
- }
49
- path { # declarative stable path
50
- arc(400, 220, 180, 90, 90, false)
51
-
52
- fill r: 204, g: 102, b: 204, a: 0.5
53
- stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
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|
@@ -32,7 +32,8 @@ window('Area Gallery', 400, 400) {
32
32
  height 100
33
33
  }
34
34
 
35
- fill r: 204, g: 102, b: 204
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
- path { # declarative stable path
98
- circle {
99
- x_center 200
100
- y_center 200
101
- radius 90
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
- fill r: 202, g: 102, b: 204, a: 0.5
105
- stroke r: 0, g: 0, b: 0, thickness: 2
106
- }
107
- path { # declarative stable path
108
- arc {
109
- x_center 400
110
- y_center 220
111
- radius 180
112
- start_angle 90
113
- sweep 90
114
- is_negative false
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|
@@ -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
- fill r: 204, g: 102, b: 204
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
- path { # a dynamic path is added semi-declaratively inside on_draw block
45
- circle(200, 200, 90)
46
-
47
- fill r: 202, g: 102, b: 204, a: 0.5
48
- stroke r: 0, g: 0, b: 0, thickness: 2
49
- }
50
- path { # a dynamic path is added semi-declaratively inside on_draw block
51
- arc(400, 220, 180, 90, 90, false)
52
-
53
- fill r: 204, g: 102, b: 204, a: 0.5
54
- stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
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
 
@@ -33,7 +33,8 @@ window('Area Gallery', 400, 400) {
33
33
  height 100
34
34
  }
35
35
 
36
- fill r: 204, g: 102, b: 204
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
- 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
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
- fill r: 202, g: 102, b: 204, a: 0.5
106
- stroke r: 0, g: 0, b: 0, thickness: 2
107
- }
108
- path { # a dynamic path is added semi-declaratively inside on_draw block
109
- arc {
110
- x_center 400
111
- y_center 220
112
- radius 180
113
- start_angle 90
114
- sweep 90
115
- is_negative false
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
 
@@ -16,7 +16,6 @@ class BasicDrawText
16
16
  else
17
17
  color r: 0, g: 128, b: 0, a: 0.7
18
18
  end
19
-
20
19
  block.call + "\n\n"
21
20
  }
22
21
  end
@@ -12,7 +12,7 @@ data = [
12
12
  %w[cow moo delete]
13
13
  ]
14
14
 
15
- window('Animal sounds', 300, 200) {
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
  }
@@ -12,7 +12,7 @@ data = [
12
12
  ['cow', 'moo', true]
13
13
  ]
14
14
 
15
- window('Animal sounds', 300, 200) {
15
+ window('Animal sounds', 400, 200) {
16
16
  horizontal_box {
17
17
  table {
18
18
  text_column('Animal')
@@ -14,6 +14,7 @@ IMAGE_ROWS = []
14
14
  50.times do |i|
15
15
  url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
16
16
  puts "Processing Image: #{url}"
17
+ $stdout.flush # for Windows
17
18
  f = URI.open(url)
18
19
  canvas = ChunkyPNG::Canvas.from_io(f)
19
20
  f.close
@@ -14,6 +14,7 @@ IMAGE_ROWS = []
14
14
  5.times do |i|
15
15
  url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
16
16
  puts "Processing Image: #{url}"
17
+ $stdout.flush # for Windows
17
18
  f = URI.open(url)
18
19
  canvas = ChunkyPNG::Canvas.from_io(f)
19
20
  f.close
@@ -6,6 +6,8 @@ include Glimmer
6
6
 
7
7
  window('color button', 230) {
8
8
  color_button { |cb|
9
+ color :blue
10
+
9
11
  on_changed do
10
12
  rgba = cb.color
11
13
  p rgba
@@ -1,28 +1,29 @@
1
1
  require 'glimmer-dsl-libui'
2
2
 
3
- class ColorTheCircles
3
+ class ColorTheShapes
4
4
  include Glimmer
5
5
 
6
6
  WINDOW_WIDTH = 800
7
7
  WINDOW_HEIGHT = 600
8
- CIRCLE_MIN_RADIUS = 15
9
- CIRCLE_MAX_RADIUS = 50
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
- @circles_data = []
21
+ @shapes_data = []
21
22
  @score = 0
22
23
  @time_max = TIME_MAX_HARD
23
24
  @game_over = false
24
25
  register_observers
25
- setup_circle_factory
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 setup_circle_factory
45
+ def setup_shape_factory
45
46
  consumer = Proc.new do
46
47
  unless @game_over
47
- if @circles_data.empty?
48
- # start with 3 circles to make more challenging
49
- add_circle until @circles_data.size > 3
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
- add_circle
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 add_circle
61
- circle_x_center = rand * (WINDOW_WIDTH - MARGIN_WIDTH - CIRCLE_MAX_RADIUS) + CIRCLE_MAX_RADIUS
62
- circle_y_center = rand * (WINDOW_HEIGHT - MARGIN_HEIGHT - CIRCLE_MAX_RADIUS) + CIRCLE_MAX_RADIUS
63
- circle_radius = rand * (CIRCLE_MAX_RADIUS - CIRCLE_MIN_RADIUS) + CIRCLE_MIN_RADIUS
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
- @circles_data << {
66
- args: [circle_x_center, circle_y_center, circle_radius],
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
- @circles_data.clear
77
+ @shapes_data.clear
77
78
  @game_over = false
78
79
  end
79
80
 
80
- def color_circle(x, y)
81
- clicked_circle_data = @circles_data.find do |circle_data|
82
- circle_data[:fill].nil? && circle_data[:circle].include?(x, y)
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 clicked_circle_data
85
- clicked_circle_data[:fill] = clicked_circle_data[:stroke]
86
- push_colored_circle_behind_uncolored_circles(clicked_circle_data)
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 push_colored_circle_behind_uncolored_circles(colored_circle_data)
93
- removed_colored_circle_data = @circles_data.delete(colored_circle_data)
94
- last_colored_circle_data = @circles_data.select {|cd| cd[:fill]}.last
95
- last_colored_circle_data_index = @circles_data.index(last_colored_circle_data) || -1
96
- @circles_data.insert(last_colored_circle_data_index + 1, removed_colored_circle_data)
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 circles are added.\nIf it reaches -20, you lose!\n\nClick circles to color and score!\nOnce score reaches 0, you win!\n\nBeware of concealed light-colored circles!\nThey are revealed once darker circles intersect them.\n\nThere are four levels of difficulty.\nChange via difficulty menu if the game gets too tough.")
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 Circles', WINDOW_WIDTH, WINDOW_HEIGHT) {
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 circles are added. If it reaches -20, you lose!') {
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 circles to color and score! Once score reaches 0, you win!') {
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
- @circles_data.each do |circle_data|
201
+
202
+ @shapes_data.each do |shape_data|
202
203
  path {
203
- circle_data[:circle] = circle(*circle_data[:args])
204
-
205
- fill circle_data[:fill]
206
- stroke circle_data[: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
- color_circle(area_mouse_event[:x], area_mouse_event[:y])
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
- ColorTheCircles.new.launch
221
+ ColorTheShapes.new.launch
@@ -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
  }
@@ -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 Name') {
29
+ button('Display Info') {
30
+ stretchy false
31
+
22
32
  on_clicked do
23
- msg_box('Name', "#{@first_name_entry.text} #{@last_name_entry.text}")
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
  }