rubygoo 0.0.5 → 0.0.6

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/History.txt CHANGED
@@ -17,3 +17,11 @@
17
17
 
18
18
  * Minor API tweaks
19
19
  * fixing gem deps
20
+
21
+ === 0.0.6 / 2008-11-13
22
+
23
+ * Getting closer to a 1.0 release
24
+ * Better TextField support for Gosu
25
+ * small rendering bugs fixed
26
+ * added relative positioning of widgets
27
+ * added RadioButton and RadioGroup
data/Manifest.txt CHANGED
@@ -30,10 +30,19 @@ lib/rubygoo/goo_color.rb
30
30
  lib/rubygoo/goo_event.rb
31
31
  lib/rubygoo/label.rb
32
32
  lib/rubygoo/mouse_cursor.rb
33
+ lib/rubygoo/radio_button.rb
34
+ lib/rubygoo/radio_group.rb
33
35
  lib/rubygoo/rect.rb
36
+ lib/rubygoo/tab_group.rb
34
37
  lib/rubygoo/text_field.rb
35
38
  lib/rubygoo/widget.rb
39
+ samples/create_gui.rb
36
40
  samples/gosu_app.rb
41
+ samples/icon.png
37
42
  samples/rubygame_app.rb
43
+ test/app_spec.rb
44
+ test/test_rubygoo.rb
45
+ test/test_setup.rb
46
+ test/widget_spec.rb
38
47
  themes/default/Vera.ttf
39
48
  themes/default/config.yml
data/README.txt CHANGED
@@ -10,19 +10,35 @@ Rubygoo is a theme-able gui framework for use with rubygame and soon gosu. It ha
10
10
 
11
11
  * theme-able gui widgets
12
12
  * named css colors
13
- * works with rubygame, gosu support on its way
14
- * containers, labels, buttons, checkboxes
13
+ * works with rubygame and gosu
14
+ * containers, labels, buttons, checkboxes, radio buttons, radio groups
15
15
  * tabbing focus of widgets
16
16
  * modal dialogs
17
17
 
18
18
  == SYNOPSIS:
19
+ require 'rubygems'
20
+ $: << './lib'
21
+ $: << File.dirname(__FILE__)
22
+ require 'rubygoo'
23
+ require 'rubygame'
24
+ require 'create_gui'
25
+ include Rubygame
26
+ include Rubygoo
27
+
28
+ if $0 == __FILE__
29
+
30
+ screen = Screen.new [600,480]
31
+ screen.show_cursor = false
32
+
33
+ factory = AdapterFactory.new
34
+ render_adapter = factory.renderer_for :rubygame, screen
35
+ icon = Surface.load File.dirname(__FILE__) + "/icon.png"
19
36
 
20
- def build_gui(renderer)
21
37
  app = App.new :renderer => renderer
22
38
 
23
39
  label = Label.new "click the button to set the time", :x=>20, :y=>30
24
40
 
25
- button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20
41
+ button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20, :icon => icon
26
42
  button.on :pressed do |*opts|
27
43
  label.set_text(Time.now.to_s)
28
44
  end
@@ -32,45 +48,88 @@ def build_gui(renderer)
32
48
  label.set_text("CHECKED [#{check.checked?}]")
33
49
  end
34
50
 
35
- text_field = TextField.new "initial text", :x => 70, :y => 170
51
+ text_field = TextField.new "initial text", :x => 70, :y => 170, :max_length => 20, :min_length => 6
36
52
 
37
53
  text_field.on_key K_RETURN, K_KP_ENTER do |evt|
38
54
  puts "BOO-YAH"
39
55
  end
40
-
56
+
57
+ modal_button = Button.new "Modal dialogs", :x=>270, :y=>280, :x_pad=>20, :y_pad=>20
58
+ modal_button.on :pressed do |*opts|
59
+ modal = Dialog.new :modal => app, :x=>60, :y=>110, :w=>250, :h=>250
60
+
61
+ modal.add Label.new("Message Here", :x=>20, :y=>70, :x_pad=>20, :y_pad=>20, :relative=>true)
62
+
63
+ ok_butt = Button.new("OK", :x=>70, :y=>180, :x_pad=>20, :y_pad=>20,:relative=>true)
64
+ ok_butt.on :pressed do |*opts|
65
+ app.remove_modal(modal)
66
+ end
67
+ modal.add ok_butt
68
+
69
+ modal.show
70
+ end
71
+
72
+ grp = RadioGroup.new :x=>10, :y=>380, :x_pad=>20, :y_pad=>20, :w=> 500, :h=>80
73
+ grp_label = Label.new "RadioGroups are fun!", :x=>40, :y=>10, :w=>20, :h=>20, :relative=>true
74
+ grp_radio_one = RadioButton.new :x=>40, :y=>40, :w=>20, :h=>20, :relative=>true
75
+ grp_radio_two = RadioButton.new :x=>90, :y=>40, :w=>20, :h=>20, :relative=>true
76
+ grp_radio_three = RadioButton.new :x=>140, :y=>40, :w=>20, :h=>20, :relative=>true
77
+
78
+ grp.add grp_label, grp_radio_one, grp_radio_two, grp_radio_three
79
+
41
80
  # implicit tab ordering based on order of addition, can
42
81
  # specify if you want on widget creation
43
82
 
44
83
  # can add many or one at a time
45
- app.add text_field, label, button
84
+ app.add text_field, label, button, modal_button, grp
46
85
  app.add check
47
- end
48
-
49
- screen = Screen.new [600,480]
50
86
 
51
- factory = AdapterFactory.new
52
- render_adapter = factory.renderer_for :rubygame, screen
53
- app = create_gui(render_adapter)
54
- app_adapter = factory.app_for :rubygame, app
87
+ # pulldown = Pulldown.new {:x=>70, :y=>80}
88
+ # pulldown.on :changed do |*opts|
89
+ # label.set_text(opts.first)
90
+ # end
91
+ #
92
+ # app.add pulldown
55
93
 
56
- # <standard rubygame setup stuff here>
57
-
58
- # rubygame loop do ..
59
-
60
- # each event in our queue do ..
61
- # pass on our events to the GUI
62
- app_adapter.on_event event
94
+ app_adapter = factory.app_for :rubygame, app
95
+
96
+ # rubygame standard stuff below here
97
+ queue = EventQueue.new
98
+ queue.ignore = [
99
+ ActiveEvent, JoyAxisEvent, JoyBallEvent, JoyDownEvent,
100
+ JoyHatEvent, JoyUpEvent, ResizeEvent
101
+ ]
102
+ clock = Clock.new
103
+ clock.target_framerate = 20
104
+
105
+ catch(:rubygame_quit) do
106
+ loop do
107
+ queue.each do |event|
108
+ case event
109
+ when KeyDownEvent
110
+ case event.key
111
+ when K_ESCAPE
112
+ throw :rubygame_quit
113
+ end
114
+ when QuitEvent
115
+ throw :rubygame_quit
116
+ end
117
+
118
+ # pass on our events to the GUI
119
+ app_adapter.on_event event
120
+ end
121
+
122
+ app_adapter.update clock.tick
123
+ app_adapter.draw render_adapter
124
+ end
63
125
  end
64
-
65
- app_adapter.update clock.tick
66
- app_adapter.draw render_adapter
67
126
  end
68
127
 
69
128
  == REQUIREMENTS:
70
129
 
71
130
  * publisher gem
72
131
  * constructor gem
73
- * rubygame gem (for now)
132
+ * rubygame gem or gosu
74
133
 
75
134
  == INSTALL:
76
135
 
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
 
6
6
  module Rubygoo
7
- VERSION = '0.0.5'
7
+ VERSION = '0.0.6'
8
8
  end
9
9
  Hoe.new('rubygoo', Rubygoo::VERSION) do |p|
10
10
  p.developer('Shawn Anderson', 'shawn42@gmail.com')
@@ -13,10 +13,11 @@ Hoe.new('rubygoo', Rubygoo::VERSION) do |p|
13
13
  p.email = 'boss@topfunky.com'
14
14
  p.summary = "Beautiful graphs for one or multiple datasets."
15
15
  p.url = "http://rubygoo.googlecode.com"
16
- p.changes = p.paragraphs_of('History.txt', 0..2).join("\n\n")
16
+ p.changes = p.paragraphs_of('History.txt', 6..7).join("\n\n")
17
17
  p.remote_rdoc_dir = '' # Release to root
18
18
  p.extra_deps << ['constructor']
19
19
  p.extra_deps << ['publisher']
20
+ p.extra_deps << ['rspec']
20
21
  end
21
22
 
22
23
  # run rubygame_app
@@ -35,4 +36,37 @@ task :stats do
35
36
  CodeStatistics.new(*STATS_DIRECTORIES).to_s
36
37
  end
37
38
 
39
+ begin
40
+ require 'spec/rake/spectask'
41
+
42
+ desc "Run all specs (tests)"
43
+ Spec::Rake::SpecTask.new do |t|
44
+ t.spec_files = FileList['test/*_spec.rb']
45
+ t.spec_opts = ["--format", "specdoc"]
46
+ end
47
+
48
+ rule(/spec:.+/) do |t|
49
+ name = t.name.gsub("spec:","")
50
+
51
+ path = File.join( File.dirname(__FILE__),'test','%s_spec.rb'%name )
52
+
53
+ if File.exist? path
54
+ Spec::Rake::SpecTask.new(name) do |t|
55
+ t.spec_files = [path]
56
+ end
57
+
58
+ puts "\nRunning spec/%s_spec.rb"%[name]
59
+ Rake::Task[name].invoke
60
+ else
61
+ puts "File does not exist: %s"%path
62
+ end
63
+ end
64
+
65
+ rescue LoadError
66
+ task :spec do
67
+ puts "ERROR: RSpec is not installed?"
68
+ end
69
+ end
70
+
71
+
38
72
  # vim: syntax=Ruby
data/TODO CHANGED
@@ -1,7 +1,8 @@
1
1
  TODO
2
- - make mouse cursor injectable
2
+ - KEYTOASCII in gosu adapter
3
+ - image icons for buttons
4
+ - create GooImage for agnostic access to image sizes, have renderer handle loading of images?
5
+ - double-check the tab focus stuff on modal dialogs (tab focus of containers?)
6
+ - can still tab through other widgets when modal dialog is up
3
7
  - make clicking on a component focus it
4
8
  - add more listener types (when mouse_enter, mouse_leave, mouse_click, focus, key_pressed...)
5
- - image icons for buttons
6
-
7
- - double-check the tab focus stuff on modal dialogs