summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2010-12-21 09:32:50 +0000
committerCarsten Haitzler <raster@rasterman.com>2010-12-21 09:32:50 +0000
commit45962539bde402b7ab1dcaa6c58271202c1da3c7 (patch)
treeb396490c8aa277bbcfc4a7c1f5cb85f4953e0925
parent7000f805ec243c390876070c4811e5c9ff1cb6d0 (diff)
Rajeev Ranjan(in India) made a patch for elm_button.
Reasons for this patch are as follows. 1. Clicked signal is emitted from button when mouse release region coincides with button region and there has not been any drag outside the region during pressed state. (theme change) 2. Unpressed signal is emitted from button every time we press on button and unpress it irrespective of whether we unpress in button's region or outside. (theme change) 3. The unsetting of maximum size hint has been removed from _sizing_eval function as there is a possibility that some application may set this hint and if we unset it then this information set by application will be lost. 4. Modification in test code for button to show the difference between clicked and unpressed signal emission from this widget. Added a scroller in the heirarchy to show the effect of hold on clicked signal emission. SVN revision: 55687
-rw-r--r--AUTHORS1
-rw-r--r--data/themes/default.edc5
-rw-r--r--src/bin/test_button.c49
-rw-r--r--src/lib/elm_button.c4
4 files changed, 49 insertions, 10 deletions
diff --git a/AUTHORS b/AUTHORS
index 9357d10c6..8fe1cad79 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -29,3 +29,4 @@ Otavio Pontes <otavio@profusion.mobi>
29Viktor Kojouharov <vkojouharov@gmail.com> 29Viktor Kojouharov <vkojouharov@gmail.com>
30Daniel Juyung Seo (SeoZ) <juyung.seo@samsung.com> <seojuyung2@gmail.com> 30Daniel Juyung Seo (SeoZ) <juyung.seo@samsung.com> <seojuyung2@gmail.com>
31Sangho Park <sangho.g.park@samsung.com> <gouache95@gmail.com> 31Sangho Park <sangho.g.park@samsung.com> <gouache95@gmail.com>
32Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com>
diff --git a/data/themes/default.edc b/data/themes/default.edc
index 18d4f59e3..f59b81587 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -2094,7 +2094,6 @@ collections {
2094 } 2094 }
2095 description { state: "clicked" 0.0; 2095 description { state: "clicked" 0.0;
2096 inherit: "default" 0.0; 2096 inherit: "default" 0.0;
2097 visible: 1;
2098 color: 255 255 255 255; 2097 color: 255 255 255 255;
2099 } 2098 }
2100 } 2099 }
@@ -2126,7 +2125,7 @@ collections {
2126 program { 2125 program {
2127 name: "button_unclick"; 2126 name: "button_unclick";
2128 signal: "mouse,up,1"; 2127 signal: "mouse,up,1";
2129 source: "over2"; 2128 source: "over3";
2130 action: SIGNAL_EMIT "elm,action,unpress" ""; 2129 action: SIGNAL_EMIT "elm,action,unpress" "";
2131 after: "button_unclick_anim"; 2130 after: "button_unclick_anim";
2132 } 2131 }
@@ -2168,7 +2167,7 @@ collections {
2168 } 2167 }
2169 program { 2168 program {
2170 name: "button_unclick3"; 2169 name: "button_unclick3";
2171 signal: "mouse,up,1"; 2170 signal: "mouse,clicked,1";
2172 source: "over2"; 2171 source: "over2";
2173 action: SIGNAL_EMIT "elm,action,click" ""; 2172 action: SIGNAL_EMIT "elm,action,click" "";
2174 } 2173 }
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