rubygoo 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/Manifest.txt +9 -0
- data/README.txt +84 -25
- data/Rakefile +36 -2
- data/TODO +5 -4
- data/lib/rubygoo/adapters/gosu_app_adapter.rb +216 -220
- data/lib/rubygoo/adapters/gosu_render_adapter.rb +45 -17
- data/lib/rubygoo/adapters/rubygame_render_adapter.rb +14 -7
- data/lib/rubygoo/app.rb +82 -24
- data/lib/rubygoo/button.rb +29 -10
- data/lib/rubygoo/check_box.rb +21 -11
- data/lib/rubygoo/container.rb +53 -33
- data/lib/rubygoo/dialog.rb +4 -9
- data/lib/rubygoo/label.rb +14 -9
- data/lib/rubygoo/radio_button.rb +29 -0
- data/lib/rubygoo/radio_group.rb +40 -0
- data/lib/rubygoo/tab_group.rb +67 -0
- data/lib/rubygoo/text_field.rb +49 -31
- data/lib/rubygoo/widget.rb +53 -7
- data/lib/rubygoo.rb +4 -0
- data/samples/create_gui.rb +67 -0
- data/samples/gosu_app.rb +8 -61
- data/samples/icon.png +0 -0
- data/samples/rubygame_app.rb +5 -56
- data/test/app_spec.rb +24 -0
- data/test/test_rubygoo.rb +1 -0
- data/test/test_setup.rb +4 -0
- data/test/widget_spec.rb +19 -0
- data/themes/default/config.yml +2 -0
- metadata +25 -5
data/lib/rubygoo/text_field.rb
CHANGED
@@ -6,9 +6,9 @@ module Rubygoo
|
|
6
6
|
super opts
|
7
7
|
@text = text
|
8
8
|
|
9
|
-
# TODO make widget respect these?
|
10
9
|
@max_length = opts[:max_length]
|
11
10
|
@min_length = opts[:min_length]
|
11
|
+
@min_length ||= 1
|
12
12
|
|
13
13
|
@key_handlers = {}
|
14
14
|
end
|
@@ -40,12 +40,17 @@ module Rubygoo
|
|
40
40
|
|
41
41
|
@font_file = File.join(@app.theme_dir,font)
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
# we have the default from widget, we want to set the
|
44
|
+
# default to 6 chars wide and 1 char tall
|
45
|
+
# wow, this is REALLY bad, but I think M is the widest char
|
46
|
+
size = @app.renderer.size_text "M"*@min_length, @font_file, @font_size
|
47
|
+
@min_w = size[0]
|
48
|
+
@min_h = size[1]
|
49
|
+
|
50
|
+
if @max_length
|
51
|
+
size = @app.renderer.size_text "M"*@max_length, @font_file, @font_size
|
52
|
+
@max_w = size[0]
|
53
|
+
@max_h = size[1]
|
49
54
|
end
|
50
55
|
|
51
56
|
set_text @text
|
@@ -61,6 +66,10 @@ module Rubygoo
|
|
61
66
|
@rendered_text = @app.renderer.render_text @text, @font_file, @font_size, @color
|
62
67
|
w = [@rendered_text.width,@min_w].max + @x_pad
|
63
68
|
h = [@rendered_text.height,@min_h].max + @y_pad
|
69
|
+
if @max_length
|
70
|
+
w = [w,@max_w].min
|
71
|
+
h = [h,@max_h].min
|
72
|
+
end
|
64
73
|
@rect = Rect.new [@x,@y,w,h]
|
65
74
|
end
|
66
75
|
end
|
@@ -80,18 +89,19 @@ module Rubygoo
|
|
80
89
|
|
81
90
|
end
|
82
91
|
|
83
|
-
def draw(
|
84
|
-
|
85
|
-
|
92
|
+
def draw(adapter)
|
93
|
+
x1 = @rect[0] - 2
|
94
|
+
y1 = @rect[1] - 2
|
95
|
+
x2 = @rect[2] + x1 + 4
|
96
|
+
y2 = @rect[3] + y1 + 4
|
97
|
+
|
98
|
+
adapter.fill x1, y1, x2, y2, @fg_color
|
99
|
+
adapter.fill x1-2, y1-2, x2+2, y2+2, @bg_color
|
86
100
|
if @border_color
|
87
|
-
x1
|
88
|
-
y1 = @rect[1] - 2
|
89
|
-
x2 = @rect[2] + x1 + 4
|
90
|
-
y2 = @rect[3] + y1 + 4
|
91
|
-
screen.draw_box x1, y1, x2, y2, @border_color
|
101
|
+
adapter.draw_box x1, y1, x2, y2, @border_color
|
92
102
|
end
|
93
103
|
defaultY = @app.renderer.size_text(@text.slice(0,1),@font_file,@font_size)[1]
|
94
|
-
|
104
|
+
|
95
105
|
if @focussed
|
96
106
|
caretX = @app.renderer.size_text(@text.slice(0,@caret_pos),@font_file,@font_size)[0]
|
97
107
|
unless @select_pos.nil?
|
@@ -101,19 +111,23 @@ module Rubygoo
|
|
101
111
|
selectX1 = [caretX, selectX].max
|
102
112
|
if selectX0 < selectX1
|
103
113
|
# TODO cache this height
|
104
|
-
|
114
|
+
x = x1+1+selectX0
|
115
|
+
y = y1+1
|
116
|
+
adapter.fill x, y, x+selectX1-selectX0, y+defaultY, @bg_select_color
|
105
117
|
end
|
106
118
|
end
|
107
119
|
end
|
108
120
|
|
109
121
|
unless @text.nil? or @text.empty?
|
110
122
|
@rendered_text = @app.renderer.render_text @text, @font_file, @font_size, @color
|
111
|
-
|
123
|
+
adapter.draw_image @rendered_text, x1+1, y1+1, @color
|
112
124
|
end
|
113
125
|
|
114
126
|
# draw caret
|
115
127
|
if @focussed
|
116
|
-
|
128
|
+
x = x1+1+caretX
|
129
|
+
y = y1+1
|
130
|
+
adapter.fill x, y, x+1, y+defaultY, @fg_select_color
|
117
131
|
end
|
118
132
|
|
119
133
|
# don't really need this??
|
@@ -161,18 +175,22 @@ module Rubygoo
|
|
161
175
|
def mouse_down(event)
|
162
176
|
x = event.data[:x]
|
163
177
|
y = event.data[:y]
|
164
|
-
return 0 unless contains?([x,y])
|
165
178
|
|
166
|
-
|
167
|
-
|
179
|
+
self.app.focus self
|
180
|
+
|
168
181
|
@caret_pos = find_mouse_position([x,y])
|
169
182
|
@select_pos = @caret_pos
|
170
|
-
@dragging = true
|
171
183
|
render
|
172
184
|
end
|
173
185
|
|
174
|
-
def
|
175
|
-
|
186
|
+
def mouse_dragging(event)
|
187
|
+
x = event.data[:x]
|
188
|
+
y = event.data[:y]
|
189
|
+
@caret_pos = find_mouse_position([x,y])
|
190
|
+
render
|
191
|
+
end
|
192
|
+
|
193
|
+
def mouse_drag(event)
|
176
194
|
x = event.data[:x]
|
177
195
|
y = event.data[:y]
|
178
196
|
@caret_pos = find_mouse_position([x,y])
|
@@ -180,13 +198,9 @@ module Rubygoo
|
|
180
198
|
end
|
181
199
|
|
182
200
|
def mouse_up(event)
|
183
|
-
if not @dragging
|
184
|
-
return 0
|
185
|
-
end
|
186
201
|
x = event.data[:x]
|
187
202
|
y = event.data[:y]
|
188
203
|
@caret_pos = find_mouse_position([x,y])
|
189
|
-
@dragging = false
|
190
204
|
render
|
191
205
|
end
|
192
206
|
|
@@ -282,9 +296,13 @@ module Rubygoo
|
|
282
296
|
|
283
297
|
when *KEY2ASCII.keys
|
284
298
|
# add regular text to the box
|
299
|
+
return if @text.size == @max_length
|
285
300
|
if @caret_pos == @select_pos
|
286
|
-
|
287
|
-
|
301
|
+
event_string = event.data[:string]
|
302
|
+
unless event_string.nil? or event_string == ""
|
303
|
+
@text = @text.slice(0,@caret_pos) + event_string + @text.slice(@caret_pos,@text.length-@caret_pos)
|
304
|
+
@caret_pos += 1
|
305
|
+
end
|
288
306
|
else
|
289
307
|
positions = [@caret_pos,@select_pos]
|
290
308
|
min = positions.min
|
data/lib/rubygoo/widget.rb
CHANGED
@@ -5,10 +5,13 @@ require 'rect'
|
|
5
5
|
module Rubygoo
|
6
6
|
class Widget
|
7
7
|
extend Publisher
|
8
|
-
|
8
|
+
|
9
|
+
# fire resized whenever a dimensional variable changes
|
10
|
+
can_fire :clicked, :resized
|
11
|
+
|
9
12
|
attr_accessor :enabled, :parent, :container,
|
10
13
|
:x, :y, :w, :h, :app, :x_pad, :y_pad, :focussed,
|
11
|
-
:focus_priority
|
14
|
+
:focus_priority, :relative
|
12
15
|
|
13
16
|
DEFAULT_PARAMS = {
|
14
17
|
:x => 0,
|
@@ -17,6 +20,7 @@ module Rubygoo
|
|
17
20
|
:h => 1,
|
18
21
|
:x_pad => 2,
|
19
22
|
:y_pad => 2,
|
23
|
+
:relative => false,
|
20
24
|
}
|
21
25
|
def initialize(opts={})
|
22
26
|
merged_opts = DEFAULT_PARAMS.merge opts
|
@@ -26,11 +30,12 @@ module Rubygoo
|
|
26
30
|
@y_pad = merged_opts[:y_pad]
|
27
31
|
@w = merged_opts[:w]
|
28
32
|
@h = merged_opts[:h]
|
33
|
+
@relative = merged_opts[:relative]
|
29
34
|
update_rect
|
30
35
|
end
|
31
36
|
|
32
37
|
def update_rect()
|
33
|
-
@rect = Rect.new [@x,@y,@w
|
38
|
+
@rect = Rect.new [@x,@y,@w,@h]
|
34
39
|
end
|
35
40
|
|
36
41
|
# called when the widget is added to a container
|
@@ -60,14 +65,22 @@ module Rubygoo
|
|
60
65
|
def mouse_down(event)
|
61
66
|
end
|
62
67
|
|
63
|
-
# called when there is a mouse motion
|
68
|
+
# called when there is a mouse motion and no button pressed
|
64
69
|
def mouse_motion(event)
|
65
70
|
end
|
71
|
+
#
|
72
|
+
# called when there is a mouse motion and a button pressed
|
73
|
+
def mouse_dragging(event)
|
74
|
+
end
|
66
75
|
|
67
|
-
# called when there is a mouse release
|
76
|
+
# called when there is a mouse release w/o drag
|
68
77
|
def mouse_up(event)
|
69
78
|
end
|
70
79
|
|
80
|
+
# called when there is a mouse release at the end of a drag
|
81
|
+
def mouse_drag(event)
|
82
|
+
end
|
83
|
+
|
71
84
|
# called when a key press is sent to us
|
72
85
|
def key_pressed(event)
|
73
86
|
end
|
@@ -142,11 +155,44 @@ module Rubygoo
|
|
142
155
|
|
143
156
|
GooColor.new *new_color
|
144
157
|
end
|
158
|
+
|
159
|
+
# does this widget want tabbed focus? Widget do usually
|
160
|
+
def tab_to?()
|
161
|
+
true
|
162
|
+
end
|
163
|
+
|
164
|
+
def modal?()
|
165
|
+
false
|
166
|
+
end
|
145
167
|
|
146
|
-
# called each update cycle with the amount of time that has
|
147
|
-
# for animations, etc
|
168
|
+
# called each update cycle with the amount of time that has
|
169
|
+
# passed. useful for animations, etc
|
148
170
|
def update(time)
|
149
171
|
end
|
150
172
|
|
173
|
+
def x=(val)
|
174
|
+
@x = val
|
175
|
+
fire :resized, self
|
176
|
+
end
|
177
|
+
def y=(val)
|
178
|
+
@y = val
|
179
|
+
fire :resized, self
|
180
|
+
end
|
181
|
+
def w=(val)
|
182
|
+
@w = val
|
183
|
+
fire :resized, self
|
184
|
+
end
|
185
|
+
def h=(val)
|
186
|
+
@h = val
|
187
|
+
fire :resized, self
|
188
|
+
end
|
189
|
+
def x_pad=(val)
|
190
|
+
@x_pad = val
|
191
|
+
fire :resized, self
|
192
|
+
end
|
193
|
+
def y_pad=(val)
|
194
|
+
@y_pad = val
|
195
|
+
fire :resized, self
|
196
|
+
end
|
151
197
|
end
|
152
198
|
end
|
data/lib/rubygoo.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
$: << File.dirname(__FILE__)
|
2
2
|
$: << File.join(File.dirname(__FILE__),"rubygoo")
|
3
3
|
$: << File.join(File.dirname(__FILE__),"rubygoo","adapters")
|
4
|
+
require 'rubygems'
|
4
5
|
require 'rubygoo/goo_event'
|
5
6
|
require 'rubygoo/goo_color'
|
6
7
|
require 'rubygoo/adapters/adapter_factory'
|
@@ -8,9 +9,12 @@ require 'yaml'
|
|
8
9
|
require 'rubygoo/widget'
|
9
10
|
require 'rubygoo/container'
|
10
11
|
require 'rubygoo/mouse_cursor'
|
12
|
+
require 'rubygoo/tab_group'
|
11
13
|
require 'rubygoo/app'
|
12
14
|
require 'rubygoo/label'
|
13
15
|
require 'rubygoo/button'
|
14
16
|
require 'rubygoo/check_box'
|
17
|
+
require 'rubygoo/radio_button'
|
18
|
+
require 'rubygoo/radio_group'
|
15
19
|
require 'rubygoo/text_field'
|
16
20
|
require 'rubygoo/dialog'
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module CreateGui
|
2
|
+
def create_gui(renderer, icon)
|
3
|
+
app = App.new :renderer => renderer
|
4
|
+
|
5
|
+
label = Label.new "click the button to set the time", :x=>20, :y=>30
|
6
|
+
|
7
|
+
button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20, :icon => icon
|
8
|
+
button.on :pressed do |*opts|
|
9
|
+
label.set_text(Time.now.to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
check = CheckBox.new :x=>370, :y=>70, :w=>20, :h=>20
|
13
|
+
check.on :checked do
|
14
|
+
label.set_text("CHECKED [#{check.checked?}]")
|
15
|
+
end
|
16
|
+
|
17
|
+
text_field = TextField.new "initial text", :x => 70, :y => 170, :max_length => 20, :min_length => 6
|
18
|
+
|
19
|
+
text_field.on_key K_RETURN, K_KP_ENTER do |evt|
|
20
|
+
puts "BOO-YAH"
|
21
|
+
end
|
22
|
+
|
23
|
+
modal_button = Button.new "Modal dialogs", :x=>270, :y=>280, :x_pad=>20, :y_pad=>20
|
24
|
+
modal_button.on :pressed do |*opts|
|
25
|
+
# TODO make some of this stuff relative and/or make Dialog's
|
26
|
+
# constructor take a layout to use
|
27
|
+
modal = Dialog.new :modal => app, :x=>60, :y=>110, :w=>250, :h=>250
|
28
|
+
|
29
|
+
modal.add Label.new("Message Here", :x=>20, :y=>70, :x_pad=>20, :y_pad=>20, :relative=>true)
|
30
|
+
resize_me = Button.new "resize", :relative=>true, :x=>170, :y=>180
|
31
|
+
resize_me.on :pressed do |*opts|
|
32
|
+
modal.resize opts.first
|
33
|
+
end
|
34
|
+
|
35
|
+
ok_butt = Button.new("OK", :x=>70, :y=>180, :x_pad=>20, :y_pad=>20,:relative=>true)
|
36
|
+
ok_butt.on :pressed do |*opts|
|
37
|
+
app.remove_modal(modal)
|
38
|
+
end
|
39
|
+
modal.add ok_butt, resize_me
|
40
|
+
|
41
|
+
modal.show
|
42
|
+
end
|
43
|
+
|
44
|
+
grp = RadioGroup.new :x=>10, :y=>380, :x_pad=>20, :y_pad=>20, :w=> 500, :h=>80
|
45
|
+
grp_label = Label.new "RadioGroups are fun!", :x=>40, :y=>10, :w=>20, :h=>20, :relative=>true
|
46
|
+
grp_radio_one = RadioButton.new :x=>40, :y=>40, :w=>20, :h=>20, :relative=>true
|
47
|
+
grp_radio_two = RadioButton.new :x=>90, :y=>40, :w=>20, :h=>20, :relative=>true
|
48
|
+
grp_radio_three = RadioButton.new :x=>140, :y=>40, :w=>20, :h=>20, :relative=>true
|
49
|
+
|
50
|
+
grp.add grp_label, grp_radio_one, grp_radio_two, grp_radio_three
|
51
|
+
|
52
|
+
# implicit tab ordering based on order of addition, can
|
53
|
+
# specify if you want on widget creation
|
54
|
+
|
55
|
+
# can add many or one at a time
|
56
|
+
app.add text_field, label, button, modal_button, grp
|
57
|
+
app.add check
|
58
|
+
|
59
|
+
# pulldown = Pulldown.new {:x=>70, :y=>80}
|
60
|
+
# pulldown.on :changed do |*opts|
|
61
|
+
# label.set_text(opts.first)
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# app.add pulldown
|
65
|
+
app
|
66
|
+
end
|
67
|
+
end
|
data/samples/gosu_app.rb
CHANGED
@@ -1,98 +1,45 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
$: << './lib'
|
3
|
+
$: << File.dirname(__FILE__)
|
3
4
|
require 'rubygoo'
|
4
|
-
|
5
5
|
require 'gosu'
|
6
6
|
include Gosu
|
7
7
|
include Rubygoo
|
8
8
|
|
9
|
+
require 'create_gui'
|
9
10
|
class RubygooWindow < Window
|
11
|
+
include CreateGui
|
10
12
|
def initialize()
|
11
13
|
|
12
14
|
super(640, 480, false)
|
13
15
|
|
14
|
-
# TODO, how can I do this
|
16
|
+
# TODO, how can I do this more cleanly?
|
15
17
|
%w{a b c d e f g h i j k l m n o p q r s t u v w x y z}.each do |letter|
|
16
18
|
eval "::Kb#{letter.upcase} = #{self.char_to_button_id(letter)}"
|
17
19
|
end
|
20
|
+
|
18
21
|
# how do I get rid of this?
|
19
22
|
require 'gosu_app_adapter'
|
20
23
|
factory = AdapterFactory.new
|
21
24
|
@render_adapter = factory.renderer_for :gosu, self
|
22
|
-
|
25
|
+
icon = Image.new self, File.dirname(__FILE__) + "/icon.png"
|
26
|
+
app = create_gui(@render_adapter,icon)
|
23
27
|
@app_adapter = factory.app_for :gosu, app, self
|
24
28
|
self.caption = "Gosu Tutorial Game"
|
25
29
|
|
26
30
|
end
|
27
31
|
|
28
|
-
def create_gui(renderer)
|
29
|
-
app = App.new :renderer => renderer
|
30
|
-
|
31
|
-
label = Label.new "click the button to set the time", :x=>20, :y=>30
|
32
|
-
|
33
|
-
button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20
|
34
|
-
button.on :pressed do |*opts|
|
35
|
-
label.set_text(Time.now.to_s)
|
36
|
-
end
|
37
|
-
|
38
|
-
check = CheckBox.new :x=>370, :y=>70, :w=>20, :h=>20
|
39
|
-
check.on :checked do
|
40
|
-
label.set_text("CHECKED [#{check.checked?}]")
|
41
|
-
end
|
42
|
-
|
43
|
-
text_field = TextField.new "initial text", :x => 70, :y => 170
|
44
|
-
|
45
|
-
text_field.on_key K_RETURN, K_KP_ENTER do |evt|
|
46
|
-
puts "BOO-YAH"
|
47
|
-
end
|
48
|
-
|
49
|
-
modal_button = Button.new "Modal dialogs", :x=>270, :y=>280, :x_pad=>20, :y_pad=>20
|
50
|
-
modal_button.on :pressed do |*opts|
|
51
|
-
msg = "I AM MODAL"
|
52
|
-
# TODO make some of this stuff relative and/or make Dialog's
|
53
|
-
# constructor take a layout to use
|
54
|
-
modal = Dialog.new :modal => app, :x=>10, :y=>110, :w=>250, :h=>250
|
55
|
-
|
56
|
-
modal.add Label.new("Message Here", :x=>70, :y=>180, :x_pad=>20, :y_pad=>20)
|
57
|
-
ok_butt = Button.new("OK", :x=>90, :y=>280, :x_pad=>20, :y_pad=>20)
|
58
|
-
ok_butt.on :pressed do |*opts|
|
59
|
-
# TODO not sure about this yet
|
60
|
-
app.remove(modal)
|
61
|
-
end
|
62
|
-
modal.add ok_butt
|
63
|
-
|
64
|
-
modal.show
|
65
|
-
end
|
66
|
-
|
67
|
-
# implicit tab ordering based on order of addition, can
|
68
|
-
# specify if you want on widget creation
|
69
|
-
|
70
|
-
# can add many or one at a time
|
71
|
-
app.add text_field, label, button, modal_button
|
72
|
-
app.add check
|
73
|
-
|
74
|
-
# pulldown = Pulldown.new {:x=>70, :y=>80}
|
75
|
-
# pulldown.on :changed do |*opts|
|
76
|
-
# label.set_text(opts.first)
|
77
|
-
# end
|
78
|
-
#
|
79
|
-
# app.add pulldown
|
80
|
-
app
|
81
|
-
end
|
82
|
-
|
83
32
|
def update
|
84
33
|
@app_adapter.update Gosu::milliseconds
|
85
34
|
end
|
86
35
|
|
87
36
|
def draw
|
88
|
-
# possibly need to set something like GosuRenderer vs
|
89
|
-
# RubygameRenderer that each know how to draw a textbox in
|
90
|
-
# its own way?
|
91
37
|
@app_adapter.draw @render_adapter
|
92
38
|
end
|
93
39
|
|
94
40
|
# in gosu this captures mouse and keyboard events
|
95
41
|
def button_down(id)
|
42
|
+
close if id == Gosu::Button::KbEscape
|
96
43
|
@app_adapter.button_down id
|
97
44
|
end
|
98
45
|
|
data/samples/icon.png
ADDED
Binary file
|
data/samples/rubygame_app.rb
CHANGED
@@ -1,64 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
$: << './lib'
|
3
|
+
$: << File.dirname(__FILE__)
|
3
4
|
require 'rubygoo'
|
4
5
|
require 'rubygame'
|
6
|
+
require 'create_gui'
|
5
7
|
include Rubygame
|
6
8
|
include Rubygoo
|
7
|
-
|
8
|
-
def create_gui(renderer)
|
9
|
-
app = App.new :renderer => renderer
|
10
|
-
|
11
|
-
label = Label.new "click the button to set the time", :x=>20, :y=>30
|
12
|
-
|
13
|
-
button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20
|
14
|
-
button.on :pressed do |*opts|
|
15
|
-
label.set_text(Time.now.to_s)
|
16
|
-
end
|
17
|
-
|
18
|
-
check = CheckBox.new :x=>370, :y=>70, :w=>20, :h=>20
|
19
|
-
check.on :checked do
|
20
|
-
label.set_text("CHECKED [#{check.checked?}]")
|
21
|
-
end
|
22
|
-
|
23
|
-
text_field = TextField.new "initial text", :x => 70, :y => 170
|
24
|
-
|
25
|
-
text_field.on_key K_RETURN, K_KP_ENTER do |evt|
|
26
|
-
puts "BOO-YAH"
|
27
|
-
end
|
28
|
-
|
29
|
-
modal_button = Button.new "Modal dialogs", :x=>270, :y=>280, :x_pad=>20, :y_pad=>20
|
30
|
-
modal_button.on :pressed do |*opts|
|
31
|
-
msg = "I AM MODAL"
|
32
|
-
# TODO make some of this stuff relative and/or make Dialog's
|
33
|
-
# constructor take a layout to use
|
34
|
-
modal = Dialog.new :modal => app, :x=>10, :y=>110, :w=>250, :h=>250
|
35
|
-
|
36
|
-
modal.add Label.new("Message Here", :x=>70, :y=>180, :x_pad=>20, :y_pad=>20)
|
37
|
-
ok_butt = Button.new("OK", :x=>90, :y=>280, :x_pad=>20, :y_pad=>20)
|
38
|
-
ok_butt.on :pressed do |*opts|
|
39
|
-
# TODO not sure about this yet
|
40
|
-
app.remove(modal)
|
41
|
-
end
|
42
|
-
modal.add ok_butt
|
43
|
-
|
44
|
-
modal.show
|
45
|
-
end
|
46
|
-
|
47
|
-
# implicit tab ordering based on order of addition, can
|
48
|
-
# specify if you want on widget creation
|
49
|
-
|
50
|
-
# can add many or one at a time
|
51
|
-
app.add text_field, label, button, modal_button
|
52
|
-
app.add check
|
53
|
-
|
54
|
-
# pulldown = Pulldown.new {:x=>70, :y=>80}
|
55
|
-
# pulldown.on :changed do |*opts|
|
56
|
-
# label.set_text(opts.first)
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# app.add pulldown
|
60
|
-
app
|
61
|
-
end
|
9
|
+
include CreateGui
|
62
10
|
|
63
11
|
if $0 == __FILE__
|
64
12
|
|
@@ -67,7 +15,8 @@ if $0 == __FILE__
|
|
67
15
|
|
68
16
|
factory = AdapterFactory.new
|
69
17
|
render_adapter = factory.renderer_for :rubygame, screen
|
70
|
-
|
18
|
+
icon = Surface.load File.dirname(__FILE__) + "/icon.png"
|
19
|
+
app = create_gui(render_adapter,icon)
|
71
20
|
app_adapter = factory.app_for :rubygame, app
|
72
21
|
|
73
22
|
# rubygame standard stuff below here
|
data/test/app_spec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__)+"/test_setup.rb"
|
2
|
+
|
3
|
+
describe App do
|
4
|
+
|
5
|
+
describe "basic app behavior" do
|
6
|
+
before :each do
|
7
|
+
# @widget = Map.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should merge in defaults for any options not given" do
|
11
|
+
@app = App.new
|
12
|
+
for k,v in App::DEFAULT_PARAMS.dup.delete(:theme)
|
13
|
+
@app.instance_variable_get("@#{k}").should == v
|
14
|
+
end
|
15
|
+
|
16
|
+
theme_dir = File.join(App::DEFAULT_PARAMS[:data_dir],
|
17
|
+
App::DEFAULT_PARAMS[:theme])
|
18
|
+
exp_theme = YAML::load_file(File.join(theme_dir,"config.yml"))
|
19
|
+
@app.theme.should == exp_theme
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# TODO change this to include/run all specs in this directory
|
data/test/test_setup.rb
ADDED
data/test/widget_spec.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.dirname(__FILE__)+"/test_setup.rb"
|
2
|
+
|
3
|
+
describe Widget do
|
4
|
+
|
5
|
+
describe "basic widget behavior" do
|
6
|
+
before :each do
|
7
|
+
# @widget = Map.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should merge in defaults for any options not given" do
|
11
|
+
@widget = Widget.new
|
12
|
+
for k,v in Widget::DEFAULT_PARAMS
|
13
|
+
@widget.instance_variable_get("@#{k}").should == v
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/themes/default/config.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shawn Anderson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-13 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,16 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
35
45
|
- !ruby/object:Gem::Dependency
|
36
46
|
name: hoe
|
37
47
|
type: :development
|
@@ -40,7 +50,7 @@ dependencies:
|
|
40
50
|
requirements:
|
41
51
|
- - ">="
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.
|
53
|
+
version: 1.8.2
|
44
54
|
version:
|
45
55
|
description: GUI library for use with Gosu or Rubygame
|
46
56
|
email: boss@topfunky.com
|
@@ -85,11 +95,20 @@ files:
|
|
85
95
|
- lib/rubygoo/goo_event.rb
|
86
96
|
- lib/rubygoo/label.rb
|
87
97
|
- lib/rubygoo/mouse_cursor.rb
|
98
|
+
- lib/rubygoo/radio_button.rb
|
99
|
+
- lib/rubygoo/radio_group.rb
|
88
100
|
- lib/rubygoo/rect.rb
|
101
|
+
- lib/rubygoo/tab_group.rb
|
89
102
|
- lib/rubygoo/text_field.rb
|
90
103
|
- lib/rubygoo/widget.rb
|
104
|
+
- samples/create_gui.rb
|
91
105
|
- samples/gosu_app.rb
|
106
|
+
- samples/icon.png
|
92
107
|
- samples/rubygame_app.rb
|
108
|
+
- test/app_spec.rb
|
109
|
+
- test/test_rubygoo.rb
|
110
|
+
- test/test_setup.rb
|
111
|
+
- test/widget_spec.rb
|
93
112
|
- themes/default/Vera.ttf
|
94
113
|
- themes/default/config.yml
|
95
114
|
has_rdoc: true
|
@@ -119,5 +138,6 @@ rubygems_version: 1.2.0
|
|
119
138
|
signing_key:
|
120
139
|
specification_version: 2
|
121
140
|
summary: Beautiful graphs for one or multiple datasets.
|
122
|
-
test_files:
|
123
|
-
|
141
|
+
test_files:
|
142
|
+
- test/test_rubygoo.rb
|
143
|
+
- test/test_setup.rb
|