2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-10-17 08:56:11 -07:00
|
|
|
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
|
|
|
|
#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
|
2016-04-11 09:51:15 -07:00
|
|
|
#define ELM_WIDGET_PROTECTED
|
2014-09-27 22:16:15 -07:00
|
|
|
#define ELM_WIDGET_ITEM_PROTECTED
|
2014-10-17 08:56:11 -07:00
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2012-08-30 09:46:34 -07:00
|
|
|
#include "elm_widget_popup.h"
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
#include "elm_popup_item.eo.h"
|
|
|
|
|
2016-05-24 04:40:18 -07:00
|
|
|
#include "elm_popup_internal_part.eo.h"
|
|
|
|
#include "elm_part_helper.h"
|
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_POPUP_CLASS
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_CLASS_NAME "Elm_Popup"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_popup"
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static void _button_remove(Evas_Object *, int, Eina_Bool);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2013-01-28 20:41:50 -08:00
|
|
|
static const char ACCESS_TITLE_PART[] = "access.title";
|
|
|
|
static const char ACCESS_BODY_PART[] = "access.body";
|
2013-02-21 03:44:49 -08:00
|
|
|
static const char CONTENT_PART[] = "elm.swallow.content";
|
2013-01-28 20:41:50 -08:00
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
static const char SIG_BLOCK_CLICKED[] = "block,clicked";
|
|
|
|
static const char SIG_TIMEOUT[] = "timeout";
|
2014-02-17 11:03:34 -08:00
|
|
|
static const char SIG_ITEM_FOCUSED[] = "item,focused";
|
|
|
|
static const char SIG_ITEM_UNFOCUSED[] = "item,unfocused";
|
2013-06-09 02:54:43 -07:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{SIG_BLOCK_CLICKED, ""},
|
|
|
|
{SIG_TIMEOUT, ""},
|
2014-02-17 11:03:34 -08:00
|
|
|
{SIG_ITEM_FOCUSED, ""},
|
|
|
|
{SIG_ITEM_UNFOCUSED, ""},
|
2014-01-23 02:30:34 -08:00
|
|
|
{SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-07 21:05:06 -08:00
|
|
|
{SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-05 23:18:57 -08:00
|
|
|
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
|
|
|
|
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
|
2012-08-30 09:46:34 -07:00
|
|
|
{NULL, NULL}
|
2012-03-05 15:51:56 -08:00
|
|
|
};
|
|
|
|
|
2014-04-14 22:47:19 -07:00
|
|
|
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
|
2016-05-18 05:55:35 -07:00
|
|
|
static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
|
2015-03-10 00:51:44 -07:00
|
|
|
static void _parent_geom_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED);
|
2016-08-30 05:34:10 -07:00
|
|
|
static void _block_clicked_cb(void *data, const Efl_Event *event);
|
|
|
|
static void _timeout_cb(void *data, const Efl_Event *event);
|
2014-04-14 22:47:19 -07:00
|
|
|
|
2016-08-30 05:34:10 -07:00
|
|
|
static void _hide_effect_finished_cb(void *data, const Efl_Event *event);
|
2015-12-30 20:08:28 -08:00
|
|
|
|
2014-04-14 22:47:19 -07:00
|
|
|
static const Elm_Action key_actions[] = {
|
|
|
|
{"move", _key_action_move},
|
2016-05-18 05:55:35 -07:00
|
|
|
{"escape", _key_action_escape},
|
2014-04-14 22:47:19 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
EFL_CALLBACKS_ARRAY_DEFINE(_notify_cb,
|
2015-09-23 15:23:46 -07:00
|
|
|
{ ELM_NOTIFY_EVENT_BLOCK_CLICKED, _block_clicked_cb },
|
2015-12-30 20:08:28 -08:00
|
|
|
{ ELM_NOTIFY_EVENT_TIMEOUT, _timeout_cb },
|
|
|
|
{ ELM_NOTIFY_EVENT_DISMISSED, _hide_effect_finished_cb }
|
2015-09-23 15:23:46 -07:00
|
|
|
);
|
|
|
|
|
2012-11-25 22:10:53 -08:00
|
|
|
static void _on_content_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd)
|
2013-04-23 04:30:15 -07:00
|
|
|
{
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it;
|
2013-04-23 04:30:15 -07:00
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->items, l, it)
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_wdg_item_translate(EO_OBJ(it));
|
2013-04-23 04:30:15 -07:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
elm_obj_widget_translate(efl_super(obj, MY_CLASS));
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_widget_translate(sd->main_layout);
|
2014-01-23 03:20:43 -08:00
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_TRUE;
|
2013-04-23 04:30:15 -07:00
|
|
|
}
|
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
static void
|
2012-08-30 09:46:34 -07:00
|
|
|
_visuals_set(Evas_Object *obj)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
if (!sd->title_text && !sd->title_icon)
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title_area,hidden", "elm");
|
2012-03-05 15:51:56 -08:00
|
|
|
else
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title_area,visible", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-04-26 13:54:42 -07:00
|
|
|
if (sd->action_area)
|
2016-11-01 17:28:26 -07:00
|
|
|
{
|
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,action_area,visible", "elm");
|
|
|
|
evas_object_show(sd->action_area);
|
|
|
|
}
|
2012-03-05 15:51:56 -08:00
|
|
|
else
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,action_area,hidden", "elm");
|
2016-03-22 19:42:14 -07:00
|
|
|
|
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(sd->main_layout));
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_block_clicked_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(data, ELM_POPUP_EVENT_BLOCK_CLICKED, NULL);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_timeout_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
|
|
|
evas_object_hide(data);
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(data, ELM_POPUP_EVENT_TIMEOUT, NULL);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_hide_effect_finished_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2015-12-30 20:08:28 -08:00
|
|
|
{
|
2017-03-08 23:36:20 -08:00
|
|
|
efl_gfx_visible_set(data, EINA_FALSE);
|
2017-05-11 22:59:32 -07:00
|
|
|
efl_event_callback_legacy_call(data, ELM_POPUP_EVENT_DISMISSED, NULL);
|
2015-12-30 20:08:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-28 20:41:50 -08:00
|
|
|
static Evas_Object *
|
2013-01-28 21:49:34 -08:00
|
|
|
_access_object_get(const Evas_Object *obj, const char* part)
|
2013-01-28 20:41:50 -08:00
|
|
|
{
|
|
|
|
Evas_Object *po, *ao;
|
2014-07-09 00:32:09 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
2013-01-28 20:41:50 -08:00
|
|
|
|
2014-07-09 00:32:09 -07:00
|
|
|
po = (Evas_Object *)edje_object_part_object_get
|
|
|
|
(elm_layout_edje_get(sd->main_layout), part);
|
2013-01-28 20:41:50 -08:00
|
|
|
ao = evas_object_data_get(po, "_part_access_obj");
|
|
|
|
|
|
|
|
return ao;
|
|
|
|
}
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
_on_show(void *data EINA_UNUSED,
|
|
|
|
Evas *e EINA_UNUSED,
|
2012-08-30 09:46:34 -07:00
|
|
|
Evas_Object *obj,
|
2014-01-06 06:30:02 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2013-02-15 02:39:00 -08:00
|
|
|
elm_object_focus_set(obj, EINA_TRUE);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_scroller_size_calc(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Coord h;
|
|
|
|
Evas_Coord h_title = 0;
|
|
|
|
Evas_Coord h_action_area = 0;
|
|
|
|
const char *action_area_height;
|
|
|
|
|
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
2015-08-15 08:32:33 -07:00
|
|
|
if (!sd->scroll && !sd->items) return;
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
sd->scr_size_recalc = EINA_FALSE;
|
|
|
|
sd->max_sc_h = -1;
|
|
|
|
evas_object_geometry_get(sd->notify, NULL, NULL, NULL, &h);
|
|
|
|
if (sd->title_text || sd->title_icon)
|
2014-07-09 00:32:09 -07:00
|
|
|
edje_object_part_geometry_get(elm_layout_edje_get(sd->main_layout),
|
2012-08-30 09:46:34 -07:00
|
|
|
"elm.bg.title", NULL, NULL, NULL, &h_title);
|
2013-04-26 13:54:42 -07:00
|
|
|
if (sd->action_area)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
|
|
|
action_area_height = edje_object_data_get(
|
|
|
|
elm_layout_edje_get(sd->action_area), "action_area_height");
|
|
|
|
if (action_area_height)
|
|
|
|
h_action_area =
|
|
|
|
(int)(atoi(action_area_height)
|
2016-04-11 07:31:03 -07:00
|
|
|
* elm_config_scale_get() * elm_object_scale_get(obj))
|
|
|
|
/ edje_object_base_scale_get(elm_layout_edje_get(sd->action_area));
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
2013-08-11 06:35:10 -07:00
|
|
|
sd->max_sc_h = h - (h_title + h_action_area);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_size_hints_changed_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
|
|
|
elm_layout_sizing_eval(data);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
elc_popup: If popup's parent is resized, popup need to resized, too
Summary:
When window's size is not enough to show popup, popup resize smaller to show it in appropriate size.
But if window resize larger enough to show popup, popup is locked in small size.
On the contrary to this case, if window resize too smaller, popup has still large size, so popup doesn't display properly.
Test Plan:
1. elementary_test popup
2. maximize test list window
3. click 8th item, "popup-center-title + items + 3 buttons"
4. restore window size
5. close popup, resize window to smaller than popup in 3).
6. click 8th item, "popup-center-title + items + 3 buttons"
7. restore window size
popup size of 4. and 7. is different
Reviewers: jaehwan, cedric, raster, id213sin, singh.amitesh, SanghyeonLee
Subscribers: jpeg
Differential Revision: https://phab.enlightenment.org/D3854
2016-04-11 08:28:55 -07:00
|
|
|
static void
|
|
|
|
_notify_resize_cb(void *data,
|
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *popup = data;
|
|
|
|
|
|
|
|
ELM_POPUP_CHECK(popup);
|
|
|
|
|
|
|
|
elm_layout_sizing_eval(popup);
|
|
|
|
}
|
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_list_del(Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
if (!sd->scr) return;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_event_callback_del
|
|
|
|
(sd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _size_hints_changed_cb);
|
|
|
|
|
2014-01-21 17:38:55 -08:00
|
|
|
ELM_SAFE_FREE(sd->tbl, evas_object_del);
|
2012-08-30 09:46:34 -07:00
|
|
|
sd->scr = NULL;
|
|
|
|
sd->box = NULL;
|
|
|
|
sd->spacer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_items_remove(Elm_Popup_Data *sd)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
if (!sd->items) return;
|
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
EINA_LIST_FREE(sd->items, it)
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_wdg_item_del(EO_OBJ(it));
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
sd->items = NULL;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_popup_efl_canvas_group_group_del(Eo *obj, Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2015-03-10 00:51:44 -07:00
|
|
|
evas_object_event_callback_del_full(sd->parent, EVAS_CALLBACK_RESIZE, _parent_geom_cb, obj);
|
|
|
|
evas_object_event_callback_del_full(sd->parent, EVAS_CALLBACK_MOVE, _parent_geom_cb, obj);
|
elc_popup: If popup's parent is resized, popup need to resized, too
Summary:
When window's size is not enough to show popup, popup resize smaller to show it in appropriate size.
But if window resize larger enough to show popup, popup is locked in small size.
On the contrary to this case, if window resize too smaller, popup has still large size, so popup doesn't display properly.
Test Plan:
1. elementary_test popup
2. maximize test list window
3. click 8th item, "popup-center-title + items + 3 buttons"
4. restore window size
5. close popup, resize window to smaller than popup in 3).
6. click 8th item, "popup-center-title + items + 3 buttons"
7. restore window size
popup size of 4. and 7. is different
Reviewers: jaehwan, cedric, raster, id213sin, singh.amitesh, SanghyeonLee
Subscribers: jpeg
Differential Revision: https://phab.enlightenment.org/D3854
2016-04-11 08:28:55 -07:00
|
|
|
evas_object_event_callback_del_full(sd->notify, EVAS_CALLBACK_RESIZE, _notify_resize_cb, obj);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_array_del(sd->notify, _notify_cb(), obj);
|
2012-11-25 23:09:53 -08:00
|
|
|
evas_object_event_callback_del
|
|
|
|
(sd->content, EVAS_CALLBACK_DEL, _on_content_del);
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, _on_show);
|
2013-02-15 02:39:00 -08:00
|
|
|
|
2013-10-13 08:57:42 -07:00
|
|
|
sd->last_button_number = 0;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
for (i = 0; i < ELM_POPUP_ACTION_BUTTON_MAX; i++)
|
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->buttons[i])
|
|
|
|
{
|
|
|
|
evas_object_del(sd->buttons[i]->btn);
|
2014-01-21 17:38:55 -08:00
|
|
|
ELM_SAFE_FREE(sd->buttons[i], free);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sd->items)
|
|
|
|
{
|
|
|
|
_items_remove(sd);
|
|
|
|
_list_del(sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-08-09 01:48:31 -07:00
|
|
|
// XXX? delete other objects? just to be sure.
|
2014-07-09 00:32:09 -07:00
|
|
|
ELM_SAFE_FREE(sd->main_layout, evas_object_del);
|
2013-08-09 01:48:31 -07:00
|
|
|
ELM_SAFE_FREE(sd->notify, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->title_icon, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->content_area, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->text_content_obj, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->action_area, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->box, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->tbl, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->spacer, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->scr, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->content, evas_object_del);
|
|
|
|
ELM_SAFE_FREE(sd->title_text, eina_stringshare_del);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-30 09:46:34 -07:00
|
|
|
_mirrored_set(Evas_Object *obj,
|
|
|
|
Eina_Bool rtl)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
elm_object_mirrored_set(sd->notify, rtl);
|
2017-06-02 00:25:11 -07:00
|
|
|
elm_object_mirrored_set(sd->main_layout, rtl);
|
|
|
|
if (sd->scr) elm_object_mirrored_set(sd->scr, rtl);
|
|
|
|
if (sd->action_area) elm_object_mirrored_set(sd->action_area, rtl);
|
|
|
|
if (sd->items)
|
|
|
|
{
|
|
|
|
Elm_Popup_Item_Data *it;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->items, l, it)
|
|
|
|
elm_object_mirrored_set(VIEW(it), rtl);
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
2013-02-27 04:03:13 -08:00
|
|
|
static void
|
|
|
|
_access_obj_process(Eo *obj, Eina_Bool is_access)
|
|
|
|
{
|
|
|
|
Evas_Object *ao;
|
|
|
|
|
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (is_access)
|
|
|
|
{
|
|
|
|
if (sd->title_text)
|
|
|
|
{
|
|
|
|
ao = _elm_access_edje_object_part_object_register
|
2014-07-09 00:32:09 -07:00
|
|
|
(obj, elm_layout_edje_get(sd->main_layout), ACCESS_TITLE_PART);
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao),
|
2013-02-27 04:03:13 -08:00
|
|
|
ELM_ACCESS_TYPE, E_("Popup Title"));
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao),
|
2013-02-27 04:03:13 -08:00
|
|
|
ELM_ACCESS_INFO, sd->title_text);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sd->text_content_obj)
|
|
|
|
{
|
|
|
|
ao = _elm_access_edje_object_part_object_register
|
2014-07-09 00:32:09 -07:00
|
|
|
(obj, elm_layout_edje_get(sd->main_layout), ACCESS_BODY_PART);
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao),
|
2013-02-27 04:03:13 -08:00
|
|
|
ELM_ACCESS_TYPE, E_("Popup Body Text"));
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao),
|
2013-02-27 04:03:13 -08:00
|
|
|
ELM_ACCESS_INFO, elm_object_text_get(sd->text_content_obj));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sd->title_text)
|
|
|
|
{
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
2014-07-09 00:32:09 -07:00
|
|
|
(obj, elm_layout_edje_get(sd->main_layout), ACCESS_TITLE_PART);
|
2013-02-27 04:03:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sd->text_content_obj)
|
|
|
|
{
|
|
|
|
_elm_access_edje_object_part_object_unregister
|
2014-07-09 00:32:09 -07:00
|
|
|
(obj, elm_layout_edje_get(sd->main_layout), ACCESS_BODY_PART);
|
2013-02-27 04:03:13 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-15 08:32:33 -07:00
|
|
|
static void
|
|
|
|
_populate_theme_scroll(Elm_Popup_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->content_area)
|
|
|
|
{
|
2015-08-17 22:34:30 -07:00
|
|
|
const char *content_area_width =
|
|
|
|
edje_object_data_get(elm_layout_edje_get(sd->content_area),
|
|
|
|
"scroller_enable");
|
|
|
|
if ((content_area_width) && (!strcmp(content_area_width, "on")))
|
|
|
|
{
|
|
|
|
sd->theme_scroll = EINA_TRUE;
|
|
|
|
return;
|
|
|
|
}
|
2015-08-15 08:32:33 -07:00
|
|
|
}
|
2015-08-17 22:34:30 -07:00
|
|
|
sd->theme_scroll = EINA_FALSE;
|
2015-08-15 08:32:33 -07:00
|
|
|
}
|
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
EOLIAN static Elm_Theme_Apply
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_elm_widget_theme_apply(Eo *obj, Elm_Popup_Data *sd)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it;
|
2012-08-30 09:46:34 -07:00
|
|
|
Eina_List *elist;
|
2013-10-04 06:39:30 -07:00
|
|
|
char buf[1024], style[1024];
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2017-06-13 03:41:15 -07:00
|
|
|
_mirrored_set(obj, efl_ui_mirrored_get(obj));
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-10-04 06:39:30 -07:00
|
|
|
snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
|
|
|
|
elm_widget_style_set(sd->notify, style);
|
2013-08-10 00:41:25 -07:00
|
|
|
|
2014-07-09 00:32:09 -07:00
|
|
|
if (!elm_layout_theme_set(sd->main_layout, "popup", "base",
|
|
|
|
elm_widget_style_get(obj)))
|
|
|
|
CRI("Failed to set layout!");
|
|
|
|
|
2013-04-26 13:54:42 -07:00
|
|
|
if (sd->action_area)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-10-13 08:57:42 -07:00
|
|
|
snprintf(buf, sizeof(buf), "buttons%i", sd->last_button_number);
|
2013-10-04 06:39:30 -07:00
|
|
|
if (!elm_layout_theme_set(sd->action_area, "popup", buf, style))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2013-10-04 06:39:30 -07:00
|
|
|
if (!elm_layout_theme_set(sd->content_area, "popup", "content", style))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->text_content_obj)
|
2013-10-04 06:39:30 -07:00
|
|
|
elm_object_style_set(sd->text_content_obj, style);
|
2012-08-30 09:46:34 -07:00
|
|
|
else if (sd->items)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
EINA_LIST_FOREACH(sd->items, elist, it)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-10-04 06:39:30 -07:00
|
|
|
if (!elm_layout_theme_set(VIEW(it), "popup", "item", style))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2013-09-09 03:15:26 -07:00
|
|
|
else
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-09 03:15:26 -07:00
|
|
|
if (it->label)
|
|
|
|
{
|
|
|
|
elm_layout_text_set(VIEW(it), "elm.text", it->label);
|
|
|
|
elm_layout_signal_emit(VIEW(it),
|
|
|
|
"elm,state,item,text,visible",
|
|
|
|
"elm");
|
|
|
|
}
|
|
|
|
if (it->icon)
|
|
|
|
elm_layout_signal_emit(VIEW(it),
|
|
|
|
"elm,state,item,icon,visible",
|
|
|
|
"elm");
|
|
|
|
if (it->disabled)
|
|
|
|
elm_layout_signal_emit(VIEW(it),
|
|
|
|
"elm,state,item,disabled", "elm");
|
|
|
|
evas_object_show(VIEW(it));
|
|
|
|
edje_object_message_signal_process(
|
|
|
|
elm_layout_edje_get(VIEW(it)));
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->title_text)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_text_set(sd->main_layout, "elm.text.title", sd->title_text);
|
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title,text,visible", "elm");
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->title_icon)
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title,icon,visible", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2015-08-15 08:32:33 -07:00
|
|
|
_populate_theme_scroll(sd);
|
2015-08-15 11:53:44 -07:00
|
|
|
if (!sd->scroll && sd->theme_scroll)
|
|
|
|
elm_layout_signal_emit(sd->content_area, "elm,scroll,disable", "elm");
|
|
|
|
else if (sd->scroll && sd->theme_scroll)
|
|
|
|
elm_layout_signal_emit(sd->content_area, "elm,scroll,enable", "elm");
|
2015-08-15 08:32:33 -07:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
_visuals_set(obj);
|
2015-02-09 23:01:23 -08:00
|
|
|
elm_layout_sizing_eval(obj);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-02-27 04:03:13 -08:00
|
|
|
/* access */
|
|
|
|
if (_elm_config->access_mode) _access_obj_process(obj, EINA_TRUE);
|
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return ELM_THEME_APPLY_SUCCESS;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-27 22:16:15 -07:00
|
|
|
_item_sizing_eval(Elm_Popup_Item_Data *it)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
Evas_Coord min_w = -1, min_h = -1, max_w = -1, max_h = -1;
|
2013-09-02 19:08:41 -07:00
|
|
|
Evas_Object *edje = elm_layout_edje_get(VIEW(it));
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
edje_object_size_min_restricted_calc
|
2013-09-02 19:08:41 -07:00
|
|
|
(edje, &min_w, &min_h, min_w, min_h);
|
|
|
|
evas_object_size_hint_min_set(edje, min_w, min_h);
|
|
|
|
evas_object_size_hint_max_set(edje, max_w, max_h);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_elm_layout_sizing_eval(Eo *obj, Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
Eina_List *elist;
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it;
|
2012-07-23 05:35:48 -07:00
|
|
|
Evas_Coord h_box = 0, minh_box = 0;
|
2013-10-16 22:18:22 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2016-04-11 08:36:12 -07:00
|
|
|
_scroller_size_calc(obj);
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->items)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
EINA_LIST_FOREACH(sd->items, elist, it)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
_item_sizing_eval(it);
|
2016-06-09 00:29:40 -07:00
|
|
|
efl_gfx_size_hint_combined_min_get(elm_layout_edje_get(VIEW(it)),
|
2013-09-02 19:08:41 -07:00
|
|
|
NULL, &minh_box);
|
2012-07-23 05:35:48 -07:00
|
|
|
if (minh_box != -1) h_box += minh_box;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_size_hint_min_set(sd->spacer, 0, MIN(h_box, sd->max_sc_h));
|
|
|
|
evas_object_size_hint_max_set(sd->spacer, -1, sd->max_sc_h);
|
|
|
|
|
2016-06-09 00:29:40 -07:00
|
|
|
efl_gfx_size_hint_combined_min_get(sd->scr, &minw, &minh);
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_size_hint_max_get(sd->scr, &minw, &minh);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2015-08-15 08:32:33 -07:00
|
|
|
else if (sd->scroll && (sd->content || sd->text_content_obj))
|
2015-05-14 23:10:34 -07:00
|
|
|
{
|
|
|
|
double horizontal, vertical;
|
|
|
|
Evas_Coord w, h;
|
|
|
|
|
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(sd->content_area));
|
|
|
|
|
|
|
|
elm_popup_align_get(obj, &horizontal, &vertical);
|
2016-04-11 10:11:23 -07:00
|
|
|
evas_object_geometry_get(sd->parent, NULL, NULL, &w, &h);
|
2015-05-14 23:10:34 -07:00
|
|
|
|
2017-01-06 09:57:46 -08:00
|
|
|
if (EINA_DBL_EQ(horizontal, ELM_NOTIFY_ALIGN_FILL))
|
2015-05-14 23:10:34 -07:00
|
|
|
minw = w;
|
2017-01-06 09:57:46 -08:00
|
|
|
if (EINA_DBL_EQ(vertical, ELM_NOTIFY_ALIGN_FILL))
|
2015-05-14 23:10:34 -07:00
|
|
|
minh = h;
|
|
|
|
edje_object_size_min_restricted_calc(elm_layout_edje_get(sd->content_area),
|
|
|
|
&minw, &minh, minw, minh);
|
2015-08-15 08:32:33 -07:00
|
|
|
|
2015-05-14 23:10:34 -07:00
|
|
|
evas_object_size_hint_min_set(sd->content_area, minw, minh);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2015-05-14 23:10:34 -07:00
|
|
|
if (minh > sd->max_sc_h)
|
|
|
|
evas_object_size_hint_min_set(sd->spacer, minw, sd->max_sc_h);
|
|
|
|
else
|
|
|
|
evas_object_size_hint_min_set(sd->spacer, minw, minh);
|
2015-08-15 08:32:33 -07:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
edje_object_size_min_calc(elm_layout_edje_get(sd->main_layout), &minw, &minh);
|
|
|
|
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, -1, -1);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
From: Kim Shinwoo <kimcinoo.efl@gmail.com>
Subject: [E-devel] [patch][elementary] popup - getting proper geometry value]
current popup does not give proper geometry value,
evas_object_geometry_get(popup, &x, &y, &w, &h) gives 0, 0, 0, 0.
the patch resolves it, but it would be not a good way to get geometry
value. which is the best way to set obj->cur.geometry.x(y,w,h)?
please enlighten me. thanks.
SVN revision: 74409
2012-07-25 20:57:25 -07:00
|
|
|
|
2016-04-04 21:46:38 -07:00
|
|
|
EOLIAN static void
|
2016-08-05 10:31:49 -07:00
|
|
|
_elm_popup_elm_layout_signal_emit(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, const char *emission, const char *source)
|
2016-04-04 21:46:38 -07:00
|
|
|
{
|
2016-08-05 10:31:49 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, emission, source);
|
2016-04-04 21:46:38 -07:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_elm_widget_sub_object_del(Eo *obj, Elm_Popup_Data *sd, Evas_Object *sobj)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it;
|
2014-04-03 06:08:39 -07:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
int_ret = elm_obj_widget_sub_object_del(efl_super(obj, MY_CLASS), sobj);
|
2014-03-25 05:00:33 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
if (sobj == sd->title_icon)
|
|
|
|
{
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title,icon,hidden", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
2013-09-02 16:52:09 -07:00
|
|
|
else if ((it =
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_data_get(sobj, "_popup_icon_parent_item")) != NULL)
|
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
if (sobj == it->icon)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_unset(efl_part(VIEW(it), CONTENT_PART));
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it),
|
|
|
|
"elm,state,item,icon,hidden", "elm");
|
2013-09-02 16:52:09 -07:00
|
|
|
it->icon = NULL;
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_TRUE;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-30 09:46:34 -07:00
|
|
|
_on_content_del(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->content = NULL;
|
2015-02-09 23:01:23 -08:00
|
|
|
elm_layout_sizing_eval(data);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-30 09:46:34 -07:00
|
|
|
_on_text_content_del(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
sd->text_content_obj = NULL;
|
2015-02-09 23:01:23 -08:00
|
|
|
elm_layout_sizing_eval(data);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_on_table_del(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
|
|
|
ELM_POPUP_DATA_GET(data, sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
sd->tbl = NULL;
|
|
|
|
sd->spacer = NULL;
|
|
|
|
sd->scr = NULL;
|
|
|
|
sd->box = NULL;
|
2015-02-09 23:01:23 -08:00
|
|
|
elm_layout_sizing_eval(data);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_on_button_del(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
2012-08-30 09:46:34 -07:00
|
|
|
Evas_Object *obj,
|
2014-01-06 06:30:02 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ELM_POPUP_DATA_GET(data, sd);
|
|
|
|
|
|
|
|
for (i = 0; i < ELM_POPUP_ACTION_BUTTON_MAX; i++)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->buttons[i] && obj == sd->buttons[i]->btn &&
|
|
|
|
sd->buttons[i]->delete_me == EINA_TRUE)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
_button_remove(data, i, EINA_FALSE);
|
|
|
|
break;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_button_remove(Evas_Object *obj,
|
|
|
|
int pos,
|
|
|
|
Eina_Bool delete)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
char buf[128];
|
|
|
|
|
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
2013-10-13 08:57:42 -07:00
|
|
|
if (!sd->last_button_number) return;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
if (!sd->buttons[pos]) return;
|
|
|
|
|
2013-10-13 08:57:42 -07:00
|
|
|
if (delete)
|
|
|
|
{
|
|
|
|
evas_object_del(sd->buttons[pos]->btn);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del
|
|
|
|
(sd->buttons[pos]->btn, EVAS_CALLBACK_DEL, _on_button_del);
|
|
|
|
snprintf(buf, sizeof(buf), "elm.swallow.content.button%i", pos + 1);
|
|
|
|
elm_object_part_content_unset(sd->action_area, buf);
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-05-29 04:15:12 -07:00
|
|
|
ELM_SAFE_FREE(sd->buttons[pos], free);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2017-05-11 22:57:01 -07:00
|
|
|
sd->last_button_number = 0;
|
|
|
|
|
2013-10-13 08:57:42 -07:00
|
|
|
for (i = ELM_POPUP_ACTION_BUTTON_MAX - 1; i >= 0; i--)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-10-13 08:57:42 -07:00
|
|
|
if (sd->buttons[i])
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-10-13 08:57:42 -07:00
|
|
|
sd->last_button_number = i + 1;
|
|
|
|
break;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-10-13 08:57:42 -07:00
|
|
|
if (!sd->last_button_number)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
_visuals_set(obj);
|
2014-01-21 17:38:55 -08:00
|
|
|
ELM_SAFE_FREE(sd->action_area, evas_object_del);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
else
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-10-04 06:39:30 -07:00
|
|
|
char style[1024];
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2013-10-04 06:39:30 -07:00
|
|
|
snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
|
2013-10-13 08:57:42 -07:00
|
|
|
snprintf(buf, sizeof(buf), "buttons%i", sd->last_button_number);
|
2013-10-04 06:39:30 -07:00
|
|
|
if (!elm_layout_theme_set(sd->action_area, "popup", buf, style))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-09 00:32:09 -07:00
|
|
|
_layout_change_cb(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj,
|
2014-01-06 06:30:02 -08:00
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2015-08-15 08:32:33 -07:00
|
|
|
static void
|
|
|
|
_create_scroller(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
char style[1024];
|
|
|
|
|
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
//table
|
|
|
|
sd->tbl = elm_table_add(sd->main_layout);
|
|
|
|
evas_object_event_callback_add(sd->tbl, EVAS_CALLBACK_DEL,
|
|
|
|
_on_table_del, obj);
|
|
|
|
if (!sd->scroll)
|
|
|
|
{
|
popup: fix unintentional object deletion when change scrollable
Summary:
If popup scrollable change from FALSE to TRUE after content or text is added,
content_area is deleted, so it cause null pointer problem.
main_layout has content_area in its CONTENT_PART, but in scrollable_set API,
tbl set into main_layout's CONTENT_PART, so content_area is deleted.
On the contrary, if scrollable change to FALSE,
content object in content_area is deleted, because tbl set into content_area's CONTENT_PART.
So if some object set into other object,
unset previous object and set it into properly part after that.
A case using item_append should be fixed by other patch.
@fix
Test Plan: Change scrollable repeatedly after adding content or text to popup.
Reviewers: jpeg, singh.amitesh, conr2d, cedric, raster
Reviewed By: cedric
Subscribers: herb
Differential Revision: https://phab.enlightenment.org/D4894
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-06-05 11:08:45 -07:00
|
|
|
if (sd->content || sd->text_content_obj) efl_content_unset(efl_part(sd->content_area, CONTENT_PART));
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(sd->content_area, CONTENT_PART), sd->tbl);
|
|
|
|
efl_content_set(efl_part(sd->main_layout, CONTENT_PART), sd->content_area);
|
2015-08-15 08:32:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//spacer
|
|
|
|
sd->spacer = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_color_set(sd->spacer, 0, 0, 0, 0);
|
|
|
|
elm_table_pack(sd->tbl, sd->spacer, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
//Scroller
|
|
|
|
sd->scr = elm_scroller_add(sd->tbl);
|
|
|
|
if (!sd->scroll)
|
|
|
|
{
|
|
|
|
snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
|
|
|
|
elm_object_style_set(sd->scr, style);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elm_object_style_set(sd->scr, "popup/no_inset_shadow");
|
|
|
|
evas_object_size_hint_weight_set(sd->scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(sd->scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_scroller_policy_set(sd->scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
|
|
|
|
elm_scroller_content_min_limit(sd->scr, EINA_TRUE, EINA_FALSE);
|
|
|
|
elm_scroller_bounce_set(sd->scr, EINA_FALSE, EINA_TRUE);
|
|
|
|
evas_object_event_callback_add(sd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_size_hints_changed_cb, obj);
|
2017-06-14 19:12:00 -07:00
|
|
|
efl_ui_mirrored_automatic_set(sd->scr, EINA_FALSE);
|
2017-06-02 00:25:11 -07:00
|
|
|
elm_object_mirrored_set(sd->scr, elm_object_mirrored_get(obj));
|
2015-08-15 08:32:33 -07:00
|
|
|
elm_table_pack(sd->tbl, sd->scr, 0, 0, 1, 1);
|
|
|
|
evas_object_show(sd->scr);
|
|
|
|
}
|
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
static void
|
2012-08-30 09:46:34 -07:00
|
|
|
_list_add(Evas_Object *obj)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2016-04-05 01:29:12 -07:00
|
|
|
if (!sd->scr)
|
2015-08-15 08:32:33 -07:00
|
|
|
_create_scroller(obj);
|
2012-08-30 09:46:34 -07:00
|
|
|
//Box
|
2014-07-09 00:32:09 -07:00
|
|
|
sd->box = elm_box_add(sd->scr);
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_size_hint_weight_set(sd->box, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(sd->box, EVAS_HINT_FILL, 0.0);
|
|
|
|
elm_object_content_set(sd->scr, sd->box);
|
|
|
|
evas_object_show(sd->box);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-30 09:46:34 -07:00
|
|
|
_item_select_cb(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it = data;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
if (!it || it->disabled) return;
|
|
|
|
if (it->func)
|
2014-09-14 04:51:26 -07:00
|
|
|
it->func((void *)WIDGET_ITEM_DATA_GET(EO_OBJ(it)), WIDGET(it), EO_OBJ(it));
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-27 22:16:15 -07:00
|
|
|
_item_text_set(Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
const char *label)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
if (!eina_stringshare_replace(&it->label, label)) return;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_text_set(VIEW(it), "elm.text", label);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
if (it->label)
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it),
|
|
|
|
"elm,state,item,text,visible", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
else
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it),
|
|
|
|
"elm,state,item,text,hidden", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-09-02 19:08:41 -07:00
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(VIEW(it)));
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_popup_item_elm_widget_item_part_text_set(Eo *eo_it EINA_UNUSED, Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
const char *part,
|
|
|
|
const char *label)
|
|
|
|
{
|
|
|
|
ELM_POPUP_ITEM_CHECK_OR_RETURN(it);
|
|
|
|
|
|
|
|
if ((!part) || (!strcmp(part, "default")))
|
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
_item_text_set(it, label);
|
2012-08-30 09:46:34 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
WRN("The part name is invalid! : popup=%p", WIDGET(it));
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
EOLIAN static const char *
|
|
|
|
_elm_popup_item_elm_widget_item_part_text_get(Eo *eo_it EINA_UNUSED, Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
const char *part)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_ITEM_CHECK_OR_RETURN(it, NULL);
|
|
|
|
|
|
|
|
if ((!part) || (!strcmp(part, "default")))
|
2013-09-02 16:52:09 -07:00
|
|
|
return it->label;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
WRN("The part name is invalid! : popup=%p", WIDGET(it));
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
return NULL;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-27 22:16:15 -07:00
|
|
|
_item_icon_set(Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
Evas_Object *icon)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
if (it->icon == icon) return;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2014-01-21 17:38:55 -08:00
|
|
|
evas_object_del(it->icon);
|
2013-09-02 16:52:09 -07:00
|
|
|
it->icon = icon;
|
|
|
|
if (it->icon)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
elm_widget_sub_object_add(WIDGET(it), it->icon);
|
|
|
|
evas_object_data_set(it->icon, "_popup_icon_parent_item", it);
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(VIEW(it), CONTENT_PART), it->icon);
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it), "elm,state,item,icon,visible", "elm");
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
else
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it), "elm,state,item,icon,hidden", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-09-02 19:08:41 -07:00
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(VIEW(it)));
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_popup_item_elm_widget_item_part_content_set(Eo *eo_it EINA_UNUSED, Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
const char *part,
|
|
|
|
Evas_Object *content)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_ITEM_CHECK_OR_RETURN(it);
|
|
|
|
|
|
|
|
if ((!(part)) || (!strcmp(part, "default")))
|
2013-09-02 16:52:09 -07:00
|
|
|
_item_icon_set(it, content);
|
2012-08-30 09:46:34 -07:00
|
|
|
else
|
2013-09-02 16:52:09 -07:00
|
|
|
WRN("The part name is invalid! : popup=%p", WIDGET(it));
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
EOLIAN static Evas_Object *
|
|
|
|
_elm_popup_item_elm_widget_item_part_content_get(Eo *eo_it EINA_UNUSED, Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
const char *part)
|
|
|
|
{
|
|
|
|
ELM_POPUP_ITEM_CHECK_OR_RETURN(it, NULL);
|
|
|
|
|
|
|
|
if ((!(part)) || (!strcmp(part, "default")))
|
2013-09-02 16:52:09 -07:00
|
|
|
return it->icon;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
WRN("The part name is invalid! : popup=%p", WIDGET(it));
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2014-09-27 22:16:15 -07:00
|
|
|
_item_icon_unset(Elm_Popup_Item_Data *it)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2013-09-02 16:52:09 -07:00
|
|
|
Evas_Object *icon = it->icon;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
if (!it->icon) return NULL;
|
2016-05-29 17:47:39 -07:00
|
|
|
_elm_widget_sub_object_redirect_to_top(WIDGET(it), icon);
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_data_del(icon, "_popup_icon_parent_item");
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_unset(efl_part(VIEW(it), CONTENT_PART));
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it), "elm,state,item,icon,hidden", "elm");
|
2013-09-02 16:52:09 -07:00
|
|
|
it->icon = NULL;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
EOLIAN static Evas_Object *
|
|
|
|
_elm_popup_item_elm_widget_item_part_content_unset(Eo *eo_it EINA_UNUSED, Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
const char *part)
|
|
|
|
{
|
|
|
|
Evas_Object *content = NULL;
|
|
|
|
|
|
|
|
ELM_POPUP_ITEM_CHECK_OR_RETURN(it, NULL);
|
|
|
|
|
|
|
|
if ((!(part)) || (!strcmp(part, "default")))
|
2013-09-02 16:52:09 -07:00
|
|
|
content = _item_icon_unset(it);
|
2012-08-30 09:46:34 -07:00
|
|
|
else
|
2013-09-02 16:52:09 -07:00
|
|
|
WRN("The part name is invalid! : popup=%p", WIDGET(it));
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
return content;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
EOLIAN static void
|
2014-08-13 23:17:01 -07:00
|
|
|
_elm_popup_item_elm_widget_item_disable(Eo *eo_it, Elm_Popup_Item_Data *it)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_ITEM_CHECK_OR_RETURN(it);
|
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
if (elm_wdg_item_disabled_get(eo_it))
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it), "elm,state,item,disabled", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
else
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it), "elm,state,item,enabled", "elm");
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-09-17 06:44:05 -07:00
|
|
|
EOLIAN static void
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_popup_item_efl_object_destructor(Eo *eo_it, Elm_Popup_Item_Data *it)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-09-17 06:44:05 -07:00
|
|
|
ELM_POPUP_ITEM_CHECK_OR_RETURN(it);
|
2013-09-02 16:52:09 -07:00
|
|
|
ELM_POPUP_DATA_GET(WIDGET(it), sd);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2014-01-21 17:12:44 -08:00
|
|
|
evas_object_del(it->icon);
|
2013-09-02 16:52:09 -07:00
|
|
|
eina_stringshare_del(it->label);
|
|
|
|
sd->items = eina_list_remove(sd->items, it);
|
2012-08-30 09:46:34 -07:00
|
|
|
if (!eina_list_count(sd->items))
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
sd->items = NULL;
|
|
|
|
_list_del(sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_destructor(efl_super(eo_it, ELM_POPUP_ITEM_CLASS));
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-09-27 22:16:15 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_popup_item_elm_widget_item_signal_emit(Eo *eo_it EINA_UNUSED, Elm_Popup_Item_Data *it,
|
2012-08-30 09:46:34 -07:00
|
|
|
const char *emission,
|
|
|
|
const char *source)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-09-02 19:08:41 -07:00
|
|
|
elm_layout_signal_emit(VIEW(it), emission, source);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_item_focused_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2014-02-17 11:03:34 -08:00
|
|
|
{
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it = data;
|
2014-02-17 11:03:34 -08:00
|
|
|
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(WIDGET(it), ELM_POPUP_EVENT_ITEM_FOCUSED, EO_OBJ(it));
|
2014-02-17 11:03:34 -08:00
|
|
|
}
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_item_unfocused_cb(void *data, const Efl_Event *event EINA_UNUSED)
|
2014-02-17 11:03:34 -08:00
|
|
|
{
|
2014-09-27 22:16:15 -07:00
|
|
|
Elm_Popup_Item_Data *it = data;
|
2014-02-17 11:03:34 -08:00
|
|
|
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(WIDGET(it), ELM_POPUP_EVENT_ITEM_UNFOCUSED, EO_OBJ(it));
|
2014-09-27 22:16:15 -07:00
|
|
|
}
|
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_popup_item_efl_object_constructor(Eo *eo_it, Elm_Popup_Item_Data *it)
|
2014-09-27 22:16:15 -07:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
eo_it = efl_constructor(efl_super(eo_it, ELM_POPUP_ITEM_CLASS));
|
|
|
|
it->base = efl_data_scope_get(eo_it, ELM_WIDGET_ITEM_CLASS);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return eo_it;
|
2014-02-17 11:03:34 -08:00
|
|
|
}
|
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
static void
|
2014-09-27 22:16:15 -07:00
|
|
|
_item_new(Elm_Popup_Item_Data *it)
|
2013-09-02 16:52:09 -07:00
|
|
|
{
|
2013-10-04 06:39:30 -07:00
|
|
|
char style[1024];
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2013-09-02 19:08:41 -07:00
|
|
|
VIEW(it) = elm_layout_add(WIDGET(it));
|
2014-02-17 11:03:34 -08:00
|
|
|
elm_object_focus_allow_set(VIEW(it), EINA_TRUE);
|
2017-06-14 19:12:00 -07:00
|
|
|
efl_ui_mirrored_automatic_set(VIEW(it), EINA_FALSE);
|
2017-06-02 00:25:11 -07:00
|
|
|
elm_object_mirrored_set(VIEW(it), elm_object_mirrored_get(WIDGET(it)));
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2013-10-04 06:39:30 -07:00
|
|
|
snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(WIDGET(it)));
|
|
|
|
if (!elm_layout_theme_set(VIEW(it), "popup", "item", style))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2013-09-09 03:15:26 -07:00
|
|
|
else
|
|
|
|
{
|
2013-10-11 22:10:16 -07:00
|
|
|
elm_layout_signal_callback_add(VIEW(it), "elm,action,click", "*",
|
2013-09-09 03:15:26 -07:00
|
|
|
_item_select_cb, it);
|
|
|
|
evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_add
|
2016-03-02 04:10:48 -08:00
|
|
|
(VIEW(it), ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, it);
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_add
|
2016-03-02 04:10:48 -08:00
|
|
|
(VIEW(it), ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, it);
|
2013-09-09 03:15:26 -07:00
|
|
|
evas_object_show(VIEW(it));
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_title_text_set(Evas_Object *obj,
|
|
|
|
const char *text)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-01-28 20:41:50 -08:00
|
|
|
Evas_Object *ao;
|
2012-03-05 15:51:56 -08:00
|
|
|
Eina_Bool title_visibility_old, title_visibility_current;
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (sd->title_text == text) return EINA_TRUE;
|
|
|
|
|
|
|
|
title_visibility_old = (sd->title_text) || (sd->title_icon);
|
|
|
|
eina_stringshare_replace(&sd->title_text, text);
|
|
|
|
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_text_set(sd->main_layout, "elm.text.title", text);
|
2012-07-26 19:27:16 -07:00
|
|
|
|
2013-01-28 20:41:50 -08:00
|
|
|
/* access */
|
|
|
|
if (_elm_config->access_mode)
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
2013-01-28 20:41:50 -08:00
|
|
|
ao = _access_object_get(obj, ACCESS_TITLE_PART);
|
2013-01-28 21:49:34 -08:00
|
|
|
if (!ao)
|
|
|
|
{
|
|
|
|
ao = _elm_access_edje_object_part_object_register
|
2014-07-09 00:32:09 -07:00
|
|
|
(obj, elm_layout_edje_get(sd->main_layout), ACCESS_TITLE_PART);
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao),
|
2013-01-28 21:49:34 -08:00
|
|
|
ELM_ACCESS_TYPE, E_("Popup Title"));
|
|
|
|
}
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao), ELM_ACCESS_INFO, text);
|
2012-08-30 09:46:34 -07:00
|
|
|
}
|
2012-07-26 19:27:16 -07:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->title_text)
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title,text,visible", "elm");
|
2012-03-05 15:51:56 -08:00
|
|
|
else
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title,text,hidden", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
title_visibility_current = (sd->title_text) || (sd->title_icon);
|
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
if (title_visibility_old != title_visibility_current)
|
2012-08-30 09:46:34 -07:00
|
|
|
_visuals_set(obj);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_content_text_set(Evas_Object *obj,
|
|
|
|
const char *text)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-02-15 04:55:43 -08:00
|
|
|
Evas_Object *ao;
|
2013-10-04 06:39:30 -07:00
|
|
|
char style[1024];
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (sd->items)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
_items_remove(sd);
|
|
|
|
_list_del(sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2015-08-15 08:32:33 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!sd->scroll)
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(sd->main_layout, CONTENT_PART), sd->content_area);
|
2015-08-15 08:32:33 -07:00
|
|
|
else
|
|
|
|
elm_object_content_set(sd->scr, sd->content_area);
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
if (!text) goto end;
|
|
|
|
|
2015-03-25 11:02:15 -07:00
|
|
|
if (sd->text_content_obj)
|
|
|
|
{
|
2016-05-24 04:40:18 -07:00
|
|
|
sd->text_content_obj = efl_content_unset(efl_part(sd->content_area, CONTENT_PART));
|
2015-03-25 11:02:15 -07:00
|
|
|
evas_object_del(sd->text_content_obj);
|
|
|
|
sd->text_content_obj = NULL;
|
|
|
|
}
|
|
|
|
|
2014-07-09 00:32:09 -07:00
|
|
|
sd->text_content_obj = elm_label_add(sd->content_area);
|
2013-10-04 06:39:30 -07:00
|
|
|
snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
|
|
|
|
elm_object_style_set(sd->text_content_obj, style);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(sd->text_content_obj, EVAS_CALLBACK_DEL, _on_text_content_del, obj);
|
|
|
|
|
|
|
|
elm_label_line_wrap_set(sd->text_content_obj, sd->content_text_wrap_type);
|
|
|
|
elm_object_text_set(sd->text_content_obj, text);
|
|
|
|
evas_object_size_hint_weight_set
|
|
|
|
(sd->text_content_obj, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set
|
|
|
|
(sd->text_content_obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2016-04-19 22:55:26 -07:00
|
|
|
efl_content_set
|
2016-05-24 04:40:18 -07:00
|
|
|
(efl_part(sd->content_area, CONTENT_PART), sd->text_content_obj);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-01-28 20:41:50 -08:00
|
|
|
/* access */
|
|
|
|
if (_elm_config->access_mode)
|
|
|
|
{
|
2013-02-15 02:39:00 -08:00
|
|
|
/* unregister label, ACCESS_BODY_PART will register */
|
|
|
|
elm_access_object_unregister(sd->text_content_obj);
|
|
|
|
|
2013-01-28 20:41:50 -08:00
|
|
|
ao = _access_object_get(obj, ACCESS_BODY_PART);
|
2013-01-28 21:49:34 -08:00
|
|
|
if (!ao)
|
|
|
|
{
|
|
|
|
ao = _elm_access_edje_object_part_object_register
|
2014-07-09 00:32:09 -07:00
|
|
|
(obj, elm_layout_edje_get(sd->main_layout), ACCESS_BODY_PART);
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao),
|
2013-01-28 21:49:34 -08:00
|
|
|
ELM_ACCESS_TYPE, E_("Popup Body Text"));
|
|
|
|
}
|
2013-07-30 20:53:04 -07:00
|
|
|
_elm_access_text_set(_elm_access_info_get(ao), ELM_ACCESS_INFO, text);
|
2013-01-28 20:41:50 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
end:
|
|
|
|
return EINA_TRUE;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2017-06-04 07:25:36 -07:00
|
|
|
_elm_popup_text_set(Eo *obj, Elm_Popup_Data *_pd, const char *part, const char *label)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-04-03 06:08:39 -07:00
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
if (!part || !strcmp(part, "default"))
|
2012-11-25 22:32:53 -08:00
|
|
|
int_ret = _content_text_set(obj, label);
|
2012-03-05 15:51:56 -08:00
|
|
|
else if (!strcmp(part, "title,text"))
|
2012-11-25 22:32:53 -08:00
|
|
|
int_ret = _title_text_set(obj, label);
|
2012-03-05 15:51:56 -08:00
|
|
|
else
|
2014-07-09 00:32:09 -07:00
|
|
|
int_ret = elm_layout_text_set(_pd->main_layout, part, label);
|
2013-07-22 14:05:16 -07:00
|
|
|
|
2015-08-04 08:51:32 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return int_ret;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static const char *
|
2014-07-09 00:32:09 -07:00
|
|
|
_title_text_get(const Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
return sd->title_text;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static const char *
|
2014-07-09 00:32:09 -07:00
|
|
|
_content_text_get(const Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
const char *str = NULL;
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->text_content_obj)
|
|
|
|
str = elm_object_text_get(sd->text_content_obj);
|
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static const char*
|
2017-06-04 07:25:36 -07:00
|
|
|
_elm_popup_text_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *_pd, const char *part)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-04-03 06:08:39 -07:00
|
|
|
const char *text = NULL;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
|
|
|
if (!part || !strcmp(part, "default"))
|
2014-07-09 00:32:09 -07:00
|
|
|
text = _content_text_get(_pd);
|
2012-03-05 15:51:56 -08:00
|
|
|
else if (!strcmp(part, "title,text"))
|
2014-07-09 00:32:09 -07:00
|
|
|
text = _title_text_get(_pd);
|
2012-03-05 15:51:56 -08:00
|
|
|
else
|
2014-07-09 00:32:09 -07:00
|
|
|
text = elm_layout_text_get(_pd->main_layout, part);
|
2014-03-25 05:00:33 -07:00
|
|
|
|
|
|
|
return text;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_title_icon_set(Evas_Object *obj,
|
|
|
|
Evas_Object *icon)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
Eina_Bool title_visibility_old, title_visibility_current;
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (sd->title_icon == icon) return EINA_TRUE;
|
|
|
|
title_visibility_old = (sd->title_text) || (sd->title_icon);
|
2014-01-21 17:38:55 -08:00
|
|
|
evas_object_del(sd->title_icon);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
sd->title_icon = icon;
|
|
|
|
title_visibility_current = (sd->title_text) || (sd->title_icon);
|
|
|
|
|
2016-04-19 22:55:26 -07:00
|
|
|
efl_content_set
|
2016-05-24 04:40:18 -07:00
|
|
|
(efl_part(sd->main_layout, "elm.swallow.title.icon"), sd->title_icon);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
if (sd->title_icon)
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_layout_signal_emit(sd->main_layout, "elm,state,title,icon,visible", "elm");
|
2012-08-30 09:46:34 -07:00
|
|
|
if (title_visibility_old != title_visibility_current) _visuals_set(obj);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_content_set(Evas_Object *obj,
|
|
|
|
Evas_Object *content)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (sd->content && sd->content == content) return EINA_TRUE;
|
|
|
|
if (sd->items)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
_items_remove(sd);
|
|
|
|
_list_del(sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2017-05-30 21:12:59 -07:00
|
|
|
evas_object_del(sd->content);
|
2012-08-30 09:46:34 -07:00
|
|
|
sd->content = content;
|
2017-05-30 21:12:59 -07:00
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
if (content)
|
|
|
|
{
|
2015-08-15 08:32:33 -07:00
|
|
|
if (!sd->scroll)
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(sd->main_layout, CONTENT_PART), sd->content_area);
|
2015-08-15 08:32:33 -07:00
|
|
|
else
|
|
|
|
elm_object_content_set(sd->scr, sd->content_area);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2016-11-01 17:28:26 -07:00
|
|
|
evas_object_show(content);
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(sd->content_area, CONTENT_PART), content);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_event_callback_add
|
|
|
|
(content, EVAS_CALLBACK_DEL, _on_content_del, obj);
|
|
|
|
}
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
return EINA_TRUE;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-30 09:46:34 -07:00
|
|
|
_action_button_set(Evas_Object *obj,
|
|
|
|
Evas_Object *btn,
|
|
|
|
unsigned int idx)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-10-04 06:39:30 -07:00
|
|
|
char buf[128], style[1024];
|
2015-04-04 09:21:12 -07:00
|
|
|
unsigned int i;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (idx >= ELM_POPUP_ACTION_BUTTON_MAX) return;
|
|
|
|
|
|
|
|
if (!btn)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
_button_remove(obj, idx, EINA_TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-13 08:57:42 -07:00
|
|
|
if (sd->buttons[idx])
|
2012-08-30 09:46:34 -07:00
|
|
|
{
|
|
|
|
evas_object_del(sd->buttons[idx]->btn);
|
2013-10-13 08:57:42 -07:00
|
|
|
free(sd->buttons[idx]);
|
|
|
|
}
|
|
|
|
|
|
|
|
sd->buttons[idx] = ELM_NEW(Action_Area_Data);
|
|
|
|
sd->buttons[idx]->obj = obj;
|
|
|
|
sd->buttons[idx]->btn = btn;
|
|
|
|
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(btn, EVAS_CALLBACK_DEL, _on_button_del, obj);
|
|
|
|
|
2015-04-04 09:21:12 -07:00
|
|
|
for (i = ELM_POPUP_ACTION_BUTTON_MAX - 1; i >= idx; i--)
|
2013-10-13 08:57:42 -07:00
|
|
|
{
|
|
|
|
if (sd->buttons[i])
|
|
|
|
{
|
|
|
|
sd->last_button_number = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-04-26 13:54:42 -07:00
|
|
|
if (!sd->action_area)
|
|
|
|
{
|
2014-07-09 00:32:09 -07:00
|
|
|
sd->action_area = elm_layout_add(sd->main_layout);
|
2013-04-26 13:54:42 -07:00
|
|
|
evas_object_event_callback_add
|
|
|
|
(sd->action_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
2014-07-09 00:32:09 -07:00
|
|
|
_size_hints_changed_cb, sd->main_layout);
|
2017-06-14 19:12:00 -07:00
|
|
|
efl_ui_mirrored_automatic_set(sd->action_area, EINA_FALSE);
|
2017-06-02 00:25:11 -07:00
|
|
|
elm_object_mirrored_set(sd->action_area, elm_object_mirrored_get(obj));
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(sd->main_layout, "elm.swallow.action_area"), sd->action_area);
|
2013-10-13 08:57:42 -07:00
|
|
|
|
|
|
|
_visuals_set(obj);
|
2013-04-26 13:54:42 -07:00
|
|
|
}
|
|
|
|
|
2016-07-06 12:50:36 -07:00
|
|
|
snprintf(buf, sizeof(buf), "buttons%i", sd->last_button_number);
|
2013-10-04 06:39:30 -07:00
|
|
|
snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
|
|
|
|
if (!elm_layout_theme_set(sd->action_area, "popup", buf, style))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-10-04 06:39:30 -07:00
|
|
|
snprintf(buf, sizeof(buf), "elm.swallow.content.button%i", idx + 1);
|
2016-11-01 17:28:26 -07:00
|
|
|
evas_object_show(sd->buttons[idx]->btn);
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_object_part_content_set
|
|
|
|
(sd->action_area, buf, sd->buttons[idx]->btn);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2016-05-24 04:40:18 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_elm_popup_content_set(Eo *obj, Elm_Popup_Data *_pd EINA_UNUSED, const char *part, Evas_Object *content)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2015-08-03 02:28:55 -07:00
|
|
|
Eina_Bool ret = EINA_TRUE;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
|
|
|
if (!part || !strcmp(part, "default"))
|
2015-08-03 02:28:55 -07:00
|
|
|
ret = _content_set(obj, content);
|
2012-03-05 15:51:56 -08:00
|
|
|
else if (!strcmp(part, "title,icon"))
|
2015-08-03 02:28:55 -07:00
|
|
|
ret = _title_icon_set(obj, content);
|
2012-03-05 15:51:56 -08:00
|
|
|
else if (!strncmp(part, "button", 6))
|
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
i = atoi(part + 6) - 1;
|
|
|
|
|
|
|
|
if (i >= ELM_POPUP_ACTION_BUTTON_MAX)
|
2013-08-30 02:00:33 -07:00
|
|
|
{
|
|
|
|
ERR("The part name is invalid! : popup=%p", obj);
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_FALSE;
|
2013-08-30 02:00:33 -07:00
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
_action_button_set(obj, content, i);
|
2013-08-30 02:00:33 -07:00
|
|
|
}
|
|
|
|
else
|
2016-05-24 04:40:18 -07:00
|
|
|
ret = efl_content_set(efl_part(_pd->main_layout, part), content);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2015-08-03 02:28:55 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
|
|
|
|
return ret;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2014-07-09 00:32:09 -07:00
|
|
|
_title_icon_get(const Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
return sd->title_icon;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2014-07-09 00:32:09 -07:00
|
|
|
_content_get(const Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
return sd->content;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2012-08-30 09:46:34 -07:00
|
|
|
_action_button_get(const Evas_Object *obj,
|
|
|
|
unsigned int idx)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
Evas_Object *button = NULL;
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
2013-04-26 13:54:42 -07:00
|
|
|
if (!sd->action_area) return NULL;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2012-12-17 02:50:12 -08:00
|
|
|
if (sd->buttons[idx])
|
|
|
|
button = sd->buttons[idx]->btn;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
2016-05-24 04:40:18 -07:00
|
|
|
static Evas_Object*
|
|
|
|
_elm_popup_content_get(Eo *obj, Elm_Popup_Data *_pd, const char *part)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
Evas_Object *content = NULL;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!part || !strcmp(part, "default"))
|
2014-07-09 00:32:09 -07:00
|
|
|
content = _content_get(_pd);
|
2012-03-05 15:51:56 -08:00
|
|
|
else if (!strcmp(part, "title,text"))
|
2014-07-09 00:32:09 -07:00
|
|
|
content = _title_icon_get(_pd);
|
2012-03-05 15:51:56 -08:00
|
|
|
else if (!strncmp(part, "button", 6))
|
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
i = atoi(part + 6) - 1;
|
|
|
|
|
|
|
|
if (i >= ELM_POPUP_ACTION_BUTTON_MAX)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
content = _action_button_get(obj, i);
|
|
|
|
}
|
2012-03-05 15:51:56 -08:00
|
|
|
else
|
2016-05-24 04:40:18 -07:00
|
|
|
content = efl_content_get(efl_part(_pd->main_layout, part));
|
2013-12-28 00:33:10 -08:00
|
|
|
|
|
|
|
if (!content)
|
2012-08-30 09:46:34 -07:00
|
|
|
goto err;
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return content;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
err:
|
|
|
|
WRN("The part name is invalid! : popup=%p", obj);
|
2014-03-25 05:00:33 -07:00
|
|
|
return NULL;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_content_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *content;
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
|
|
|
|
|
|
|
if (!sd->content) return NULL;
|
|
|
|
|
|
|
|
evas_object_event_callback_del
|
|
|
|
(sd->content, EVAS_CALLBACK_DEL, _on_content_del);
|
|
|
|
|
2016-05-24 04:40:18 -07:00
|
|
|
content = efl_content_unset(efl_part(sd->content_area, CONTENT_PART));
|
2012-08-30 09:46:34 -07:00
|
|
|
sd->content = NULL;
|
|
|
|
|
2015-02-09 23:01:23 -08:00
|
|
|
elm_layout_sizing_eval(obj);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_title_icon_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Evas_Object *icon;
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
ELM_POPUP_DATA_GET(obj, sd);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
if (!sd->title_icon) return NULL;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
icon = sd->title_icon;
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_unset(efl_part(sd->main_layout, "elm.swallow.title.icon"));
|
2012-08-30 09:46:34 -07:00
|
|
|
sd->title_icon = NULL;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
return icon;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2016-05-24 04:40:18 -07:00
|
|
|
static Evas_Object*
|
|
|
|
_elm_popup_content_unset(Eo *obj, Elm_Popup_Data *_pd EINA_UNUSED, const char *part)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
|
|
|
Evas_Object *content = NULL;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!part || !strcmp(part, "default"))
|
|
|
|
content = _content_unset(obj);
|
|
|
|
else if (!strcmp(part, "title,icon"))
|
|
|
|
content = _title_icon_unset(obj);
|
|
|
|
else if (!strncmp(part, "button", 6))
|
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
i = atoi(part + 6) - 1;
|
|
|
|
|
|
|
|
if (i >= ELM_POPUP_ACTION_BUTTON_MAX)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
_button_remove(obj, i, EINA_FALSE);
|
|
|
|
}
|
2012-03-05 15:51:56 -08:00
|
|
|
else
|
2012-08-30 09:46:34 -07:00
|
|
|
goto err;
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return content;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
err:
|
|
|
|
ERR("The part name is invalid! : popup=%p", obj);
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return NULL;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Popup_Data *_pd EINA_UNUSED)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2015-09-15 03:41:51 -07:00
|
|
|
_elm_popup_elm_widget_focus_next(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-02-15 02:39:00 -08:00
|
|
|
Evas_Object *ao;
|
|
|
|
Eina_List *items = NULL;
|
2016-03-28 21:30:13 -07:00
|
|
|
Eina_Iterator *base_it;
|
2013-02-15 02:39:00 -08:00
|
|
|
|
|
|
|
/* access */
|
|
|
|
if (_elm_config->access_mode)
|
2012-07-26 19:27:16 -07:00
|
|
|
{
|
2013-02-15 02:39:00 -08:00
|
|
|
if (sd->title_text)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-02-15 02:39:00 -08:00
|
|
|
ao = _access_object_get(obj, ACCESS_TITLE_PART);
|
|
|
|
items = eina_list_append(items, ao);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2013-02-15 02:39:00 -08:00
|
|
|
|
|
|
|
ao = _access_object_get(obj, ACCESS_BODY_PART);
|
|
|
|
if (ao) items = eina_list_append(items, ao);
|
2012-07-26 19:27:16 -07:00
|
|
|
}
|
2013-02-15 02:39:00 -08:00
|
|
|
|
2016-04-19 22:55:26 -07:00
|
|
|
base_it = efl_content_iterate(sd->main_layout);
|
2016-03-28 21:30:13 -07:00
|
|
|
EINA_ITERATOR_FOREACH(base_it, ao)
|
|
|
|
if (ao) items = eina_list_append(items, ao);
|
|
|
|
eina_iterator_free(base_it);
|
2013-12-28 00:33:10 -08:00
|
|
|
|
2015-09-15 03:41:51 -07:00
|
|
|
if (!elm_widget_focus_list_next_get(sd->main_layout, items, eina_list_data_get, dir, next, next_item))
|
2014-07-09 00:32:09 -07:00
|
|
|
*next = sd->main_layout;
|
2013-12-28 00:33:10 -08:00
|
|
|
eina_list_free(items);
|
2013-02-15 02:39:00 -08:00
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-07-26 19:27:16 -07:00
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Popup_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_TRUE;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-04-06 00:14:10 -07:00
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2015-09-24 23:24:53 -07:00
|
|
|
_elm_popup_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
|
2012-07-25 03:28:51 -07:00
|
|
|
{
|
2013-02-18 22:51:19 -08:00
|
|
|
Evas_Object *ao;
|
|
|
|
Eina_List *items = NULL;
|
2016-03-28 21:30:13 -07:00
|
|
|
Eina_Iterator *base_it;
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-02-18 22:51:19 -08:00
|
|
|
/* access */
|
|
|
|
if (_elm_config->access_mode)
|
|
|
|
{
|
|
|
|
if (sd->title_text)
|
|
|
|
{
|
|
|
|
ao = _access_object_get(obj, ACCESS_TITLE_PART);
|
|
|
|
items = eina_list_append(items, ao);
|
|
|
|
}
|
|
|
|
|
|
|
|
ao = _access_object_get(obj, ACCESS_BODY_PART);
|
|
|
|
if (ao) items = eina_list_append(items, ao);
|
|
|
|
}
|
|
|
|
|
2016-04-19 22:55:26 -07:00
|
|
|
base_it = efl_content_iterate(sd->main_layout);
|
2016-03-28 21:30:13 -07:00
|
|
|
EINA_ITERATOR_FOREACH(base_it, ao)
|
|
|
|
if (ao) items = eina_list_append(items, ao);
|
|
|
|
eina_iterator_free(base_it);
|
2013-12-28 00:33:10 -08:00
|
|
|
|
2013-02-18 22:51:19 -08:00
|
|
|
elm_widget_focus_list_direction_get
|
2015-09-24 23:24:53 -07:00
|
|
|
(sd->main_layout, base, items, eina_list_data_get, degree, direction, direction_item, weight);
|
2013-12-28 00:33:10 -08:00
|
|
|
eina_list_free(items);
|
2013-02-18 22:51:19 -08:00
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_TRUE;
|
2012-07-25 03:28:51 -07:00
|
|
|
}
|
|
|
|
|
2014-04-14 22:47:19 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_move(Evas_Object *obj, const char *params)
|
|
|
|
{
|
|
|
|
const char *dir = params;
|
|
|
|
|
2015-09-10 02:29:24 -07:00
|
|
|
_elm_widget_focus_auto_show(obj);
|
2014-04-14 22:47:19 -07:00
|
|
|
if (!strcmp(dir, "previous"))
|
|
|
|
elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
|
|
|
|
else if (!strcmp(dir, "next"))
|
|
|
|
elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
|
|
|
|
else if (!strcmp(dir, "left"))
|
|
|
|
elm_widget_focus_cycle(obj, ELM_FOCUS_LEFT);
|
|
|
|
else if (!strcmp(dir, "right"))
|
|
|
|
elm_widget_focus_cycle(obj, ELM_FOCUS_RIGHT);
|
|
|
|
else if (!strcmp(dir, "up"))
|
|
|
|
elm_widget_focus_cycle(obj, ELM_FOCUS_UP);
|
|
|
|
else if (!strcmp(dir, "down"))
|
|
|
|
elm_widget_focus_cycle(obj, ELM_FOCUS_DOWN);
|
|
|
|
else return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-18 05:55:35 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_escape(Evas_Object *obj, const char *params EINA_UNUSED)
|
|
|
|
{
|
|
|
|
ELM_POPUP_DATA_GET(obj, pd);
|
|
|
|
elm_layout_signal_emit(pd->main_layout, "elm,state,hide", "elm");
|
|
|
|
elm_notify_dismiss(pd->notify);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2017-01-01 23:48:17 -08:00
|
|
|
_elm_popup_elm_widget_widget_event(Eo *obj, Elm_Popup_Data *_pd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
|
2013-02-15 02:39:00 -08:00
|
|
|
{
|
2013-10-28 07:06:14 -07:00
|
|
|
(void)src;
|
2014-03-25 05:00:33 -07:00
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
2013-02-15 02:39:00 -08:00
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
2013-02-15 02:39:00 -08:00
|
|
|
|
2015-12-21 04:55:23 -08:00
|
|
|
if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions))
|
2014-04-14 22:47:19 -07:00
|
|
|
return EINA_FALSE;
|
2013-02-18 22:51:19 -08:00
|
|
|
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
2014-03-25 05:00:33 -07:00
|
|
|
return EINA_TRUE;
|
2013-02-15 02:39:00 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_popup_efl_canvas_group_group_add(Eo *obj, Elm_Popup_Data *priv)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2013-10-04 06:39:30 -07:00
|
|
|
char style[1024];
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
2013-09-24 21:33:39 -07:00
|
|
|
elm_widget_sub_object_parent_add(obj);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2014-07-09 00:32:09 -07:00
|
|
|
snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
priv->notify = elm_notify_add(obj);
|
2013-10-04 06:39:30 -07:00
|
|
|
elm_object_style_set(priv->notify, style);
|
2015-12-07 15:53:47 -08:00
|
|
|
|
|
|
|
elm_notify_align_set(priv->notify,
|
|
|
|
_elm_config->popup_horizontal_align,
|
|
|
|
_elm_config->popup_vertical_align);
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_notify_allow_events_set(priv->notify, EINA_FALSE);
|
|
|
|
evas_object_size_hint_weight_set
|
|
|
|
(priv->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set
|
|
|
|
(priv->notify, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2014-07-09 00:32:09 -07:00
|
|
|
evas_object_smart_member_add(priv->notify, obj);
|
2017-06-14 19:12:00 -07:00
|
|
|
efl_ui_mirrored_automatic_set(priv->notify, EINA_FALSE);
|
2017-06-02 00:25:11 -07:00
|
|
|
elm_object_mirrored_set(priv->notify, elm_object_mirrored_get(obj));
|
2014-07-09 00:32:09 -07:00
|
|
|
|
elc_popup: If popup's parent is resized, popup need to resized, too
Summary:
When window's size is not enough to show popup, popup resize smaller to show it in appropriate size.
But if window resize larger enough to show popup, popup is locked in small size.
On the contrary to this case, if window resize too smaller, popup has still large size, so popup doesn't display properly.
Test Plan:
1. elementary_test popup
2. maximize test list window
3. click 8th item, "popup-center-title + items + 3 buttons"
4. restore window size
5. close popup, resize window to smaller than popup in 3).
6. click 8th item, "popup-center-title + items + 3 buttons"
7. restore window size
popup size of 4. and 7. is different
Reviewers: jaehwan, cedric, raster, id213sin, singh.amitesh, SanghyeonLee
Subscribers: jpeg
Differential Revision: https://phab.enlightenment.org/D3854
2016-04-11 08:28:55 -07:00
|
|
|
evas_object_event_callback_add(priv->notify, EVAS_CALLBACK_RESIZE, _notify_resize_cb, obj);
|
|
|
|
|
2014-07-09 00:32:09 -07:00
|
|
|
priv->main_layout = elm_layout_add(obj);
|
|
|
|
if (!elm_layout_theme_set(priv->main_layout, "popup", "base",
|
|
|
|
elm_widget_style_get(obj)))
|
|
|
|
CRI("Failed to set layout!");
|
|
|
|
|
|
|
|
elm_object_content_set(priv->notify, priv->main_layout);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL);
|
2017-06-14 19:12:00 -07:00
|
|
|
efl_ui_mirrored_automatic_set(priv->main_layout, EINA_FALSE);
|
2017-06-02 00:25:11 -07:00
|
|
|
elm_object_mirrored_set(priv->main_layout, elm_object_mirrored_get(obj));
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_layout_signal_callback_add
|
2014-07-09 00:32:09 -07:00
|
|
|
(priv->main_layout, "elm,state,title_area,visible", "elm", _layout_change_cb, NULL);
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_layout_signal_callback_add
|
2014-07-09 00:32:09 -07:00
|
|
|
(priv->main_layout, "elm,state,title_area,hidden", "elm", _layout_change_cb, NULL);
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_layout_signal_callback_add
|
2014-07-09 00:32:09 -07:00
|
|
|
(priv->main_layout, "elm,state,action_area,visible", "elm", _layout_change_cb, NULL);
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_layout_signal_callback_add
|
2014-07-09 00:32:09 -07:00
|
|
|
(priv->main_layout, "elm,state,action_area,hidden", "elm", _layout_change_cb, NULL);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2014-07-09 00:32:09 -07:00
|
|
|
priv->content_area = elm_layout_add(priv->main_layout);
|
2013-10-04 06:39:30 -07:00
|
|
|
if (!elm_layout_theme_set(priv->content_area, "popup", "content", style))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2013-09-09 03:15:26 -07:00
|
|
|
else
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(priv->content_area, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
2015-08-15 08:32:33 -07:00
|
|
|
_size_hints_changed_cb, priv->main_layout);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
priv->content_text_wrap_type = ELM_WRAP_MIXED;
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_callback_array_add(priv->notify, _notify_cb(), obj);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2013-02-15 02:39:00 -08:00
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
2014-07-09 00:32:09 -07:00
|
|
|
elm_widget_can_focus_set(priv->main_layout, EINA_TRUE);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2015-08-15 08:32:33 -07:00
|
|
|
_populate_theme_scroll(priv);
|
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
_visuals_set(obj);
|
popup: add popup default scrollable flag config for other profiles.
Summary:
The default scrollable flag of popup can be different in each profiles.
So I added the scrollable configuration of popup.
@feature
Test Plan:
1. Before
1) elementary_test -to popup
2) resize window to smaller
3) Click 15th item, "popup-center-title + genlist content + 1 button"
4) Then popup will show, but its list is very long, only small part of popup could be shown.
2. After Patch
1) change "popup_scroller" value to 1 in base.src, then run elementary_test -to popup or ELM_POPUP_SCROLLABLE=1 elemantary_test -to popup
2) resize window to smaller
3) Click 15th item, "popup-center-title + genlist content + 1 button"
4) Then popup will show, popup's genlist will be in scroller, so entire popup can be shown.
Reviewers: jaehwan, id213sin, cedric, raster, singh.amitesh, SanghyeonLee, Hermet
Subscribers: Hermet, minkyu, herb, jpeg
Differential Revision: https://phab.enlightenment.org/D3856
2016-05-16 18:22:07 -07:00
|
|
|
|
|
|
|
if (_elm_config->popup_scrollable)
|
|
|
|
elm_popup_scrollable_set(obj, _elm_config->popup_scrollable);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2015-03-10 00:21:16 -07:00
|
|
|
static void
|
2015-03-10 00:51:44 -07:00
|
|
|
_parent_geom_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2015-03-10 00:21:16 -07:00
|
|
|
{
|
2015-03-10 00:51:44 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
2015-03-10 00:21:16 -07:00
|
|
|
Evas_Object *popup = data;
|
|
|
|
|
2015-03-10 01:03:36 -07:00
|
|
|
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
if (efl_isa(obj, EFL_UI_WIN_CLASS))
|
2015-03-10 00:51:44 -07:00
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
evas_object_move(popup, x, y);
|
2015-03-10 00:21:16 -07:00
|
|
|
evas_object_resize(popup, w, h);
|
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2016-04-11 09:51:15 -07:00
|
|
|
_elm_popup_elm_widget_widget_parent_set(Eo *obj, Elm_Popup_Data *sd, Evas_Object *parent)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-07-09 00:32:09 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
evas_object_geometry_get(parent, &x, &y, &w, &h);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
if (efl_isa(parent, EFL_UI_WIN_CLASS))
|
2014-07-09 00:32:09 -07:00
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
}
|
|
|
|
evas_object_move(obj, x, y);
|
|
|
|
evas_object_resize(obj, w, h);
|
2015-03-10 00:21:16 -07:00
|
|
|
|
|
|
|
sd->parent = parent;
|
2015-03-10 00:51:44 -07:00
|
|
|
evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _parent_geom_cb, obj);
|
|
|
|
evas_object_event_callback_add(parent, EVAS_CALLBACK_MOVE, _parent_geom_cb, obj);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_elm_widget_access(Eo *obj, Elm_Popup_Data *_pd EINA_UNUSED, Eina_Bool is_access)
|
2013-01-28 20:41:50 -08:00
|
|
|
{
|
|
|
|
_access_obj_process(obj, is_access);
|
|
|
|
}
|
|
|
|
|
2012-03-05 15:51:56 -08:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_popup_add(Evas_Object *parent)
|
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2016-08-15 06:44:41 -07:00
|
|
|
Evas_Object *obj = efl_add(MY_CLASS, parent);
|
2013-02-14 01:20:54 -08:00
|
|
|
|
2013-10-05 01:13:14 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
2013-02-14 01:20:54 -08:00
|
|
|
wd->highlight_root = EINA_TRUE;
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
return obj;
|
|
|
|
}
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_popup_efl_object_constructor(Eo *obj, Elm_Popup_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2016-06-20 21:26:15 -07:00
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
|
2016-06-16 22:12:02 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_NOTIFICATION);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_content_text_wrap_type_set(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, Elm_Wrap_Type wrap)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-03-05 15:51:56 -08:00
|
|
|
//Need to wrap the content text, so not allowing ELM_WRAP_NONE
|
2016-04-04 22:39:26 -07:00
|
|
|
if (wrap == ELM_WRAP_NONE) return;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
sd->content_text_wrap_type = wrap;
|
|
|
|
if (sd->text_content_obj)
|
|
|
|
elm_label_line_wrap_set(sd->text_content_obj, wrap);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Elm_Wrap_Type
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_content_text_wrap_type_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-03-25 05:00:33 -07:00
|
|
|
return sd->content_text_wrap_type;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2012-11-06 11:54:16 -08:00
|
|
|
/* keeping old externals orient api for notify, but taking away the
|
|
|
|
* introduced deprecation warning by copying the deprecated code
|
|
|
|
* here */
|
|
|
|
static Elm_Notify_Orient
|
|
|
|
_elm_notify_orient_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Elm_Notify_Orient orient;
|
|
|
|
double horizontal, vertical;
|
|
|
|
|
|
|
|
elm_notify_align_get(obj, &horizontal, &vertical);
|
|
|
|
|
2017-01-06 09:57:46 -08:00
|
|
|
if ((EINA_DBL_EQ(horizontal, 0.5)) && (EINA_DBL_EQ(vertical, 0.0)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 0.5)) && (EINA_DBL_EQ(vertical, 0.5)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_CENTER;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 0.5)) && (EINA_DBL_EQ(vertical, 1.0)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_BOTTOM;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 0.0)) && (EINA_DBL_EQ(vertical, 0.5)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_LEFT;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 1.0)) && (EINA_DBL_EQ(vertical, 0.5)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_RIGHT;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 0.0)) && (EINA_DBL_EQ(vertical, 0.0)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP_LEFT;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 1.0)) && (EINA_DBL_EQ(vertical, 0.0)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP_RIGHT;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 0.0)) && (EINA_DBL_EQ(vertical, 1.0)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_BOTTOM_LEFT;
|
2017-01-06 09:57:46 -08:00
|
|
|
else if ((EINA_DBL_EQ(horizontal, 1.0)) && (EINA_DBL_EQ(vertical, 1.0)))
|
2012-11-06 11:54:16 -08:00
|
|
|
orient = ELM_NOTIFY_ORIENT_BOTTOM_RIGHT;
|
|
|
|
else
|
|
|
|
orient = ELM_NOTIFY_ORIENT_TOP;
|
|
|
|
return orient;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_notify_orient_set(Evas_Object *obj,
|
|
|
|
Elm_Notify_Orient orient)
|
|
|
|
{
|
|
|
|
double horizontal = 0, vertical = 0;
|
|
|
|
|
|
|
|
switch (orient)
|
|
|
|
{
|
|
|
|
case ELM_NOTIFY_ORIENT_TOP:
|
|
|
|
horizontal = 0.5; vertical = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_CENTER:
|
|
|
|
horizontal = 0.5; vertical = 0.5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM:
|
|
|
|
horizontal = 0.5; vertical = 1.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_LEFT:
|
|
|
|
horizontal = 0.0; vertical = 0.5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_RIGHT:
|
|
|
|
horizontal = 1.0; vertical = 0.5;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_TOP_LEFT:
|
|
|
|
horizontal = 0.0; vertical = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_TOP_RIGHT:
|
|
|
|
horizontal = 1.0; vertical = 0.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_LEFT:
|
|
|
|
horizontal = 0.0; vertical = 1.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_BOTTOM_RIGHT:
|
|
|
|
horizontal = 1.0; vertical = 1.0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ELM_NOTIFY_ORIENT_LAST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_notify_align_set(obj, horizontal, vertical);
|
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_orient_set(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, Elm_Popup_Orient orient)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-03-05 15:51:56 -08:00
|
|
|
if (orient >= ELM_POPUP_ORIENT_LAST) return;
|
2012-11-06 11:54:16 -08:00
|
|
|
_elm_notify_orient_set(sd->notify, (Elm_Notify_Orient)orient);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Elm_Popup_Orient
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_orient_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd)
|
2013-12-01 23:10:53 -08:00
|
|
|
{
|
2014-03-25 05:00:33 -07:00
|
|
|
return (Elm_Popup_Orient)_elm_notify_orient_get(sd->notify);
|
2013-12-01 23:10:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_align_set(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, double horizontal, double vertical)
|
2013-12-01 23:10:53 -08:00
|
|
|
{
|
|
|
|
elm_notify_align_set(sd->notify, horizontal, vertical);
|
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_align_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, double *horizontal, double *vertical)
|
2013-12-01 23:10:53 -08:00
|
|
|
{
|
|
|
|
elm_notify_align_get(sd->notify, horizontal, vertical);
|
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_timeout_set(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, double timeout)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_notify_timeout_set(sd->notify, timeout);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static double
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_timeout_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-03-25 05:00:33 -07:00
|
|
|
return elm_notify_timeout_get(sd->notify);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static void
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_allow_events_set(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd, Eina_Bool allow)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
|
|
|
Eina_Bool allow_events = !!allow;
|
2012-08-30 09:46:34 -07:00
|
|
|
|
|
|
|
elm_notify_allow_events_set(sd->notify, allow_events);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_allow_events_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *sd)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2014-03-25 05:00:33 -07:00
|
|
|
return elm_notify_allow_events_get(sd->notify);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2014-03-25 05:00:33 -07:00
|
|
|
EOLIAN static Elm_Object_Item*
|
2014-04-22 05:51:46 -07:00
|
|
|
_elm_popup_item_append(Eo *obj, Elm_Popup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2012-03-05 15:51:56 -08:00
|
|
|
Evas_Object *prev_content;
|
2014-09-27 22:16:15 -07:00
|
|
|
Eo *eo_it;
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
eo_it = efl_add(ELM_POPUP_ITEM_CLASS, obj);
|
2014-09-27 22:16:15 -07:00
|
|
|
if (!eo_it) return NULL;
|
|
|
|
ELM_POPUP_ITEM_DATA_GET(eo_it, it);
|
2012-08-30 09:46:34 -07:00
|
|
|
if (sd->content || sd->text_content_obj)
|
2012-03-05 15:51:56 -08:00
|
|
|
{
|
2016-05-24 04:40:18 -07:00
|
|
|
prev_content = efl_content_get(efl_part(sd->content_area, CONTENT_PART));
|
2014-01-21 17:38:55 -08:00
|
|
|
evas_object_del(prev_content);
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
//The first item is appended.
|
2012-08-30 09:46:34 -07:00
|
|
|
if (!sd->items)
|
|
|
|
_list_add(obj);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
it->func = func;
|
2014-11-25 04:54:24 -08:00
|
|
|
WIDGET_ITEM_DATA_SET(eo_it, data);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
_item_new(it);
|
|
|
|
_item_icon_set(it, icon);
|
|
|
|
_item_text_set(it, label);
|
2012-08-30 09:46:34 -07:00
|
|
|
|
2013-09-02 16:52:09 -07:00
|
|
|
elm_box_pack_end(sd->box, VIEW(it));
|
|
|
|
sd->items = eina_list_append(sd->items, it);
|
2012-03-05 15:51:56 -08:00
|
|
|
|
2012-08-30 09:46:34 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
|
2014-11-25 04:54:24 -08:00
|
|
|
return eo_it;
|
2012-03-05 15:51:56 -08:00
|
|
|
}
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2015-08-15 08:32:33 -07:00
|
|
|
EOLIAN void
|
|
|
|
_elm_popup_scrollable_set(Eo *obj, Elm_Popup_Data *pd, Eina_Bool scroll)
|
|
|
|
{
|
|
|
|
scroll = !!scroll;
|
|
|
|
if (pd->scroll == scroll) return;
|
|
|
|
pd->scroll = scroll;
|
|
|
|
|
|
|
|
if (!pd->scr)
|
|
|
|
_create_scroller(obj);
|
|
|
|
else
|
|
|
|
{
|
popup: fix unintentional object deletion when change scrollable
Summary:
If popup scrollable change from FALSE to TRUE after content or text is added,
content_area is deleted, so it cause null pointer problem.
main_layout has content_area in its CONTENT_PART, but in scrollable_set API,
tbl set into main_layout's CONTENT_PART, so content_area is deleted.
On the contrary, if scrollable change to FALSE,
content object in content_area is deleted, because tbl set into content_area's CONTENT_PART.
So if some object set into other object,
unset previous object and set it into properly part after that.
A case using item_append should be fixed by other patch.
@fix
Test Plan: Change scrollable repeatedly after adding content or text to popup.
Reviewers: jpeg, singh.amitesh, conr2d, cedric, raster
Reviewed By: cedric
Subscribers: herb
Differential Revision: https://phab.enlightenment.org/D4894
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-06-05 11:08:45 -07:00
|
|
|
elm_object_content_unset(pd->scr);
|
2015-08-15 08:32:33 -07:00
|
|
|
ELM_SAFE_FREE(pd->tbl, evas_object_del);
|
|
|
|
_create_scroller(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!pd->scroll)
|
|
|
|
{
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(pd->content_area, CONTENT_PART), pd->tbl);
|
|
|
|
efl_content_set(efl_part(pd->main_layout, CONTENT_PART), pd->content_area);
|
popup: fix unintentional object deletion when change scrollable
Summary:
If popup scrollable change from FALSE to TRUE after content or text is added,
content_area is deleted, so it cause null pointer problem.
main_layout has content_area in its CONTENT_PART, but in scrollable_set API,
tbl set into main_layout's CONTENT_PART, so content_area is deleted.
On the contrary, if scrollable change to FALSE,
content object in content_area is deleted, because tbl set into content_area's CONTENT_PART.
So if some object set into other object,
unset previous object and set it into properly part after that.
A case using item_append should be fixed by other patch.
@fix
Test Plan: Change scrollable repeatedly after adding content or text to popup.
Reviewers: jpeg, singh.amitesh, conr2d, cedric, raster
Reviewed By: cedric
Subscribers: herb
Differential Revision: https://phab.enlightenment.org/D4894
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-06-05 11:08:45 -07:00
|
|
|
if (pd->content) efl_content_set(efl_part(pd->content_area, CONTENT_PART), pd->content);
|
|
|
|
else if (pd->text_content_obj) efl_content_set(efl_part(pd->content_area, CONTENT_PART), pd->text_content_obj);
|
2015-08-15 08:32:33 -07:00
|
|
|
if (pd->theme_scroll)
|
|
|
|
elm_layout_signal_emit(pd->content_area, "elm,scroll,disable", "elm");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
popup: fix unintentional object deletion when change scrollable
Summary:
If popup scrollable change from FALSE to TRUE after content or text is added,
content_area is deleted, so it cause null pointer problem.
main_layout has content_area in its CONTENT_PART, but in scrollable_set API,
tbl set into main_layout's CONTENT_PART, so content_area is deleted.
On the contrary, if scrollable change to FALSE,
content object in content_area is deleted, because tbl set into content_area's CONTENT_PART.
So if some object set into other object,
unset previous object and set it into properly part after that.
A case using item_append should be fixed by other patch.
@fix
Test Plan: Change scrollable repeatedly after adding content or text to popup.
Reviewers: jpeg, singh.amitesh, conr2d, cedric, raster
Reviewed By: cedric
Subscribers: herb
Differential Revision: https://phab.enlightenment.org/D4894
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-06-05 11:08:45 -07:00
|
|
|
if (pd->content || pd->text_content_obj)
|
|
|
|
{
|
|
|
|
efl_content_unset(efl_part(pd->main_layout, CONTENT_PART));
|
|
|
|
elm_object_content_set(pd->scr, pd->content_area);
|
|
|
|
}
|
2016-05-24 04:40:18 -07:00
|
|
|
efl_content_set(efl_part(pd->main_layout, CONTENT_PART), pd->tbl);
|
2015-08-15 08:32:33 -07:00
|
|
|
if (pd->theme_scroll)
|
|
|
|
elm_layout_signal_emit(pd->content_area, "elm,scroll,enable", "elm");
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN Eina_Bool
|
|
|
|
_elm_popup_scrollable_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *pd)
|
|
|
|
{
|
|
|
|
return pd->scroll;
|
|
|
|
}
|
|
|
|
|
2015-12-30 20:08:28 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_popup_dismiss(Eo *obj EINA_UNUSED, Elm_Popup_Data *pd)
|
|
|
|
{
|
|
|
|
elm_layout_signal_emit(pd->main_layout, "elm,state,hide", "elm");
|
|
|
|
elm_notify_dismiss(pd->notify);
|
|
|
|
}
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
static void
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_popup_class_constructor(Efl_Class *klass)
|
2014-03-25 05:00:33 -07:00
|
|
|
{
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2014-03-25 05:00:33 -07:00
|
|
|
|
2015-12-17 02:58:37 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_action_dismiss(Evas_Object *obj, const char *params EINA_UNUSED)
|
|
|
|
{
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, ELM_POPUP_EVENT_BLOCK_CLICKED, NULL);
|
2015-12-17 02:58:37 -08:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-07-25 01:33:19 -07:00
|
|
|
EOLIAN const Elm_Atspi_Action *
|
|
|
|
_elm_popup_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
static Elm_Atspi_Action atspi_actions[] = {
|
2015-12-17 02:58:37 -08:00
|
|
|
{ "dismiss", NULL, NULL, _action_dismiss},
|
2014-07-25 01:33:19 -07:00
|
|
|
{ NULL, NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
return &atspi_actions[0];
|
|
|
|
}
|
|
|
|
|
2015-07-08 23:25:05 -07:00
|
|
|
EOLIAN static Elm_Atspi_State_Set
|
|
|
|
_elm_popup_elm_interface_atspi_accessible_state_set_get(Eo *obj, Elm_Popup_Data *sd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Elm_Atspi_State_Set ret;
|
2016-08-15 06:44:41 -07:00
|
|
|
ret = elm_interface_atspi_accessible_state_set_get(efl_super(obj, MY_CLASS));
|
2015-07-08 23:25:05 -07:00
|
|
|
|
|
|
|
STATE_TYPE_SET(ret, ELM_ATSPI_STATE_MODAL);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-05-24 04:40:18 -07:00
|
|
|
/* Efl.Part begin */
|
|
|
|
|
|
|
|
ELM_PART_OVERRIDE(elm_popup, ELM_POPUP, ELM_LAYOUT, Elm_Popup_Data, Elm_Part_Data)
|
|
|
|
ELM_PART_OVERRIDE_CONTENT_SET(elm_popup, ELM_POPUP, ELM_LAYOUT, Elm_Popup_Data, Elm_Part_Data)
|
|
|
|
ELM_PART_OVERRIDE_CONTENT_GET(elm_popup, ELM_POPUP, ELM_LAYOUT, Elm_Popup_Data, Elm_Part_Data)
|
|
|
|
ELM_PART_OVERRIDE_CONTENT_UNSET(elm_popup, ELM_POPUP, ELM_LAYOUT, Elm_Popup_Data, Elm_Part_Data)
|
2017-06-04 07:25:36 -07:00
|
|
|
ELM_PART_OVERRIDE_TEXT_SET(elm_popup, ELM_POPUP, ELM_LAYOUT, Elm_Popup_Data, Elm_Part_Data)
|
|
|
|
ELM_PART_OVERRIDE_TEXT_GET(elm_popup, ELM_POPUP, ELM_LAYOUT, Elm_Popup_Data, Elm_Part_Data)
|
2016-05-24 04:40:18 -07:00
|
|
|
#include "elm_popup_internal_part.eo.c"
|
|
|
|
|
|
|
|
/* Efl.Part end */
|
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
|
|
|
#define ELM_POPUP_EXTRA_OPS \
|
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(elm_popup)
|
|
|
|
|
2014-08-11 07:46:11 -07:00
|
|
|
#include "elm_popup.eo.c"
|
2014-09-27 22:16:15 -07:00
|
|
|
#include "elm_popup_item.eo.c"
|