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
|
2016-04-20 05:07:38 -07:00
|
|
|
#define ELM_LAYOUT_PROTECTED
|
2014-10-17 08:56:11 -07:00
|
|
|
|
2008-10-28 18:51:45 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2016-10-18 03:34:12 -07:00
|
|
|
#include "elm_bubble.eo.h"
|
2012-08-01 14:04:39 -07:00
|
|
|
#include "elm_widget_bubble.h"
|
2012-11-25 22:32:53 -08:00
|
|
|
#include "elm_widget_layout.h"
|
2008-10-28 18:51:45 -07:00
|
|
|
|
2017-06-04 07:25:36 -07:00
|
|
|
#include "elm_bubble_internal_part.eo.h"
|
|
|
|
#include "elm_part_helper.h"
|
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_BUBBLE_CLASS
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2013-11-07 03:44:22 -08:00
|
|
|
#define MY_CLASS_NAME "Elm_Bubble"
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_bubble"
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2011-04-15 10:01:39 -07:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
2013-06-09 02:54:43 -07:00
|
|
|
|
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] =
|
|
|
|
{
|
|
|
|
{SIG_CLICKED, ""},
|
2014-02-05 23:18:57 -08:00
|
|
|
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
|
|
|
|
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
|
2013-06-09 02:54:43 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2011-04-15 10:01:39 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
2010-11-11 10:04:45 -08:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
{"default", "elm.swallow.content"},
|
|
|
|
{"icon", "elm.swallow.icon"},
|
|
|
|
{NULL, NULL}
|
2010-11-11 10:04:45 -08:00
|
|
|
};
|
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
static const Elm_Layout_Part_Alias_Description _text_aliases[] =
|
2012-02-28 19:41:31 -08:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
{"default", "elm.text"},
|
|
|
|
{"info", "elm.info"},
|
|
|
|
{NULL, NULL}
|
2012-02-28 19:41:31 -08:00
|
|
|
};
|
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
static const char *corner_string[] =
|
2011-02-08 04:08:28 -08:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
"top_left",
|
|
|
|
"top_right",
|
|
|
|
"bottom_left",
|
|
|
|
"bottom_right"
|
|
|
|
};
|
2008-11-15 05:58:50 -08:00
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_bubble_elm_layout_sizing_eval(Eo *obj, Elm_Bubble_Data *_pd EINA_UNUSED)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2013-10-16 22:18:22 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2013-10-05 01:13:35 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2011-10-31 09:16:21 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
|
|
|
edje_object_size_min_restricted_calc
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, &minw, &minh, minw, minh);
|
2012-05-03 15:42:26 -07:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
2013-10-16 22:18:22 -07:00
|
|
|
evas_object_size_hint_max_set(obj, -1, -1);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2011-10-31 09:16:21 -07:00
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:42:26 -07:00
|
|
|
_on_mouse_up(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2012-05-03 15:42:26 -07:00
|
|
|
void *event_info)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
2012-05-02 09:59:07 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
|
|
|
|
return;
|
2011-11-07 17:05:01 -08:00
|
|
|
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(data, EFL_UI_EVENT_CLICKED, NULL);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2011-11-07 17:05:01 -08:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
/* overriding layout's focus_next() in order to just cycle through the
|
|
|
|
* content's tree */
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2015-09-15 03:41:51 -07:00
|
|
|
_elm_bubble_elm_widget_focus_next(Eo *obj, Elm_Bubble_Data *_pd EINA_UNUSED, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
Evas_Object *content;
|
2014-03-19 23:40:07 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
|
2012-09-18 03:56:19 -07:00
|
|
|
if ((elm_widget_can_focus_get(obj)) &&
|
2012-11-25 22:32:53 -08:00
|
|
|
(!wd->focused))
|
2012-09-18 03:56:19 -07:00
|
|
|
{
|
|
|
|
// ACCESS
|
|
|
|
*next = (Evas_Object *)obj;
|
2014-03-19 23:40:07 -07:00
|
|
|
return EINA_TRUE;
|
2012-09-18 03:56:19 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
content = elm_layout_content_get(obj, NULL);
|
2014-03-19 23:40:07 -07:00
|
|
|
if (!content) return EINA_FALSE;
|
2012-05-03 15:42:26 -07:00
|
|
|
|
2012-09-18 03:56:19 -07:00
|
|
|
/* attempt to follow focus cycle into sub-object */
|
2015-09-15 03:41:51 -07:00
|
|
|
return elm_widget_focus_next_get(content, dir, next, next_item);
|
2012-09-18 03:56:19 -07:00
|
|
|
}
|
2011-11-07 17:05:01 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2015-09-24 23:24:53 -07:00
|
|
|
_elm_bubble_elm_widget_focus_direction(Eo *obj, Elm_Bubble_Data *_pd EINA_UNUSED, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
|
2010-10-01 12:03:02 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
Evas_Object *content;
|
2010-10-01 12:03:02 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
content = elm_layout_content_get(obj, NULL);
|
2010-10-01 12:03:02 -07:00
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
if (!content) return EINA_FALSE;
|
2010-10-01 12:03:02 -07:00
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
/* Try Focus cycle in subitem */
|
2014-03-19 23:40:07 -07:00
|
|
|
return elm_widget_focus_direction_get
|
2015-09-24 23:24:53 -07:00
|
|
|
(content, base, degree, direction, direction_item, weight);
|
2010-10-01 12:03:02 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2017-06-04 07:25:36 -07:00
|
|
|
_elm_bubble_text_set(Eo *obj, Elm_Bubble_Data *_pd EINA_UNUSED, const char *part, const char *label)
|
2012-05-02 20:02:54 -07:00
|
|
|
{
|
2017-06-04 07:25:36 -07:00
|
|
|
Eina_Bool int_ret = EINA_TRUE;
|
2013-07-22 14:05:16 -07:00
|
|
|
|
2017-06-29 11:33:12 -07:00
|
|
|
if (!part) part = _text_aliases[0].real_part;
|
2017-06-04 07:25:36 -07:00
|
|
|
efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label);
|
2014-03-19 23:40:07 -07:00
|
|
|
if (!int_ret) return EINA_FALSE;
|
2012-09-14 06:30:18 -07:00
|
|
|
|
2013-07-22 13:34:19 -07:00
|
|
|
if (part && (!strcmp(part, "info") || !strcmp(part, "elm.info")))
|
2012-05-03 15:42:26 -07:00
|
|
|
{
|
|
|
|
if (label)
|
|
|
|
elm_layout_signal_emit(obj, "elm,state,info,visible", "elm");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(obj, "elm,state,info,hidden", "elm");
|
|
|
|
}
|
2012-05-02 20:02:54 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
2012-05-02 20:02:54 -07:00
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2008-10-28 18:51:45 -07:00
|
|
|
|
2012-09-18 03:56:19 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2012-09-18 03:56:19 -07:00
|
|
|
{
|
|
|
|
char *ret;
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
Evas_Object *content;
|
|
|
|
const char *default_txt = NULL;
|
|
|
|
const char *content_txt = NULL;
|
|
|
|
const char *info_txt = NULL;
|
|
|
|
|
|
|
|
default_txt = elm_widget_access_info_get(obj);
|
|
|
|
if (!default_txt) default_txt = elm_layout_text_get(obj, NULL);
|
|
|
|
if (default_txt) eina_strbuf_append(buf, default_txt);
|
|
|
|
|
|
|
|
content = elm_layout_content_get(obj, NULL);
|
|
|
|
if (content) content_txt = elm_layout_text_get(content, NULL);
|
|
|
|
if (content_txt)
|
|
|
|
{
|
|
|
|
if (!eina_strbuf_length_get(buf))
|
|
|
|
eina_strbuf_append(buf, content_txt);
|
|
|
|
else
|
|
|
|
eina_strbuf_append_printf(buf, ", %s", content_txt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
info_txt = edje_object_part_text_get(elm_layout_edje_get(obj), "elm.info");
|
|
|
|
if (info_txt)
|
|
|
|
{
|
|
|
|
if (!eina_strbuf_length_get(buf))
|
|
|
|
eina_strbuf_append(buf, info_txt);
|
|
|
|
else
|
|
|
|
eina_strbuf_append_printf(buf, ", %s", info_txt);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = eina_strbuf_string_steal(buf);
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_elm_bubble_efl_canvas_group_group_add(Eo *obj, Elm_Bubble_Data *priv)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2013-10-05 01:13:35 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2010-11-11 10:04:45 -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);
|
2013-08-26 08:29:45 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
priv->pos = ELM_BUBBLE_POS_TOP_LEFT; //default
|
2011-07-04 03:14:11 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
evas_object_event_callback_add
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, EVAS_CALLBACK_MOUSE_UP,
|
2012-05-03 15:42:26 -07:00
|
|
|
_on_mouse_up, obj);
|
|
|
|
|
2012-09-18 03:56:19 -07:00
|
|
|
// ACCESS
|
2012-11-25 22:32:53 -08:00
|
|
|
_elm_access_object_register(obj, wd->resize_obj);
|
2012-09-18 03:56:19 -07:00
|
|
|
_elm_access_text_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Bubble"));
|
2012-09-18 03:56:19 -07:00
|
|
|
_elm_access_callback_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
|
2012-09-18 03:56:19 -07:00
|
|
|
|
2013-03-01 18:04:31 -08:00
|
|
|
if (!elm_layout_theme_set(obj, "bubble", "base", elm_widget_style_get(obj)))
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-07-17 11:44:55 -07:00
|
|
|
|
|
|
|
elm_layout_sizing_eval(obj);
|
2012-09-18 03:56:19 -07:00
|
|
|
|
2013-03-22 01:42:04 -07:00
|
|
|
if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
|
2012-09-18 03:56:19 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_bubble_elm_widget_access(Eo *obj, Elm_Bubble_Data *_pd EINA_UNUSED, Eina_Bool is_access)
|
2012-09-18 03:56:19 -07:00
|
|
|
{
|
|
|
|
ELM_BUBBLE_CHECK(obj);
|
|
|
|
|
|
|
|
if (is_access)
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
|
|
|
else
|
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2011-07-04 03:14:11 -07:00
|
|
|
|
2008-10-28 18:51:45 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_bubble_add(Evas_Object *parent)
|
|
|
|
{
|
2012-05-03 15:42:26 -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);
|
2012-11-25 22:32:53 -08:00
|
|
|
return obj;
|
|
|
|
}
|
2012-05-03 15:42:26 -07:00
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_bubble_efl_object_constructor(Eo *obj, Elm_Bubble_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_FILLER);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2008-10-28 18:51:45 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_elm_bubble_pos_set(Eo *obj, Elm_Bubble_Data *sd, Elm_Bubble_Pos pos)
|
2008-12-04 23:42:14 -08:00
|
|
|
{
|
2013-10-05 01:29:13 -07:00
|
|
|
ELM_LAYOUT_DATA_GET(obj, ld);
|
2012-05-03 15:42:26 -07:00
|
|
|
|
|
|
|
if (pos < ELM_BUBBLE_POS_TOP_LEFT || pos > ELM_BUBBLE_POS_BOTTOM_RIGHT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sd->pos = pos;
|
|
|
|
|
|
|
|
eina_stringshare_replace
|
2012-11-25 22:32:53 -08:00
|
|
|
(&ld->group, corner_string[sd->pos]);
|
2012-05-03 15:42:26 -07:00
|
|
|
|
2016-03-02 04:10:48 -08:00
|
|
|
elm_obj_widget_theme_apply(obj);
|
2010-11-11 10:04:08 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static Elm_Bubble_Pos
|
|
|
|
_elm_bubble_pos_get(Eo *obj EINA_UNUSED, Elm_Bubble_Data *sd)
|
2012-02-28 19:41:31 -08:00
|
|
|
{
|
2014-03-19 23:40:07 -07:00
|
|
|
return sd->pos;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_bubble_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Bubble_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-19 23:40:07 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_elm_bubble_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Bubble_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-19 23:40:07 -07:00
|
|
|
return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static const Elm_Layout_Part_Alias_Description*
|
|
|
|
_elm_bubble_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Bubble_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-19 23:40:07 -07:00
|
|
|
return _text_aliases;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static const Elm_Layout_Part_Alias_Description*
|
|
|
|
_elm_bubble_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Bubble_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2014-03-19 23:40:07 -07:00
|
|
|
return _content_aliases;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
EOLIAN static void
|
2016-08-10 07:23:04 -07:00
|
|
|
_elm_bubble_class_constructor(Efl_Class *klass)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-11-07 03:44:22 -08:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
2008-12-04 23:42:14 -08:00
|
|
|
}
|
2014-03-19 23:40:07 -07:00
|
|
|
|
2017-06-04 07:25:36 -07:00
|
|
|
/* Efl.Part begin */
|
|
|
|
ELM_PART_OVERRIDE(elm_bubble, ELM_BUBBLE, ELM_LAYOUT, Elm_Bubble_Data, Elm_Part_Data)
|
|
|
|
ELM_PART_OVERRIDE_TEXT_SET(elm_bubble, ELM_BUBBLE, ELM_LAYOUT, Elm_Bubble_Data, Elm_Part_Data)
|
|
|
|
|
|
|
|
#include "elm_bubble_internal_part.eo.c"
|
|
|
|
/* Efl.Part end */
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
|
|
|
#define ELM_BUBBLE_EXTRA_OPS \
|
|
|
|
EFL_CANVAS_GROUP_ADD_OPS(elm_bubble)
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
#include "elm_bubble.eo.c"
|