ffi-efl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/Changelog +13 -1
  2. data/README.rdoc +24 -14
  3. data/lib/efl/ecore.rb +7 -7
  4. data/lib/efl/ecore_evas.rb +78 -0
  5. data/lib/efl/ecore_getopt.rb +28 -29
  6. data/lib/efl/ecore_input.rb +14 -0
  7. data/lib/efl/edje.rb +47 -1
  8. data/lib/efl/eet.rb +18 -25
  9. data/lib/efl/eina.rb +14 -0
  10. data/lib/efl/eina_hash.rb +84 -0
  11. data/lib/efl/eina_list.rb +77 -0
  12. data/lib/efl/elementary.rb +22 -9
  13. data/lib/efl/evas.rb +67 -25
  14. data/lib/efl/{ecore/ecore-ffi.rb → ffi/ecore.rb} +8 -5
  15. data/lib/efl/{ecore/ecore_evas-ffi.rb → ffi/ecore_evas.rb} +10 -7
  16. data/lib/efl/{ecore/ecore_getopt-ffi.rb → ffi/ecore_getopt.rb} +8 -5
  17. data/lib/efl/{ecore/ecore_input-ffi.rb → ffi/ecore_input.rb} +9 -6
  18. data/lib/efl/{edje/edje-ffi.rb → ffi/edje.rb} +10 -7
  19. data/lib/efl/{eet/eet-ffi.rb → ffi/eet.rb} +8 -5
  20. data/lib/efl/ffi/eina.rb +48 -0
  21. data/lib/efl/ffi/eina_hash.rb +111 -0
  22. data/lib/efl/ffi/eina_list.rb +108 -0
  23. data/lib/efl/{eina/eina_types-ffi.rb → ffi/eina_types.rb} +8 -5
  24. data/lib/efl/{elementary/elementary-ffi.rb → ffi/elementary.rb} +16 -9
  25. data/lib/efl/{evas/evas-ffi.rb → ffi/evas.rb} +153 -150
  26. data/lib/efl/ffi.rb +81 -38
  27. data/lib/efl.rb +9 -4
  28. data/spec/ecore_evas_spec.rb +24 -0
  29. data/spec/ecore_getopt_spec.rb +1 -2
  30. data/spec/ecore_input_spec.rb +24 -0
  31. data/spec/ecore_spec.rb +2 -3
  32. data/spec/edje_spec.rb +1 -1
  33. data/spec/eet_spec.rb +68 -69
  34. data/spec/eina_hash_spec.rb +180 -0
  35. data/spec/eina_list_spec.rb +101 -0
  36. data/spec/eina_spec.rb +20 -0
  37. data/spec/evas_spec.rb +288 -40
  38. data/tasks/ffi.rake +1 -1
  39. data/test/test_edje.rb +141 -0
  40. data/test/test_elm_win.rb +25 -28
  41. data/test/test_elm_win_class.rb +7 -7
  42. data/test/test_evas.rb +106 -0
  43. metadata +30 -17
@@ -0,0 +1,101 @@
1
+ #! /usr/bin/env ruby
2
+ # -*- coding: UTF-8 -*-
3
+ #
4
+ require 'efl/eina'
5
+ require 'efl/eina_list'
6
+ #
7
+ describe Efl::EinaList do
8
+ #
9
+ before(:all) {
10
+ REinaList = Efl::EinaList::REinaList
11
+ Efl::Eina.init.should eql 1
12
+ }
13
+ after(:all) {
14
+ Efl::Eina.shutdown.should eql 0
15
+ }
16
+ #
17
+ it "should append prepend and fetch" do
18
+ l = REinaList.new
19
+ d1 = ::FFI::MemoryPointer.from_string "D0"
20
+ d2 = ::FFI::MemoryPointer.from_string "D1"
21
+ d3 = ::FFI::MemoryPointer.from_string "D2"
22
+ d4 = ::FFI::MemoryPointer.from_string "D3"
23
+ l.append d3
24
+ l.prepend d2
25
+ l << d4
26
+ l.unshift d1
27
+ 0.upto 3 do |i|
28
+ l.nth(i).read_string.should eql "D#{i}"
29
+ end
30
+ l.each { |p| p.read_string.empty?.should be_false }
31
+ l.free
32
+ end
33
+ #
34
+ it "should be able to convert into ruby Array from NULL pointer" do
35
+ ary = Array.from_eina_list ::FFI::Pointer::NULL
36
+ ary.empty?.should be_true
37
+ ary.is_a?(Array).should be_true
38
+ end
39
+ #
40
+ it "should be able to convert into ruby Array from empty REinaList" do
41
+ ary = Array.from_eina_list REinaList.new
42
+ ary.empty?.should be_true
43
+ ary.is_a?(Array).should be_true
44
+ end
45
+ #
46
+ it "should be able to convert into ruby Array from empty REinaList pointer" do
47
+ ary = Array.from_eina_list REinaList.new.to_ptr
48
+ ary.empty?.should be_true
49
+ ary.is_a?(Array).should be_true
50
+ end
51
+ #
52
+ it "should be able to convert into ruby Array from non empty REinaList" do
53
+ l = REinaList.new
54
+ d1 = ::FFI::MemoryPointer.from_string "D0"
55
+ d2 = ::FFI::MemoryPointer.from_string "D1"
56
+ d3 = ::FFI::MemoryPointer.from_string "D2"
57
+ d4 = ::FFI::MemoryPointer.from_string "D3"
58
+ l.append d3
59
+ l.prepend d2
60
+ l << d4
61
+ l.unshift d1
62
+ ary = Array.from_eina_list l
63
+ ary.length.should eql 4
64
+ 0.upto 3 do |i|
65
+ ary[i].read_string.should eql "D#{i}"
66
+ end
67
+ l.free
68
+ end
69
+ #
70
+ it "should be able to convert into ruby Array from non empty REinaList pointer" do
71
+ l = REinaList.new
72
+ d1 = ::FFI::MemoryPointer.from_string "D0"
73
+ d2 = ::FFI::MemoryPointer.from_string "D1"
74
+ d3 = ::FFI::MemoryPointer.from_string "D2"
75
+ d4 = ::FFI::MemoryPointer.from_string "D3"
76
+ l.append d3
77
+ l.prepend d2
78
+ l << d4
79
+ l.unshift d1
80
+ ary = Array.from_eina_list l.to_ptr
81
+ ary.length.should eql 4
82
+ 0.upto 3 do |i|
83
+ ary[i].read_string.should eql "D#{i}"
84
+ end
85
+ l.free
86
+ end
87
+ #
88
+ it "should be able to build from ruby Array" do
89
+ a = []
90
+ a << ::FFI::MemoryPointer.from_string("D0")
91
+ a << ::FFI::MemoryPointer.from_string("D1")
92
+ a << ::FFI::MemoryPointer.from_string("D2")
93
+ a << ::FFI::MemoryPointer.from_string("D3")
94
+ l = REinaList.new a
95
+ 0.upto 3 do |i|
96
+ l.nth(i).read_string.should eql "D#{i}"
97
+ end
98
+ l.free
99
+ end
100
+ #
101
+ end
data/spec/eina_spec.rb ADDED
@@ -0,0 +1,20 @@
1
+ #! /usr/bin/env ruby
2
+ # -*- coding: UTF-8 -*-
3
+ #
4
+ require 'efl/eina'
5
+ #
6
+ describe Efl::Eina do
7
+ #
8
+ it "should init" do
9
+ Efl::Eina.init.should eql 1
10
+ Efl::Eina.init.should eql 2
11
+ Efl::Eina.init.should eql 3
12
+ end
13
+ #
14
+ it "should shutdown" do
15
+ Efl::Eina.shutdown.should eql 2
16
+ Efl::Eina.shutdown.should eql 1
17
+ Efl::Eina.shutdown.should eql 0
18
+ end
19
+ #
20
+ end
data/spec/evas_spec.rb CHANGED
@@ -5,7 +5,7 @@ require 'efl/evas'
5
5
  #
6
6
  describe Efl::Evas do
7
7
  #
8
- include Efl
8
+ before(:all) { Evas = Efl::Evas }
9
9
  #
10
10
  it "should init" do
11
11
  Evas.init.should eql 1
@@ -20,15 +20,15 @@ describe Efl::Evas do
20
20
  end
21
21
  #
22
22
  it "evas alloc error enum is ok" do
23
- Efl::API.enum_value(:evas_alloc_error_none).should eql 0
24
- Efl::API.enum_value(:evas_alloc_error_fatal).should eql 1
25
- Efl::API.enum_value(:evas_alloc_error_recovered).should eql 2
26
- Efl::API.enum_type(:evas_alloc_error)[0].should eql :evas_alloc_error_none
27
- Efl::API.enum_type(:evas_alloc_error)[1].should eql :evas_alloc_error_fatal
28
- Efl::API.enum_type(:evas_alloc_error)[2].should eql :evas_alloc_error_recovered
29
- Efl::API.enum_type(:evas_alloc_error)[:evas_alloc_error_none].should eql 0
30
- Efl::API.enum_type(:evas_alloc_error)[:evas_alloc_error_fatal].should eql 1
31
- Efl::API.enum_type(:evas_alloc_error)[:evas_alloc_error_recovered].should eql 2
23
+ Efl::Evas.enum_value(:evas_alloc_error_none).should eql 0
24
+ Efl::Evas.enum_value(:evas_alloc_error_fatal).should eql 1
25
+ Efl::Evas.enum_value(:evas_alloc_error_recovered).should eql 2
26
+ Efl::Evas.enum_type(:evas_alloc_error)[0].should eql :evas_alloc_error_none
27
+ Efl::Evas.enum_type(:evas_alloc_error)[1].should eql :evas_alloc_error_fatal
28
+ Efl::Evas.enum_type(:evas_alloc_error)[2].should eql :evas_alloc_error_recovered
29
+ Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_none].should eql 0
30
+ Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_fatal].should eql 1
31
+ Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_recovered].should eql 2
32
32
  end
33
33
  #
34
34
  it "should have no memory allocation error occured" do
@@ -52,15 +52,39 @@ describe Efl::Evas do
52
52
  Evas.shutdown
53
53
  end
54
54
  #
55
- describe Efl::Evas::Evas do
55
+ describe Efl::Evas::REvas do
56
+ before(:all) do
57
+ Evas.init
58
+ @width = 800
59
+ @height = 600
60
+ @pixels = FFI::MemoryPointer.new :int, @width*@height
61
+ @e = Evas::REvas.new
62
+ @e.output_method_set Evas::render_method_lookup("buffer")
63
+ @e.output_viewport_set 0, 0, @width, @height
64
+ @e.output_size_set @width, @height
65
+ einfo = Efl::Evas::EngineInfoBufferStruct.new @e.engine_info_get
66
+ einfo[:info][:depth_type] = Efl::Evas::EVAS_ENGINE_BUFFER_DEPTH_ARGB32
67
+ einfo[:info][:dest_buffer] = @pixels
68
+ einfo[:info][:dest_buffer_row_bytes] = @width * FFI::type_size(:int);
69
+ einfo[:info][:use_color_key] = 0;
70
+ einfo[:info][:alpha_threshold] = 0;
71
+ einfo[:info][:func][:new_update_region] = nil #FFI::Pointer::NULL;
72
+ einfo[:info][:func][:free_update_region] = nil #FFI::Pointer::NULL;
73
+ @e.engine_info_set einfo
74
+ end
75
+ after(:all) do
76
+ @e.free
77
+ @pixels.free
78
+ Evas.shutdown
79
+ end
56
80
  it "should be able to create and destroy evas" do
57
- e1 = Evas::Evas.new
58
- e1.ptr.address.should_not eql 0
59
- e2 = Evas::Evas.new e1
60
- e1.ptr.address.should eql e2.ptr.address
61
- e3 = Evas::Evas.new e1.ptr
62
- e1.ptr.address.should eql e3.ptr.address
63
- e2.ptr.address.should eql e3.ptr.address
81
+ e1 = Evas::REvas.new
82
+ e1.address.should_not eql 0
83
+ e2 = Evas::REvas.new e1
84
+ e1.address.should eql e2.address
85
+ e3 = Evas::REvas.new e1.to_ptr
86
+ e1.address.should eql e3.address
87
+ e2.address.should eql e3.address
64
88
  (e1==e2).should be_false
65
89
  (e2==e3).should be_false
66
90
  (e1==e3).should be_false
@@ -68,36 +92,260 @@ describe Efl::Evas do
68
92
  (e2===e3).should be_true
69
93
  (e1===e3).should be_true
70
94
  e1.free
71
- e1.ptr.should be_nil
72
- e4 = Evas::Evas.new Efl::API.evas_new
73
- e4.ptr.address.should_not eql 0
95
+ e1.to_ptr.should be_nil
96
+ e4 = Evas::REvas.new Evas.evas_new
97
+ e4.address.should_not eql 0
74
98
  e5 = e4.dup
75
- e4.ptr.address.should eql e5.ptr.address
99
+ e4.address.should eql e5.address
76
100
  e6 = e4.clone
77
- e4.ptr.address.should eql e6.ptr.address
101
+ e4.address.should eql e6.address
78
102
  e4.free
79
- e4.ptr.should be_nil
103
+ e4.to_ptr.should be_nil
80
104
  end
81
105
  #
82
106
  it "focus should work" do
83
- e = Evas::Evas.new
84
- Efl::API.evas_focus_in e.ptr
85
- Efl::API.evas_focus_state_get(e.ptr).should be_true
86
- Efl::API.evas_focus_out e.ptr
87
- Efl::API.evas_focus_state_get(e.ptr).should be_false
88
- Efl::Evas.focus_in e.ptr
89
- Efl::Evas.focus_state_get(e.ptr).should be_true
90
- Efl::Evas.focus_out e.ptr
91
- Efl::Evas.focus_state_get(e.ptr).should be_false
92
- e.focus_in { |r| r.should be_nil }
93
- e.focus_state_get.should be_true
94
- e.focus_state_get { |r| r.should be_true }
95
- e.focus_out.should be_nil
96
- e.focus_state_get.should be_false
97
- e.focus_state_get { |r| r.should be_false }
98
- e.free
107
+ Efl::Evas.evas_focus_in @e.to_ptr
108
+ Efl::Evas.evas_focus_state_get(@e.to_ptr).should be_true
109
+ Efl::Evas.evas_focus_out @e.to_ptr
110
+ Efl::Evas.evas_focus_state_get(@e.to_ptr).should be_false
111
+ Efl::Evas.focus_in @e.to_ptr
112
+ Efl::Evas.focus_state_get(@e.to_ptr).should be_true
113
+ Efl::Evas.focus_out @e.to_ptr
114
+ Efl::Evas.focus_state_get(@e.to_ptr).should be_false
115
+ @e.focus_in { |r| r.should be_nil }
116
+ @e.focus_state_get.should be_true
117
+ @e.focus_state_get { |r| r.should be_true }
118
+ @e.focus_out.should be_nil
119
+ @e.focus_state_get.should be_false
120
+ @e.focus_state_get { |r| r.should be_false }
121
+ end
122
+ #
123
+ it "nochange should work" do
124
+ @e.nochange_push
125
+ @e.nochange_pop
126
+ end
127
+ #
128
+ it "attach data should work" do
129
+ data = FFI::MemoryPointer.from_string "my data"
130
+ @e.data_attach_set data
131
+ @e.data_attach_get.read_string.should eql "my data"
132
+ end
133
+ #
134
+ it "should not crash" do
135
+ @e.damage_rectangle_add 1, 2, 3, 4
136
+ @e.obscured_rectangle_add 1, 2, 3, 4
137
+ @e.obscured_clear
138
+ list = @e.render_updates
139
+ Evas.render_updates_free list
140
+ @e.render
141
+ @e.norender
142
+ @e.render_idle_flush
143
+ @e.render_dump
144
+ end
145
+ it "output method should work" do
146
+ @e.output_method_get.should eql Evas::render_method_lookup("buffer")
147
+ # output_method_set tested in before(:all)
148
+ l = Efl::Evas::render_method_list
149
+ Evas::render_method_list_free l
150
+ end
151
+ #
152
+ it "engine info should work" do
153
+ # engine_info_get and engine_info_set tested in before(:all)
154
+ true.should be_true
155
+ end
156
+ #
157
+ it "output size should work" do
158
+ @e.output_size_set 69, 666
159
+ @e.output_size_get.should eql [69,666]
160
+ end
161
+ it "output viewport should work" do
162
+ @e.output_viewport_set 0, 0, 666, 69
163
+ @e.output_viewport_get.should eql [0,0,666,69]
164
+ end
165
+ #
166
+ it "coordinates evas<=>world should work" do
167
+ @e.output_viewport_set 0, 0, 800, 600
168
+ x = @e.coord_screen_x_to_world 666
169
+ r = @e.coord_world_x_to_screen x
170
+ r.should <= 668
171
+ r.should >= 664
172
+ y = @e.coord_screen_y_to_world 69
173
+ r = @e.coord_world_y_to_screen y
174
+ r.should <= 71
175
+ r.should >= 67
176
+ end
177
+ #
178
+ it "freeze and thaw should work" do
179
+ @e.event_freeze_get.should eql 0
180
+ @e.event_freeze
181
+ @e.event_freeze_get.should eql 1
182
+ @e.event_thaw
183
+ @e.event_freeze_get.should eql 0
184
+ end
185
+ #
186
+ it "up/down mouse event should work" do
187
+ @e.event_feed_mouse_down 2, :evas_button_double_click, Time.now.to_i, FFI::Pointer::NULL
188
+ @e.pointer_button_down_mask_get.should eql 2
189
+ @e.event_feed_mouse_up 2, :evas_button_double_click, Time.now.to_i, FFI::Pointer::NULL
190
+ @e.pointer_button_down_mask_get.should eql 0
191
+ end
192
+ #
193
+ it "move mouse event should work" do
194
+ @e.pointer_output_xy_get.should eql [0,0]
195
+ @e.pointer_canvas_xy_get.should eql [0,0]
196
+ @e.event_feed_mouse_move 6, 6, Time.now.to_i, FFI::Pointer::NULL
197
+ @e.pointer_output_xy_get.should eql [6,6]
198
+ @e.pointer_canvas_xy_get.should eql [6,6]
199
+ end
200
+ #
201
+ it "in/out mouse event should work" do
202
+ @e.pointer_inside_get.should be_false
203
+ @e.event_feed_mouse_in Time.now.to_i, FFI::Pointer::NULL
204
+ @e.pointer_inside_get.should be_true
205
+ @e.event_feed_mouse_out Time.now.to_i, FFI::Pointer::NULL
206
+ @e.pointer_inside_get.should be_false
207
+ end
208
+ #
209
+ # TODO
210
+ # evas_event_feed_multi_down
211
+ # evas_event_feed_multi_up
212
+ # evas_event_feed_multi_move
213
+ # evas_event_feed_mouse_cancel
214
+ # evas_event_feed_mouse_wheel
215
+ # evas_event_feed_key_down
216
+ # evas_event_feed_key_up
217
+ # evas_event_feed_hold
218
+ #
219
+ it "add/del event callback should work" do
220
+ @cb = false
221
+ kd_cb = Proc.new do |data, e, obj, event_info|
222
+ data.read_string.should eq "mouse_in"
223
+ e.address.should eql @e.address
224
+ obj.address.should eql @bg.address
225
+ @db=true
226
+ true
227
+ end
228
+ kd_d = FFI::MemoryPointer.from_string "mouse_in"
229
+ @bg = Evas::REvasObject.new @e.object_rectangle_add
230
+ @bg.move 0, 0
231
+ @bg.resize 20, 20
232
+ @bg.show
233
+ @bg.event_callback_add :evas_callback_mouse_in, kd_cb, kd_d
234
+ @e.event_feed_mouse_in Time.now.to_i, FFI::Pointer::NULL
235
+ @bg.event_callback_del(:evas_callback_mouse_in, kd_cb).address.should eql kd_d.address
236
+ @db.should be_true
237
+ end
238
+ #
239
+ it "image cache functions should work" do
240
+ @e.image_cache_flush
241
+ @e.image_cache_reload
242
+ @e.image_cache_set 666
243
+ @e.image_cache_get.should eql 666
244
+ end
245
+ #
246
+ it "font functions should work" do
247
+ @e.font_hinting_set :evas_font_hinting_bytecode
248
+ @e.font_hinting_get.should eql :evas_font_hinting_bytecode
249
+ @e.font_hinting_can_hint(:evas_font_hinting_none).should be_true
250
+ @e.font_cache_flush
251
+ @e.font_cache_set 666
252
+ @e.font_cache_get.should eql 666
253
+ l = @e.font_available_list
254
+ @e.font_available_list_free l
255
+ @e.font_path_clear
256
+ a = ['/tmp1','/tmp2']
257
+ @e.font_path_append a[1]
258
+ @e.font_path_prepend a[0]
259
+ require 'efl/eina_list'
260
+ Efl::EinaList::REinaList.new(@e.font_path_list).each_with_index do |p,i|
261
+ p.read_string.should eql a[i]
262
+ end
263
+ end
264
+ end
265
+ describe Efl::Evas::REvasObject do
266
+ #
267
+ before(:all) do
268
+ Evas.init
269
+ @pixels = FFI::MemoryPointer.new :int, 100*100
270
+ @e = Evas::REvas.new
271
+ @e.output_method_set Evas::render_method_lookup("buffer")
272
+ @e.output_viewport_set 0, 0, 100, 100
273
+ @e.output_size_set 100, 100
274
+ einfo = Efl::Evas::EngineInfoBufferStruct.new @e.engine_info_get
275
+ einfo[:info][:depth_type] = Efl::Evas::EVAS_ENGINE_BUFFER_DEPTH_ARGB32
276
+ einfo[:info][:dest_buffer] = @pixels
277
+ einfo[:info][:dest_buffer_row_bytes] = 100 * FFI::type_size(:int);
278
+ einfo[:info][:use_color_key] = 0;
279
+ einfo[:info][:alpha_threshold] = 0;
280
+ einfo[:info][:func][:new_update_region] = nil #FFI::Pointer::NULL;
281
+ einfo[:info][:func][:free_update_region] = nil #FFI::Pointer::NULL;
282
+ @e.engine_info_set einfo
283
+ @o = @e.object_add :rectangle
284
+ @o.color = 200,200,200,200
285
+ @o.move 0, 0
286
+ @o.resize 100, 100
287
+ @o.show
288
+ end
289
+ after(:all) do
290
+ @e.free
291
+ @o.free
292
+ @pixels.free
293
+ Evas.shutdown
99
294
  end
100
295
  #
296
+ it "clipper should work" do
297
+ clipper = @e.object_add :rectangle
298
+ clipper.color = 255,255,255,255
299
+ clipper.move 25, 25
300
+ clipper.resize 50, 50
301
+ @o.clip = clipper.to_ptr
302
+ clipper.show
303
+ @o.clip_get.address.should eql clipper.address
304
+ require 'efl/eina_list'
305
+ Efl::EinaList::REinaList.new(clipper.clipees_get).to_ary[0].address.should eql @o.address
306
+ @o.clip_unset
307
+ @o.clip_get.address.should eql 0
308
+
309
+ end
310
+ #
311
+ it "focus functions should work" do
312
+ @o.focus_get.should be_false
313
+ @o.focus_set true
314
+ @o.focus_get.should be_true
315
+ @o.focus = false
316
+ @o.focus_get.should be_false
317
+ end
318
+ #
319
+ it "layer functions should work" do
320
+ @o.layer_get.should eql 0
321
+ @o.layer_set 2
322
+ @o.layer_get.should eql 2
323
+ @o.layer = 0
324
+ @o.layer_get.should eql 0
325
+ end
326
+ #
327
+ it "name functions should work" do
328
+ @o.name_set "My name"
329
+ @o.name_get.should eql "My name"
330
+ end
331
+ #
332
+ it "geometry functions should work" do
333
+ # FIXME
334
+ # @o.geometry_get.should eql [0,0,100,100]
335
+ # @o.resize 50,50
336
+ # @o.geometry_get.should eql [0,0,50,50]
337
+ # @o.move 10, 10
338
+ # @o.geometry_get.should eql [10,10,50,50]
339
+ end
340
+ #
341
+ it "show hide visible should work" do
342
+ @o.show
343
+ @o.visible?.should be_true
344
+ @o.hide
345
+ @o.visible_get.should be_false
346
+ @o.show
347
+ @o.visible?.should be_true
348
+ end
101
349
  end
102
350
  #
103
351
  end
data/tasks/ffi.rake CHANGED
@@ -12,7 +12,7 @@ namespace :ffi do
12
12
  #
13
13
  desc "generate ffi bindings"
14
14
  task :ruby do
15
- sh 'ruby ./tools/genruby.rb'
15
+ sh './tools/genruby.rb'
16
16
  end
17
17
  end
18
18
  #
data/test/test_edje.rb ADDED
@@ -0,0 +1,141 @@
1
+ #! /usr/bin/env ruby
2
+ # -*- coding: UTF-8 -*-
3
+ #
4
+ require 'efl/eina'
5
+ require 'efl/evas'
6
+ require 'efl/ecore'
7
+ require 'efl/ecore_evas'
8
+ require 'efl/edje'
9
+ #
10
+ Efl::Eina::init
11
+ Efl::Evas::init
12
+ Efl::Ecore::init
13
+ Efl::EcoreEvas::init
14
+ Efl::Edje::init
15
+ #
16
+ WIDTH=320
17
+ HEIGHT=240
18
+ EDC_FILE=File.join '/tmp','edje_test.edc'
19
+ EDJE_FILE=File.join '/tmp','edje_test.edj'
20
+ #
21
+ if not File.exists? EDJE_FILE
22
+ File.open(EDC_FILE,'w') do |f| f << DATA.read end
23
+ system "edje_cc #{EDC_FILE}"
24
+ end
25
+ #
26
+ def create_my_group canvas, txt
27
+ #edje = edje_object_add(canvas);
28
+ edje = canvas.edje_object_add
29
+ if not edje.file_set EDJE_FILE, "my_group"
30
+ puts "unable to open #{EDJE_FILE}"
31
+ exit 1
32
+ end
33
+ edje.part_text_set "text", txt unless txt.nil?
34
+ edje.move 0, 0
35
+ edje.resize WIDTH, HEIGHT
36
+ edje.show
37
+ edje
38
+ end
39
+ #
40
+ txt = ( ARGV.length>0 ? ARGV[0] : nil )
41
+ #
42
+ window = Efl::EcoreEvas::REcoreEvas.new { |w|
43
+ w.resize WIDTH, HEIGHT
44
+ }
45
+ #
46
+ canvas = window.get
47
+ edje = create_my_group canvas, txt
48
+ window.show
49
+ #
50
+ Efl::Ecore.main_loop_begin
51
+ #
52
+ edje.free
53
+ window.free
54
+ #
55
+
56
+ __END__
57
+
58
+ // compile: edje_cc edje_example.edc
59
+ collections {
60
+ group {
61
+ name: "my_group"; // must be the same as in edje_example.c
62
+ parts {
63
+ part {
64
+ name: "background";
65
+ type: RECT; // plain boring rectangle
66
+ mouse_events: 0; // we don't need any mouse event on the background
67
+ // just one state "default"
68
+ description {
69
+ state: "default" 0.0; // must always exist
70
+ color: 255 255 255 255; // white
71
+ // define part coordinates:
72
+ rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
73
+ relative: 0.0 0.0;
74
+ offset: 0 0;
75
+ }
76
+ rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
77
+ relative: 1.0 1.0;
78
+ offset: -1 -1;
79
+ }
80
+ }
81
+ }
82
+ part {
83
+ name: "text";
84
+ type: TEXT;
85
+ mouse_events: 1; // we want to change the color on mouse-over
86
+ // 2 states, one "default" and another "over" to be used
87
+ // on mouse over effect
88
+ description {
89
+ state: "default" 0.0;
90
+ color: 255 0 0 255; // red
91
+ // define part coordinates:
92
+ rel1 { // top-left at (WIDTH * 0.1 + 5, HEIGHT * 0.2 + 10)
93
+ relative: 0.1 0.2;
94
+ offset: 5 10;
95
+ }
96
+ rel2 { // bottom-right at (WIDTH * 0.9 - 6, HEIGHT * 0.8 - 11)
97
+ relative: 0.9 0.8;
98
+ offset: -6 -11;
99
+ }
100
+ // define text specific state details
101
+ text {
102
+ font: "Sans"; /* using fontconfig name! */
103
+ size: 10;
104
+ text: "hello world";
105
+ }
106
+ }
107
+ description {
108
+ state: "over" 0.0;
109
+ inherit: "default" 0.0; // copy everything from "default" at this point
110
+ color: 0 255 0 255; // override color, now it is green
111
+ }
112
+ }
113
+ // do programs to change color on text mouse in/out (over)
114
+ programs {
115
+ program {
116
+ // what triggers this program:
117
+ signal: "mouse,in";
118
+ source: "text";
119
+ // what this program does:
120
+ action: STATE_SET "over" 0.0;
121
+ target: "text";
122
+ // do the state-set in a nice interpolation animation
123
+ // using linear time in 0.1 second
124
+ transition: LINEAR 0.1;
125
+ }
126
+ program {
127
+ // what triggers this program:
128
+ signal: "mouse,out";
129
+ source: "text";
130
+ // what this program does:
131
+ action: STATE_SET "default" 0.0;
132
+ target: "text";
133
+ // do the state-set in a nice interpolation animation
134
+ // using linear time in 0.1 second
135
+ transition: LINEAR 0.1;
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+