diff options
-rw-r--r-- | lib/efl/elementary.rb | 15 | ||||
-rw-r--r-- | test/elm_win_class.rb | 32 |
2 files changed, 28 insertions, 19 deletions
diff --git a/lib/efl/elementary.rb b/lib/efl/elementary.rb index 4d82d54..ba263a8 100644 --- a/lib/efl/elementary.rb +++ b/lib/efl/elementary.rb @@ -20,20 +20,25 @@ module Efl end # class ElmWin < Efl::Evas::EvasObject - attr_reader :ptr + attr_reader :evas_object def initialize parent, title, type=:elm_win_basic - @ptr = Efl::API.elm_win_add parent, title, type + @evas_object = Evas::EvasObject.new Efl::API.elm_win_add parent, title, type yield self if block_given? end def add e - Efl::API.send "elm_#{e}_add", @ptr + eo = Evas::EvasObject.new Efl::API.send "elm_#{e}_add", @evas_object.ptr + yield eo if block_given? + eo + end + def smart_callback_add event_str, cb, data=FFI::MemoryPointer::NULL + Efl::API.evas_object_smart_callback_add @evas_object.ptr, event_str, cb, data end def method_missing m, *args, &block [ 'elm_win_', 'elm_' ].each do |s| sym = s+m.to_s - puts sym - return Efl::API.send( sym, @ptr, *args, &block ) if Efl::API.respond_to? sym + return Efl::API.send( sym, @evas_object.ptr, *args, &block ) if Efl::API.respond_to? sym end + Efl::API.send m end end # diff --git a/test/elm_win_class.rb b/test/elm_win_class.rb index dad9b4e..4dae894 100644 --- a/test/elm_win_class.rb +++ b/test/elm_win_class.rb @@ -10,30 +10,34 @@ puts Elm.init class MyWin < Elm::ElmWin def initialize name, title super FFI::MemoryPointer::NULL, name - win_title_set title + title_set title feed - Efl::API.evas_object_smart_callback_add @ptr, "delete,request", method(:exit), FFI::MemoryPointer::NULL + smart_callback_add "delete,request", method(:exit) end def feed - @bg = add 'bg' - Efl::API.evas_object_size_hint_weight_set @bg, 1.0, 1.0 - resize_object_add @bg - Efl::API.evas_object_show @bg - @lb = add 'label' - Efl::API.elm_label_label_set @lb, "Hello World!" - Efl::API.evas_object_size_hint_weight_set @lb, 1.0, 1.0 - resize_object_add @lb - Efl::API.evas_object_show @lb + @bg = add 'bg' do |bg| + bg.size_hint_weight_set 1.0, 1.0 + bg.show + end + resize_object_add @bg.ptr + @lb = add 'label'do |lb| + lb.elm_label_label_set "Hello World!" + lb.size_hint_weight_set 1.0, 1.0 + lb.show + end + resize_object_add @lb.ptr end def exit *args + puts "EXIT" Efl::API.elm_exit(); end end # win = MyWin.new "App name", "Window Title" do |w| - Efl::API.evas_object_move w.ptr, 300, 300 - Efl::API.evas_object_resize w.ptr, 200, 100 - Efl::API.evas_object_show w.ptr + eo = w.evas_object + eo.move 300, 300 + eo.resize 200, 100 + eo.show end Elm.run |