efl_ui_popup: Make backwall efl part object of Efl.Ui.Popup

This commit is contained in:
Jaehyun Cho 2017-11-10 17:56:34 +09:00
parent 91df6723c9
commit c752d8fe6b
6 changed files with 106 additions and 51 deletions

View File

@ -34,6 +34,7 @@ elm_public_eolian_files = \
lib/elementary/efl_ui_text_interactive.eo \ lib/elementary/efl_ui_text_interactive.eo \
lib/elementary/efl_ui_text.eo \ lib/elementary/efl_ui_text.eo \
lib/elementary/efl_ui_popup.eo \ lib/elementary/efl_ui_popup.eo \
lib/elementary/efl_ui_popup_part.eo \
lib/elementary/efl_ui_popup_alert.eo \ lib/elementary/efl_ui_popup_alert.eo \
lib/elementary/efl_ui_popup_alert_part.eo \ lib/elementary/efl_ui_popup_alert_part.eo \
lib/elementary/efl_ui_popup_alert_scroll.eo \ lib/elementary/efl_ui_popup_alert_scroll.eo \

View File

@ -84,12 +84,12 @@ _backwall_cb(void *data EINA_UNUSED, const Efl_Event *ev)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get()); snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
efl_ui_popup_backwall_set(p_data->efl_ui_popup, buf, NULL); efl_file_set(efl_part(p_data->efl_ui_popup, "backwall"), buf, NULL);
efl_text_set(ev->object, "Backwall UnSet"); efl_text_set(ev->object, "Backwall UnSet");
} }
else else
{ {
efl_ui_popup_backwall_set(p_data->efl_ui_popup, NULL, NULL); efl_file_set(efl_part(p_data->efl_ui_popup, "backwall"), NULL, NULL);
efl_text_set(ev->object, "Backwall Set"); efl_text_set(ev->object, "Backwall Set");
} }
k = !k; k = !k;
@ -100,14 +100,14 @@ _repeat_event_cb(void *data EINA_UNUSED, const Efl_Event *ev)
{ {
efl_ui_popup_data *p_data = data; efl_ui_popup_data *p_data = data;
if (!p_data->efl_ui_popup) return; if (!p_data->efl_ui_popup) return;
if (!efl_ui_popup_backwall_repeat_events_get(p_data->efl_ui_popup)) if (!efl_canvas_object_repeat_events_get(efl_part(p_data->efl_ui_popup, "backwall")))
{ {
efl_ui_popup_backwall_repeat_events_set(p_data->efl_ui_popup, EINA_TRUE); efl_canvas_object_repeat_events_set(efl_part(p_data->efl_ui_popup, "backwall"), EINA_TRUE);
efl_text_set(ev->object, "Repeat Event UnSet"); efl_text_set(ev->object, "Repeat Event UnSet");
} }
else else
{ {
efl_ui_popup_backwall_repeat_events_set(p_data->efl_ui_popup, EINA_FALSE); efl_canvas_object_repeat_events_set(efl_part(p_data->efl_ui_popup, "backwall"), EINA_FALSE);
efl_text_set(ev->object, "Repeat Event Set"); efl_text_set(ev->object, "Repeat Event Set");
} }
} }
@ -453,7 +453,7 @@ test_ui_popup_anchor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_ANCHOR_CLASS, win); Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_ANCHOR_CLASS, win);
efl_ui_popup_backwall_repeat_events_set(efl_ui_popup, EINA_TRUE); efl_canvas_object_repeat_events_set(efl_part(efl_ui_popup, "backwall"), EINA_TRUE);
//Default align priority order is top, left, right, bottom, center. //Default align priority order is top, left, right, bottom, center.
efl_ui_popup_anchor_align_priority_set(efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP, efl_ui_popup_anchor_align_priority_set(efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP,

View File

@ -8,6 +8,8 @@
#include "elm_priv.h" #include "elm_priv.h"
#include "efl_ui_popup_private.h" #include "efl_ui_popup_private.h"
#include "efl_ui_popup_part.eo.h"
#include "elm_part_helper.h"
#define MY_CLASS EFL_UI_POPUP_CLASS #define MY_CLASS EFL_UI_POPUP_CLASS
#define MY_CLASS_NAME "Efl.Ui.Popup" #define MY_CLASS_NAME "Efl.Ui.Popup"
@ -249,42 +251,101 @@ _efl_ui_popup_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
_calc_align(obj); _calc_align(obj);
} }
EOLIAN static void static Eina_Bool
_efl_ui_popup_backwall_set(Eo *obj, Efl_Ui_Popup_Data *pd, const char* file, const char* group) _efl_ui_popup_content_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, const char *part, Eo *content)
{ {
Eo *prev_obj = edje_object_part_swallow_get(pd->backwall, "elm.swallow.image"); return efl_content_set(efl_part(efl_super(obj, MY_CLASS), part), content);
if (prev_obj) }
{
edje_object_part_unswallow(pd->backwall, prev_obj);
efl_del(prev_obj);
}
Eo *image = elm_image_add(obj); Eo *
Eina_Bool ret = elm_image_file_set(image, file, group); _efl_ui_popup_content_get(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, const char *part)
if (!ret) {
{ return efl_content_get(efl_part(efl_super(obj, MY_CLASS), part));
edje_object_signal_emit(pd->backwall, "elm,state,image,hidden", "elm"); }
efl_del(image);
return; static Eo *
} _efl_ui_popup_content_unset(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, const char *part)
edje_object_part_swallow(pd->backwall, "elm.swallow.image", image); {
edje_object_signal_emit(pd->backwall, "elm,state,image,visible", "elm"); return efl_content_unset(efl_part(efl_super(obj, MY_CLASS), part));
}
/* Efl.Part begin */
ELM_PART_OVERRIDE_CONTENT_SET(efl_ui_popup, EFL_UI_POPUP, Efl_Ui_Popup_Data)
ELM_PART_OVERRIDE_CONTENT_GET(efl_ui_popup, EFL_UI_POPUP, Efl_Ui_Popup_Data)
ELM_PART_OVERRIDE_CONTENT_UNSET(efl_ui_popup, EFL_UI_POPUP, Efl_Ui_Popup_Data)
EOLIAN static Eo *
_efl_ui_popup_efl_part_part(const Eo *obj, Efl_Ui_Popup_Data *_pd EINA_UNUSED, const char *part)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
if (eina_streq(part, "backwall"))
return ELM_PART_IMPLEMENT(EFL_UI_POPUP_PART_CLASS, obj, part);
return efl_part(efl_super(obj, MY_CLASS), part);
} }
EOLIAN static void EOLIAN static void
_efl_ui_popup_backwall_repeat_events_set(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd, Eina_Bool repeat) _efl_ui_popup_part_efl_canvas_object_repeat_events_set(Eo *obj, void *_pd EINA_UNUSED, Eina_Bool repeat)
{ {
pd->backwall_repeat_events = repeat; Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
Efl_Ui_Popup_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_POPUP_CLASS);
efl_canvas_object_repeat_events_set(pd->backwall, repeat); if (eina_streq(pd->part, "backwall"))
efl_canvas_object_repeat_events_set(sd->backwall, repeat);
else
efl_canvas_object_repeat_events_set(efl_part(efl_super(pd->obj, MY_CLASS), pd->part), repeat);
} }
EOLIAN static Eina_Bool EOLIAN static Eina_Bool
_efl_ui_popup_backwall_repeat_events_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd) _efl_ui_popup_part_efl_canvas_object_repeat_events_get(Eo *obj, void *_pd EINA_UNUSED)
{ {
return pd->backwall_repeat_events; Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
Efl_Ui_Popup_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_POPUP_CLASS);
if (eina_streq(pd->part, "backwall"))
return efl_canvas_object_repeat_events_get(sd->backwall);
return efl_canvas_object_repeat_events_get(efl_part(efl_super(pd->obj, MY_CLASS), pd->part));
} }
EOLIAN static Eina_Bool
_efl_ui_popup_part_efl_file_file_set(Eo *obj, void *_pd EINA_UNUSED, const char *file, const char *group)
{
Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
Efl_Ui_Popup_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_POPUP_CLASS);
if (eina_streq(pd->part, "backwall"))
{
Eo *prev_obj = edje_object_part_swallow_get(sd->backwall, "elm.swallow.image");
if (prev_obj)
{
edje_object_part_unswallow(sd->backwall, prev_obj);
efl_del(prev_obj);
}
Eo *image = elm_image_add(pd->obj);
Eina_Bool ret = elm_image_file_set(image, file, group);
if (!ret)
{
edje_object_signal_emit(sd->backwall, "elm,state,image,hidden", "elm");
efl_del(image);
return EINA_FALSE;
}
edje_object_part_swallow(sd->backwall, "elm.swallow.image", image);
edje_object_signal_emit(sd->backwall, "elm,state,image,visible", "elm");
return EINA_TRUE;
}
return efl_file_set(efl_part(efl_super(pd->obj, MY_CLASS), pd->part), file, group);
}
#include "efl_ui_popup_part.eo.c"
/* Efl.Part end */
/* Internal EO APIs and hidden overrides */ /* Internal EO APIs and hidden overrides */
#define EFL_UI_POPUP_EXTRA_OPS \ #define EFL_UI_POPUP_EXTRA_OPS \

View File

@ -10,27 +10,6 @@ enum Efl.Ui.Popup.Align {
class Efl.Ui.Popup(Efl.Ui.Layout) class Efl.Ui.Popup(Efl.Ui.Layout)
{ {
methods { methods {
backwall_set {
params {
@in file: string; [[The image file path.]]
@in group: string; [[The image key in $file (if its an Eet one), or
$null, otherwise.]]
}
}
@property backwall_repeat_events {
set {
[[Sets whether events should be passed to by a click outside.
Note: The default value is $false.
]]
}
get {
[[Returns value indicating whether backwall repeat events is enabled or not.]]
}
values {
repeat: bool; [[If $true, events are passed to lower objects.]]
}
}
@property align { @property align {
set { set {
[[ Set the popup alignment.]] [[ Set the popup alignment.]]
@ -56,6 +35,9 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
} }
} }
} }
parts {
backwall: Efl.Ui.Popup.Part; [[A backwall behind the popup.]]
}
implements { implements {
Efl.Object.constructor; Efl.Object.constructor;
Efl.Object.destructor; Efl.Object.destructor;
@ -64,6 +46,7 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
Elm.Widget.widget_parent { set; } Elm.Widget.widget_parent { set; }
Efl.Container.content { get; set; } Efl.Container.content { get; set; }
Efl.Container.content_unset; Efl.Container.content_unset;
Efl.Part.part;
} }
events { events {
backwall,clicked; [[This is called whenever the user clicks back wall of popup.]] backwall,clicked; [[This is called whenever the user clicks back wall of popup.]]

View File

@ -0,0 +1,11 @@
class Efl.Ui.Popup.Part (Efl.Ui.Layout.Part_Content, Efl.Canvas.Object, Efl.File)
{
[[Efl UI Popup internal part class]]
data: null;
implements {
Efl.Container.content { get; set; }
Efl.Container.content_unset;
Efl.Canvas.Object.repeat_events { set; get; }
Efl.File.file { set; }
}
}

View File

@ -9,7 +9,6 @@ struct _Efl_Ui_Popup_Data
Efl_Ui_Popup_Align align; Efl_Ui_Popup_Align align;
Ecore_Timer *timer; Ecore_Timer *timer;
double timeout; double timeout;
Eina_Bool backwall_repeat_events : 1;
}; };
#endif #endif