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/History.txt
CHANGED
@@ -25,3 +25,15 @@
|
|
25
25
|
* small rendering bugs fixed
|
26
26
|
* added relative positioning of widgets
|
27
27
|
* added RadioButton and RadioGroup
|
28
|
+
|
29
|
+
=== 0.0.7 / 2008-12-6
|
30
|
+
|
31
|
+
* Getting closer to a 1.0 release
|
32
|
+
* added none options in themes
|
33
|
+
* added Icon widget
|
34
|
+
* cleaned up internals
|
35
|
+
* added show/hide and enable/disable to widgets
|
36
|
+
* added :label option to checkboxes
|
37
|
+
* added mouse_enter/exit events and hover states for button/checkboxes
|
38
|
+
* new color theme from nedric
|
39
|
+
* bug fixes
|
data/Manifest.txt
CHANGED
@@ -3,9 +3,7 @@ Manifest.txt
|
|
3
3
|
README.txt
|
4
4
|
Rakefile
|
5
5
|
TODO
|
6
|
-
docs/.DS_Store
|
7
6
|
docs/Picture 1.png
|
8
|
-
docs/ui/.DS_Store
|
9
7
|
docs/ui/UI.hpp
|
10
8
|
docs/ui/abutton.png
|
11
9
|
docs/ui/background.png
|
@@ -28,6 +26,7 @@ lib/rubygoo/css_colors.rb
|
|
28
26
|
lib/rubygoo/dialog.rb
|
29
27
|
lib/rubygoo/goo_color.rb
|
30
28
|
lib/rubygoo/goo_event.rb
|
29
|
+
lib/rubygoo/icon.rb
|
31
30
|
lib/rubygoo/label.rb
|
32
31
|
lib/rubygoo/mouse_cursor.rb
|
33
32
|
lib/rubygoo/radio_button.rb
|
data/README.txt
CHANGED
@@ -16,114 +16,114 @@ Rubygoo is a theme-able gui framework for use with rubygame and soon gosu. It ha
|
|
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
19
|
|
28
|
-
|
20
|
+
require 'rubygems'
|
21
|
+
$: << './lib'
|
22
|
+
$: << File.dirname(__FILE__)
|
23
|
+
require 'rubygoo'
|
24
|
+
require 'rubygame'
|
25
|
+
include Rubygame
|
26
|
+
include Rubygoo
|
29
27
|
|
30
|
-
|
31
|
-
screen.show_cursor = false
|
28
|
+
if $0 == __FILE__
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
icon = Surface.load File.dirname(__FILE__) + "/icon.png"
|
30
|
+
screen = Screen.new [600,480]
|
31
|
+
screen.show_cursor = false
|
36
32
|
|
37
|
-
|
33
|
+
factory = AdapterFactory.new
|
34
|
+
render_adapter = factory.renderer_for :rubygame, screen
|
35
|
+
icon = Surface.load File.dirname(__FILE__) + "/icon.png"
|
38
36
|
|
39
|
-
|
37
|
+
app = App.new :renderer => render_adapter
|
40
38
|
|
41
|
-
|
42
|
-
button.on :pressed do |*opts|
|
43
|
-
label.set_text(Time.now.to_s)
|
44
|
-
end
|
39
|
+
label = Label.new "click the button to set the time", :x=>20, :y=>30
|
45
40
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
button = Button.new "Click Me!", :x=>70, :y=>80, :x_pad=>20, :y_pad=>20, :icon => icon
|
42
|
+
button.on :pressed do |*opts|
|
43
|
+
label.set_text(Time.now.to_s)
|
44
|
+
end
|
50
45
|
|
51
|
-
|
46
|
+
check = CheckBox.new :x=>370, :y=>70, :w=>20, :h=>20
|
47
|
+
check.on :checked do
|
48
|
+
label.set_text("CHECKED [#{check.checked?}]")
|
49
|
+
end
|
52
50
|
|
53
|
-
|
54
|
-
puts "BOO-YAH"
|
55
|
-
end
|
51
|
+
text_field = TextField.new "initial text", :x => 70, :y => 170, :max_length => 20, :min_length => 6
|
56
52
|
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
text_field.on_key K_RETURN, K_KP_ENTER do |evt|
|
54
|
+
puts "BOO-YAH"
|
55
|
+
end
|
60
56
|
|
61
|
-
|
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
|
62
60
|
|
63
|
-
|
64
|
-
ok_butt.on :pressed do |*opts|
|
65
|
-
app.remove_modal(modal)
|
66
|
-
end
|
67
|
-
modal.add ok_butt
|
61
|
+
modal.add Label.new("Message Here", :x=>20, :y=>70, :x_pad=>20, :y_pad=>20, :relative=>true)
|
68
62
|
|
69
|
-
|
70
|
-
|
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.display
|
70
|
+
end
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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
|
+
|
80
|
+
# implicit tab ordering based on order of addition, can
|
81
|
+
# specify if you want on widget creation
|
82
|
+
|
83
|
+
# can add many or one at a time
|
84
|
+
app.add text_field, label, button, modal_button, grp
|
85
|
+
app.add check
|
86
|
+
|
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
|
93
|
+
|
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
|
112
115
|
throw :rubygame_quit
|
113
116
|
end
|
114
|
-
|
115
|
-
|
117
|
+
|
118
|
+
# pass on our events to the GUI
|
119
|
+
app_adapter.on_event event
|
116
120
|
end
|
117
121
|
|
118
|
-
|
119
|
-
app_adapter.
|
122
|
+
app_adapter.update clock.tick
|
123
|
+
app_adapter.draw render_adapter
|
120
124
|
end
|
121
|
-
|
122
|
-
app_adapter.update clock.tick
|
123
|
-
app_adapter.draw render_adapter
|
124
125
|
end
|
125
126
|
end
|
126
|
-
end
|
127
127
|
|
128
128
|
== REQUIREMENTS:
|
129
129
|
|
data/Rakefile
CHANGED
@@ -4,16 +4,16 @@ require 'rubygems'
|
|
4
4
|
require 'hoe'
|
5
5
|
|
6
6
|
module Rubygoo
|
7
|
-
VERSION = '0.0.
|
7
|
+
VERSION = '0.0.7'
|
8
8
|
end
|
9
9
|
Hoe.new('rubygoo', Rubygoo::VERSION) do |p|
|
10
10
|
p.developer('Shawn Anderson', 'shawn42@gmail.com')
|
11
11
|
p.author = "Shawn Anderson"
|
12
12
|
p.description = "GUI library for use with Gosu or Rubygame"
|
13
|
-
p.email = '
|
14
|
-
p.summary = "
|
13
|
+
p.email = 'shawn42@gmail.com'
|
14
|
+
p.summary = "Easy to use gui library for Rubygame or Gosu."
|
15
15
|
p.url = "http://rubygoo.googlecode.com"
|
16
|
-
p.changes = p.paragraphs_of('History.txt',
|
16
|
+
p.changes = p.paragraphs_of('History.txt', 8..8).join("\n\n")
|
17
17
|
p.remote_rdoc_dir = '' # Release to root
|
18
18
|
p.extra_deps << ['constructor']
|
19
19
|
p.extra_deps << ['publisher']
|
data/TODO
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
TODO
|
2
|
+
- enabled?/disabled? effect on tabbing?
|
3
|
+
- add show/hide effect on tabbing?
|
4
|
+
- tool tips
|
5
|
+
|
2
6
|
- KEYTOASCII in gosu adapter
|
3
7
|
- image icons for buttons
|
4
8
|
- 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
|
7
9
|
- make clicking on a component focus it
|
8
|
-
- add
|
10
|
+
- add key-call backs (alt-h, shift-L, ESC)
|
data/lib/rubygoo/app.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
require 'publisher'
|
2
|
+
|
1
3
|
module Rubygoo
|
2
4
|
class App < Container
|
5
|
+
extend Publisher
|
6
|
+
|
7
|
+
can_fire :evented
|
3
8
|
|
4
9
|
DEFAULT_PARAMS = {:theme=>'default',:x=>10,:y=>10,:data_dir=>File.join(File.dirname(__FILE__),"..","..","themes"),:mouse_cursor => true}
|
5
|
-
attr_accessor :theme_name, :theme, :data_dir, :theme_dir, :renderer, :tab_groups
|
10
|
+
attr_accessor :theme_name, :theme, :data_dir, :theme_dir, :renderer, :tab_groups, :mouse
|
6
11
|
|
7
12
|
def initialize(opts={})
|
8
13
|
merged_opts = DEFAULT_PARAMS.merge opts
|
@@ -39,8 +44,8 @@ module Rubygoo
|
|
39
44
|
|
40
45
|
def draw(screen)
|
41
46
|
@renderer.start_drawing
|
42
|
-
|
43
|
-
@mouse.
|
47
|
+
_draw @renderer
|
48
|
+
@mouse._draw @renderer if @mouse
|
44
49
|
@renderer.finish_drawing
|
45
50
|
end
|
46
51
|
|
@@ -65,9 +70,10 @@ module Rubygoo
|
|
65
70
|
end
|
66
71
|
|
67
72
|
def on_event(event)
|
73
|
+
fire :evented, event
|
68
74
|
case event.event_type
|
69
75
|
when :key_released
|
70
|
-
modal_keyboard_call :
|
76
|
+
modal_keyboard_call :_key_released, event
|
71
77
|
when :key_pressed
|
72
78
|
case event.data[:key]
|
73
79
|
when K_TAB
|
@@ -77,10 +83,10 @@ module Rubygoo
|
|
77
83
|
focus_forward
|
78
84
|
end
|
79
85
|
else
|
80
|
-
modal_keyboard_call :
|
86
|
+
modal_keyboard_call :_key_pressed, event
|
81
87
|
end
|
82
88
|
when :mouse_down
|
83
|
-
modal_mouse_call :
|
89
|
+
modal_mouse_call :_mouse_down, event
|
84
90
|
# TODO: I know this is simplistic and doesn't account for which button
|
85
91
|
# is being pressed/released
|
86
92
|
@mouse_start_x = event.data[:x]
|
@@ -89,9 +95,11 @@ module Rubygoo
|
|
89
95
|
x = event.data[:x]
|
90
96
|
y = event.data[:y]
|
91
97
|
if @mouse_start_x == x and @mouse_start_y == y
|
92
|
-
modal_mouse_call :
|
98
|
+
modal_mouse_call :_mouse_up, event
|
93
99
|
else
|
94
|
-
|
100
|
+
event.data[:start_x] = @mouse_start_x
|
101
|
+
event.data[:start_y] = @mouse_start_y
|
102
|
+
modal_mouse_call :_mouse_drag, event
|
95
103
|
end
|
96
104
|
@mouse_start_x = nil
|
97
105
|
@mouse_start_y = nil
|
@@ -99,11 +107,13 @@ module Rubygoo
|
|
99
107
|
x = event.data[:x]
|
100
108
|
y = event.data[:y]
|
101
109
|
if @mouse_start_x
|
102
|
-
|
110
|
+
event.data[:start_x] = @mouse_start_x
|
111
|
+
event.data[:start_y] = @mouse_start_y
|
112
|
+
modal_mouse_call :_mouse_dragging, event
|
103
113
|
else
|
104
|
-
modal_mouse_call :
|
114
|
+
modal_mouse_call :_mouse_motion, event
|
105
115
|
end
|
106
|
-
@mouse.
|
116
|
+
@mouse._mouse_motion event if @mouse
|
107
117
|
end
|
108
118
|
end
|
109
119
|
|
@@ -128,8 +138,8 @@ module Rubygoo
|
|
128
138
|
# distribute our mouse events to our modals first
|
129
139
|
def modal_mouse_call(meth, event)
|
130
140
|
if @modal_widgets.empty?
|
131
|
-
@widgets.each do |w|
|
132
|
-
w.send meth, event
|
141
|
+
@widgets.select{|w|w.enabled? and (w.contains? event.data[:x],event.data[:y] or meth == :_mouse_motion) }.each do |w|
|
142
|
+
w.send meth, event
|
133
143
|
end
|
134
144
|
else
|
135
145
|
@modal_widgets.last.send meth, event
|
@@ -139,13 +149,18 @@ module Rubygoo
|
|
139
149
|
# distribute our keyboard events to our modals first
|
140
150
|
def modal_keyboard_call(meth, event)
|
141
151
|
if @modal_widgets.empty?
|
142
|
-
@widgets.each do |w|
|
143
|
-
w.send meth, event
|
152
|
+
@widgets.select{|w|w.enabled? and w.focussed?}.each do |w|
|
153
|
+
w.send meth, event
|
144
154
|
end
|
145
155
|
else
|
146
156
|
@modal_widgets.last.send meth, event
|
147
157
|
end
|
148
158
|
end
|
149
159
|
|
160
|
+
def update(time)
|
161
|
+
_update(time)
|
162
|
+
end
|
163
|
+
|
164
|
+
|
150
165
|
end
|
151
166
|
end
|
data/lib/rubygoo/button.rb
CHANGED
@@ -11,13 +11,18 @@ module Rubygoo
|
|
11
11
|
|
12
12
|
def added()
|
13
13
|
font = theme_property :font
|
14
|
-
@font_size =
|
14
|
+
@font_size = @opts[:font_size]
|
15
|
+
@font_size ||= theme_property :font_size
|
15
16
|
@color = theme_property :color
|
16
17
|
@bg_color = theme_property :bg_color
|
17
18
|
@border_color = theme_property :border_color
|
18
19
|
@focus_color = theme_property :focus_color
|
20
|
+
@hover_color = theme_property :hover_color
|
21
|
+
@disabled_color = theme_property :disabled_color
|
22
|
+
|
19
23
|
@font_file = File.join(@app.theme_dir,font)
|
20
24
|
@rendered_text ||= @app.renderer.render_text @text, @font_file, @font_size, @color
|
25
|
+
|
21
26
|
@w = @rendered_text.width+2*@x_pad
|
22
27
|
@h = @rendered_text.height+2*@y_pad
|
23
28
|
@x = @x - @x_pad
|
@@ -59,6 +64,15 @@ module Rubygoo
|
|
59
64
|
if @border_color
|
60
65
|
adapter.draw_box x1, y1, x2, y2, @border_color
|
61
66
|
end
|
67
|
+
|
68
|
+
if mouse_over? and @hover_color
|
69
|
+
adapter.fill x1, y1, x2, y2, @hover_color
|
70
|
+
end
|
71
|
+
|
72
|
+
if @disabled_color and !enabled?
|
73
|
+
adapter.fill x1, y1, x2, y2, @disabled_color
|
74
|
+
end
|
75
|
+
|
62
76
|
if @icon
|
63
77
|
# TODO center icon
|
64
78
|
ix = x1#+((x2-x1)-@icon.w)
|
data/lib/rubygoo/check_box.rb
CHANGED
@@ -1,20 +1,45 @@
|
|
1
|
+
require 'label'
|
1
2
|
module Rubygoo
|
2
3
|
class CheckBox < Widget
|
3
4
|
attr_accessor :checked
|
4
5
|
can_fire :checked
|
6
|
+
DEFAULT_PARAMS = {:align=>:right}
|
5
7
|
def initialize(opts={})
|
8
|
+
opts = DEFAULT_PARAMS.merge opts
|
6
9
|
super opts
|
10
|
+
@checked = opts[:checked]
|
11
|
+
|
12
|
+
# only supports label on the right
|
13
|
+
# TODO maybe I should do this in added
|
14
|
+
@label_text = opts[:label]
|
15
|
+
@label_alignment = opts[:align]
|
7
16
|
end
|
8
17
|
|
9
18
|
def added()
|
10
|
-
@checked = false
|
11
19
|
@color = theme_property :color
|
12
20
|
@bg_color = theme_property :bg_color
|
13
21
|
@border_color = theme_property :border_color
|
14
22
|
@focus_color = theme_property :focus_color
|
15
23
|
@checked_color = theme_property :checked_color
|
24
|
+
@hover_color = theme_property :hover_color
|
16
25
|
|
17
26
|
@rect = Rect.new [@x-@x_pad,@y-@y_pad,@w+2*@x_pad,@h+2*@y_pad]
|
27
|
+
unless @label_text.nil? or @label_text.empty?
|
28
|
+
@label = Label.new @label_text, :x=>0,:y=>0, :relative=>@relative, :visible=>false
|
29
|
+
@parent.add @label
|
30
|
+
|
31
|
+
case @label_alignment
|
32
|
+
when :right
|
33
|
+
lx = @x+2*@x_pad+@w
|
34
|
+
ly = @y
|
35
|
+
when :left
|
36
|
+
ly = @y
|
37
|
+
lx = @x-2*@x_pad-@label.w
|
38
|
+
end
|
39
|
+
@label.x = lx
|
40
|
+
@label.y = ly
|
41
|
+
@label.show
|
42
|
+
end
|
18
43
|
end
|
19
44
|
|
20
45
|
def checked?()
|
@@ -77,6 +102,10 @@ module Rubygoo
|
|
77
102
|
adapter.fill cx1, cy1, cx2, cy2, @checked_color
|
78
103
|
end
|
79
104
|
|
105
|
+
if mouse_over? and @hover_color
|
106
|
+
adapter.fill x1, y1, x2, y2, @hover_color
|
107
|
+
end
|
108
|
+
|
80
109
|
if @border_color
|
81
110
|
adapter.draw_box x1, y1, x2, y2, @border_color
|
82
111
|
end
|
data/lib/rubygoo/container.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
require 'publisher'
|
2
1
|
module Rubygoo
|
3
2
|
class Container < Widget
|
4
|
-
extend Publisher
|
5
3
|
attr_accessor :widgets, :bg_color, :rect, :queued_widgets
|
6
4
|
|
7
5
|
def initialize(opts={})
|
@@ -64,7 +62,7 @@ module Rubygoo
|
|
64
62
|
end
|
65
63
|
|
66
64
|
# draw ourself and our children
|
67
|
-
def
|
65
|
+
def _draw(adapter)
|
68
66
|
# any container specific code here (border_colors?)
|
69
67
|
if @bg_color
|
70
68
|
if app == self
|
@@ -77,61 +75,68 @@ module Rubygoo
|
|
77
75
|
adapter.fill x1, y1, x2, y2, @bg_color
|
78
76
|
end
|
79
77
|
end
|
78
|
+
draw adapter unless app == self
|
80
79
|
|
81
80
|
# draw kiddies
|
82
|
-
@widgets.each do |w|
|
83
|
-
w.
|
81
|
+
@widgets.select{|w|w.visible?}.each do |w|
|
82
|
+
w._draw adapter
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
87
86
|
# called when there is a mouse motion
|
88
|
-
def
|
89
|
-
|
90
|
-
|
87
|
+
def _mouse_motion(event)
|
88
|
+
mouse_motion event
|
89
|
+
@widgets.select{|w|w.enabled?}.each do |w|
|
90
|
+
w._mouse_motion event
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
# called when there is a mouse click
|
95
|
-
def
|
96
|
-
|
97
|
-
|
95
|
+
def _mouse_down(event)
|
96
|
+
mouse_down event
|
97
|
+
@widgets.select{|w|w.enabled? and w.contains? event.data[:x],event.data[:y] }.each do |w|
|
98
|
+
w._mouse_down event
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
101
102
|
# called when there is a mouse release
|
102
|
-
def
|
103
|
-
|
104
|
-
|
103
|
+
def _mouse_up(event)
|
104
|
+
mouse_up event
|
105
|
+
@widgets.select{|w| w.contains? event.data[:x],event.data[:y] and w.enabled?}.each do |w|
|
106
|
+
w._mouse_up event
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
108
110
|
# called when there is a mouse release after dragging
|
109
|
-
def
|
110
|
-
|
111
|
-
|
111
|
+
def _mouse_drag(event)
|
112
|
+
mouse_drag event
|
113
|
+
@widgets.select{|w| w.contains? event.data[:x],event.data[:y] and w.enabled?}.each do |w|
|
114
|
+
w._mouse_drag event
|
112
115
|
end
|
113
116
|
end
|
114
117
|
|
115
118
|
# pass on the key press to our widgets
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
+
def _key_pressed(event)
|
120
|
+
key_pressed event
|
121
|
+
@widgets.select{|w| w.enabled? and w.focussed?}.each do |w|
|
122
|
+
w._key_pressed event
|
119
123
|
end
|
120
124
|
end
|
121
125
|
|
122
126
|
# pass on the key release to our widgets
|
123
|
-
def
|
124
|
-
|
125
|
-
|
127
|
+
def _key_released(event)
|
128
|
+
key_released event
|
129
|
+
@widgets.select{|w| w.enabled? and w.focussed?}.each do |w|
|
130
|
+
w._key_released event
|
126
131
|
end
|
127
132
|
end
|
128
133
|
|
129
|
-
|
130
134
|
# called each update cycle with the amount of time that has passed. useful
|
131
135
|
# for animations, etc
|
132
|
-
def
|
133
|
-
|
134
|
-
|
136
|
+
def _update(time)
|
137
|
+
update time unless app == self
|
138
|
+
@widgets.select{|w|w.enabled?}.each do |w|
|
139
|
+
w._update time
|
135
140
|
end
|
136
141
|
end
|
137
142
|
|
data/lib/rubygoo/css_colors.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module Rubygoo
|
3
3
|
# colors from: http://www.w3schools.com/css/css_colornames.asp
|
4
|
-
|
4
|
+
new_colors = {
|
5
5
|
:AliceBlue => [240,248,255,255],
|
6
6
|
:AntiqueWhite => [250,235,215,255],
|
7
7
|
:Aqua => [0,255,255,255],
|
@@ -150,4 +150,5 @@ module Rubygoo
|
|
150
150
|
:Yellow => [255,255,0],
|
151
151
|
:YellowGreen => [154,205,50,255]
|
152
152
|
}
|
153
|
+
COLORS.merge! new_colors
|
153
154
|
end
|
data/lib/rubygoo/dialog.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
module Rubygoo
|
2
2
|
class Dialog < Container
|
3
3
|
|
4
|
-
def initialize(opts
|
4
|
+
def initialize(opts)
|
5
5
|
super opts
|
6
|
-
@close_callback = close_callback if block_given?
|
7
6
|
@modal_target = opts[:modal]
|
8
7
|
end
|
9
8
|
|
@@ -15,8 +14,6 @@ module Rubygoo
|
|
15
14
|
|
16
15
|
@border_color = theme_property :border_color
|
17
16
|
@focus_color = theme_property :focus_color
|
18
|
-
|
19
|
-
@rect = Rect.new [@x-@x_pad,@y-@y_pad,@w+2*@x_pad,@h+2*@y_pad]
|
20
17
|
end
|
21
18
|
|
22
19
|
def modal?()
|
@@ -25,10 +22,15 @@ module Rubygoo
|
|
25
22
|
|
26
23
|
# show the dialog by adding it to the @modal_target and
|
27
24
|
# intercepting all of its events
|
28
|
-
def
|
25
|
+
def display()
|
29
26
|
@modal_target.add_modal self
|
30
27
|
end
|
31
28
|
|
29
|
+
# close this modal dialog
|
30
|
+
def close()
|
31
|
+
@modal_target.remove_modal self
|
32
|
+
end
|
33
|
+
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
data/lib/rubygoo/goo_color.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
require 'css_colors'
|
2
1
|
module Rubygoo
|
2
|
+
COLORS = {} unless const_defined? 'COLORS'
|
3
|
+
require 'css_colors'
|
4
|
+
|
3
5
|
# is an rbga color
|
4
6
|
class GooColor
|
5
7
|
attr_accessor :r,:g,:b,:a
|
@@ -7,10 +9,11 @@ module Rubygoo
|
|
7
9
|
@r,@g,@b,@a = r,g,b,a
|
8
10
|
end
|
9
11
|
|
10
|
-
def self.
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def self.color(color, alpha=nil)
|
13
|
+
c = COLORS[color]
|
14
|
+
c ||= [0,0,0,255]
|
15
|
+
c[3] = alpha if alpha
|
16
|
+
GooColor.new *c
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|