1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
|