summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <boris@fau.re>2016-06-10 03:31:10 +0200
committerBoris Faure <boris@fau.re>2016-06-10 03:31:10 +0200
commit37e92063307effe8682998a62ad4e8a69b74bb10 (patch)
treee1c47c6104115e4167aac9a88f6f7fb442c7c4ee
parent8b6036a8f73b2afd1f5fd592867d3d8b9d9eaf80 (diff)
options_keys: use an edje layout
-rw-r--r--data/themes/default.edc31
-rw-r--r--src/bin/options_keys.c71
2 files changed, 66 insertions, 36 deletions
diff --git a/data/themes/default.edc b/data/themes/default.edc
index 7b5cc26..5bc66e4 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -7,6 +7,36 @@ color_classes {
7 7
8collections { 8collections {
9 9
10 group { name: "terminology/keybinding";
11 parts {
12 part { name: "shadow"; type: RECT;
13 description { state: "default" 0.0;
14 color: 0 0 0 196;
15 }
16 }
17 part { name: "label"; type: TEXT;
18 mouse_events: 0;
19 effect: SOFT_SHADOW BOTTOM;
20 scale: 1;
21 description { state: "default" 0.0;
22 fixed: 1 1;
23 rel1.to: "shadow";
24 rel2.to: "shadow";
25 rel1.relative: 0.5 0.5;
26 rel1.offset: 0 0;
27 rel2.relative: 0.5 0.5;
28 rel2.offset: 0 0;
29 color: 255 255 255 255;
30 color3: 0 0 0 18;
31 align: 0.5 0.5;
32 text { font: "Sans"; size: 12;
33 min: 1 1;
34 ellipsis: 0;
35 }
36 }
37 }
38 };
39 };
10 group { name: "terminology/miniview"; 40 group { name: "terminology/miniview";
11 images { 41 images {
12 image: "icon_close.png" COMP; 42 image: "icon_close.png" COMP;
@@ -1110,7 +1140,6 @@ collections {
1110 part { name: "tabtitle"; type: TEXT; mouse_events: 0; 1140 part { name: "tabtitle"; type: TEXT; mouse_events: 0;
1111 scale: 1; 1141 scale: 1;
1112 effect: SOFT_SHADOW BOTTOM; 1142 effect: SOFT_SHADOW BOTTOM;
1113 mouse_events: 0;
1114 description { state: "default" 0.0; 1143 description { state: "default" 0.0;
1115 color: 255 255 255 255; 1144 color: 255 255 255 255;
1116 color3: 0 0 0 18; 1145 color3: 0 0 0 18;
diff --git a/src/bin/options_keys.c b/src/bin/options_keys.c
index b70035f..d74089c 100644
--- a/src/bin/options_keys.c
+++ b/src/bin/options_keys.c
@@ -10,7 +10,7 @@
10/*XXX: can have only one widget at a time… */ 10/*XXX: can have only one widget at a time… */
11static Config *_config; 11static Config *_config;
12static Evas_Object *_fr; 12static Evas_Object *_fr;
13static Evas_Object *_rect, *_bg, *_lbl; 13static Evas_Object *_layout;
14 14
15static void _hover_del(Evas_Object *o); 15static void _hover_del(Evas_Object *o);
16 16
@@ -154,22 +154,10 @@ _hover_sizing_eval(void)
154 Evas_Coord x = 0, y = 0, w = 0, h = 0, min_w, min_h, new_x, new_y; 154 Evas_Coord x = 0, y = 0, w = 0, h = 0, min_w, min_h, new_x, new_y;
155 evas_object_geometry_get(_fr, &x, &y, &w, &h); 155 evas_object_geometry_get(_fr, &x, &y, &w, &h);
156#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8) 156#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
157 evas_object_geometry_set(_rect, x, y, w, h); 157 evas_object_geometry_set(_layout, x, y, w, h);
158#else 158#else
159 evas_object_move(_rect, x, y); 159 evas_object_move(_layout, x, y);
160 evas_object_resize(_rect, w, h); 160 evas_object_resize(_layout, w, h);
161#endif
162 evas_object_size_hint_min_get(_lbl, &min_w, &min_h);
163 new_x = x + w/2 - min_w/2;
164 new_y = y + h/2 - min_h/2;
165#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
166 evas_object_geometry_set(_lbl, new_x, new_y, min_w, min_h);
167 evas_object_geometry_set(_bg, new_x - 1, new_y - 1, min_w + 2, min_h + 2);
168#else
169 evas_object_move(_lbl, new_x, new_y);
170 evas_object_resize(_lbl, min_w, min_h);
171 evas_object_move(_bg, new_x - 1, new_y - 1);
172 evas_object_resize(_bg, min_w + 2, min_h + 2);
173#endif 161#endif
174} 162}
175 163
@@ -210,7 +198,6 @@ _parent_del_cb(void *data,
210static void 198static void
211_hover_del(Evas_Object *o) 199_hover_del(Evas_Object *o)
212{ 200{
213 elm_object_focus_set(o, EINA_FALSE);
214 evas_object_event_callback_del(o, EVAS_CALLBACK_KEY_UP, 201 evas_object_event_callback_del(o, EVAS_CALLBACK_KEY_UP,
215 _cb_key_up); 202 _cb_key_up);
216 evas_object_event_callback_del(o, EVAS_CALLBACK_MOUSE_DOWN, 203 evas_object_event_callback_del(o, EVAS_CALLBACK_MOUSE_DOWN,
@@ -223,35 +210,49 @@ _hover_del(Evas_Object *o)
223 _parent_hide_cb); 210 _parent_hide_cb);
224 evas_object_event_callback_del(_fr, EVAS_CALLBACK_DEL, 211 evas_object_event_callback_del(_fr, EVAS_CALLBACK_DEL,
225 _parent_del_cb); 212 _parent_del_cb);
226 evas_object_del(_bg);
227 _bg = NULL;
228 evas_object_del(_lbl);
229 _lbl = NULL;
230 evas_object_del(o); 213 evas_object_del(o);
231 _rect = NULL; 214 _layout = NULL;
215}
216
217static void
218_cb_focused(void *data EINA_UNUSED,
219 Evas_Object *obj EINA_UNUSED,
220 void *event EINA_UNUSED)
221{
222 DBG("focused");
223}
224static void
225_cb_unfocused(void *data EINA_UNUSED,
226 Evas_Object *obj EINA_UNUSED,
227 void *event EINA_UNUSED)
228{
229 DBG("unfocused");
230 if (_layout)
231 elm_object_focus_set(_layout, EINA_TRUE);
232} 232}
233 233
234static void 234static void
235on_shortcut_add(void *data, 235on_shortcut_add(void *data,
236 Evas_Object *obj, 236 Evas_Object *bt,
237 void *event_info EINA_UNUSED) 237 void *event_info EINA_UNUSED)
238{ 238{
239 Evas_Object *o, *bx; 239 Evas_Object *o, *oe;
240 240 Evas_Object *bx = data;
241 bx = data;
242 241
243 _rect = o = evas_object_rectangle_add(evas_object_evas_get(obj)); 242 _layout = o = elm_layout_add(bt);
244 evas_object_repeat_events_set(o, EINA_TRUE); 243 oe = elm_layout_edje_get(o);
245 evas_object_color_set(o, 0, 0, 0, 127); 244 theme_apply(oe, _config, "terminology/keybinding");
246 elm_object_focus_set(o, EINA_TRUE); 245 theme_auto_reload_enable(oe);
246 elm_layout_text_set(o, "label", _("Please press key sequence"));
247 evas_object_show(o); 247 evas_object_show(o);
248 elm_object_focus_allow_set(o, EINA_TRUE);
249 evas_object_smart_callback_add(o, "focused",
250 _cb_focused, NULL);
251 evas_object_smart_callback_add(o, "unfocused",
252 _cb_unfocused, NULL);
253 elm_object_focus_set(o, EINA_TRUE);
248 254
249 _bg = elm_bg_add(_fr);
250 _lbl = elm_label_add(_fr);
251 elm_layout_text_set(_lbl, NULL, _("Please press key sequence"));
252 _hover_sizing_eval(); 255 _hover_sizing_eval();
253 evas_object_show(_bg);
254 evas_object_show(_lbl);
255 256
256 evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_UP, 257 evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_UP,
257 _cb_key_up, bx); 258 _cb_key_up, bx);