summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/efl/ecore_evas.rb68
-rw-r--r--spec/ecore_evas_spec.rb255
2 files changed, 306 insertions, 17 deletions
diff --git a/lib/efl/ecore_evas.rb b/lib/efl/ecore_evas.rb
index cb08d30..c1372f6 100644
--- a/lib/efl/ecore_evas.rb
+++ b/lib/efl/ecore_evas.rb
@@ -10,33 +10,79 @@ module Efl
class REcoreEvas
include Efl::ClassHelper
proxy_list [Efl::EcoreEvas,'ecore_evas_'].freeze
- def initialize o=nil, &block
+ def initialize o=nil
@ptr = (
case o
when NilClass
- FFI::AutoPointer.new Efl::EcoreEvas.ecore_evas_new(nil, 0, 0, 0, 0, nil), method(:free)
- when self.class
- o.to_ptr
- when FFI::AutoPointer
- o
+ FFI::AutoPointer.new Efl::EcoreEvas.ecore_evas_new(nil, 0, 0, 0, 0, nil), REcoreEvas.method(:release)
+ when Hash
+ FFI::AutoPointer.new Efl::EcoreEvas.ecore_evas_new(o[:engine_name], o[:x], o[:y], o[:w], o[:h], o[:extra_options]), REcoreEvas.method(:release)
when FFI::Pointer
- FFI::AutoPointer.new o, method(:free)
+ o
else
raise ArgumentError.new "wrong argument #{o.class.name}"
end
)
yield self if block_given?
end
+ def self.release p
+ Efl::EcoreEvas.ecore_evas_free p unless p.nil?
+ end
def free p=nil
- return Efl::EcoreEvas.ecore_evas_free p unless p.nil?
- Efl::EcoreEvas.ecore_evas_free @ptr
- @ptr.free
+ @ptr.autorelease=false
+ REcoreEvas.release @ptr
@ptr=nil
end
- def get
+ def geometry_get
+ x = FFI::MemoryPointer.new :int
+ y = FFI::MemoryPointer.new :int
+ w = FFI::MemoryPointer.new :int
+ h = FFI::MemoryPointer.new :int
+ Efl::EcoreEvas.ecore_evas_geometry_get @ptr, x, y, w, h
+ [ x.read_int, y.read_int, w.read_int, h.read_int ]
+ end
+ alias :geometry :geometry_get
+ def size
+ geometry_get[2..-1]
+ end
+ def size= wh
+ Efl::Evas.evas_object_resize @ptr, *wh
+ end
+ def name_class_get
+ n = FFI::MemoryPointer.new :pointer
+ c = FFI::MemoryPointer.new :pointer
+ Efl::EcoreEvas.ecore_evas_name_class_get @ptr, n, c
+ [ n.read_pointer.read_string, c.read_pointer.read_string ]
+ end
+ def size_min_get
+ w = FFI::MemoryPointer.new :int
+ h = FFI::MemoryPointer.new :int
+ Efl::EcoreEvas.ecore_evas_size_min_get @ptr, w, h
+ [ w.read_int, h.read_int ]
+ end
+ def size_max_get
+ w = FFI::MemoryPointer.new :int
+ h = FFI::MemoryPointer.new :int
+ Efl::EcoreEvas.ecore_evas_size_max_get @ptr, w, h
+ [ w.read_int, h.read_int ]
+ end
+ def size_base_get
+ w = FFI::MemoryPointer.new :int
+ h = FFI::MemoryPointer.new :int
+ Efl::EcoreEvas.ecore_evas_size_base_get @ptr, w, h
+ [ w.read_int, h.read_int ]
+ end
+ def size_step_get
+ w = FFI::MemoryPointer.new :int
+ h = FFI::MemoryPointer.new :int
+ Efl::EcoreEvas.ecore_evas_size_step_get @ptr, w, h
+ [ w.read_int, h.read_int ]
+ end
+ def evas
# EAPI Evas *ecore_evas_get(const Ecore_Evas *ee);
Efl::Evas::REvas.new Efl::EcoreEvas.ecore_evas_get @ptr
end
+ alias :get :evas
def object_image_new
# EAPI Evas_Object *ecore_evas_object_image_new(Ecore_Evas *ee_target);
Efl::Evas::REvasObject.new Efl::EcoreEvas.ecore_evas_object_image_new @prt
diff --git a/spec/ecore_evas_spec.rb b/spec/ecore_evas_spec.rb
index c4d2275..afb1b48 100644
--- a/spec/ecore_evas_spec.rb
+++ b/spec/ecore_evas_spec.rb
@@ -1,24 +1,267 @@
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
+require 'efl/evas'
+require 'efl/ecore'
require 'efl/ecore_evas'
#
+def ecore_loop n
+ n.downto(0) do
+ sleep 0.1
+ Efl::Ecore.main_loop_iterate
+ end
+end
+#
describe Efl::EcoreEvas do
#
before(:all) do
EcoreEvas = Efl::EcoreEvas
+ EcoreEvas.init
+ end
+ after(:all) do
+ EcoreEvas.shutdown
end
#
it "should init" do
- EcoreEvas.init.should eql 1
- EcoreEvas.init.should eql 2
- EcoreEvas.init.should eql 3
+ EcoreEvas.init.should == 2
+ EcoreEvas.init.should == 3
end
#
it "should shutdown" do
- EcoreEvas.shutdown.should eql 2
- EcoreEvas.shutdown.should eql 1
- EcoreEvas.shutdown.should eql 0
+ EcoreEvas.shutdown.should == 2
+ EcoreEvas.shutdown.should == 1
end
#
+ it "should work" do
+ EcoreEvas.engines_free EcoreEvas.engines_get
+# require 'efl/eina_list'
+# l = Efl::EinaList::REinaList.new EcoreEvas.engines_get
+# l.each do |e| puts e.read_string end
+# EcoreEvas.engines_free l
+ end
+ #
+ describe Efl::EcoreEvas::REcoreEvas do
+ before(:all) {
+ EcoreEvas.init
+ }
+ before(:each) do
+ @e = EcoreEvas::REcoreEvas.new :engine_name=>"software_x11", :x=>10, :y=>10, :w=>100, :h=>120
+ @e.move 10, 10
+ @canvas = @e.evas
+ @bg = @canvas.object_add(:rectangle) { |o|
+ o.color = 100, 100, 255, 255
+ o.size = @e.size
+ }
+ @bg.show
+ @e.show
+ end
+ after(:each) do
+ @e.free
+ end
+ after(:all) do
+ EcoreEvas.shutdown
+ end
+ #
+ it "engine_name_get should work" do
+ @e.engine_name_get.should == "software_x11"
+ end
+ #
+ it "data get/set should work" do
+ @e.data_set 'key', '666'
+ @e.data_get('key').read_string.should == '666'
+ end
+ #
+ it "move, resize move_resize and geometry_get should work" do
+ @e.geometry_get.should == [10,10,100,120]
+ @e.move 20, 17 # w+23 window bar height
+ ecore_loop 3
+ @e.geometry_get.should == [20,40,100,120]
+ @e.resize 200,150
+ ecore_loop 3
+ @e.geometry_get.should == [20,40,200,150]
+ @e.move_resize 10, 0, 130, 100
+ ecore_loop 3
+ @e.geometry_get.should == [10,23,130,100]
+ g = @e.geometry_get
+ end
+ #
+ it "rotation should work" do
+ @e.rotation_set 25
+ @e.rotation_get.should == 25
+ @e.rotation_set 50
+ @e.rotation_get.should == 50
+ end
+ #
+ it "shaped get/set should work" do
+ @e.shaped?.should be_false
+ @e.shaped_set true
+ @e.shaped_get.should be_true
+ @e.shaped = false
+ @e.shaped?.should be_false
+ end
+ #
+ it "alpha get/set should work" do
+ @e.alpha?.should be_false
+ @e.alpha_set true
+ @e.alpha_get.should be_true
+ @e.alpha = false
+ @e.alpha?.should be_false
+ end
+ #
+ it "transparent get/set should work" do
+ @e.transparent?.should be_false
+ @e.transparent_set true
+ @e.transparent_get.should be_true
+ @e.transparent = false
+ @e.transparent?.should be_false
+ end
+ #
+ it "show hide visibility should work" do
+ ecore_loop 3
+ @e.visibility?.should == 1
+ @e.hide
+ ecore_loop 3
+ @e.visibility_get.should == 0
+ @e.show
+ ecore_loop 3
+ @e.visibility?.should == 1
+ end
+ #
+ it "raise lower activate should work" do
+ @e.raise
+ @e.lower
+ @e.activate
+ end
+ #
+ it "title set/get should work" do
+ @e.title_set "title"
+ @e.title_get.should == "title"
+ @e.title = "other"
+ @e.title_get.should == "other"
+ end
+ #
+ #
+ it "name_class set/get should work" do
+ @e.name_class_set "name", "class"
+ @e.name_class_get.should == ['name','class']
+ @e.name_class = "name1", "class1"
+ @e.name_class_get.should == ['name1','class1']
+ end
+ #
+ it "size_min set/get should work" do
+ @e.size_min_set 20, 30
+ @e.size_min_get.should == [20, 30]
+ end
+ #
+ it "size_max set/get should work" do
+ @e.size_max_set 20, 30
+ @e.size_max_get.should == [20, 30]
+ end
+ #
+ it "size_base set/get should work" do
+ @e.size_base_set 20, 30
+ @e.size_base_get.should == [20, 30]
+ end
+ #
+ it "size_step set/get should work" do
+ @e.size_step_set 20, 30
+ @e.size_step_get.should == [20, 30]
+ end
+ #
+ # TODO : 3 * cursor
+ #
+ it "layer set/get should work" do
+ @e.layer_set 2
+ @e.layer_get.should == 2
+ @e.layer = 1
+ @e.layer?.should == 1
+ end
+ #
+ it "focus set/get should work" do
+ @e.focus?.should be_false
+ @e.focus_set true
+ ecore_loop 3
+ @e.focus_get.should be_true
+ @e.focus?.should be_true
+ end
+ #
+ it "iconified set/get should work" do
+ @e.iconified_set true
+ @e.iconified_get.should be_true
+ @e.iconified = false
+ @e.iconified?.should be_false
+ end
+ #
+ it "borderless set/get should work" do
+ @e.borderless_set true
+ @e.borderless_get.should be_true
+ @e.borderless = false
+ @e.borderless?.should be_false
+ end
+ #
+ it "override set/get should work" do
+ @e.override_set true
+ @e.override_get.should be_true
+ @e.override = false
+ @e.override?.should be_false
+ end
+ #
+ # FIXME
+ # ecore/src/lib/ecore_evas/ecore_evas.c => ecore_evas_maximized_set => IFC => return
+# it "maximized set/get should work" do
+# @e.maximized?.should be_false
+# @e.maximized_set true
+# ecore_loop 10
+# @e.maximized_get.should be_true
+# @e.maximized = false
+# ecore_loop 3
+# @e.maximized?.should be_false
+# end
+ #
+ it "fullscreen set/get should work" do
+ @e.fullscreen_set true
+ ecore_loop 3
+ @e.fullscreen_get.should be_true
+ @e.fullscreen = false
+ ecore_loop 3
+ @e.fullscreen?.should be_false
+ end
+ #
+ it "avoid_damage set/get should work" do
+ @e.avoid_damage_set :ecore_evas_avoid_damage_expose
+ ecore_loop 3
+ @e.avoid_damage_get.should == :ecore_evas_avoid_damage_expose
+ @e.avoid_damage = :ecore_evas_avoid_damage_built_in
+ ecore_loop 3
+ @e.avoid_damage?.should == :ecore_evas_avoid_damage_built_in
+ end
+ #
+ it "withdrawn set/get should work" do
+ @e.withdrawn_set true
+ @e.withdrawn_get.should be_true
+ @e.withdrawn = false
+ @e.withdrawn?.should be_false
+ end
+ #
+ it "sticky set/get should work" do
+ @e.sticky_set true
+ ecore_loop 3
+ @e.sticky_get.should be_true
+ @e.sticky = false
+ ecore_loop 3
+ @e.sticky?.should be_false
+ end
+ #
+ it "ignore_events set/get should work" do
+ @e.ignore_events_set true
+ @e.ignore_events_get.should be_true
+ @e.ignore_events = false
+ @e.ignore_events?.should be_false
+ end
+ #
+# it "object_associate dissociate should work" do
+# @e.object_associate_set true
+# @e.object_associate_set true
+# end
+ end
end