summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/test_button.c49
-rw-r--r--src/lib/elm_button.c4
2 files changed, 46 insertions, 7 deletions
diff --git a/src/bin/test_button.c b/src/bin/test_button.c
index c90ab1c23..de9c64f47 100644
--- a/src/bin/test_button.c
+++ b/src/bin/test_button.c
@@ -15,10 +15,26 @@ _bt_repeated(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED_
15 elm_button_label_set(obj, buf); 15 elm_button_label_set(obj, buf);
16} 16}
17 17
18static void
19_bt_clicked(void *data, Evas_Object * obj, void *event_info)
20{
21 int param = (int)(data);
22
23 printf("clicked event on Button:%d\n", param);
24}
25
26static void
27_bt_unpressed(void *data, Evas_Object * obj, void *event_info)
28{
29 int param = (int)(data);
30
31 printf("unpressed event on Button:%d\n", param);
32}
33
18void 34void
19test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 35test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
20{ 36{
21 Evas_Object *win, *bg, *bx, *ic, *bt; 37 Evas_Object *win, *bg, *scr, *bx, *ic, *bt;
22 char buf[PATH_MAX]; 38 char buf[PATH_MAX];
23 39
24 win = elm_win_add(NULL, "buttons", ELM_WIN_BASIC); 40 win = elm_win_add(NULL, "buttons", ELM_WIN_BASIC);
@@ -30,9 +46,16 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
30 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 46 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
31 evas_object_show(bg); 47 evas_object_show(bg);
32 48
49 scr = elm_scroller_add(win);
50 elm_scroller_bounce_set(scr, EINA_FALSE, EINA_TRUE);
51 elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
52 elm_win_resize_object_add(win, scr);
53 evas_object_show(scr);
54 evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55
33 bx = elm_box_add(win); 56 bx = elm_box_add(win);
34 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 57 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
35 elm_win_resize_object_add(win, bx); 58 elm_scroller_content_set(scr, bx);
36 evas_object_show(bx); 59 evas_object_show(bx);
37 60
38 ic = elm_icon_add(win); 61 ic = elm_icon_add(win);
@@ -42,17 +65,21 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
42 bt = elm_button_add(win); 65 bt = elm_button_add(win);
43 elm_button_label_set(bt, "Icon sized to button"); 66 elm_button_label_set(bt, "Icon sized to button");
44 elm_button_icon_set(bt, ic); 67 elm_button_icon_set(bt, ic);
68 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)1);
69 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)1);
45 elm_box_pack_end(bx, bt); 70 elm_box_pack_end(bx, bt);
46 evas_object_show(bt); 71 evas_object_show(bt);
47 evas_object_show(ic); 72 evas_object_show(ic);
48 73
49 ic = elm_icon_add(win); 74 ic = elm_icon_add(bx);
50 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); 75 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
51 elm_icon_file_set(ic, buf, NULL); 76 elm_icon_file_set(ic, buf, NULL);
52 elm_icon_scale_set(ic, 0, 0); 77 elm_icon_scale_set(ic, 0, 0);
53 bt = elm_button_add(win); 78 bt = elm_button_add(win);
54 elm_button_label_set(bt, "Icon no scale"); 79 elm_button_label_set(bt, "Icon no scale");
55 elm_button_icon_set(bt, ic); 80 elm_button_icon_set(bt, ic);
81 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)2);
82 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)2);
56 elm_box_pack_end(bx, bt); 83 elm_box_pack_end(bx, bt);
57 evas_object_show(bt); 84 evas_object_show(bt);
58 evas_object_show(ic); 85 evas_object_show(ic);
@@ -65,6 +92,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
65 elm_button_label_set(bt, "Disabled Button"); 92 elm_button_label_set(bt, "Disabled Button");
66 elm_button_icon_set(bt, ic); 93 elm_button_icon_set(bt, ic);
67 elm_object_disabled_set(bt, 1); 94 elm_object_disabled_set(bt, 1);
95 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)3);
96 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)3);
68 elm_box_pack_end(bx, bt); 97 elm_box_pack_end(bx, bt);
69 evas_object_show(bt); 98 evas_object_show(bt);
70 evas_object_show(ic); 99 evas_object_show(ic);
@@ -76,12 +105,16 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
76 bt = elm_button_add(win); 105 bt = elm_button_add(win);
77 elm_button_icon_set(bt, ic); 106 elm_button_icon_set(bt, ic);
78 elm_object_disabled_set(bt, 1); 107 elm_object_disabled_set(bt, 1);
108 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)4);
109 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)4);
79 elm_box_pack_end(bx, bt); 110 elm_box_pack_end(bx, bt);
80 evas_object_show(bt); 111 evas_object_show(bt);
81 evas_object_show(ic); 112 evas_object_show(ic);
82 113
83 bt = elm_button_add(win); 114 bt = elm_button_add(win);
84 elm_button_label_set(bt, "Label Only"); 115 elm_button_label_set(bt, "Label Only");
116 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)5);
117 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)5);
85 elm_box_pack_end(bx, bt); 118 elm_box_pack_end(bx, bt);
86 evas_object_smart_callback_add(bt, "repeated", _bt_repeated, NULL); 119 evas_object_smart_callback_add(bt, "repeated", _bt_repeated, NULL);
87 elm_button_autorepeat_set(bt, 1); 120 elm_button_autorepeat_set(bt, 1);
@@ -95,6 +128,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
95 elm_icon_scale_set(ic, 0, 0); 128 elm_icon_scale_set(ic, 0, 0);
96 bt = elm_button_add(win); 129 bt = elm_button_add(win);
97 elm_button_icon_set(bt, ic); 130 elm_button_icon_set(bt, ic);
131 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)6);
132 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)6);
98 elm_box_pack_end(bx, bt); 133 elm_box_pack_end(bx, bt);
99 evas_object_show(bt); 134 evas_object_show(bt);
100 evas_object_show(ic); 135 evas_object_show(ic);
@@ -103,6 +138,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
103 bt = elm_button_add(win); 138 bt = elm_button_add(win);
104 elm_object_style_set(bt, "anchor"); 139 elm_object_style_set(bt, "anchor");
105 elm_button_label_set(bt, "Anchor style"); 140 elm_button_label_set(bt, "Anchor style");
141 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)7);
142 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)7);
106 elm_box_pack_end(bx, bt); 143 elm_box_pack_end(bx, bt);
107 evas_object_show(bt); 144 evas_object_show(bt);
108 145
@@ -113,6 +150,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
113 bt = elm_button_add(win); 150 bt = elm_button_add(win);
114 elm_object_style_set(bt, "anchor"); 151 elm_object_style_set(bt, "anchor");
115 elm_button_icon_set(bt, ic); 152 elm_button_icon_set(bt, ic);
153 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)8);
154 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)8);
116 elm_box_pack_end(bx, bt); 155 elm_box_pack_end(bx, bt);
117 evas_object_show(bt); 156 evas_object_show(bt);
118 evas_object_show(ic); 157 evas_object_show(ic);
@@ -126,10 +165,12 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
126 elm_object_style_set(bt, "anchor"); 165 elm_object_style_set(bt, "anchor");
127 elm_button_icon_set(bt, ic); 166 elm_button_icon_set(bt, ic);
128 elm_object_disabled_set(bt, 1); 167 elm_object_disabled_set(bt, 1);
168 evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)9);
169 evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)9);
129 elm_box_pack_end(bx, bt); 170 elm_box_pack_end(bx, bt);
130 evas_object_show(bt); 171 evas_object_show(bt);
131 evas_object_show(ic); 172 evas_object_show(ic);
132 173 evas_object_resize(win, 320, 480);
133 evas_object_show(win); 174 evas_object_show(win);
134} 175}
135#endif 176#endif
diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c
index 3a1645aa4..6ebd759d5 100644
--- a/src/lib/elm_button.c
+++ b/src/lib/elm_button.c
@@ -161,14 +161,13 @@ static void
161_sizing_eval(Evas_Object *obj) 161_sizing_eval(Evas_Object *obj)
162{ 162{
163 Widget_Data *wd = elm_widget_data_get(obj); 163 Widget_Data *wd = elm_widget_data_get(obj);
164 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; 164 Evas_Coord minw = -1, minh = -1;
165 165
166 if (!wd) return; 166 if (!wd) return;
167 elm_coords_finger_size_adjust(1, &minw, 1, &minh); 167 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
168 edje_object_size_min_restricted_calc(wd->btn, &minw, &minh, minw, minh); 168 edje_object_size_min_restricted_calc(wd->btn, &minw, &minh, minw, minh);
169 elm_coords_finger_size_adjust(1, &minw, 1, &minh); 169 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
170 evas_object_size_hint_min_set(obj, minw, minh); 170 evas_object_size_hint_min_set(obj, minw, minh);
171 evas_object_size_hint_max_set(obj, maxw, maxh);
172} 171}
173 172
174static void 173static void
@@ -209,7 +208,6 @@ _activate(Evas_Object *obj)
209 } 208 }
210 wd->repeating = EINA_FALSE; 209 wd->repeating = EINA_FALSE;
211 evas_object_smart_callback_call(obj, SIG_CLICKED, NULL); 210 evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
212 _signal_unpressed(obj, wd->btn, NULL, NULL); /* safe guard when the theme does not emit the 'unpress' signal */
213} 211}
214 212
215static void 213static void