2008-10-28 18:51:45 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2012-08-01 14:04:39 -07:00
|
|
|
#include "elm_widget_bubble.h"
|
2008-10-28 18:51:45 -07:00
|
|
|
|
2012-08-01 14:04:39 -07:00
|
|
|
EAPI const char ELM_BUBBLE_SMART_NAME[] = "elm_bubble";
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2011-04-15 10:01:39 -07:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
|
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 Evas_Smart_Cb_Description _smart_callbacks[] =
|
2008-10-28 18:51:45 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2008-10-28 18:51:45 -07: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
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
EVAS_SMART_SUBCLASS_NEW
|
2012-08-01 14:04:39 -07:00
|
|
|
(ELM_BUBBLE_SMART_NAME, _elm_bubble, Elm_Bubble_Smart_Class,
|
2012-05-03 15:42:26 -07:00
|
|
|
Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
|
2011-11-07 17:05:01 -08:00
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:42:26 -07:00
|
|
|
_elm_bubble_smart_sizing_eval(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
2012-05-02 09:59:07 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
ELM_BUBBLE_DATA_GET(obj, sd);
|
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
|
|
|
|
(ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh, minw, minh);
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
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,
|
|
|
|
Evas *e __UNUSED__,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
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
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_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 */
|
|
|
|
static Eina_Bool
|
|
|
|
_elm_bubble_smart_focus_next(const Evas_Object *obj,
|
|
|
|
Elm_Focus_Direction dir,
|
|
|
|
Evas_Object **next)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
Evas_Object *content;
|
2011-11-07 17:05:01 -08:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
content = elm_layout_content_get(obj, NULL);
|
|
|
|
|
|
|
|
if (!content) return EINA_FALSE;
|
|
|
|
|
|
|
|
/* attempt to follow focus cycle into sub-object */
|
|
|
|
return elm_widget_focus_next_get(content, dir, next);
|
2011-11-07 17:05:01 -08:00
|
|
|
}
|
|
|
|
|
2010-10-01 12:03:02 -07:00
|
|
|
static Eina_Bool
|
2012-05-03 15:42:26 -07:00
|
|
|
_elm_bubble_smart_focus_direction(const Evas_Object *obj,
|
|
|
|
const Evas_Object *base,
|
|
|
|
double degree,
|
|
|
|
Evas_Object **direction,
|
|
|
|
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
|
|
|
|
2012-05-10 00:21:26 -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 */
|
2012-05-03 15:42:26 -07:00
|
|
|
return elm_widget_focus_direction_get
|
|
|
|
(content, base, degree, direction, weight);
|
2010-10-01 12:03:02 -07:00
|
|
|
}
|
|
|
|
|
2012-05-02 20:02:54 -07:00
|
|
|
static Eina_Bool
|
2012-05-03 15:42:26 -07:00
|
|
|
_elm_bubble_smart_text_set(Evas_Object *obj,
|
|
|
|
const char *item,
|
|
|
|
const char *label)
|
2012-05-02 20:02:54 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
if (item && (!strcmp(item, "info") || !strcmp(item, "elm.info")))
|
|
|
|
{
|
|
|
|
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-29 14:02:01 -07:00
|
|
|
else if (!_elm_bubble_parent_sc->text_set(obj, item, label))
|
|
|
|
return EINA_FALSE;
|
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
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2008-10-28 18:51:45 -07:00
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:42:26 -07:00
|
|
|
_elm_bubble_smart_add(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
EVAS_SMART_DATA_ALLOC(obj, Elm_Bubble_Smart_Data);
|
2010-11-11 10:04:45 -08:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
ELM_WIDGET_CLASS(_elm_bubble_parent_sc)->base.add(obj);
|
2011-07-04 03:14:11 -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
|
|
|
|
(ELM_WIDGET_DATA(priv)->resize_obj, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_on_mouse_up, obj);
|
|
|
|
|
|
|
|
elm_layout_theme_set(obj, "bubble", "base", elm_widget_style_get(obj));
|
2012-07-17 11:44:55 -07:00
|
|
|
|
|
|
|
elm_layout_sizing_eval(obj);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2011-07-04 03:14:11 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
static void
|
2012-08-01 14:04:39 -07:00
|
|
|
_elm_bubble_smart_set_user(Elm_Bubble_Smart_Class *sc)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
ELM_WIDGET_CLASS(sc)->base.add = _elm_bubble_smart_add;
|
2012-05-02 09:59:07 -07:00
|
|
|
|
2012-05-03 15:42:26 -07:00
|
|
|
ELM_WIDGET_CLASS(sc)->focus_next = _elm_bubble_smart_focus_next;
|
|
|
|
ELM_WIDGET_CLASS(sc)->focus_direction = _elm_bubble_smart_focus_direction;
|
|
|
|
|
2012-08-01 14:04:39 -07:00
|
|
|
ELM_LAYOUT_CLASS(sc)->text_set = _elm_bubble_smart_text_set;
|
|
|
|
ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_bubble_smart_sizing_eval;
|
|
|
|
|
|
|
|
ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
|
|
|
|
ELM_LAYOUT_CLASS(sc)->text_aliases = _text_aliases;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const Elm_Bubble_Smart_Class *
|
|
|
|
elm_bubble_smart_class_get(void)
|
|
|
|
{
|
|
|
|
static Elm_Bubble_Smart_Class _sc =
|
|
|
|
ELM_BUBBLE_SMART_CLASS_INIT_NAME_VERSION(ELM_BUBBLE_SMART_NAME);
|
|
|
|
static const Elm_Bubble_Smart_Class *class = NULL;
|
|
|
|
Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
|
|
|
|
|
|
|
|
if (class)
|
|
|
|
return class;
|
|
|
|
|
|
|
|
_elm_bubble_smart_set(&_sc);
|
|
|
|
esc->callbacks = _smart_callbacks;
|
|
|
|
class = &_sc;
|
2011-07-04 03:14:11 -07:00
|
|
|
|
2012-08-01 14:04:39 -07:00
|
|
|
return class;
|
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
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
|
2012-07-18 14:03:39 -07:00
|
|
|
obj = elm_widget_add(_elm_bubble_smart_class_new(), parent);
|
|
|
|
if (!obj) return NULL;
|
2012-05-03 15:42:26 -07:00
|
|
|
|
|
|
|
if (!elm_widget_sub_object_add(parent, obj))
|
|
|
|
ERR("could not add %p as sub object of %p", obj, parent);
|
|
|
|
|
2008-10-28 18:51:45 -07:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2012-02-28 19:41:31 -08:00
|
|
|
EAPI void
|
2012-05-03 15:42:26 -07:00
|
|
|
elm_bubble_pos_set(Evas_Object *obj,
|
|
|
|
Elm_Bubble_Pos pos)
|
2008-12-04 23:42:14 -08:00
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
ELM_BUBBLE_CHECK(obj);
|
|
|
|
ELM_BUBBLE_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
|
|
|
if (pos < ELM_BUBBLE_POS_TOP_LEFT || pos > ELM_BUBBLE_POS_BOTTOM_RIGHT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sd->pos = pos;
|
|
|
|
|
|
|
|
eina_stringshare_replace
|
|
|
|
(&(ELM_LAYOUT_DATA(sd)->group), corner_string[sd->pos]);
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA(sd)->api->theme(obj);
|
2010-11-11 10:04:08 -08:00
|
|
|
}
|
|
|
|
|
2012-02-28 19:41:31 -08:00
|
|
|
EAPI Elm_Bubble_Pos
|
|
|
|
elm_bubble_pos_get(const Evas_Object *obj)
|
|
|
|
{
|
2012-05-03 15:42:26 -07:00
|
|
|
ELM_BUBBLE_CHECK(obj) ELM_BUBBLE_POS_INVALID;
|
|
|
|
ELM_BUBBLE_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_BUBBLE_POS_INVALID);
|
|
|
|
|
|
|
|
return sd->pos;
|
2008-12-04 23:42:14 -08:00
|
|
|
}
|