summaryrefslogtreecommitdiffstats
path: root/test/test_genlist-native.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-02-19 00:45:15 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-02-19 00:45:15 +0100
commit90ae47e71fb3d7179a703bcc344c284e468f59da (patch)
tree6e006829cd89edd17b929e43e8f4ae5d69390262 /test/test_genlist-native.rb
parentb1c747d11c0e51e28cc3db53cae780654b88c1e5 (diff)
parent745d270cc955b01264e9f11297ec6bd3ab2fb47d (diff)
downloadffi-efl-90ae47e71fb3d7179a703bcc344c284e468f59da.zip
ffi-efl-90ae47e71fb3d7179a703bcc344c284e468f59da.tar.gz
Merge branch 'master' of github.com:jeremyz/ffi-efl
Diffstat (limited to 'test/test_genlist-native.rb')
-rw-r--r--test/test_genlist-native.rb75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/test_genlist-native.rb b/test/test_genlist-native.rb
new file mode 100644
index 0000000..19f8712
--- /dev/null
+++ b/test/test_genlist-native.rb
@@ -0,0 +1,75 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/native/elm/elm_win'
+require 'efl/native/elm/elm_bg'
+require 'efl/native/elm/elm_label'
+require 'efl/native/elm/elm_genlist'
+#
+class ElmGenItemClass < FFI::Struct
+ layout :version, :int,
+ :refcount, :uint,
+ :delete_me, :pointer,
+ :item_style, :pointer,
+ :decorate_item_style, :pointer,
+ :decorate_all_item_style, :pointer,
+ :text_get, :pointer,
+ :content_get, :pointer,
+ :state_get, :pointer,
+ :del, :pointer
+end
+#
+include Efl::Native
+#
+elm_init 0, FFI::MemoryPointer::NULL
+#
+win = elm_win_add(nil, "genlist", 0)
+elm_win_title_set(win, "Genlist")
+elm_policy_set(0, 1)
+elm_win_autodel_set(win, true)
+#
+bg = elm_bg_add(win)
+elm_bg_color_set(bg, 255, 255, 255)
+evas_object_size_hint_weight_set(bg, 1.0, 1.0)
+elm_win_resize_object_add(win, bg)
+evas_object_show(bg)
+#
+if !@itc
+ itc_ptr = elm_genlist_item_class_new
+ @itc = ElmGenItemClass.new(itc_ptr)
+ @itc[:item_style] = FFI::MemoryPointer.from_string("default")
+ @itc[:text_get] = FFI::Function.new(:pointer, [:pointer, :pointer, :string]) {|data, *_|
+ ptr = FFI::MemoryPointer.from_string("Item # #{data.read_string}")
+ ptr.autorelease = false
+ ptr
+ }
+ @itc[:content_get] = FFI::Function.new(:pointer, [:pointer, :pointer, :string]) do
+ |data, obj, part|
+ ic = elm_icon_add(obj)
+ elm_icon_standard_set(ic, "clock") if part == "elm.swallow.icon"
+ evas_object_size_hint_aspect_set(ic, 0, 1, 1)
+ ic
+ end
+ @itc[:state_get] = nil
+ @itc[:del] = nil
+end
+#
+list = elm_genlist_add(win)
+#
+30.times do |i|
+ elm_genlist_item_append(list, @itc, i.to_s, nil, :elm_genlist_item_none,
+ FFI::Function.new(:pointer, [:pointer, :pointer, :pointer]) {|data, obj, evt|
+ p [:selected, data.read_string] }, i.to_s)
+end
+#
+evas_object_size_hint_weight_set(list, 1.0, 1.0)
+elm_win_resize_object_add(win, list)
+evas_object_show(list)
+#
+evas_object_resize(win, 200, 300)
+evas_object_show(win)
+#
+elm_run
+elm_shutdown
+#
+# EOF