summaryrefslogtreecommitdiffstats
path: root/test
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
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')
-rw-r--r--test/test_ecore_pipe-native.rb52
-rw-r--r--test/test_ecore_pipe.rb56
-rw-r--r--test/test_layout.rb64
-rw-r--r--test/test_naviframe.rb58
-rw-r--r--test/test_panel.rb87
-rw-r--r--test/test_panes.rb73
6 files changed, 390 insertions, 0 deletions
diff --git a/test/test_ecore_pipe-native.rb b/test/test_ecore_pipe-native.rb
new file mode 100644
index 0000000..7dc095a
--- /dev/null
+++ b/test/test_ecore_pipe-native.rb
@@ -0,0 +1,52 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/native/ecore'
+require 'efl/native/elm/elm_win'
+require 'efl/native/elm/elm_bg'
+require 'efl/native/elm/elm_label'
+require 'efl/native/elm/elm_object'
+#
+include Efl::Native
+#
+elm_init 0, FFI::MemoryPointer::NULL
+#
+win_del = Proc.new { |data,evas_object,event_info| elm_exit() }
+#
+win = elm_win_add nil, "App name", :elm_win_basic
+elm_win_title_set win, "Window title"
+evas_object_smart_callback_add win, "delete,request", win_del, nil
+#
+bg = elm_bg_add win
+evas_object_size_hint_weight_set bg, 1.0, 1.0
+elm_win_resize_object_add win, bg
+evas_object_show bg
+#
+lb = elm_label_add win
+elm_object_part_text_set lb, nil, "Hello World"
+evas_object_size_hint_weight_set lb, 1.0, 1.0
+elm_win_resize_object_add win, lb
+evas_object_show lb
+#
+evas_object_move win, 300, 300
+evas_object_resize win, 200, 100
+#
+evas_object_show win
+#
+pipe_cb = Proc.new { |date,buffer,n|
+ elm_object_part_text_set lb, nil, buffer.read_string[0..n-1]
+}
+#
+pipe = ecore_pipe_add pipe_cb, nil
+#
+pid = fork {
+ ecore_pipe_read_close(pipe);
+ [ "hello", "dying", "old", "planet", "earth"].each do |w|
+ sleep 1
+ ecore_pipe_write pipe, w, w.length
+ end
+}
+#
+elm_run
+ecore_pipe_del pipe
+elm_shutdown
diff --git a/test/test_ecore_pipe.rb b/test/test_ecore_pipe.rb
new file mode 100644
index 0000000..e2786b3
--- /dev/null
+++ b/test/test_ecore_pipe.rb
@@ -0,0 +1,56 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/ecore'
+require 'efl/elm/elm_win'
+require 'efl/elm/elm_bg'
+require 'efl/elm/elm_label'
+#
+include Efl
+#
+class MyWin < Elm::ElmWin
+ #
+ attr_reader :pipe
+ def initialize
+ super(nil, "Pipe test") do
+ title_set "Hello, World!"
+ resize 200, 100
+ show
+ end
+ @bg = Elm::ElmBg.new(self) do
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @bg
+ #
+ @label = Elm::ElmLabel.new(self) do
+ text_set "Hello World"
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @label
+ #
+ @pipe = Ecore.ecore_pipe_add(method(:pipe_cb), nil)
+ end
+ #
+ def pipe_cb date, buffer, n
+ @label.text_set buffer.read_string[0..n-1]
+ end
+end
+#
+Elm.init
+#
+@win = MyWin.new
+#
+pid = fork do
+ Ecore.ecore_pipe_read_close(@win.pipe)
+ [ "hello", "dying", "old", "planet", "earth"].each do |w|
+ sleep 1
+ Ecore.ecore_pipe_write @win.pipe, w, w.length
+ end
+end
+Elm.run
+Ecore.ecore_pipe_del @win.pipe
+Elm.shutdown
+#
+# EOF
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
diff --git a/test/test_naviframe.rb b/test/test_naviframe.rb
new file mode 100644
index 0000000..9350d06
--- /dev/null
+++ b/test/test_naviframe.rb
@@ -0,0 +1,58 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/elm/elm_win'
+require 'efl/elm/elm_bg'
+require 'efl/elm/elm_button'
+require 'efl/elm/elm_naviframe'
+#
+include Efl
+#
+class MyWin < Elm::ElmWin
+ #
+ attr_reader :frames
+ def initialize
+ super(nil, "Greetings") do
+ title_set "Hello, World!"
+ resize 240, 400
+ show
+ end
+ @bg = Elm::ElmBg.new(self) do
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @bg
+ #
+ @naviframe = Elm::ElmNaviFrame.new(self) do
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ resize_object_add @naviframe
+ #
+ @frames = 0
+ add_frame
+ end
+ #
+ def add_frame *a
+ @frames += 1
+ _self = self
+ @content = Elm::ElmButton.new(self) do
+ text_set "content #{_self.frames}"
+ size_hint_weight_expand
+ size_hint_align_fill
+ smart_callback_add "clicked", _self.method(:add_frame)
+ show
+ end
+ @naviframe.item_push("test #{@frames}", nil, nil, @content, nil)
+ end
+end
+#
+Elm.init
+#
+MyWin.new
+#
+Elm.run
+Elm.shutdown
+#
+# EOF
diff --git a/test/test_panel.rb b/test/test_panel.rb
new file mode 100644
index 0000000..ac04894
--- /dev/null
+++ b/test/test_panel.rb
@@ -0,0 +1,87 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/elm/elm_win'
+require 'efl/elm/elm_bg'
+require 'efl/elm/elm_box'
+require 'efl/elm/elm_panel'
+require 'efl/elm/elm_label'
+#
+include Efl
+#
+class MyWin < Elm::ElmWin
+ #
+ def initialize
+ super(nil, "Greetings") do
+ title_set "Hello, World!"
+ resize 240, 400
+ show
+ end
+ @bg = Elm::ElmBg.new(self) do
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @bg
+ #
+ @bx = Elm::ElmBox.new(self) do
+ horizontal_set false
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ resize_object_add @bx
+ #
+ @panel1 = Elm::ElmPanel.new(self) do
+ orient_set :elm_panel_orient_top
+ toggle
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ @bx.pack_end @panel1
+ #
+ @content = Elm::ElmLabel.new(self) do
+ text_set "content 1"
+ show
+ end
+ @panel1.content_set @content
+ #
+ @panel2 = Elm::ElmPanel.new(self) do
+ orient_set :elm_panel_orient_right
+ hidden_set true
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ @bx.pack_end @panel2
+ #
+ @content = Elm::ElmLabel.new(self) do
+ text_set "content 2"
+ show
+ end
+ @panel2.content_set @content
+ #
+ @panel3 = Elm::ElmPanel.new(self) do
+ orient_set :elm_panel_orient_bottom
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ @bx.pack_end @panel3
+ #
+ @content = Elm::ElmLabel.new(self) do
+ text_set "content 3"
+ show
+ end
+ @panel3.content_set @content
+ end
+end
+#
+Elm.init
+#
+MyWin.new
+#
+Elm.run
+Elm.shutdown
+#
+# EOF
diff --git a/test/test_panes.rb b/test/test_panes.rb
new file mode 100644
index 0000000..db2de03
--- /dev/null
+++ b/test/test_panes.rb
@@ -0,0 +1,73 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/elm/elm_win'
+require 'efl/elm/elm_bg'
+require 'efl/elm/elm_panes'
+require 'efl/elm/elm_button'
+#
+include Efl
+#
+class MyWin < Elm::ElmWin
+ #
+ def initialize
+ super(nil, "Greetings") do
+ title_set "Hello, World!"
+ resize 320, 400
+ show
+ end
+ @bg = Elm::ElmBg.new(self) do
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @bg
+ #
+ @panes = Elm::ElmPanes.new(self) do
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ resize_object_add @panes
+ #
+ @bt1 = Elm::ElmButton.new(self) do
+ part_text_set(nil, "Left")
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ @panes.part_content_set("left", @bt1)
+ #
+ @panes_h = Elm::ElmPanes.new(self) do
+ horizontal_set true
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ @panes.part_content_set("right", @panes_h)
+ #
+ @bt2 = Elm::ElmButton.new(self) do
+ part_text_set(nil, "Up")
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ @panes_h.part_content_set("left", @bt2)
+ #
+ @bt3 = Elm::ElmButton.new(self) do
+ part_text_set(nil, "Down")
+ size_hint_weight_expand
+ size_hint_align_fill
+ show
+ end
+ @panes_h.part_content_set("right", @bt3)
+ end
+end
+#
+Elm.init
+#
+MyWin.new
+#
+Elm.run
+Elm.shutdown
+#
+# EOF