2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
#define EFL_ACCESS_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
|
|
|
|
edje/elm: Rename _internal_ to _part_ (EO)
In Edje and Elementary, we have part objects, which are what is returned
by the interface efl_part(). Those objects can't be of an opaque type as
this doesn't work nicely with strongly typed languages such as C++ or
C#. In JS, Lua, C the types are weak and mostly runtime-based so it
doesn't matter much.
As a consequence, the documentation and the types need to look nice in
this EO API. Thus, we remove the abusive term "internal" and explicitly
call all those classes "part" something.
Eventually we want the types to be declared in the EO file so bindings
(C#, C++, ...) can generate the proper access methods, returning the
best possible types.
Note that right now a few of those part types are used in the legacy API
but don't actually need to be exposed externally.
This is kind of a mega commit that does all the renaming at once, but
it's really just a big sed operation. The power of good IDEs :)
Ref T5315
Ref T5306
2017-09-12 21:29:25 -07:00
|
|
|
#include "elm_bubble_part.eo.h"
|
2017-06-04 07:25:36 -07:00
|
|
|
#include "elm_part_helper.h"
|
|
|
|
|
2014-06-03 03:35:28 -07:00
|
|
|
#define MY_CLASS ELM_BUBBLE_CLASS
|
2017-07-27 23:35:10 -07:00
|
|
|
#define MY_CLASS_PFX elm_bubble
|
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
|
|
|
|
2017-07-05 04:06:24 -07:00
|
|
|
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-07-04 02:54:44 -07:00
|
|
|
if (!_elm_layout_part_aliasing_eval(obj, &part, EINA_TRUE))
|
|
|
|
return EINA_FALSE;
|
2013-07-22 14:05:16 -07:00
|
|
|
|
2017-06-04 07:25:36 -07:00
|
|
|
efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label);
|
2012-09-14 06:30:18 -07:00
|
|
|
|
2017-07-04 02:54:44 -07:00
|
|
|
if (!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
|
2017-08-23 23:31:05 -07:00
|
|
|
_elm_bubble_elm_widget_on_access_update(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);
|
2017-11-06 21:00:43 -08:00
|
|
|
return elm_legacy_add(MY_CLASS, parent);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
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);
|
2017-10-18 18:13:54 -07:00
|
|
|
efl_access_role_set(obj, EFL_ACCESS_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
|
|
|
{
|
2017-08-07 19:48:31 -07:00
|
|
|
/* FIXME: Why is this dealing with layout data directly? */
|
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;
|
|
|
|
|
2017-11-14 01:42:48 -08:00
|
|
|
elm_widget_theme_element_set(obj, corner_string[sd->pos]);
|
2012-05-03 15:42:26 -07:00
|
|
|
|
2017-10-23 22:03:46 -07:00
|
|
|
efl_ui_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 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 */
|
2017-09-19 04:02:26 -07:00
|
|
|
ELM_PART_OVERRIDE(elm_bubble, ELM_BUBBLE, Elm_Bubble_Data)
|
|
|
|
ELM_PART_OVERRIDE_TEXT_SET(elm_bubble, ELM_BUBBLE, Elm_Bubble_Data)
|
2017-06-04 07:25:36 -07:00
|
|
|
|
edje/elm: Rename _internal_ to _part_ (EO)
In Edje and Elementary, we have part objects, which are what is returned
by the interface efl_part(). Those objects can't be of an opaque type as
this doesn't work nicely with strongly typed languages such as C++ or
C#. In JS, Lua, C the types are weak and mostly runtime-based so it
doesn't matter much.
As a consequence, the documentation and the types need to look nice in
this EO API. Thus, we remove the abusive term "internal" and explicitly
call all those classes "part" something.
Eventually we want the types to be declared in the EO file so bindings
(C#, C++, ...) can generate the proper access methods, returning the
best possible types.
Note that right now a few of those part types are used in the legacy API
but don't actually need to be exposed externally.
This is kind of a mega commit that does all the renaming at once, but
it's really just a big sed operation. The power of good IDEs :)
Ref T5315
Ref T5306
2017-09-12 21:29:25 -07:00
|
|
|
#include "elm_bubble_part.eo.c"
|
2017-06-04 07:25:36 -07:00
|
|
|
/* Efl.Part end */
|
2017-07-27 23:35:10 -07:00
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
2017-08-07 19:48:31 -07:00
|
|
|
ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
|
|
|
|
ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
|
2017-07-27 23:35:10 -07:00
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
#define ELM_BUBBLE_EXTRA_OPS \
|
2017-08-07 19:48:31 -07:00
|
|
|
ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
|
|
|
|
ELM_LAYOUT_TEXT_ALIASES_OPS(MY_CLASS_PFX), \
|
2017-08-07 00:13:38 -07:00
|
|
|
ELM_LAYOUT_SIZING_EVAL_OPS(elm_bubble), \
|
2017-05-18 01:52:17 -07:00
|
|
|
EFL_CANVAS_GROUP_ADD_OPS(elm_bubble)
|
|
|
|
|
2014-03-19 23:40:07 -07:00
|
|
|
#include "elm_bubble.eo.c"
|