From 9aba5f0bc6594806df6954df88749d1db99dd232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 6 May 2011 15:45:11 +0200 Subject: add REvasObject#center set/get/= --- lib/efl/evas.rb | 10 ++++++++++ spec/evas_spec.rb | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb index 8ce5369..b706b8b 100644 --- a/lib/efl/evas.rb +++ b/lib/efl/evas.rb @@ -168,6 +168,16 @@ module Efl [ x.read_int, y.read_int, w.read_int, h.read_int ] end alias :geometry :geometry_get + def center_get + g = geometry_get + [ g[0]+(g[2]/2.0), g[1]+(g[3]/2.0) ] + end + alias :center :center_get + def center_set x, y + g = geometry_get + move x-(g[2]/2.0), y-(g[3]/2.0) + end + alias :center= :center_set def size geometry_get[2..-1] end diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb index 94d549c..926ff22 100644 --- a/spec/evas_spec.rb +++ b/spec/evas_spec.rb @@ -378,6 +378,15 @@ describe Efl::Evas do @o.geometry_get.should == [10,10,50,50] end # + it "center should work" do + @o.geometry.should == [10,10,50,50] + @o.center_get.should == [35,35] + @o.center.should == [35,35] + @o.center_set 50, 50 + @o.center.should == [50,50] + @o.geometry.should == [25,25,50,50] + end + # it "show hide visible should work" do @o.show @o.visible?.should be_true -- cgit v1.1-2-g2b99