summaryrefslogtreecommitdiffstats
path: root/test/test_layout.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-02-23 21:55:31 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-02-23 21:55:31 +0100
commite417bd57d7c213f2a50a94ec8690ae76c7f0ebba (patch)
treea58cf76c782c7c3a13457347fa362b60a66184b6 /test/test_layout.rb
parent90ae47e71fb3d7179a703bcc344c284e468f59da (diff)
parent08de292b856e0e182db831ee7a6348695a19c103 (diff)
downloadffi-efl-e417bd57d7c213f2a50a94ec8690ae76c7f0ebba.zip
ffi-efl-e417bd57d7c213f2a50a94ec8690ae76c7f0ebba.tar.gz
Merge pull request #6 from mhanne/examples
Some more examples
Diffstat (limited to 'test/test_layout.rb')
-rw-r--r--test/test_layout.rb64
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