rubygoo 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/Manifest.txt +1 -2
- data/README.txt +87 -87
- data/Rakefile +4 -4
- data/TODO +5 -3
- data/lib/rubygoo/app.rb +30 -15
- data/lib/rubygoo/button.rb +15 -1
- data/lib/rubygoo/check_box.rb +30 -1
- data/lib/rubygoo/container.rb +32 -27
- data/lib/rubygoo/css_colors.rb +2 -1
- data/lib/rubygoo/dialog.rb +7 -5
- data/lib/rubygoo/goo_color.rb +8 -5
- data/lib/rubygoo/goo_event.rb +5 -1
- data/lib/rubygoo/icon.rb +26 -0
- data/lib/rubygoo/label.rb +6 -3
- data/lib/rubygoo/radio_button.rb +4 -0
- data/lib/rubygoo/radio_group.rb +3 -8
- data/lib/rubygoo/tab_group.rb +4 -4
- data/lib/rubygoo/widget.rb +221 -84
- data/lib/rubygoo.rb +1 -0
- data/samples/create_gui.rb +29 -6
- data/samples/gosu_app.rb +1 -0
- data/samples/rubygame_app.rb +2 -1
- data/themes/default/config.yml +21 -15
- metadata +5 -6
- data/docs/.DS_Store +0 -0
- data/docs/ui/.DS_Store +0 -0
data/lib/rubygoo/goo_event.rb
CHANGED
@@ -2,12 +2,16 @@ module Rubygoo
|
|
2
2
|
# all events in the system are converted to these for internal use by our
|
3
3
|
# adapter
|
4
4
|
class GooEvent
|
5
|
-
attr_accessor :event_type, :data
|
5
|
+
attr_accessor :event_type, :data, :handled
|
6
6
|
|
7
7
|
def initialize(event_type, event_data = nil)
|
8
8
|
@event_type = event_type
|
9
9
|
@data = event_data
|
10
10
|
end
|
11
11
|
|
12
|
+
def handled?()
|
13
|
+
@handled
|
14
|
+
end
|
15
|
+
|
12
16
|
end
|
13
17
|
end
|
data/lib/rubygoo/icon.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Rubygoo
|
2
|
+
# Icon is basically a place holder for images
|
3
|
+
class Icon < Widget
|
4
|
+
def initialize(opts={})
|
5
|
+
@icon = opts[:icon]
|
6
|
+
super opts
|
7
|
+
end
|
8
|
+
|
9
|
+
def added()
|
10
|
+
update_rect
|
11
|
+
end
|
12
|
+
|
13
|
+
def draw(adapter)
|
14
|
+
x1 = @rect[0]
|
15
|
+
y1 = @rect[1]
|
16
|
+
x2 = @rect[2] + x1
|
17
|
+
y2 = @rect[3] + y1
|
18
|
+
|
19
|
+
# TODO center icon
|
20
|
+
ix = x1#+((x2-x1)-@icon.w)
|
21
|
+
iy = y1#+((y2-y1)-@icon.h)
|
22
|
+
adapter.draw_image @icon, ix+@x_pad,iy+@y_pad
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/lib/rubygoo/label.rb
CHANGED
@@ -2,18 +2,19 @@ require 'publisher'
|
|
2
2
|
module Rubygoo
|
3
3
|
class Label < Widget
|
4
4
|
def initialize(text, opts={})
|
5
|
+
@font_size = opts[:font_size]
|
5
6
|
super opts
|
6
7
|
@text = text
|
7
8
|
end
|
8
9
|
|
9
10
|
def added()
|
10
11
|
font = theme_property :font
|
11
|
-
@font_size
|
12
|
+
@font_size ||= theme_property :font_size
|
12
13
|
@color = theme_property :color
|
13
14
|
@bg_color = theme_property :bg_color
|
14
15
|
@focus_color = theme_property :focus_color
|
15
16
|
@border_color = theme_property :border_color
|
16
|
-
@font_file
|
17
|
+
@font_file ||= File.join(@app.theme_dir,font)
|
17
18
|
|
18
19
|
set_text @text
|
19
20
|
end
|
@@ -21,7 +22,9 @@ module Rubygoo
|
|
21
22
|
def set_text(text)
|
22
23
|
@text = text
|
23
24
|
@rendered_text = @app.renderer.render_text @text, @font_file, @font_size, @color
|
24
|
-
@
|
25
|
+
@w = @rendered_text.width
|
26
|
+
@h = @rendered_text.height
|
27
|
+
update_rect
|
25
28
|
end
|
26
29
|
|
27
30
|
def draw(adapter)
|
data/lib/rubygoo/radio_button.rb
CHANGED
@@ -20,6 +20,10 @@ module Rubygoo
|
|
20
20
|
adapter.draw_circle_filled @rect.centerx, @rect.centery, radius-@x_pad, @checked_color
|
21
21
|
end
|
22
22
|
|
23
|
+
if mouse_over? and @hover_color
|
24
|
+
adapter.draw_circle_filled @rect.centerx, @rect.centery, radius-@x_pad, @hover_color
|
25
|
+
end
|
26
|
+
|
23
27
|
if @border_color
|
24
28
|
adapter.draw_circle @rect.centerx, @rect.centery, radius, @border_color
|
25
29
|
end
|
data/lib/rubygoo/radio_group.rb
CHANGED
@@ -4,7 +4,6 @@ module Rubygoo
|
|
4
4
|
class RadioGroup < Container
|
5
5
|
|
6
6
|
def initialize(opts={})
|
7
|
-
# TODO add label, border
|
8
7
|
super opts
|
9
8
|
end
|
10
9
|
|
@@ -24,13 +23,9 @@ module Rubygoo
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def update_group_selection(selected_widget)
|
27
|
-
@widgets.each do |w|
|
28
|
-
|
29
|
-
|
30
|
-
unless selected_widget == w
|
31
|
-
w.uncheck
|
32
|
-
end
|
33
|
-
end
|
26
|
+
@widgets.select{|w| w.respond_to? :checked? and w.checked?}.each do |w|
|
27
|
+
unless selected_widget == w
|
28
|
+
w.uncheck
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
data/lib/rubygoo/tab_group.rb
CHANGED
@@ -48,18 +48,18 @@ module Rubygoo
|
|
48
48
|
def focus(w)
|
49
49
|
index = @widgets.index w
|
50
50
|
if index
|
51
|
-
@widgets[@selected_index].
|
51
|
+
@widgets[@selected_index]._unfocus if @widgets[@selected_index]
|
52
52
|
@selected_index = index
|
53
|
-
@widgets[@selected_index].
|
53
|
+
@widgets[@selected_index]._focus
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
def rotate(dir)
|
58
58
|
if @widgets.size > 0
|
59
|
-
@widgets[@selected_index].
|
59
|
+
@widgets[@selected_index]._unfocus if @widgets[@selected_index]
|
60
60
|
@selected_index += dir
|
61
61
|
@selected_index %= @widgets.size
|
62
|
-
@widgets[@selected_index].
|
62
|
+
@widgets[@selected_index]._focus
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
data/lib/rubygoo/widget.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'publisher'
|
2
|
-
require 'css_colors'
|
3
2
|
require 'goo_color'
|
4
3
|
require 'rect'
|
5
4
|
module Rubygoo
|
@@ -7,11 +6,13 @@ module Rubygoo
|
|
7
6
|
extend Publisher
|
8
7
|
|
9
8
|
# fire resized whenever a dimensional variable changes
|
10
|
-
can_fire :
|
9
|
+
can_fire :resized, :mouse_enter, :mouse_exit, :focus, :unfocus,
|
10
|
+
:key_pressed, :key_released, :mouse_down, :mouse_up, :mouse_drag,
|
11
|
+
:mouse_dragging, :mouse_motion, :enable, :disable, :hide, :show
|
11
12
|
|
12
|
-
attr_accessor :enabled, :parent, :container,
|
13
|
+
attr_accessor :enabled, :parent, :container, :opts,
|
13
14
|
:x, :y, :w, :h, :app, :x_pad, :y_pad, :focussed,
|
14
|
-
:focus_priority, :relative
|
15
|
+
:focus_priority, :relative, :mouse_over, :visible
|
15
16
|
|
16
17
|
DEFAULT_PARAMS = {
|
17
18
|
:x => 0,
|
@@ -21,6 +22,8 @@ module Rubygoo
|
|
21
22
|
:x_pad => 2,
|
22
23
|
:y_pad => 2,
|
23
24
|
:relative => false,
|
25
|
+
:enabled => true,
|
26
|
+
:visible => true,
|
24
27
|
}
|
25
28
|
def initialize(opts={})
|
26
29
|
merged_opts = DEFAULT_PARAMS.merge opts
|
@@ -31,6 +34,11 @@ module Rubygoo
|
|
31
34
|
@w = merged_opts[:w]
|
32
35
|
@h = merged_opts[:h]
|
33
36
|
@relative = merged_opts[:relative]
|
37
|
+
@enabled = merged_opts[:enabled]
|
38
|
+
@visible = merged_opts[:visible]
|
39
|
+
|
40
|
+
@opts = merged_opts
|
41
|
+
|
34
42
|
update_rect
|
35
43
|
end
|
36
44
|
|
@@ -38,75 +46,32 @@ module Rubygoo
|
|
38
46
|
@rect = Rect.new [@x,@y,@w,@h]
|
39
47
|
end
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
# called when the widget is removed from a container
|
46
|
-
def removed()
|
47
|
-
end
|
48
|
-
|
49
|
-
def contains?(pos)
|
50
|
-
@rect.collide_point? pos[0], pos[1]
|
51
|
-
end
|
52
|
-
|
53
|
-
def enabled?()
|
54
|
-
@enabled
|
55
|
-
end
|
56
|
-
|
57
|
-
def update(millis)
|
58
|
-
end
|
59
|
-
|
60
|
-
# draw ourself on the screen
|
61
|
-
def draw(screen)
|
62
|
-
end
|
63
|
-
|
64
|
-
# called when there is a mouse click
|
65
|
-
def mouse_down(event)
|
66
|
-
end
|
67
|
-
|
68
|
-
# called when there is a mouse motion and no button pressed
|
69
|
-
def mouse_motion(event)
|
70
|
-
end
|
71
|
-
#
|
72
|
-
# called when there is a mouse motion and a button pressed
|
73
|
-
def mouse_dragging(event)
|
49
|
+
def contains?(x, y)
|
50
|
+
@rect.collide_point? x, y
|
74
51
|
end
|
75
52
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
# called when there is a mouse release at the end of a drag
|
81
|
-
def mouse_drag(event)
|
53
|
+
def mouse_over?()
|
54
|
+
@mouse_over
|
82
55
|
end
|
83
56
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
# called when the widget loses focus
|
102
|
-
def on_unfocus()
|
57
|
+
def _mouse_motion(event) #:nodoc:
|
58
|
+
if contains?(event.data[:x],event.data[:y])
|
59
|
+
unless @mouse_over
|
60
|
+
@mouse_over = true
|
61
|
+
fire :mouse_enter, event
|
62
|
+
mouse_enter event
|
63
|
+
end
|
64
|
+
else
|
65
|
+
if @mouse_over
|
66
|
+
@mouse_over = false
|
67
|
+
fire :mouse_exit, event
|
68
|
+
mouse_exit event
|
69
|
+
end
|
70
|
+
end
|
71
|
+
fire :mouse_motion, event
|
72
|
+
mouse_motion event
|
103
73
|
end
|
104
74
|
|
105
|
-
def unfocus()
|
106
|
-
@focussed = false
|
107
|
-
on_unfocus
|
108
|
-
end
|
109
|
-
|
110
75
|
def focussed?()
|
111
76
|
@focussed
|
112
77
|
end
|
@@ -121,19 +86,21 @@ module Rubygoo
|
|
121
86
|
if class_theme
|
122
87
|
class_prop = class_theme[prop_key]
|
123
88
|
if class_prop
|
89
|
+
return nil if class_prop == :none
|
124
90
|
prop = class_prop
|
125
91
|
break
|
126
92
|
end
|
127
93
|
end
|
128
94
|
parent = parent.superclass
|
129
95
|
end
|
130
|
-
if prop_key.to_s.match
|
96
|
+
if prop_key.to_s.match(/color/i) and prop
|
131
97
|
get_color prop
|
132
98
|
else
|
133
99
|
prop
|
134
100
|
end
|
135
101
|
end
|
136
102
|
|
103
|
+
# converts theme property to a GooColor
|
137
104
|
def get_color(color)
|
138
105
|
new_color = nil
|
139
106
|
if color.is_a? Array
|
@@ -141,14 +108,14 @@ module Rubygoo
|
|
141
108
|
new_color = color
|
142
109
|
else
|
143
110
|
# fill in zeros for all other colors
|
144
|
-
3-color.size.times do
|
111
|
+
(3 - color.size).times do
|
145
112
|
color << 0
|
146
113
|
end
|
147
114
|
# fill in alpha as 255
|
148
115
|
color << 255
|
149
116
|
end
|
150
117
|
elsif color.is_a? Symbol
|
151
|
-
new_color =
|
118
|
+
new_color = COLORS[color]
|
152
119
|
else
|
153
120
|
raise "invalid color"
|
154
121
|
end
|
@@ -156,43 +123,213 @@ module Rubygoo
|
|
156
123
|
GooColor.new *new_color
|
157
124
|
end
|
158
125
|
|
159
|
-
#
|
160
|
-
def tab_to?()
|
161
|
-
true
|
162
|
-
end
|
163
|
-
|
164
|
-
def modal?()
|
165
|
-
false
|
166
|
-
end
|
167
|
-
|
168
|
-
# called each update cycle with the amount of time that has
|
169
|
-
# passed. useful for animations, etc
|
170
|
-
def update(time)
|
171
|
-
end
|
172
|
-
|
126
|
+
# sets x and fires resized event
|
173
127
|
def x=(val)
|
174
128
|
@x = val
|
129
|
+
update_rect
|
175
130
|
fire :resized, self
|
176
131
|
end
|
132
|
+
|
133
|
+
# sets y and fires resized event
|
177
134
|
def y=(val)
|
178
135
|
@y = val
|
136
|
+
update_rect
|
179
137
|
fire :resized, self
|
180
138
|
end
|
139
|
+
|
140
|
+
# sets width and fires resized event
|
181
141
|
def w=(val)
|
182
142
|
@w = val
|
143
|
+
update_rect
|
183
144
|
fire :resized, self
|
184
145
|
end
|
146
|
+
|
147
|
+
# sets height and fires resized event
|
185
148
|
def h=(val)
|
186
149
|
@h = val
|
150
|
+
update_rect
|
187
151
|
fire :resized, self
|
188
152
|
end
|
153
|
+
|
154
|
+
# sets x padding and fires resized event
|
189
155
|
def x_pad=(val)
|
190
156
|
@x_pad = val
|
157
|
+
update_rect
|
191
158
|
fire :resized, self
|
192
159
|
end
|
160
|
+
|
161
|
+
# sets y padding and fires resized event
|
193
162
|
def y_pad=(val)
|
194
163
|
@y_pad = val
|
164
|
+
update_rect
|
195
165
|
fire :resized, self
|
196
166
|
end
|
167
|
+
|
168
|
+
def enabled?()
|
169
|
+
@enabled
|
170
|
+
end
|
171
|
+
|
172
|
+
# called when the widget is disabled
|
173
|
+
def disable()
|
174
|
+
if enabled?
|
175
|
+
fire :disable
|
176
|
+
@enabled = false
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
# called when the widget is enabled
|
181
|
+
def enable()
|
182
|
+
unless enabled?
|
183
|
+
fire :enable
|
184
|
+
@enabled = true
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def visible?()
|
189
|
+
@visible
|
190
|
+
end
|
191
|
+
|
192
|
+
# called when the widget is hidden
|
193
|
+
def hide()
|
194
|
+
if visible?
|
195
|
+
fire :hide
|
196
|
+
@visible = false
|
197
|
+
disable
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# called when the widget is shown
|
202
|
+
def show()
|
203
|
+
unless visible?
|
204
|
+
fire :show
|
205
|
+
@visible = true
|
206
|
+
enable
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def _update(time) #:nodoc:
|
211
|
+
update time
|
212
|
+
end
|
213
|
+
|
214
|
+
def _focus() #:nodoc:
|
215
|
+
fire :focus
|
216
|
+
@focussed = true
|
217
|
+
focus
|
218
|
+
end
|
219
|
+
|
220
|
+
def _unfocus() #:nodoc:
|
221
|
+
fire :unfocus
|
222
|
+
@focussed = false
|
223
|
+
unfocus
|
224
|
+
end
|
225
|
+
|
226
|
+
def _mouse_dragging(event) #:nodoc:
|
227
|
+
fire :mouse_dragging, event
|
228
|
+
mouse_dragging event
|
229
|
+
end
|
230
|
+
|
231
|
+
def _mouse_drag(event) #:nodoc:
|
232
|
+
fire :mouse_drag, event
|
233
|
+
mouse_drag event
|
234
|
+
end
|
235
|
+
|
236
|
+
def _mouse_up(event) #:nodoc:
|
237
|
+
fire :mouse_up, event
|
238
|
+
mouse_up event
|
239
|
+
end
|
240
|
+
|
241
|
+
def _mouse_down(event) #:nodoc:
|
242
|
+
fire :mouse_down, event
|
243
|
+
mouse_down event
|
244
|
+
end
|
245
|
+
|
246
|
+
def _key_pressed(event) #:nodoc:
|
247
|
+
fire :key_pressed, event
|
248
|
+
key_pressed event
|
249
|
+
end
|
250
|
+
|
251
|
+
def _key_released(event) #:nodoc:
|
252
|
+
fire :key_released, event
|
253
|
+
key_released event
|
254
|
+
end
|
255
|
+
|
256
|
+
def _draw(screen) #:nodoc:
|
257
|
+
draw screen
|
258
|
+
end
|
259
|
+
|
260
|
+
#
|
261
|
+
# STUFF TO OVER RIDE
|
262
|
+
#
|
263
|
+
|
264
|
+
# does this widget want tabbed focus? Widget do usually
|
265
|
+
def tab_to?()
|
266
|
+
true
|
267
|
+
end
|
268
|
+
|
269
|
+
def modal?()
|
270
|
+
false
|
271
|
+
end
|
272
|
+
|
273
|
+
# called when the widget is added to a container
|
274
|
+
def added()
|
275
|
+
end
|
276
|
+
|
277
|
+
# called when the widget is removed from a container
|
278
|
+
def removed()
|
279
|
+
end
|
280
|
+
|
281
|
+
# called each update cycle with the amount of time that has
|
282
|
+
# passed. useful for animations, etc
|
283
|
+
def update(time)
|
284
|
+
end
|
285
|
+
|
286
|
+
# called when there is a mouse motion and a button pressed
|
287
|
+
def mouse_dragging(event)
|
288
|
+
end
|
289
|
+
|
290
|
+
# called when there is a mouse release w/o drag
|
291
|
+
def mouse_up(event)
|
292
|
+
end
|
293
|
+
|
294
|
+
# called when there is a mouse click
|
295
|
+
def mouse_down(event)
|
296
|
+
end
|
297
|
+
|
298
|
+
# called when there is a mouse release at the end of a drag
|
299
|
+
def mouse_drag(event)
|
300
|
+
end
|
301
|
+
|
302
|
+
# called when the mouse first enters a widget
|
303
|
+
def mouse_enter(event)
|
304
|
+
end
|
305
|
+
|
306
|
+
# called when the mouse exits a widget
|
307
|
+
def mouse_exit(event)
|
308
|
+
end
|
309
|
+
|
310
|
+
# called when there is a mouse motion and no button pressed
|
311
|
+
def mouse_motion(event)
|
312
|
+
end
|
313
|
+
|
314
|
+
# called when a key press is sent to us
|
315
|
+
def key_pressed(event)
|
316
|
+
end
|
317
|
+
|
318
|
+
# called when a key release is sent to us
|
319
|
+
def key_released(event)
|
320
|
+
end
|
321
|
+
|
322
|
+
# draw ourself on the screen
|
323
|
+
def draw(screen)
|
324
|
+
end
|
325
|
+
|
326
|
+
# called when the widget receives focus
|
327
|
+
def focus()
|
328
|
+
end
|
329
|
+
|
330
|
+
# called when the widget loses focus
|
331
|
+
def unfocus()
|
332
|
+
end
|
333
|
+
|
197
334
|
end
|
198
335
|
end
|
data/lib/rubygoo.rb
CHANGED
data/samples/create_gui.rb
CHANGED
@@ -4,14 +4,28 @@ module CreateGui
|
|
4
4
|
|
5
5
|
label = Label.new "click the button to set the time", :x=>20, :y=>30
|
6
6
|
|
7
|
-
button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20, :icon => icon
|
7
|
+
button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20, :icon => icon, :enabled => false
|
8
8
|
button.on :pressed do |*opts|
|
9
9
|
label.set_text(Time.now.to_s)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
icon_widget = Icon.new :x => 280, :y => 80, :icon => icon
|
13
|
+
|
14
|
+
check = CheckBox.new :x=>370, :y=>70, :w=>20, :h=>20, :label=> "Check me out!"
|
15
|
+
check.on :mouse_enter do
|
16
|
+
puts "ENTERING #{self.class}"
|
17
|
+
end
|
18
|
+
check.on :mouse_exit do
|
19
|
+
puts "EXITING #{self.class}"
|
20
|
+
end
|
21
|
+
|
13
22
|
check.on :checked do
|
14
23
|
label.set_text("CHECKED [#{check.checked?}]")
|
24
|
+
if check.checked?
|
25
|
+
button.enable
|
26
|
+
else
|
27
|
+
button.disable
|
28
|
+
end
|
15
29
|
end
|
16
30
|
|
17
31
|
text_field = TextField.new "initial text", :x => 70, :y => 170, :max_length => 20, :min_length => 6
|
@@ -20,7 +34,7 @@ module CreateGui
|
|
20
34
|
puts "BOO-YAH"
|
21
35
|
end
|
22
36
|
|
23
|
-
modal_button = Button.new "Modal dialogs", :x=>270, :y=>
|
37
|
+
modal_button = Button.new "Modal dialogs", :x=>270, :y=>240, :x_pad=>20, :y_pad=>20
|
24
38
|
modal_button.on :pressed do |*opts|
|
25
39
|
# TODO make some of this stuff relative and/or make Dialog's
|
26
40
|
# constructor take a layout to use
|
@@ -34,11 +48,11 @@ module CreateGui
|
|
34
48
|
|
35
49
|
ok_butt = Button.new("OK", :x=>70, :y=>180, :x_pad=>20, :y_pad=>20,:relative=>true)
|
36
50
|
ok_butt.on :pressed do |*opts|
|
37
|
-
|
51
|
+
modal.close
|
38
52
|
end
|
39
53
|
modal.add ok_butt, resize_me
|
40
54
|
|
41
|
-
modal.
|
55
|
+
modal.display
|
42
56
|
end
|
43
57
|
|
44
58
|
grp = RadioGroup.new :x=>10, :y=>380, :x_pad=>20, :y_pad=>20, :w=> 500, :h=>80
|
@@ -49,11 +63,20 @@ module CreateGui
|
|
49
63
|
|
50
64
|
grp.add grp_label, grp_radio_one, grp_radio_two, grp_radio_three
|
51
65
|
|
66
|
+
hide_button = Button.new "Hide the radios!", :x=>170, :y=>330, :x_pad=>10, :y_pad=>10
|
67
|
+
hide_button.on :pressed do |*opts|
|
68
|
+
if grp.visible?
|
69
|
+
grp.hide
|
70
|
+
else
|
71
|
+
grp.show
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
52
75
|
# implicit tab ordering based on order of addition, can
|
53
76
|
# specify if you want on widget creation
|
54
77
|
|
55
78
|
# can add many or one at a time
|
56
|
-
app.add text_field, label, button, modal_button, grp
|
79
|
+
app.add text_field, label, button, modal_button, grp, hide_button, icon_widget
|
57
80
|
app.add check
|
58
81
|
|
59
82
|
# pulldown = Pulldown.new {:x=>70, :y=>80}
|
data/samples/gosu_app.rb
CHANGED
data/samples/rubygame_app.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
#require 'unprof'
|
2
3
|
$: << './lib'
|
3
4
|
$: << File.dirname(__FILE__)
|
4
5
|
require 'rubygoo'
|
@@ -26,7 +27,7 @@ if $0 == __FILE__
|
|
26
27
|
JoyHatEvent, JoyUpEvent, ResizeEvent
|
27
28
|
]
|
28
29
|
clock = Clock.new
|
29
|
-
clock.target_framerate =
|
30
|
+
clock.target_framerate = 40
|
30
31
|
|
31
32
|
catch(:rubygame_quit) do
|
32
33
|
loop do
|
data/themes/default/config.yml
CHANGED
@@ -1,25 +1,31 @@
|
|
1
1
|
---
|
2
|
-
Rubygoo::App:
|
3
|
-
:bg_color: :
|
2
|
+
Rubygoo::App: # look at Rubygoo::CssColors for list
|
3
|
+
:bg_color: :Snow
|
4
4
|
Rubygoo::Container:
|
5
|
-
:bg_color: :
|
6
|
-
Rubygoo::Widget:
|
5
|
+
:bg_color: :Silver
|
6
|
+
Rubygoo::Widget: # fonts should live in the theme's dir
|
7
7
|
:font: Vera.ttf
|
8
8
|
:font_size: 20
|
9
|
-
:color: :
|
10
|
-
:focus_color: :
|
11
|
-
:bg_color: :
|
12
|
-
:
|
9
|
+
:color: :Tomato
|
10
|
+
:focus_color: :LightSlateGray
|
11
|
+
:bg_color: :WhiteSmoke
|
12
|
+
:disabled_color: :WhiteSmoke
|
13
|
+
:border_color: :DarkSlateBlue
|
14
|
+
:hover_color: # can specify a color by r,g,b,a as well
|
15
|
+
- 55
|
16
|
+
- 55
|
17
|
+
- 55
|
18
|
+
- 150
|
13
19
|
Rubygoo::Button:
|
14
|
-
:bg_color: :
|
20
|
+
:bg_color: :LightGray
|
15
21
|
Rubygoo::CheckBox:
|
16
|
-
:checked_color: :
|
22
|
+
:checked_color: :LightSlateGray
|
17
23
|
Rubygoo::TextField:
|
18
|
-
:fg_color: :
|
19
|
-
:bg_color: :
|
20
|
-
:bg_select_color: :
|
24
|
+
:fg_color: :Black
|
25
|
+
:bg_color: :Silver
|
26
|
+
:bg_select_color: :DarkSlateBlue
|
21
27
|
:fg_select_color: :Snow
|
22
|
-
:border_color: :
|
28
|
+
:border_color: :DarkSlateBlue
|
23
29
|
Rubygoo::MouseCursor:
|
24
|
-
:color: :
|
30
|
+
:color: :DarkSlateGray
|
25
31
|
:mouse_cursor: cursor.png
|