diff options
author | Marius Hanne <marius.hanne@sourceagency.org> | 2013-02-23 20:13:22 +0100 |
---|---|---|
committer | Marius Hanne <marius.hanne@sourceagency.org> | 2013-02-23 20:49:45 +0100 |
commit | c26b2ad177a6636ebdcea9b89c52017de8089fca (patch) | |
tree | eb3f00e59f9d79f301eab06ad1d33cb17c5fb38f /test/test_layout.rb | |
parent | 65813de1b704f7d208665ca216c63fa53d0722d2 (diff) | |
download | ffi-efl-c26b2ad177a6636ebdcea9b89c52017de8089fca.zip ffi-efl-c26b2ad177a6636ebdcea9b89c52017de8089fca.tar.gz |
example for ElmLayout
Diffstat (limited to 'test/test_layout.rb')
-rw-r--r-- | test/test_layout.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/test_layout.rb b/test/test_layout.rb new file mode 100644 index 0000000..34cc4aa --- /dev/null +++ b/test/test_layout.rb @@ -0,0 +1,64 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elm/elm_win' +require 'efl/elm/elm_bg' +require 'efl/elm/elm_icon' +require 'efl/elm/elm_layout' +# +include Efl +# +IMAGES = ["home", "close", "arrow_up", "arrow_down"] +# +class MyWin < Elm::ElmWin + # + attr_reader :current + def initialize + @current = 0 + super(nil, "Layout") do + title_set "Layout" + resize 320, 320 + show + end + @bg = Elm::ElmBg.new(self) do + size_hint_weight_expand + show + end + resize_object_add @bg + # + @layout = Elm::ElmLayout.new(self) do + size_hint_weight_expand + theme_set "layout", "application", "content-back-next" + show + end + resize_object_add @layout + # + @icon = Elm::ElmIcon.new(self) + @icon.standard_set IMAGES[@current] + # + @layout.part_content_set("elm.swallow.content", @icon) + @layout.part_text_set("elm.text.title", "Test #{@current}") + # + @layout.signal_callback_add("elm,action,back", "", method(:signal_cb), nil) + @layout.signal_callback_add("elm,action,next", "", method(:signal_cb), nil) + end + # + def signal_cb data, object, emission, source + @current -= 1 if emission == "elm,action,back" + @current += 1 if emission == "elm,action,next" + @current = IMAGES.size - 1 if @current < 0 + @current = 0 if @current >= IMAGES.size + # + @icon.standard_set IMAGES[@current] + @layout.part_text_set("elm.text.title", "Test #{@current}") + end +end +# +Elm.init +# +MyWin.new +# +Elm.run +Elm.shutdown +# +# EOF |