summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-05-06 09:43:35 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-05-06 09:43:35 +0200
commite70f8fdfbb74919d38392123b26a764db3561192 (patch)
treede9aea7eba773ea6ff6e01dbc6f717dfb099976e
parentbe6a692686130aaed436812ac85eaf854e11c902 (diff)
downloadffi-efl-e70f8fdfbb74919d38392123b26a764db3561192.zip
ffi-efl-e70f8fdfbb74919d38392123b26a764db3561192.tar.gz
replace REvas.object_add with REvas.object_xxx_add
-rw-r--r--lib/efl/evas.rb36
-rw-r--r--spec/ecore_evas_spec.rb2
-rw-r--r--spec/evas_spec.rb16
-rw-r--r--test/test_evas.rb8
4 files changed, 35 insertions, 27 deletions
diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb
index 258efa6..942fc4e 100644
--- a/lib/efl/evas.rb
+++ b/lib/efl/evas.rb
@@ -71,20 +71,23 @@ module Efl
REvas.release @ptr
@ptr=nil
end
- def object_add t
- ts = t.to_s
- o = (
- case ts
- when 'rectangle'
- Evas::REvasRectangle.new Native.evas_object_rectangle_add @ptr
- when 'line'
- Evas::REvasLine.new Native.evas_object_line_add @ptr
- when 'polygon'
- Evas::REvasPolygon.new Native.evas_object_polygon_add @ptr
- else
- raise NameError.new "unknown or not implemented yet evas_object type #{ts}"
- end
- )
+ def object_rectangle_add
+ o = Evas::REvasRectangle.new FFI::AutoPointer.new Native.evas_object_rectangle_add(@ptr), REvasObject.method(:release)
+ yield o if block_given?
+ o
+ end
+ def object_line_add
+ o = Evas::REvasLine.new FFI::AutoPointer.new Native.evas_object_line_add(@ptr), REvasObject.method(:release)
+ yield o if block_given?
+ o
+ end
+ def object_polygon_add
+ o = Evas::REvasPolygon.new FFI::AutoPointer.new Native.evas_object_polygon_add(@ptr), REvasObject.method(:release)
+ yield o if block_given?
+ o
+ end
+ def object_text_add
+ o = Evas::REvasText.new FFI::AutoPointer.new Native.evas_object_text_add(@ptr), REvasObject.method(:release)
yield o if block_given?
o
end
@@ -273,6 +276,11 @@ module Efl
#
end
#
+ class REvasText < REvasObject
+ #
+ search_prefixes 'evas_object_text_'
+ #
+ end
end
end
#
diff --git a/spec/ecore_evas_spec.rb b/spec/ecore_evas_spec.rb
index c141460..a9abec9 100644
--- a/spec/ecore_evas_spec.rb
+++ b/spec/ecore_evas_spec.rb
@@ -62,7 +62,7 @@ describe Efl::EcoreEvas do
before(:each) do
@e = EcoreEvas::REcoreEvas.new :engine_name=>"software_x11", :x=>10, :y=>10, :w=>100, :h=>120
@canvas = @e.evas
- @bg = @canvas.object_add(:rectangle) { |o|
+ @bg = @canvas.object_rectangle_add { |o|
o.color = 100, 100, 255, 255
o.size = @e.size
}
diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb
index ac41b5a..c8845ba 100644
--- a/spec/evas_spec.rb
+++ b/spec/evas_spec.rb
@@ -243,7 +243,7 @@ describe Efl::Evas do
true
end
kd_d = FFI::MemoryPointer.from_string "mouse_in"
- @bg = Evas::REvasObject.new @e.object_rectangle_add
+ @bg = @e.object_rectangle_add
@bg.move 0, 0
@bg.resize 20, 20
@bg.show
@@ -285,7 +285,7 @@ describe Efl::Evas do
it "focus should work" do
@e.focus.should == FFI::Pointer::NULL
@e.focus_get.should == FFI::Pointer::NULL
- @o = @e.object_add(:rectangle) { |o|
+ @o = @e.object_rectangle_add { |o|
o.color = 200,200,200,200
o.move 0, 0
o.resize 100, 100
@@ -298,7 +298,7 @@ describe Efl::Evas do
#
it "object_name_find should work" do
@e.object_name_find("name").should == FFI::Pointer::NULL
- @o = @e.object_add(:rectangle)
+ @o = @e.object_rectangle_add
@o.name="name"
@e.object_name_find("name").should == @o.to_ptr
end
@@ -310,7 +310,7 @@ describe Efl::Evas do
before(:all) do
Evas.init
realize_evas
- @o = @e.object_add(:rectangle) { |o|
+ @o = @e.object_rectangle_add { |o|
o.color = 200,200,200,200
o.move 0, 0
o.resize 100, 100
@@ -325,7 +325,7 @@ describe Efl::Evas do
end
#
it "clipper should work" do
- clipper = @e.object_add :rectangle
+ clipper = @e.object_rectangle_add
clipper.color = 255,255,255,255
clipper.move 25, 25
clipper.resize 50, 50
@@ -401,7 +401,7 @@ describe Efl::Evas do
it "raise, lower, stck_below, stack_above should work" do
os = []
0.upto(3) do
- os << @e.object_add(:rectangle)
+ os << @e.object_rectangle_add
end
os[2].above.should === os[3]
os[2].below.should === os[1]
@@ -565,7 +565,7 @@ describe Efl::Evas do
before(:all) do
Evas.init
realize_evas
- @l = @e.object_add 'line'
+ @l = @e.object_line_add
end
after(:all) do
@e.free
@@ -582,7 +582,7 @@ describe Efl::Evas do
before(:all) do
Evas.init
realize_evas
- @p = @e.object_add 'polygon'
+ @p = @e.object_polygon_add
end
after(:all) do
@e.free
diff --git a/test/test_evas.rb b/test/test_evas.rb
index 6fdf111..6408360 100644
--- a/test/test_evas.rb
+++ b/test/test_evas.rb
@@ -73,7 +73,7 @@ w = 320
h = 240
canvas, pixels = create_canvas w, h
#
-bg = Evas::REvasObject.new canvas.object_rectangle_add
+bg = canvas.object_rectangle_add
bg.color = 255, 255, 255, 255
bg.move 0, 0
bg.resize w, h
@@ -81,19 +81,19 @@ bg.show
#
draw_scene canvas
#
-r1 = Evas::REvasObject.new canvas.object_rectangle_add
+r1 = canvas.object_rectangle_add
r1.color = 255, 0, 0, 255
r1.move 10, 10
r1.resize 100, 100
r1.show
#
-r2 = Evas::REvasObject.new canvas.object_rectangle_add
+r2 = canvas.object_rectangle_add
r2.color = 0, 128, 0, 128
r2.move 10, 10
r2.resize 50, 50
r2.show
#
-r3 = Evas::REvasObject.new canvas.object_rectangle_add
+r3 = canvas.object_rectangle_add
r3.color = 0, 128, 0, 255
r3.move 60, 60
r3.resize 50, 50