summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshilpa.singh <shilpa.singh@samsung.com>2015-01-08 16:06:34 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-01-08 16:06:35 +0900
commit7d6c0d12e676d5981b4110a74ffc6fe00699add3 (patch)
treebba76eb57013db5626b7315fcda1c3b86467d0e3
parenta48894a6475fec77c55d1a7ce7f25a5f907c7005 (diff)
elm_widget: elm_object_disabled_set API fix
Summary: When elm_object_disabled_set API is called on any widget, All the subobjects of the widget also has to be disabled issue fix. @fix Test Plan: Call the API elm_object_disabled_set on any container widget like box, layout etc:-, fix can be tested with test_box.c and test_layout.c test codes. Reviewers: Hermet, seoz, raster Subscribers: govi, rajeshps Differential Revision: https://phab.enlightenment.org/D1778
-rw-r--r--src/bin/Makefile.am1
-rw-r--r--src/bin/test.c5
-rw-r--r--src/bin/test_disable.c207
-rw-r--r--src/lib/elm_widget.c67
4 files changed, 277 insertions, 3 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index fbddf40dd..8c438daca 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -47,6 +47,7 @@ test_ctxpopup.c \
47test_cursor.c \ 47test_cursor.c \
48test_datetime.c \ 48test_datetime.c \
49test_dayselector.c \ 49test_dayselector.c \
50test_disable.c \
50test_diskselector.c \ 51test_diskselector.c \
51test_dnd.c \ 52test_dnd.c \
52test_eio.c \ 53test_eio.c \
diff --git a/src/bin/test.c b/src/bin/test.c
index eeec24adf..f812bb0fe 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -252,6 +252,8 @@ void test_task_switcher(void *data, Evas_Object *obj, void *event_info);
252void test_application_server_message(void *data, Evas_Object *obj, void *event_info); 252void test_application_server_message(void *data, Evas_Object *obj, void *event_info);
253void test_application_server_phone(void *data, Evas_Object *obj, void *event_info); 253void test_application_server_phone(void *data, Evas_Object *obj, void *event_info);
254void test_win_dialog(void *data, Evas_Object *obj, void *event_info); 254void test_win_dialog(void *data, Evas_Object *obj, void *event_info);
255void test_box_disable(void *data, Evas_Object *obj, void *event_info);
256void test_layout_disable(void *data, Evas_Object *obj, void *event_info);
255 257
256Evas_Object *win, *tbx; // TODO: refactoring 258Evas_Object *win, *tbx; // TODO: refactoring
257void *tt; 259void *tt;
@@ -839,6 +841,9 @@ add_tests:
839 ADD_TEST(NULL, "Application client/server", "Phone", test_application_server_phone); 841 ADD_TEST(NULL, "Application client/server", "Phone", test_application_server_phone);
840 ADD_TEST(NULL, "Application client/server", "Message", test_application_server_message); 842 ADD_TEST(NULL, "Application client/server", "Message", test_application_server_message);
841 843
844 ADD_TEST(NULL, "Widgets Disable/Enable", "Box", test_box_disable);
845 ADD_TEST(NULL, "Widgets Disable/Enable", "Layout", test_layout_disable);
846
842#undef ADD_TEST 847#undef ADD_TEST
843 848
844 if (autorun) 849 if (autorun)
diff --git a/src/bin/test_disable.c b/src/bin/test_disable.c
new file mode 100644
index 000000000..9895369aa
--- /dev/null
+++ b/src/bin/test_disable.c
@@ -0,0 +1,207 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6static void
7_disable_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
8{
9 Eina_Bool status = EINA_FALSE;
10 status = elm_object_disabled_get(data);
11 elm_object_disabled_set(data, !status);
12}
13
14void
15test_box_disable(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
16{
17 Evas_Object *win, *bx, *bt, *bx_out, *fr, *lb;
18 Evas_Object *btn[4];
19
20 win = elm_win_util_standard_add("box-transition", "Box Transition");
21 elm_win_autodel_set(win, EINA_TRUE);
22
23 bx_out = elm_box_add(win);
24 evas_object_size_hint_weight_set(bx_out, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
25 elm_win_resize_object_add(win, bx_out);
26 evas_object_show(bx_out);
27
28 fr = elm_frame_add(bx_out);
29 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
30 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
31 elm_box_pack_end(bx_out, fr);
32 elm_object_text_set(fr, "Description");
33 evas_object_show(fr);
34
35 bx = elm_box_add(fr);
36 elm_object_content_set(fr, bx);
37 evas_object_show(bx);
38
39 lb = elm_label_add(bx);
40 elm_object_text_set(lb, "This test shows how enable/disable of Container widget works");
41 evas_object_size_hint_align_set(lb, 0.0, EVAS_HINT_FILL);
42 elm_box_pack_end(bx, lb);
43 evas_object_show(lb);
44
45 btn[0] = elm_button_add(bx);
46 elm_object_text_set(btn[0], "Disable/Enable Box");
47 evas_object_size_hint_weight_set(btn[0], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
48 evas_object_size_hint_align_set(btn[0], EVAS_HINT_FILL, EVAS_HINT_FILL);
49 elm_box_pack_end(bx, btn[0]);
50 evas_object_show(btn[0]);
51
52 btn[1] = elm_button_add(bx);
53 elm_object_text_set(btn[1], "Disable/Enable Button 1");
54 evas_object_size_hint_weight_set(btn[1], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
55 evas_object_size_hint_align_set(btn[1], EVAS_HINT_FILL, EVAS_HINT_FILL);
56 elm_box_pack_end(bx, btn[1]);
57 evas_object_show(btn[1]);
58
59 btn[2] = elm_button_add(bx);
60 elm_object_text_set(btn[2], "Disable/Enable Button 2");
61 evas_object_size_hint_weight_set(btn[2], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62 evas_object_size_hint_align_set(btn[2], EVAS_HINT_FILL, EVAS_HINT_FILL);
63 elm_box_pack_end(bx, btn[2]);
64 evas_object_show(btn[2]);
65
66 btn[3] = elm_button_add(bx);
67 elm_object_text_set(btn[3], "Disable/Enable Button 3");
68 evas_object_size_hint_weight_set(btn[3], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
69 evas_object_size_hint_align_set(btn[3], EVAS_HINT_FILL, EVAS_HINT_FILL);
70 elm_box_pack_end(bx, btn[3]);
71 evas_object_show(btn[3]);
72
73 bx = elm_box_add(bx_out);
74 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
76 elm_box_pack_end(bx_out, bx);
77 evas_object_show(bx);
78 evas_object_smart_callback_add(btn[0], "clicked", _disable_cb, bx);
79
80 bt = elm_button_add(win);
81 elm_object_text_set(bt, "Button 1");
82 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
83 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
84 elm_box_pack_end(bx, bt);
85 evas_object_show(bt);
86 evas_object_smart_callback_add(btn[1], "clicked", _disable_cb, bt);
87
88 bt = elm_button_add(win);
89 elm_object_text_set(bt, "Button 2");
90 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
91 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
92 elm_box_pack_end(bx, bt);
93 evas_object_show(bt);
94 evas_object_smart_callback_add(btn[2], "clicked", _disable_cb, bt);
95
96 bt = elm_button_add(win);
97 elm_object_text_set(bt, "Button 3");
98 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
99 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
100 elm_box_pack_end(bx, bt);
101 evas_object_show(bt);
102 evas_object_smart_callback_add(btn[3], "clicked", _disable_cb, bt);
103
104 evas_object_resize(win, 300, 300);
105 evas_object_show(win);
106}
107
108void
109test_layout_disable(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
110{
111 Evas_Object *win, *box, *ly, *bt;
112 Evas_Object *fr, *btn[3], *bx, *lb;
113 char buf[PATH_MAX];
114
115 win = elm_win_util_standard_add("layout", "Layout");
116 elm_win_autodel_set(win, EINA_TRUE);
117
118 box = elm_box_add(win);
119 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
120 elm_win_resize_object_add(win, box);
121 evas_object_show(box);
122
123 fr = elm_frame_add(box);
124 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0.0);
125 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
126 elm_box_pack_end(box, fr);
127 elm_object_text_set(fr, "Description");
128 evas_object_show(fr);
129
130 bx = elm_box_add(fr);
131 elm_object_content_set(fr, bx);
132 evas_object_show(bx);
133
134 lb = elm_label_add(bx);
135 elm_object_text_set(lb, "This test shows how enable/disable of Container widget works");
136 evas_object_size_hint_align_set(lb, 0.0, EVAS_HINT_FILL);
137 elm_box_pack_end(bx, lb);
138 evas_object_show(lb);
139
140 btn[0] = elm_button_add(bx);
141 elm_object_text_set(btn[0], "Disable/Enable Layout");
142 evas_object_size_hint_weight_set(btn[0], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
143 evas_object_size_hint_align_set(btn[0], EVAS_HINT_FILL, EVAS_HINT_FILL);
144 elm_box_pack_end(bx, btn[0]);
145 evas_object_show(btn[0]);
146
147 btn[1] = elm_button_add(bx);
148 elm_object_text_set(btn[1], "Disable/Enable Button 1");
149 evas_object_size_hint_weight_set(btn[1], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
150 evas_object_size_hint_align_set(btn[1], EVAS_HINT_FILL, EVAS_HINT_FILL);
151 elm_box_pack_end(bx, btn[1]);
152 evas_object_show(btn[1]);
153
154 btn[2] = elm_button_add(bx);
155 elm_object_text_set(btn[2], "Disable/Enable Button 2");
156 evas_object_size_hint_weight_set(btn[2], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
157 evas_object_size_hint_align_set(btn[2], EVAS_HINT_FILL, EVAS_HINT_FILL);
158 elm_box_pack_end(bx, btn[2]);
159 evas_object_show(btn[2]);
160
161 btn[3] = elm_button_add(bx);
162 elm_object_text_set(btn[3], "Disable/Enable Button 3");
163 evas_object_size_hint_weight_set(btn[3], EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
164 evas_object_size_hint_align_set(btn[3], EVAS_HINT_FILL, EVAS_HINT_FILL);
165 elm_box_pack_end(bx, btn[3]);
166 evas_object_show(btn[3]);
167
168 ly = elm_layout_add(win);
169
170 if (!elm_layout_theme_set(
171 ly, "layout", "application", "titlebar"))
172 fprintf(stderr, "Failed to set layout");
173
174 elm_object_part_text_set(ly, "elm.text", "Layout Disable/Enable Test");
175 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
176 evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
177 elm_box_pack_end(box, ly);
178 evas_object_show(ly);
179
180 ly = elm_layout_add(win);
181 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
182 elm_layout_file_set(ly, buf, "layout");
183 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
184 elm_box_pack_end(box, ly);
185 evas_object_show(ly);
186 evas_object_smart_callback_add(btn[0], "clicked", _disable_cb, ly);
187
188 bt = elm_button_add(win);
189 elm_object_text_set(bt, "Button 1");
190 elm_object_part_content_set(ly, "element1", bt);
191 evas_object_show(bt);
192 evas_object_smart_callback_add(btn[1], "clicked", _disable_cb, bt);
193
194 bt = elm_button_add(win);
195 elm_object_text_set(bt, "Button 2");
196 elm_object_part_content_set(ly, "element2", bt);
197 evas_object_show(bt);
198 evas_object_smart_callback_add(btn[2], "clicked", _disable_cb, bt);
199
200 bt = elm_button_add(win);
201 elm_object_text_set(bt, "Button 3");
202 elm_object_part_content_set(ly, "element3", bt);
203 evas_object_show(bt);
204 evas_object_smart_callback_add(btn[3], "clicked", _disable_cb, bt);
205
206 evas_object_show(win);
207}
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index c0dacac7b..0323123c7 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -1098,6 +1098,15 @@ _elm_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj
1098 else 1098 else
1099 sdc->orient_mode = sd->orient_mode; 1099 sdc->orient_mode = sd->orient_mode;
1100 1100
1101 if (!sdc->on_create)
1102 {
1103 if (!sdc->disabled && (elm_widget_disabled_get(obj)))
1104 {
1105 elm_widget_focus_disabled_handle(sobj);
1106 eo_do(sobj, elm_obj_widget_disable());
1107 }
1108 }
1109
1101 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused); 1110 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
1102 1111
1103 /* update child focusable-ness on self and parents, now that a 1112 /* update child focusable-ness on self and parents, now that a
@@ -2860,19 +2869,71 @@ _elm_widget_top_win_focused_get(const Evas_Object *obj)
2860 return sd->top_win_focused; 2869 return sd->top_win_focused;
2861} 2870}
2862 2871
2872static void
2873_elm_widget_disabled_eval(const Evas_Object *obj, Eina_Bool disabled)
2874{
2875 const Eina_List *l;
2876 Evas_Object *child;
2877 ELM_WIDGET_DATA_GET(obj, sd);
2878
2879 if (disabled)
2880 {
2881 EINA_LIST_FOREACH(sd->subobjs, l, child)
2882 {
2883 if (elm_widget_is(child))
2884 {
2885 elm_widget_focus_disabled_handle(child);
2886 eo_do(child, elm_obj_widget_disable());
2887 _elm_widget_disabled_eval(child, EINA_TRUE);
2888 }
2889 }
2890 }
2891 else
2892 {
2893 EINA_LIST_FOREACH(sd->subobjs, l, child)
2894 {
2895 ELM_WIDGET_DATA_GET(child, sdc);
2896 if (elm_widget_is(child) && !sdc->disabled)
2897 {
2898 elm_widget_focus_disabled_handle(child);
2899 eo_do(child, elm_obj_widget_disable());
2900 _elm_widget_disabled_eval(child, EINA_FALSE);
2901 }
2902 }
2903 }
2904}
2905
2863EOLIAN static void 2906EOLIAN static void
2864_elm_widget_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled) 2907_elm_widget_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled)
2865{ 2908{
2909 Eina_Bool parent_state = EINA_FALSE;
2866 if (sd->disabled == disabled) return; 2910 if (sd->disabled == disabled) return;
2867 sd->disabled = !!disabled; 2911 sd->disabled = !!disabled;
2868 elm_widget_focus_disabled_handle(obj); 2912
2869 eo_do(obj, elm_obj_widget_disable()); 2913 if (disabled)
2914 {
2915 elm_widget_focus_disabled_handle(obj);
2916 eo_do(obj, elm_obj_widget_disable());
2917 _elm_widget_disabled_eval(obj, EINA_TRUE);
2918 }
2919 else
2920 {
2921 parent_state = elm_widget_disabled_get(elm_widget_parent_get(obj));
2922 if (parent_state) return;
2923 elm_widget_focus_disabled_handle(obj);
2924 eo_do(obj, elm_obj_widget_disable());
2925 _elm_widget_disabled_eval(obj, EINA_FALSE);
2926 }
2870} 2927}
2871 2928
2872EOLIAN static Eina_Bool 2929EOLIAN static Eina_Bool
2873_elm_widget_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd) 2930_elm_widget_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
2874{ 2931{
2875 return sd->disabled; 2932 Eina_Bool disabled = EINA_FALSE;
2933
2934 if (sd->disabled) disabled = EINA_TRUE;
2935 else disabled = elm_widget_disabled_get(elm_widget_parent_get(obj));
2936 return disabled;
2876} 2937}
2877 2938
2878EOLIAN static void 2939EOLIAN static void