summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanatermesis <thanatermesis@gmail.com>2014-11-28 12:36:06 +0100
committerThanatermesis <thanatermesis@gmail.com>2014-11-28 12:36:06 +0100
commit63951e9d43b56080c118a517f002fc00243ff0ba (patch)
treecae3aec148e8a545f0dc8510cb63d50758ccc859
parentab327d12ebf90a352f5db0a4e434464b0e576863 (diff)
Example code for list with buttons
This example is very simple and plain but can be used as a demo of how to make a list with buttons
-rw-r--r--test/test_list_buttons-native.rb71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/test_list_buttons-native.rb b/test/test_list_buttons-native.rb
new file mode 100644
index 0000000..3e6607f
--- /dev/null
+++ b/test/test_list_buttons-native.rb
@@ -0,0 +1,71 @@
1#! /usr/bin/env ruby
2# -*- coding: UTF-8 -*-
3#
4# This is a very simple, plain and no-dynamic code that shows how to make a simple list with buttons on it
5#
6#
7require 'efl/elm/elm_win'
8require 'efl/elm/elm_icon'
9require 'efl/elm/elm_button'
10require 'efl/elm/elm_object'
11require 'efl/elm/elm_bg'
12require 'efl/elm/elm_list'
13#
14include Efl::Native
15
16def bt_clicked data, object, event
17 puts "button clicked"
18end
19
20def it_clicked data, object, event
21 puts "item clicked"
22end
23
24
25#
26elm_init 0, FFI::MemoryPointer::NULL
27#
28win = elm_win_add(nil, "list button", 0)
29elm_win_title_set(win, "ListButton")
30elm_policy_set(0, 1)
31elm_win_autodel_set(win, true)
32#
33bg = elm_bg_add(win)
34elm_bg_color_set(bg, 255, 255, 255)
35evas_object_size_hint_weight_set(bg, 1.0, 1.0)
36elm_win_resize_object_add(win, bg)
37evas_object_show(bg)
38
39li = elm_list_add(win)
40evas_object_size_hint_weight_set(li, 1.0, 1.0)
41elm_win_resize_object_add(win, li)
42elm_list_mode_set(li, 1)
43evas_object_show(li)
44
45#ic = elm_icon_add(win)
46##snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get())
47#elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE)
48#elm_image_file_set(ic, buf, NULL)
49ic2 = elm_button_add(win)
50elm_object_part_text_set(ic2, nil, "Click me")
51evas_object_smart_callback_add(ic2, "clicked", method(:bt_clicked), nil)
52evas_object_propagate_events_set(ic2, false)
53elm_list_item_append(li, "Hello", nil, ic2, method(:it_clicked), nil)
54evas_object_show(ic2)
55
56ic3 = elm_button_add(win)
57elm_object_part_text_set(ic3, nil, "Click me")
58evas_object_smart_callback_add(ic3, "clicked", method(:bt_clicked), nil)
59evas_object_propagate_events_set(ic3, false)
60
61# elm_list_item_append is what adds entries, you can add optionally evas objetcts like buttons or icons in the start and/or the end of each entry
62elm_list_item_append(li, "Hello", nil, ic3, method(:it_clicked), nil)
63evas_object_show(ic3)
64
65#
66evas_object_resize(win, 200, 300)
67evas_object_show(win)
68#
69elm_run
70elm_shutdown
71#