summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-12-28 20:36:52 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-12-28 20:39:08 +0000
commitf989cea52ddcff188bfab56a4cf5b29612d7ebaf (patch)
tree1f9282258bb4be733f968e5c0acc5da3f3b94090 /src/bin
parent2e854ce7ed5a75249ceb7201411ccb2b83e27a4d (diff)
elm - add plain and icon style radio and check and elm tests for it
this will be common enough to put into elm - there is no way to do a gimp style "tool palette" where you select one of them (like one from a set of radio buttons) at all times... but you don't want the "round circle" but instead want it to look more like a button to fit in with a palette style look. this calls for styles... so here they are. @feat
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elementary/test_check.c63
-rw-r--r--src/bin/elementary/test_radio.c44
2 files changed, 90 insertions, 17 deletions
diff --git a/src/bin/elementary/test_check.c b/src/bin/elementary/test_check.c
index 40ca00d..b47145e 100644
--- a/src/bin/elementary/test_check.c
+++ b/src/bin/elementary/test_check.c
@@ -29,25 +29,18 @@ state_changed_cb2(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EIN
29 elm_object_text_set(obj, "text is visible when check state is true."); 29 elm_object_text_set(obj, "text is visible when check state is true.");
30} 30}
31 31
32void 32static void
33test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 33check_style(Evas_Object *win, Evas_Object *bx, const char *style)
34{ 34{
35 Evas_Object *win, *bx, *ic, *ck, *ck0; 35 Evas_Object *ic, *ck, *ck0;
36 char buf[PATH_MAX]; 36 char buf[PATH_MAX];
37 37
38 win = elm_win_util_standard_add("check", "Check");
39 elm_win_autodel_set(win, EINA_TRUE);
40
41 bx = elm_box_add(win);
42 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, bx);
44 evas_object_show(bx);
45
46 ic = elm_icon_add(win); 38 ic = elm_icon_add(win);
47 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); 39 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
48 elm_image_file_set(ic, buf, NULL); 40 elm_image_file_set(ic, buf, NULL);
49 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); 41 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
50 ck = elm_check_add(win); 42 ck = elm_check_add(win);
43 elm_object_style_set(ck, style);
51 elm_object_text_set(ck, "Icon sized to check"); 44 elm_object_text_set(ck, "Icon sized to check");
52 elm_object_part_content_set(ck, "icon", ic); 45 elm_object_part_content_set(ck, "icon", ic);
53 elm_check_state_set(ck, EINA_TRUE); 46 elm_check_state_set(ck, EINA_TRUE);
@@ -62,6 +55,7 @@ test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
62 elm_image_file_set(ic, buf, NULL); 55 elm_image_file_set(ic, buf, NULL);
63 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 56 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
64 ck = elm_check_add(win); 57 ck = elm_check_add(win);
58 elm_object_style_set(ck, style);
65 elm_object_text_set(ck, "Icon not resizable"); 59 elm_object_text_set(ck, "Icon not resizable");
66 elm_object_part_content_set(ck, "icon", ic); 60 elm_object_part_content_set(ck, "icon", ic);
67 elm_box_pack_end(bx, ck); 61 elm_box_pack_end(bx, ck);
@@ -71,17 +65,20 @@ test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
71 evas_object_smart_callback_add(ck, "changed", changed_cb, ck0); 65 evas_object_smart_callback_add(ck, "changed", changed_cb, ck0);
72 66
73 ck = elm_check_add(win); 67 ck = elm_check_add(win);
68 elm_object_style_set(ck, style);
74 elm_object_text_set(ck, "Label Only"); 69 elm_object_text_set(ck, "Label Only");
75 elm_box_pack_end(bx, ck); 70 elm_box_pack_end(bx, ck);
76 evas_object_show(ck); 71 evas_object_show(ck);
77 72
78 ck = elm_check_add(win); 73 ck = elm_check_add(win);
74 elm_object_style_set(ck, style);
79 elm_object_text_set(ck, "Use State Pointer"); 75 elm_object_text_set(ck, "Use State Pointer");
80 elm_check_state_pointer_set(ck, &eb); 76 elm_check_state_pointer_set(ck, &eb);
81 elm_box_pack_end(bx, ck); 77 elm_box_pack_end(bx, ck);
82 evas_object_show(ck); 78 evas_object_show(ck);
83 79
84 ck = elm_check_add(win); 80 ck = elm_check_add(win);
81 elm_object_style_set(ck, style);
85 elm_object_text_set(ck, "Print State Pointer Value"); 82 elm_object_text_set(ck, "Print State Pointer Value");
86 elm_box_pack_end(bx, ck); 83 elm_box_pack_end(bx, ck);
87 evas_object_show(ck); 84 evas_object_show(ck);
@@ -92,6 +89,7 @@ test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
92 elm_image_file_set(ic, buf, NULL); 89 elm_image_file_set(ic, buf, NULL);
93 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); 90 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
94 ck = elm_check_add(win); 91 ck = elm_check_add(win);
92 elm_object_style_set(ck, style);
95 elm_object_text_set(ck, "Disabled check"); 93 elm_object_text_set(ck, "Disabled check");
96 elm_object_part_content_set(ck, "icon", ic); 94 elm_object_part_content_set(ck, "icon", ic);
97 elm_check_state_set(ck, EINA_TRUE); 95 elm_check_state_set(ck, EINA_TRUE);
@@ -101,6 +99,7 @@ test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
101 evas_object_show(ic); 99 evas_object_show(ic);
102 100
103 ck = elm_check_add(win); 101 ck = elm_check_add(win);
102 elm_object_style_set(ck, style);
104 elm_box_pack_end(bx, ck); 103 elm_box_pack_end(bx, ck);
105 elm_object_disabled_set(ck, EINA_TRUE); 104 elm_object_disabled_set(ck, EINA_TRUE);
106 evas_object_show(ck); 105 evas_object_show(ck);
@@ -110,21 +109,63 @@ test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
110 elm_image_file_set(ic, buf, NULL); 109 elm_image_file_set(ic, buf, NULL);
111 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 110 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
112 ck = elm_check_add(win); 111 ck = elm_check_add(win);
112 elm_object_style_set(ck, style);
113 elm_object_part_content_set(ck, "icon", ic); 113 elm_object_part_content_set(ck, "icon", ic);
114 elm_box_pack_end(bx, ck); 114 elm_box_pack_end(bx, ck);
115 evas_object_show(ck); 115 evas_object_show(ck);
116 evas_object_show(ic); 116 evas_object_show(ic);
117 117
118 ck = elm_check_add(win); 118 ck = elm_check_add(win);
119 elm_object_style_set(ck, style);
119 elm_box_pack_end(bx, ck); 120 elm_box_pack_end(bx, ck);
120 evas_object_show(ck); 121 evas_object_show(ck);
121 122
122 ck = elm_check_add(win); 123 ck = elm_check_add(win);
124 elm_object_style_set(ck, style);
123 elm_box_pack_end(bx, ck); 125 elm_box_pack_end(bx, ck);
124 elm_object_text_set(ck, "text is visible when check state is true."); 126 elm_object_text_set(ck, "text is visible when check state is true.");
125 elm_check_state_set(ck, EINA_TRUE); 127 elm_check_state_set(ck, EINA_TRUE);
126 evas_object_show(ck); 128 evas_object_show(ck);
127 evas_object_smart_callback_add(ck, "changed", state_changed_cb2, NULL); 129 evas_object_smart_callback_add(ck, "changed", state_changed_cb2, NULL);
130}
131
132void
133test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
134{
135 Evas_Object *win, *bx, *bx0;
136
137 win = elm_win_util_standard_add("check", "Check");
138 elm_win_autodel_set(win, EINA_TRUE);
139
140 bx0 = elm_box_add(win);
141 evas_object_size_hint_weight_set(bx0, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
142 elm_box_horizontal_set(bx0, EINA_TRUE);
143 elm_win_resize_object_add(win, bx0);
144 evas_object_show(bx0);
145
146 bx = elm_box_add(win);
147 elm_box_horizontal_set(bx, EINA_FALSE);
148 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
149 elm_box_pack_end(bx0, bx);
150 evas_object_show(bx);
151
152 check_style(win, bx, "default");
153
154 bx = elm_box_add(win);
155 elm_box_horizontal_set(bx, EINA_FALSE);
156 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
157 elm_box_pack_end(bx0, bx);
158 evas_object_show(bx);
159
160 check_style(win, bx, "plain");
161
162 bx = elm_box_add(win);
163 elm_box_horizontal_set(bx, EINA_FALSE);
164 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
165 elm_box_pack_end(bx0, bx);
166 evas_object_show(bx);
167
168 check_style(win, bx, "icon");
128 169
129 evas_object_show(win); 170 evas_object_show(win);
130} 171}
diff --git a/src/bin/elementary/test_radio.c b/src/bin/elementary/test_radio.c
index 608893e..d27494f 100644
--- a/src/bin/elementary/test_radio.c
+++ b/src/bin/elementary/test_radio.c
@@ -18,7 +18,7 @@ _rdg_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
18} 18}
19 19
20static void 20static void
21_group_1_create(Evas_Object *bx) 21_group_1_create(Evas_Object *bx, const char *style)
22{ 22{
23 Evas_Object *bx2, *fr, *ic, *rd, *rdg; 23 Evas_Object *bx2, *fr, *ic, *rd, *rdg;
24 char buf[PATH_MAX]; 24 char buf[PATH_MAX];
@@ -41,6 +41,7 @@ _group_1_create(Evas_Object *bx)
41 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); 41 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
42 42
43 rd = elm_radio_add(bx2); 43 rd = elm_radio_add(bx2);
44 elm_object_style_set(rd, style);
44 elm_radio_state_value_set(rd, 0); 45 elm_radio_state_value_set(rd, 0);
45 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 46 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
46 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5); 47 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
@@ -60,6 +61,7 @@ _group_1_create(Evas_Object *bx)
60 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 61 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
61 62
62 rd = elm_radio_add(bx2); 63 rd = elm_radio_add(bx2);
64 elm_object_style_set(rd, style);
63 elm_radio_state_value_set(rd, 1); 65 elm_radio_state_value_set(rd, 1);
64 elm_radio_group_add(rd, rdg); 66 elm_radio_group_add(rd, rdg);
65 elm_object_text_set(rd, "Icon no scale"); 67 elm_object_text_set(rd, "Icon no scale");
@@ -69,6 +71,7 @@ _group_1_create(Evas_Object *bx)
69 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 71 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
70 72
71 rd = elm_radio_add(bx2); 73 rd = elm_radio_add(bx2);
74 elm_object_style_set(rd, style);
72 elm_radio_state_value_set(rd, 2); 75 elm_radio_state_value_set(rd, 2);
73 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 76 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
74 elm_object_text_set(rd, "Label Only"); 77 elm_object_text_set(rd, "Label Only");
@@ -77,6 +80,7 @@ _group_1_create(Evas_Object *bx)
77 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL); 80 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, NULL);
78 81
79 rd = elm_radio_add(bx2); 82 rd = elm_radio_add(bx2);
83 elm_object_style_set(rd, style);
80 elm_radio_state_value_set(rd, 3); 84 elm_radio_state_value_set(rd, 3);
81 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 85 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
82 elm_object_text_set(rd, "Disabled"); 86 elm_object_text_set(rd, "Disabled");
@@ -91,6 +95,7 @@ _group_1_create(Evas_Object *bx)
91 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 95 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
92 96
93 rd = elm_radio_add(bx2); 97 rd = elm_radio_add(bx2);
98 elm_object_style_set(rd, style);
94 elm_radio_state_value_set(rd, 4); 99 elm_radio_state_value_set(rd, 4);
95 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 100 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
96 elm_object_part_content_set(rd, "icon", ic); 101 elm_object_part_content_set(rd, "icon", ic);
@@ -104,6 +109,7 @@ _group_1_create(Evas_Object *bx)
104 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE); 109 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
105 110
106 rd = elm_radio_add(bx2); 111 rd = elm_radio_add(bx2);
112 elm_object_style_set(rd, style);
107 elm_radio_state_value_set(rd, 5); 113 elm_radio_state_value_set(rd, 5);
108 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg. 114 elm_radio_group_add(rd, rdg); // add a radio button rd to a radio group rdg.
109 elm_object_part_content_set(rd, "icon", ic); 115 elm_object_part_content_set(rd, "icon", ic);
@@ -116,7 +122,7 @@ _group_1_create(Evas_Object *bx)
116} 122}
117 123
118static void 124static void
119_group_2_create(Evas_Object *bx) 125_group_2_create(Evas_Object *bx, const char *style)
120{ 126{
121 Evas_Object *bx2, *fr, *rd, *rdg; 127 Evas_Object *bx2, *fr, *rd, *rdg;
122 128
@@ -134,6 +140,7 @@ _group_2_create(Evas_Object *bx)
134 140
135 // radio 1 141 // radio 1
136 rd = elm_radio_add(bx2); 142 rd = elm_radio_add(bx2);
143 elm_object_style_set(rd, style);
137 elm_radio_state_value_set(rd, 1); 144 elm_radio_state_value_set(rd, 1);
138 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0); 145 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
139 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5); 146 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
@@ -148,6 +155,7 @@ _group_2_create(Evas_Object *bx)
148 155
149 // radio 2 156 // radio 2
150 rd = elm_radio_add(bx2); 157 rd = elm_radio_add(bx2);
158 elm_object_style_set(rd, style);
151 elm_radio_state_value_set(rd, 2); 159 elm_radio_state_value_set(rd, 2);
152 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0); 160 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
153 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5); 161 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
@@ -158,6 +166,7 @@ _group_2_create(Evas_Object *bx)
158 166
159 // radio 2 167 // radio 2
160 rd = elm_radio_add(bx2); 168 rd = elm_radio_add(bx2);
169 elm_object_style_set(rd, style);
161 elm_radio_state_value_set(rd, 3); 170 elm_radio_state_value_set(rd, 3);
162 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0); 171 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
163 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5); 172 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, 0.5);
@@ -171,19 +180,42 @@ void
171test_radio(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 180test_radio(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
172 void *event_info EINA_UNUSED) 181 void *event_info EINA_UNUSED)
173{ 182{
174 Evas_Object *win, *bx; 183 Evas_Object *win, *bx, *bx0;
175 184
176 win = elm_win_util_standard_add("radios", "Radios"); 185 win = elm_win_util_standard_add("radios", "Radios");
177 elm_win_autodel_set(win, EINA_TRUE); 186 elm_win_autodel_set(win, EINA_TRUE);
178 187
188 bx0 = elm_box_add(win);
189 elm_box_horizontal_set(bx0, EINA_TRUE);
190 elm_win_resize_object_add(win, bx0);
191 evas_object_show(bx0);
192
193 bx = elm_box_add(win);
194 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
195 elm_box_horizontal_set(bx, EINA_TRUE);
196 elm_box_pack_end(bx0, bx);
197 evas_object_show(bx);
198
199 _group_1_create(bx, "default");
200 _group_2_create(bx, "default");
201
202 bx = elm_box_add(win);
203 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
204 elm_box_horizontal_set(bx, EINA_TRUE);
205 elm_box_pack_end(bx0, bx);
206 evas_object_show(bx);
207
208 _group_1_create(bx, "plain");
209 _group_2_create(bx, "plain");
210
179 bx = elm_box_add(win); 211 bx = elm_box_add(win);
180 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 212 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
181 elm_win_resize_object_add(win, bx);
182 elm_box_horizontal_set(bx, EINA_TRUE); 213 elm_box_horizontal_set(bx, EINA_TRUE);
214 elm_box_pack_end(bx0, bx);
183 evas_object_show(bx); 215 evas_object_show(bx);
184 216
185 _group_1_create(bx); 217 _group_1_create(bx, "icon");
186 _group_2_create(bx); 218 _group_2_create(bx, "icon");
187 219
188 evas_object_show(win); 220 evas_object_show(win);
189} 221}