summaryrefslogtreecommitdiffstats
path: root/test/tests/test_actionslider.rb
blob: df49cc0971d11034c5c9f4cfd7e2558c3bd28305 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
module Tests
    #
    class TestActionSlider < Efl::Elm::ElmWin
        def initialize name, title, fct
            super nil, name
            self.title = title
            self.autodel = true
            self.send fct
            self.resize 320, 400
            self.show
        end
        def simple
            @bg = Elm::ElmBg.new self do |bg|
                bg.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                self.resize_object_add bg
                bg.show
            end
            @bx = Elm::ElmBox.new self do |bx|
                bx.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                self.resize_object_add bx
                bx.show
            end
            as_pos = Native.enum_type :elm_actionslider_pos
            as = Elm::ElmActionSlider.new self do |as|
                as.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                as.size_hint_align_set Evas::EVAS_HINT_FILL, 0
                as.text_part = "left", "Snooze"
                as.text_part = "center", nil
                as.text_part = "right", "Stop"
                as.indicator_pos = :elm_actionslider_right
                as.magnet_pos = :elm_actionslider_right
                as.enabled_pos = as_pos[:elm_actionslider_left]|as_pos[:elm_actionslider_right]
                as.smart_callback_add "selected", method(:cb_pos_selected)
                as.smart_callback_add "pos_changed", method(:cb_position_change_magnetic)
                as.show
            end
            @bx.pack_end as
            as = Elm::ElmActionSlider.new self do |as|
                as.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                as.size_hint_align_set Evas::EVAS_HINT_FILL, 0
                as.text_part = "left", "Snooze"
                as.text_part = "center", nil
                as.text_part = "right", "Stop"
                as.indicator_pos = :elm_actionslider_center
                as.magnet_pos = :elm_actionslider_center
                as.enabled_pos = as_pos[:elm_actionslider_left]|as_pos[:elm_actionslider_right]
                as.smart_callback_add "selected", method(:cb_pos_selected)
                as.show
            end
            @bx.pack_end as
            as = Elm::ElmActionSlider.new self do |as|
                as.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                as.size_hint_align_set Evas::EVAS_HINT_FILL, 0
                as.style = "bar"
                as.text_part = "left", nil
                as.text_part = "center", "Accept"
                as.text_part = "right", "Reject"
                as.indicator_pos = :elm_actionslider_left
                as.magnet_pos = as_pos[:elm_actionslider_center]|as_pos[:elm_actionslider_right]
                as.enabled_pos = as_pos[:elm_actionslider_center]|as_pos[:elm_actionslider_right]
                as.smart_callback_add "selected", method(:cb_pos_selected)
                as.show
            end
            @bx.pack_end as
            as = Elm::ElmActionSlider.new self do |as|
                as.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                as.size_hint_align_set Evas::EVAS_HINT_FILL, 0
                as.style = "bar"
                as.text = "Go"
                as.text_part = "left", nil
                as.text_part = "center", "Accept"
                as.text_part = "right", "Reject"
                as.indicator_pos = :elm_actionslider_left
                as.magnet_pos = :elm_actionslider_left
                as.smart_callback_add "selected", method(:cb_pos_selected)
                as.smart_callback_add "pos_changed", method(:cb_position_change_magnetic)
                as.show
            end
            @bx.pack_end as
            as = Elm::ElmActionSlider.new self do |as|
                as.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                as.size_hint_align_set Evas::EVAS_HINT_FILL, 0
                as.text = "Go"
                as.text_part = "left", "Left"
                as.text_part = "center", "Center"
                as.text_part = "right", "Right"
                as.indicator_pos = :elm_actionslider_left
                as.magnet_pos = :elm_actionslider_all
                as.smart_callback_add "selected", method(:cb_pos_selected)
                as.show
            end
            @bx.pack_end as
            as = Elm::ElmActionSlider.new self do |as|
                as.size_hint_weight_set Evas::EVAS_HINT_EXPAND, 0
                as.size_hint_align_set Evas::EVAS_HINT_FILL, 0
                as.text = "Go"
                as.text_part = "left", "Enable"
                as.text_part = "center", "Magnet"
                as.text_part = "right", "Disable"
                as.indicator_pos = :elm_actionslider_center
                as.magnet_pos = :elm_actionslider_center
                as.smart_callback_add "selected", method(:cb_pos_selected)
                as.smart_callback_add "pos_changed", method(:cb_magnet_enable_disable)
                as.show
            end
            @bx.pack_end as
        end
        def cb_pos_selected data, evas_obj, event_info
            as = Elm::ElmActionSlider.new evas_obj
            puts "Selection #{event_info.null? ? 'NULL' : event_info.read_string}"
            puts "   label: #{Elm::ElmActionSlider.new(evas_obj).selected_label}"
        end
        def cb_position_change_magnetic data, evas_obj, event_info
            as = Elm::ElmActionSlider.new evas_obj
            return if event_info.null?
            case event_info.read_string
            when "left"
                as.magnet_pos = :elm_actionslider_left
            when "right"
                as.magnet_pos = :elm_actionslider_right
            end
        end
        def cb_magnet_enable_disable data, evas_obj, event_info
            as = Elm::ElmActionSlider.new evas_obj
            return if event_info.null?
            case event_info.read_string
            when "left"
                as.magnet_pos = :elm_actionslider_center
            when "right"
                as.magnet_pos = :elm_actionslider_none
            end
        end
    end
    #
    def self.test_actionslider
        TestActionSlider.new 'actionslider', 'Actionslider', :simple
    end
    #
end
#
# EOF