1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4
5 #define ELM_WIDGET_PROTECTED
6 #define EFL_ACCESS_OBJECT_PROTECTED
7 #define EFL_PART_PROTECTED
8
9 #include <Elementary.h>
10
11 #include "elm_priv.h"
12 #include "elm_widget_notify.h"
13 #include "elm_widget_container.h"
14
15 #include "elm_notify_part.eo.h"
16 #include "elm_part_helper.h"
17
18 #define MY_CLASS ELM_NOTIFY_CLASS
19
20 #define MY_CLASS_NAME "Elm_Notify"
21 #define MY_CLASS_NAME_LEGACY "elm_notify"
22
23 static Eina_Error
_notify_theme_apply(Evas_Object * obj)24 _notify_theme_apply(Evas_Object *obj)
25 {
26 const char *style = elm_widget_style_get(obj);
27 const char *position;
28 double ax, ay;
29
30 ELM_NOTIFY_DATA_GET(obj, sd);
31
32 ax = sd->horizontal_align;
33 ay = sd->vertical_align;
34
35 if (EINA_DBL_EQ(ay, 0.0))
36 {
37 if (EINA_DBL_EQ(ax, 0.0))
38 position = "top_left";
39 else if (EINA_DBL_EQ(ax, 1.0))
40 position = "top_right";
41 else
42 position = "top";
43 }
44 else if (EINA_DBL_EQ(ay, 1.0))
45 {
46 if (EINA_DBL_EQ(ax, 0.0))
47 position = "bottom_left";
48 else if (EINA_DBL_EQ(ax, 1.0))
49 position = "bottom_right";
50 else
51 position = "bottom";
52 }
53 else
54 {
55 if (EINA_DBL_EQ(ax, 0.0))
56 position = "left";
57 else if (EINA_DBL_EQ(ax, 1.0))
58 position = "right";
59 else
60 position = "center";
61 }
62
63 return elm_widget_theme_object_set(obj, sd->notify, "notify", position, style);
64 }
65
66 /**
67 * Moves notification to orientation.
68 *
69 * This function moves notification to orientation
70 * according to object RTL orientation.
71 *
72 * @param obj notification object.
73 *
74 * @param x, y, w, h geometry of object.
75 *
76 * @internal
77 **/
78 static void
_notify_move_to_orientation(Evas_Object * obj,Evas_Coord x,Evas_Coord y,Evas_Coord w,Evas_Coord h)79 _notify_move_to_orientation(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
80 {
81 Evas_Coord minw = -1, minh = -1;
82 double ax, ay;
83
84 ELM_NOTIFY_DATA_GET(obj, sd);
85
86 edje_object_size_min_get(sd->notify, &minw, &minh);
87 edje_object_size_min_restricted_calc(sd->notify, &minw, &minh, minw, minh);
88
89 ax = sd->horizontal_align;
90 ay = sd->vertical_align;
91 if ((efl_ui_mirrored_get(obj)) && (!EINA_DBL_EQ(ax, ELM_NOTIFY_ALIGN_FILL))) ax = 1.0 - ax;
92
93 if (EINA_DBL_EQ(ax, ELM_NOTIFY_ALIGN_FILL)) minw = w;
94 if (EINA_DBL_EQ(ay, ELM_NOTIFY_ALIGN_FILL)) minh = h;
95
96 x = x + ((w - minw) * ax);
97 y = y + ((h - minh) * ay);
98
99 evas_object_geometry_set(sd->notify, x, y, minw, minh);
100 }
101
102 static void
_block_events_theme_apply(Evas_Object * obj)103 _block_events_theme_apply(Evas_Object *obj)
104 {
105 ELM_NOTIFY_DATA_GET(obj, sd);
106
107 const char *style = elm_widget_style_get(obj);
108
109 if (!elm_layout_theme_set
110 (sd->block_events, "notify", "block_events", style))
111 CRI("Failed to set layout!");
112 }
113
114 static void
_mirrored_set(Evas_Object * obj,Eina_Bool rtl)115 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
116 {
117 Evas_Coord x, y, w, h;
118
119 ELM_NOTIFY_DATA_GET(obj, sd);
120 edje_object_mirrored_set(sd->notify, rtl);
121 evas_object_geometry_get(obj, &x, &y, &w, &h);
122 _notify_move_to_orientation(obj, x, y, w, h);
123 }
124
125 static void
_sizing_eval(Evas_Object * obj)126 _sizing_eval(Evas_Object *obj)
127 {
128 Evas_Coord x, y, w, h;
129
130 ELM_NOTIFY_DATA_GET(obj, sd);
131
132 if (!sd->parent) return;
133 evas_object_geometry_get(sd->parent, &x, &y, &w, &h);
134 if (efl_isa(sd->parent, EFL_UI_WIN_CLASS))
135 {
136 x = 0;
137 y = 0;
138 }
139 evas_object_geometry_set(obj, x, y, w, h);
140 }
141
142 EOLIAN static Eina_Error
_elm_notify_efl_ui_widget_theme_apply(Eo * obj,Elm_Notify_Data * sd)143 _elm_notify_efl_ui_widget_theme_apply(Eo *obj, Elm_Notify_Data *sd)
144 {
145 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
146 Eina_Error notify_theme_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
147 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
148 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
149
150 _mirrored_set(obj, efl_ui_mirrored_get(obj));
151
152 notify_theme_ret = _notify_theme_apply(obj);
153 if (notify_theme_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC)
154 return notify_theme_ret;
155
156 if (sd->block_events) _block_events_theme_apply(obj);
157
158 edje_object_scale_set
159 (sd->notify, efl_gfx_entity_scale_get(obj) * elm_config_scale_get());
160
161 _sizing_eval(obj);
162
163 if ((int_ret == EFL_UI_THEME_APPLY_ERROR_DEFAULT) ||
164 (notify_theme_ret == EFL_UI_THEME_APPLY_ERROR_DEFAULT))
165 return EFL_UI_THEME_APPLY_ERROR_DEFAULT;
166
167 return EFL_UI_THEME_APPLY_ERROR_NONE;
168 }
169
170 /* Legacy compat. Note that notify has no text parts in the default theme... */
171 static void
_elm_notify_text_set(Eo * obj EINA_UNUSED,Elm_Notify_Data * sd,const char * part,const char * label)172 _elm_notify_text_set(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, const char *part, const char *label)
173 {
174 edje_object_part_text_set(sd->notify, part, label);
175 }
176
177 /* Legacy compat. Note that notify has no text parts in the default theme... */
178 static const char*
_elm_notify_text_get(Eo * obj EINA_UNUSED,Elm_Notify_Data * sd,const char * part)179 _elm_notify_text_get(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, const char *part)
180 {
181 return edje_object_part_text_get(sd->notify, part);
182 }
183
184 static void
_calc(Evas_Object * obj)185 _calc(Evas_Object *obj)
186 {
187 Evas_Coord x, y, w, h;
188
189 ELM_NOTIFY_DATA_GET(obj, sd);
190
191 _sizing_eval(obj);
192
193 evas_object_geometry_get(obj, &x, &y, &w, &h);
194
195 if (sd->content)
196 {
197 _notify_move_to_orientation(obj, x, y, w, h);
198 }
199 }
200
201 static void
_changed_size_hints_cb(void * data,Evas * e EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)202 _changed_size_hints_cb(void *data,
203 Evas *e EINA_UNUSED,
204 Evas_Object *obj EINA_UNUSED,
205 void *event_info EINA_UNUSED)
206 {
207 _calc(data);
208 }
209
210 EOLIAN static Eina_Bool
_elm_notify_efl_ui_widget_widget_sub_object_del(Eo * obj,Elm_Notify_Data * sd,Evas_Object * sobj)211 _elm_notify_efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Notify_Data *sd, Evas_Object *sobj)
212 {
213 Eina_Bool int_ret = EINA_FALSE;
214 int_ret = elm_widget_sub_object_del(efl_super(obj, MY_CLASS), sobj);
215 if (!int_ret) return EINA_FALSE;
216
217 if (sobj == sd->content)
218 {
219 evas_object_event_callback_del_full
220 (sobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
221 _changed_size_hints_cb, obj);
222 sd->content = NULL;
223 }
224
225 return EINA_TRUE;
226 }
227
228 static void
_block_area_clicked_cb(void * data,Evas_Object * obj EINA_UNUSED,const char * emission EINA_UNUSED,const char * source EINA_UNUSED)229 _block_area_clicked_cb(void *data,
230 Evas_Object *obj EINA_UNUSED,
231 const char *emission EINA_UNUSED,
232 const char *source EINA_UNUSED)
233 {
234 efl_event_callback_legacy_call(data, ELM_NOTIFY_EVENT_BLOCK_CLICKED, NULL);
235 }
236
237 EOLIAN static void
_elm_notify_efl_gfx_entity_size_set(Eo * obj,Elm_Notify_Data * sd,Eina_Size2D sz)238 _elm_notify_efl_gfx_entity_size_set(Eo *obj, Elm_Notify_Data *sd, Eina_Size2D sz)
239 {
240 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
241 return;
242
243 efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz);
244
245 if (!sd->parent && sd->content)
246 {
247 Eina_Position2D pos;
248
249 pos = efl_gfx_entity_position_get(obj);
250 _notify_move_to_orientation(obj, pos.x, pos.y, sz.w, sz.h);
251 }
252 }
253
254 EOLIAN static void
_elm_notify_efl_gfx_entity_position_set(Eo * obj,Elm_Notify_Data * sd,Eina_Position2D pos)255 _elm_notify_efl_gfx_entity_position_set(Eo *obj, Elm_Notify_Data *sd, Eina_Position2D pos)
256 {
257 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
258 return;
259
260 efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
261
262 if (!sd->parent && sd->content)
263 {
264 Evas_Coord w, h;
265
266 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
267 _notify_move_to_orientation(obj, pos.x, pos.y, w, h);
268 }
269 }
270
271 static Eina_Bool
_timer_cb(void * data)272 _timer_cb(void *data)
273 {
274 Evas_Object *obj = data;
275
276 ELM_NOTIFY_DATA_GET(obj, sd);
277
278 sd->timer = NULL;
279 if (!evas_object_visible_get(obj)) goto end;
280
281 evas_object_hide(obj);
282 sd->in_timeout = EINA_TRUE;
283 efl_event_callback_legacy_call(obj, ELM_NOTIFY_EVENT_TIMEOUT, NULL);
284
285 end:
286 return ECORE_CALLBACK_CANCEL;
287 }
288
289 static void
_timer_init(Evas_Object * obj,Elm_Notify_Data * sd)290 _timer_init(Evas_Object *obj,
291 Elm_Notify_Data *sd)
292 {
293 ecore_timer_del(sd->timer);
294 if (sd->timeout > 0.0)
295 sd->timer = ecore_timer_add(sd->timeout, _timer_cb, obj);
296 else
297 sd->timer = NULL;
298 }
299
300 static void
_elm_notify_show(Eo * obj,Elm_Notify_Data * sd)301 _elm_notify_show(Eo *obj, Elm_Notify_Data *sd)
302 {
303 sd->had_hidden = EINA_FALSE;
304 sd->in_timeout = EINA_FALSE;
305 efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_TRUE);
306
307 evas_object_show(sd->notify);
308 if (!sd->allow_events) evas_object_show(sd->block_events);
309 _timer_init(obj, sd);
310 elm_object_focus_set(obj, EINA_TRUE);
311 }
312
313 static void
_elm_notify_hide(Eo * obj EINA_UNUSED,Elm_Notify_Data * sd)314 _elm_notify_hide(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd)
315 {
316 const char *hide_signal;
317
318 if (sd->had_hidden && !sd->in_timeout)
319 return;
320
321 hide_signal = edje_object_data_get(sd->notify, "hide_finished_signal");
322 if (eina_streq(hide_signal, "on"))
323 {
324 if (!sd->in_timeout)
325 {
326 elm_layout_signal_emit(sd->block_events, "elm,state,hide", "elm");
327 edje_object_signal_emit(sd->notify, "elm,state,hide", "elm");
328 }
329 }
330 else //for backport supporting: edc without emitting hide finished signal
331 {
332 efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_FALSE);
333 evas_object_hide(sd->notify);
334 if (sd->allow_events) evas_object_hide(sd->block_events);
335 }
336 ELM_SAFE_FREE(sd->timer, ecore_timer_del);
337 }
338
339 EOLIAN static void
_elm_notify_efl_gfx_entity_visible_set(Eo * obj,Elm_Notify_Data * sd,Eina_Bool vis)340 _elm_notify_efl_gfx_entity_visible_set(Eo *obj, Elm_Notify_Data *sd, Eina_Bool vis)
341 {
342 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
343 return;
344
345 if (vis) _elm_notify_show(obj, sd);
346 else _elm_notify_hide(obj, sd);
347 }
348
349 static void
_parent_del_cb(void * data,Evas * e EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)350 _parent_del_cb(void *data,
351 Evas *e EINA_UNUSED,
352 Evas_Object *obj EINA_UNUSED,
353 void *event_info EINA_UNUSED)
354 {
355 elm_notify_parent_set(data, NULL);
356 evas_object_hide(data);
357 }
358
359 static void
_parent_hide_cb(void * data,Evas * e EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)360 _parent_hide_cb(void *data,
361 Evas *e EINA_UNUSED,
362 Evas_Object *obj EINA_UNUSED,
363 void *event_info EINA_UNUSED)
364 {
365 evas_object_hide(data);
366 }
367
368 static Eina_Bool
_elm_notify_content_set(Eo * obj,Elm_Notify_Data * sd,const char * part,Evas_Object * content)369 _elm_notify_content_set(Eo *obj, Elm_Notify_Data *sd, const char *part, Evas_Object *content)
370 {
371 if (part && strcmp(part, "default")) return EINA_FALSE;
372 if (sd->content == content) return EINA_TRUE;
373
374 evas_object_del(sd->content);
375 sd->content = content;
376
377 if (content)
378 {
379 elm_widget_sub_object_add(obj, content);
380 evas_object_event_callback_add
381 (content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
382 _changed_size_hints_cb, obj);
383 edje_object_part_swallow(sd->notify, "elm.swallow.content", content);
384 }
385 efl_event_callback_call(obj, EFL_CONTENT_EVENT_CONTENT_CHANGED, content);
386
387 _calc(obj);
388
389 return EINA_TRUE;
390 }
391
392 static Evas_Object*
_elm_notify_content_get(const Eo * obj EINA_UNUSED,Elm_Notify_Data * sd,const char * part)393 _elm_notify_content_get(const Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, const char *part)
394 {
395 if (part && strcmp(part, "default")) return NULL;
396
397 return sd->content;
398 }
399
400 static Evas_Object*
_elm_notify_content_unset(Eo * obj,Elm_Notify_Data * sd,const char * part)401 _elm_notify_content_unset(Eo *obj, Elm_Notify_Data *sd, const char *part)
402 {
403 Evas_Object *content;
404
405 if (part && strcmp(part, "default")) return NULL;
406 if (!sd->content) return NULL;
407
408 content = sd->content;
409 _elm_widget_sub_object_redirect_to_top(obj, sd->content);
410 edje_object_part_unswallow(sd->notify, content);
411 efl_event_callback_call(obj, EFL_CONTENT_EVENT_CONTENT_CHANGED, NULL);
412
413 return content;
414 }
415
416 EOLIAN static Eina_Bool
_elm_notify_efl_content_content_set(Eo * obj,Elm_Notify_Data * sd,Evas_Object * content)417 _elm_notify_efl_content_content_set(Eo *obj, Elm_Notify_Data *sd, Evas_Object *content)
418 {
419 return _elm_notify_content_set(obj, sd, "default", content);
420 }
421
422 EOLIAN static Evas_Object*
_elm_notify_efl_content_content_get(const Eo * obj EINA_UNUSED,Elm_Notify_Data * sd)423 _elm_notify_efl_content_content_get(const Eo *obj EINA_UNUSED, Elm_Notify_Data *sd)
424 {
425 return _elm_notify_content_get(obj, sd, "default");
426 }
427
428 EOLIAN static Evas_Object*
_elm_notify_efl_content_content_unset(Eo * obj,Elm_Notify_Data * sd)429 _elm_notify_efl_content_content_unset(Eo *obj, Elm_Notify_Data *sd)
430 {
431 return _elm_notify_content_unset(obj, sd, "default");
432 }
433
434 static void
_hide_finished_cb(void * data,Evas_Object * obj EINA_UNUSED,const char * emission EINA_UNUSED,const char * source EINA_UNUSED)435 _hide_finished_cb(void *data,
436 Evas_Object *obj EINA_UNUSED,
437 const char *emission EINA_UNUSED,
438 const char *source EINA_UNUSED)
439 {
440 ELM_NOTIFY_DATA_GET(data, sd);
441 sd->had_hidden = EINA_TRUE;
442 evas_object_hide(sd->notify);
443 if (!sd->allow_events) evas_object_hide(sd->block_events);
444 efl_gfx_entity_visible_set(efl_super(data, MY_CLASS), EINA_FALSE);
445 efl_event_callback_legacy_call(data, ELM_NOTIFY_EVENT_DISMISSED, NULL);
446 }
447
448 EOLIAN static void
_elm_notify_efl_canvas_group_group_add(Eo * obj,Elm_Notify_Data * priv)449 _elm_notify_efl_canvas_group_group_add(Eo *obj, Elm_Notify_Data *priv)
450 {
451 efl_canvas_group_add(efl_super(obj, MY_CLASS));
452
453 priv->allow_events = EINA_TRUE;
454
455 priv->notify = edje_object_add(evas_object_evas_get(obj));
456 evas_object_smart_member_add(priv->notify, obj);
457
458 edje_object_signal_callback_add
459 (priv->notify, "elm,action,hide,finished", "elm", _hide_finished_cb, obj);
460
461 elm_widget_can_focus_set(obj, EINA_FALSE);
462 elm_notify_align_set(obj, 0.5, 0.0);
463 }
464
465 EOLIAN static void
_elm_notify_efl_canvas_group_group_del(Eo * obj,Elm_Notify_Data * sd)466 _elm_notify_efl_canvas_group_group_del(Eo *obj, Elm_Notify_Data *sd)
467 {
468 edje_object_signal_callback_del_full
469 (sd->notify, "elm,action,hide,finished", "elm", _hide_finished_cb, obj);
470 elm_notify_parent_set(obj, NULL);
471 ecore_timer_del(sd->timer);
472
473 ELM_SAFE_FREE(sd->notify, evas_object_del);
474 efl_canvas_group_del(efl_super(obj, MY_CLASS));
475 }
476
477 EAPI Evas_Object *
elm_notify_add(Evas_Object * parent)478 elm_notify_add(Evas_Object *parent)
479 {
480 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
481 return elm_legacy_add(MY_CLASS, parent);
482 }
483
484
485 static void
_parent_setup(Eo * obj,Elm_Notify_Data * sd,Evas_Object * parent)486 _parent_setup(Eo *obj, Elm_Notify_Data *sd, Evas_Object *parent)
487 {
488 if (sd->parent)
489 {
490 evas_object_event_callback_del_full
491 (sd->parent, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
492 _changed_size_hints_cb, obj);
493 evas_object_event_callback_del_full
494 (sd->parent, EVAS_CALLBACK_RESIZE, _changed_size_hints_cb, obj);
495 evas_object_event_callback_del_full
496 (sd->parent, EVAS_CALLBACK_MOVE, _changed_size_hints_cb, obj);
497 evas_object_event_callback_del_full
498 (sd->parent, EVAS_CALLBACK_DEL, _parent_del_cb, obj);
499 evas_object_event_callback_del_full
500 (sd->parent, EVAS_CALLBACK_HIDE, _parent_hide_cb, obj);
501 sd->parent = NULL;
502 }
503
504 if (parent)
505 {
506 sd->parent = parent;
507 evas_object_event_callback_add
508 (parent, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
509 _changed_size_hints_cb, obj);
510 evas_object_event_callback_add
511 (parent, EVAS_CALLBACK_RESIZE, _changed_size_hints_cb, obj);
512 evas_object_event_callback_add
513 (parent, EVAS_CALLBACK_MOVE, _changed_size_hints_cb, obj);
514 evas_object_event_callback_add
515 (parent, EVAS_CALLBACK_DEL, _parent_del_cb, obj);
516 evas_object_event_callback_add
517 (parent, EVAS_CALLBACK_HIDE, _parent_hide_cb, obj);
518 }
519
520 _calc(obj);
521 }
522
523 EOLIAN static Eo *
_elm_notify_efl_object_constructor(Eo * obj,Elm_Notify_Data * sd EINA_UNUSED)524 _elm_notify_efl_object_constructor(Eo *obj, Elm_Notify_Data *sd EINA_UNUSED)
525 {
526 obj = efl_constructor(efl_super(obj, MY_CLASS));
527 efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
528 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_NOTIFICATION);
529 _parent_setup(obj, sd, efl_parent_get(obj));
530
531 return obj;
532 }
533
534 EAPI void
elm_notify_parent_set(Evas_Object * obj,Evas_Object * parent)535 elm_notify_parent_set(Evas_Object *obj,
536 Evas_Object *parent)
537 {
538 ELM_NOTIFY_CHECK(obj);
539 ELM_NOTIFY_DATA_GET(obj, sd);
540 if (parent)
541 efl_ui_widget_sub_object_add(parent, obj);
542 _parent_setup(obj, sd, parent);
543 }
544
545 EAPI Evas_Object *
elm_notify_parent_get(const Evas_Object * obj)546 elm_notify_parent_get(const Evas_Object *obj)
547 {
548 ELM_NOTIFY_CHECK(obj) NULL;
549 Evas_Object *ret = NULL;
550 ret = efl_ui_widget_parent_get((Eo *) obj);
551 return ret;
552 }
553
554 EINA_DEPRECATED EAPI void
elm_notify_orient_set(Evas_Object * obj,Elm_Notify_Orient orient)555 elm_notify_orient_set(Evas_Object *obj,
556 Elm_Notify_Orient orient)
557 {
558 double horizontal = 0, vertical = 0;
559
560 switch (orient)
561 {
562 case ELM_NOTIFY_ORIENT_TOP:
563 horizontal = 0.5; vertical = 0.0;
564 break;
565
566 case ELM_NOTIFY_ORIENT_CENTER:
567 horizontal = 0.5; vertical = 0.5;
568 break;
569
570 case ELM_NOTIFY_ORIENT_BOTTOM:
571 horizontal = 0.5; vertical = 1.0;
572 break;
573
574 case ELM_NOTIFY_ORIENT_LEFT:
575 horizontal = 0.0; vertical = 0.5;
576 break;
577
578 case ELM_NOTIFY_ORIENT_RIGHT:
579 horizontal = 1.0; vertical = 0.5;
580 break;
581
582 case ELM_NOTIFY_ORIENT_TOP_LEFT:
583 horizontal = 0.0; vertical = 0.0;
584 break;
585
586 case ELM_NOTIFY_ORIENT_TOP_RIGHT:
587 horizontal = 1.0; vertical = 0.0;
588 break;
589
590 case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
591 horizontal = 0.0; vertical = 1.0;
592 break;
593
594 case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
595 horizontal = 1.0; vertical = 1.0;
596 break;
597
598 case ELM_NOTIFY_ORIENT_LAST:
599 break;
600 }
601 elm_notify_align_set(obj, horizontal, vertical);
602 }
603
604 EINA_DEPRECATED EAPI Elm_Notify_Orient
elm_notify_orient_get(const Evas_Object * obj)605 elm_notify_orient_get(const Evas_Object *obj)
606 {
607 Elm_Notify_Orient orient;
608 double horizontal, vertical;
609
610 elm_notify_align_get(obj, &horizontal, &vertical);
611
612 if (EINA_DBL_EQ(horizontal, 0.5) && EINA_DBL_EQ(vertical, 0.0))
613 orient = ELM_NOTIFY_ORIENT_TOP;
614 else if (EINA_DBL_EQ(horizontal, 0.5) && EINA_DBL_EQ(vertical, 0.5))
615 orient = ELM_NOTIFY_ORIENT_CENTER;
616 else if (EINA_DBL_EQ(horizontal, 0.5) && EINA_DBL_EQ(vertical, 1.0))
617 orient = ELM_NOTIFY_ORIENT_BOTTOM;
618 else if (EINA_DBL_EQ(horizontal, 0.0) && EINA_DBL_EQ(vertical, 0.5))
619 orient = ELM_NOTIFY_ORIENT_LEFT;
620 else if (EINA_DBL_EQ(horizontal, 1.0) && EINA_DBL_EQ(vertical, 0.5))
621 orient = ELM_NOTIFY_ORIENT_RIGHT;
622 else if (EINA_DBL_EQ(horizontal, 0.0) && EINA_DBL_EQ(vertical, 0.0))
623 orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
624 else if (EINA_DBL_EQ(horizontal, 1.0) && EINA_DBL_EQ(vertical, 0.0))
625 orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
626 else if (EINA_DBL_EQ(horizontal, 0.0) && EINA_DBL_EQ(vertical, 1.0))
627 orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
628 else if (EINA_DBL_EQ(horizontal, 1.0) && EINA_DBL_EQ(vertical, 1.0))
629 orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
630 else
631 orient = ELM_NOTIFY_ORIENT_TOP;
632
633 return orient;
634 }
635
636 EOLIAN static void
_elm_notify_timeout_set(Eo * obj,Elm_Notify_Data * sd,double timeout)637 _elm_notify_timeout_set(Eo *obj, Elm_Notify_Data *sd, double timeout)
638 {
639 sd->timeout = timeout;
640 _timer_init(obj, sd);
641 }
642
643 EOLIAN static double
_elm_notify_timeout_get(const Eo * obj EINA_UNUSED,Elm_Notify_Data * sd)644 _elm_notify_timeout_get(const Eo *obj EINA_UNUSED, Elm_Notify_Data *sd)
645 {
646 return sd->timeout;
647 }
648
649 EOLIAN static void
_elm_notify_allow_events_set(Eo * obj,Elm_Notify_Data * sd,Eina_Bool allow)650 _elm_notify_allow_events_set(Eo *obj, Elm_Notify_Data *sd, Eina_Bool allow)
651 {
652 if (allow == sd->allow_events) return;
653 sd->allow_events = allow;
654 if (!allow)
655 {
656 sd->block_events = elm_layout_add(obj);
657 _block_events_theme_apply(obj);
658 elm_widget_resize_object_set(obj, sd->block_events);
659 evas_object_stack_above(sd->notify, sd->block_events);
660 elm_layout_signal_callback_add
661 (sd->block_events, "elm,action,click", "elm",
662 _block_area_clicked_cb, obj);
663 }
664 else
665 {
666 evas_object_del(sd->block_events);
667 sd->block_events = NULL;
668 }
669 }
670
671 EOLIAN static Eina_Bool
_elm_notify_allow_events_get(const Eo * obj EINA_UNUSED,Elm_Notify_Data * sd)672 _elm_notify_allow_events_get(const Eo *obj EINA_UNUSED, Elm_Notify_Data *sd)
673 {
674 return sd->allow_events;
675 }
676
677 EOLIAN static void
_elm_notify_align_set(Eo * obj,Elm_Notify_Data * sd,double horizontal,double vertical)678 _elm_notify_align_set(Eo *obj, Elm_Notify_Data *sd, double horizontal, double vertical)
679 {
680 sd->horizontal_align = horizontal;
681 sd->vertical_align = vertical;
682
683 _notify_theme_apply(obj);
684 _calc(obj);
685 }
686
687 EOLIAN static void
_elm_notify_dismiss(Eo * obj EINA_UNUSED,Elm_Notify_Data * sd)688 _elm_notify_dismiss(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd)
689 {
690 elm_layout_signal_emit(sd->block_events, "elm,state,hide", "elm");
691 edje_object_signal_emit(sd->notify, "elm,state,hide", "elm");
692 }
693
694
695 EOLIAN static void
_elm_notify_align_get(const Eo * obj EINA_UNUSED,Elm_Notify_Data * sd,double * horizontal,double * vertical)696 _elm_notify_align_get(const Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, double *horizontal, double *vertical)
697 {
698 if (horizontal)
699 *horizontal = sd->horizontal_align;
700 if (vertical)
701 *vertical = sd->vertical_align;
702 }
703
704 static void
_elm_notify_class_constructor(Efl_Class * klass)705 _elm_notify_class_constructor(Efl_Class *klass)
706 {
707 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
708 }
709
710 /* Efl.Part begin */
711
ELM_PART_OVERRIDE(elm_notify,ELM_NOTIFY,Elm_Notify_Data)712 ELM_PART_OVERRIDE(elm_notify, ELM_NOTIFY, Elm_Notify_Data)
713 ELM_PART_OVERRIDE_TEXT_SET(elm_notify, ELM_NOTIFY, Elm_Notify_Data)
714 ELM_PART_OVERRIDE_TEXT_GET(elm_notify, ELM_NOTIFY, Elm_Notify_Data)
715 ELM_PART_OVERRIDE_CONTENT_SET(elm_notify, ELM_NOTIFY, Elm_Notify_Data)
716 ELM_PART_OVERRIDE_CONTENT_GET(elm_notify, ELM_NOTIFY, Elm_Notify_Data)
717 ELM_PART_OVERRIDE_CONTENT_UNSET(elm_notify, ELM_NOTIFY, Elm_Notify_Data)
718 ELM_PART_CONTENT_DEFAULT_GET(elm_notify, "default")
719
720 EOLIAN static const char *
721 _elm_notify_part_efl_ui_l10n_l10n_text_get(const Eo *obj, void *_pd EINA_UNUSED, const char **domain)
722 {
723 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
724 return elm_widget_part_translatable_text_get(pd->obj, pd->part, domain);
725 }
726
727 EOLIAN static void
_elm_notify_part_efl_ui_l10n_l10n_text_set(Eo * obj,void * _pd EINA_UNUSED,const char * label,const char * domain)728 _elm_notify_part_efl_ui_l10n_l10n_text_set(Eo *obj, void *_pd EINA_UNUSED, const char *label, const char *domain)
729 {
730 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
731 elm_widget_part_translatable_text_set(pd->obj, pd->part, label, domain);
732 }
733
734 #include "elm_notify_part.eo.c"
735
736 /* Efl.Part end */
737
738 /* Internal EO APIs and hidden overrides */
739
740 #define ELM_NOTIFY_EXTRA_OPS \
741 ELM_PART_CONTENT_DEFAULT_OPS(elm_notify), \
742 EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_notify)
743
744 #include "elm_notify_eo.c"
745