summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/efl/elementary.rb43
-rw-r--r--spec/elm_spec.rb67
2 files changed, 96 insertions, 14 deletions
diff --git a/lib/efl/elementary.rb b/lib/efl/elementary.rb
index 2b0cd22..5105786 100644
--- a/lib/efl/elementary.rb
+++ b/lib/efl/elementary.rb
@@ -4,8 +4,6 @@
require 'efl/evas'
require 'efl/native/elementary'
#
-Efl::Evas::REvasObject.search_prefixes << 'elm_' # append not prepend !
-#
module Efl
module Elm
#
@@ -21,24 +19,41 @@ module Efl
end
end
#
- class ElmWin
- include Efl::ClassHelper
- search_prefixes 'elm_win_', 'elm_'
- def initialize parent, title, type=:elm_win_basic
- @evas_object = Evas::REvasObject.new Native.elm_win_add parent, title, type
- @ptr = @evas_object.to_ptr
- yield self,@evas_object if block_given?
- end
- def add e
- eo = Evas::REvasObject.new Native.send "elm_#{e}_add", @ptr
- yield eo if block_given?
- eo
+ class ElmWin < Efl::Evas::REvasObject
+ #
+ search_prefixes 'elm_win_'
+ #
+ def initialize parent, title, type=:elm_win_basic, &block
+ super Native.method(:elm_win_add), parent, title, type, &block
end
def smart_callback_add event_str, cb, data=FFI::MemoryPointer::NULL
Native.evas_object_smart_callback_add @ptr, event_str, cb, data
end
end
#
+ class ElmBg < Efl::Evas::REvasObject
+ #
+ search_prefixes 'elm_bg_'
+ #
+ def initialize parent, &block
+ super Native.method(:elm_bg_add), parent, &block
+ end
+ def file_get
+ f = FFI::MemoryPointer.new :pointer
+ g = FFI::MemoryPointer.new :pointer
+ Native.elm_bg_file_get @ptr, f, g
+ [ f.read_pointer.read_string, g.read_pointer.read_string ]
+ end
+ alias :file :file_get
+ def color_get
+ r = FFI::MemoryPointer.new :int
+ g = FFI::MemoryPointer.new :int
+ b = FFI::MemoryPointer.new :int
+ Native.elm_bg_color_get @ptr, r, g, b
+ [ r.read_int, g.read_int, b.read_int ]
+ end
+ alias :color :color_get
+ end
end
end
#
diff --git a/spec/elm_spec.rb b/spec/elm_spec.rb
new file mode 100644
index 0000000..7454a9a
--- /dev/null
+++ b/spec/elm_spec.rb
@@ -0,0 +1,67 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/eina'
+require 'efl/elementary'
+#
+describe Efl::Elm do
+ #
+ before(:all) { Elm = Efl::Elm }
+ #
+ before(:each) {
+ Elm.init
+ @win = Elm::ElmWin.new(nil, 'TEST') do |w|
+ w.title= 'spec win'
+ w.move 100, 100
+ w.resize 100, 100
+ w.show
+ end
+ @bg = Elm::ElmBg.new(@win) do |bg|
+ bg.size_hint_weight_set 1.0, 1.0
+ bg.evas_object_color_set 200,255,100,150
+ bg.show
+ end
+ }
+ after(:each) {
+ @bg.free
+ @win.free
+ Elm.shutdown
+ }
+ #
+ describe Efl::Elm::ElmBg do
+ #
+ it "file set/get" do
+ @bg.file_set "file", "group1"
+ @bg.file_get.should == ["file","group1"]
+ @bg.file= "file", "group1"
+ @bg.file.should == ["file","group1"]
+ end
+ #
+ it "option set/get" do
+ @bg.option_set :elm_bg_option_scale
+ @bg.option_get.should == :elm_bg_option_scale
+ @bg.option=:elm_bg_option_center
+ @bg.option.should == :elm_bg_option_center
+ end
+ #
+ it "color set/get" do
+ @bg.color_set 12,24,36
+ @bg.color_get.should == [12,24,36]
+ @bg.color= 2,4,8
+ @bg.color.should == [2,4,8]
+ @bg.class.superclass.instance_method(:color).bind(@bg).call.should == [200,255,100,150]
+ end
+ #
+ it "overlay get/set unset" do
+ @r = @win.evas.object_rectangle_add
+ @bg.overlay_get.should==FFI::Pointer::NULL
+ @bg.overlay_set @r
+ @bg.overlay_get.should == @r.to_ptr
+ @bg.overlay_unset.should == @r.to_ptr
+ @bg.overlay_get.should == FFI::Pointer::NULL
+ @r.free
+ end
+ end
+ #
+end
+