elementary - introduces 3 apis elm_object_item_track/untrack/track_get().

This commit is contained in:
ChunEon Park 2013-09-12 23:24:02 +09:00
parent 5a6f5b770b
commit 5957b118de
7 changed files with 236 additions and 2 deletions

View File

@ -1611,3 +1611,8 @@
2013-09-12 Ryuan Choi (ryuan)
* elc_fileselector : Added "selected,invalid" smart callbacks.
2013-09-12 ChunEon Park (Hermet)
* elm_object_item : Introduces new APIs, elm_object_item_track(),
elm_object_item_untrack(), elm_object_item_track_get().

View File

@ -89,6 +89,7 @@ Additions:
* Add elm_table_child_get().
* Add support for flip focus direction.
* Add "selected,invalid" smart callback for fileselector.
* elm_object_item : Introduces new APIs, elm_object_item_track(), elm_object_item_untrack(), elm_object_item_track_get().
Improvements:

View File

@ -148,7 +148,8 @@ transit_example_03.c \
transit_example_04.c \
web_example_01.c \
web_example_02.c \
win_example.c
win_example.c \
track_example_01.c
.edc.edj:
$(EDJE_CC) $(EDJE_FLAGS) $< $@
@ -286,7 +287,8 @@ transit_example_03 \
transit_example_04 \
web_example_01 \
web_example_02 \
win_example
win_example \
track_example_01.c
if ELEMENTARY_WINDOWS_BUILD
efl_thread_1_SOURCES = efl_thread_win32_1.c

View File

@ -1899,3 +1899,22 @@ elm_object_item_cursor_engine_only_get(const Elm_Object_Item *it)
{
return elm_widget_item_cursor_engine_only_get(it);
}
EAPI Evas_Object *
elm_object_item_track(Elm_Object_Item *it)
{
return elm_widget_item_track((Elm_Widget_Item *)it);
}
void
elm_object_item_untrack(Elm_Object_Item *it)
{
elm_widget_item_untrack((Elm_Widget_Item *)it);
}
int
elm_object_item_track_get(const Elm_Object_Item *it)
{
return elm_widget_item_track_get((Elm_Widget_Item *)it);
}

View File

@ -652,3 +652,76 @@ EAPI void elm_object_item_cursor_engine_only_set(Elm_Obj
* @ingroup General
*/
EAPI Eina_Bool elm_object_item_cursor_engine_only_get(const Elm_Object_Item *it);
/**
* This returns track object of the item.
*
* @param it The Elementary Object Item to be tracked.
* @return The track object.
*
* @note This gets a rectangle object that represents the object item's internal
* object. If you wanna check the geometry, visibility of the item, you
* can call the evas apis such as evas_object_geometry_get(),
* evas_object_visible_get() to the track object. Note that all of the
* widget items may/may not have the internal object so this api may
* return @c NULL if the widget item doesn't have it. Additionally, the
* widget item is managed/controlled by the widget, the widget item could
* be changed(moved, resized even deleted) anytime by it's own widget's
* decision. So please dont' change the track object as well as don't
* keep the track object in your side as possible but get the track object
* at the moment you need to refer. Otherwise, you need to add some
* callbacks to the track object to track it's attributes changes.
*
* @warning After use the track object, please call the
* elm_object_item_untrack() paired to elm_object_item_track()
* definitely to free the track object properly. Don't delete the
* track object.
*
* @see elm_object_item_untrack()
* @see elm_object_item_track_get()
*
* @since 1.8
*
* @ingroup General
*/
EAPI Evas_Object *elm_object_item_track(Elm_Object_Item *it);
/**
* This retrieve the track object of the item.
*
* @param it The Elementary Object Item that returned track object.
*
* @note This retrieves the track object that was returned from
* elm_object_item_track().
*
* @see elm_object_item_track()
* @see elm_object_item_track_get()
*
* @since 1.8
*
* @ingroup General
*/
EAPI void elm_object_item_untrack(Elm_Object_Item *it);
/**
* Get the track object reference count.
*
* @param it The Elementary Object Item that returned track object.
*
* @note This gets the reference count for the track object. Whenever you call
* the elm_object_item_track(), the reference count will be increased by
* one. Likely the referece count will be decreased again when you call
* the elm_object_item_untrack(). Unless the reference count reaches to
* zero, the track object won't be deleted. So please be sure to call
* elm_object_item_untrack() paired to the elm_object_item_track() call
* count.
*
* @see elm_object_item_track()
* @see elm_object_item_track_get()
*
* @since 1.8
*
* @ingroup General
*/
EAPI int elm_object_item_track_get(const Elm_Object_Item *it);

View File

@ -4867,6 +4867,68 @@ _elm_widget_orientation_set(Eo *obj __UNUSED__, void *_pd, va_list *list)
if (ret) *ret = EINA_TRUE;
}
static void
_track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void
_track_obj_update(Evas_Object *track, Evas_Object *obj)
{
//Geometry
Evas_Coord x, y, w, h;
evas_object_geometry_get(obj, &x, &y, &w, &h);
evas_object_move(track, x, y);
evas_object_resize(track, w, h);
//Visibility
if (evas_object_visible_get(obj)) evas_object_show(track);
else evas_object_hide(track);
}
static void
_track_obj_view_update(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Evas_Object *track = data;
_track_obj_update(track, obj);
}
static void
_track_obj_view_del(void *data, Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Elm_Widget_Item *item = data;
while (evas_object_ref_get(item->track_obj) > 0)
evas_object_unref(item->track_obj);
evas_object_event_callback_del(item->track_obj, EVAS_CALLBACK_DEL,
_track_obj_del);
evas_object_del(item->track_obj);
item->track_obj = NULL;
}
static void
_track_obj_del(void *data, Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Elm_Widget_Item *item = data;
item->track_obj = NULL;
if (!item->view) return;
evas_object_event_callback_del(item->view, EVAS_CALLBACK_RESIZE,
_track_obj_view_update);
evas_object_event_callback_del(item->view, EVAS_CALLBACK_MOVE,
_track_obj_view_update);
evas_object_event_callback_del(item->view, EVAS_CALLBACK_SHOW,
_track_obj_view_update);
evas_object_event_callback_del(item->view, EVAS_CALLBACK_HIDE,
_track_obj_view_update);
evas_object_event_callback_del(item->view, EVAS_CALLBACK_DEL,
_track_obj_view_del);
}
/**
* @internal
*
@ -4923,6 +4985,13 @@ _elm_widget_item_free(Elm_Widget_Item *item)
if (item->access_info)
eina_stringshare_del(item->access_info);
if (item->track_obj)
{
evas_object_event_callback_del(item->track_obj, EVAS_CALLBACK_DEL,
_track_obj_del);
evas_object_del(item->track_obj);
}
EINA_LIST_FREE(item->signals, wisd)
{
eina_stringshare_del(wisd->emission);
@ -5204,6 +5273,66 @@ _elm_widget_item_domain_part_text_translatable_set(Elm_Widget_Item *item,
item->on_translate = EINA_FALSE;
}
EAPI Evas_Object *
elm_widget_item_track(Elm_Widget_Item *item)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, NULL);
if (item->track_obj)
{
evas_object_ref(item->track_obj);
return item->track_obj;
}
if (!item->view) return NULL;
Evas_Object *track =
evas_object_rectangle_add(evas_object_evas_get(item->widget));
evas_object_color_set(track, 0, 0, 0, 0);
evas_object_pass_events_set(track, EINA_TRUE);
_track_obj_update(track, item->view);
evas_object_event_callback_add(track, EVAS_CALLBACK_DEL, _track_obj_del,
item);
evas_object_event_callback_add(item->view, EVAS_CALLBACK_RESIZE,
_track_obj_view_update, track);
evas_object_event_callback_add(item->view, EVAS_CALLBACK_MOVE,
_track_obj_view_update, track);
evas_object_event_callback_add(item->view, EVAS_CALLBACK_SHOW,
_track_obj_view_update, track);
evas_object_event_callback_add(item->view, EVAS_CALLBACK_HIDE,
_track_obj_view_update, track);
evas_object_event_callback_add(item->view, EVAS_CALLBACK_DEL,
_track_obj_view_del, item);
evas_object_ref(track);
item->track_obj = track;
return track;
}
void
elm_widget_item_untrack(Elm_Widget_Item *item)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
if (!item->track_obj) return;
evas_object_unref(item->track_obj);
if (evas_object_ref_get(item->track_obj) == 0)
evas_object_del(item->track_obj);
}
int
elm_widget_item_track_get(const Elm_Widget_Item *item)
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, 0);
if (!item->track_obj) return 0;
return evas_object_ref_get(item->track_obj);
}
typedef struct _Elm_Widget_Item_Tooltip Elm_Widget_Item_Tooltip;
struct _Elm_Widget_Item_Tooltip

View File

@ -579,6 +579,7 @@ struct _Elm_Widget_Item
Eina_List *access_order;
Eina_Inlist *translate_strings;
Eina_List *signals;
Evas_Object *track_obj;
Eina_Bool disabled : 1;
Eina_Bool on_translate : 1;
@ -772,6 +773,10 @@ EAPI const char * _elm_widget_item_translatable_part_text_get(const Elm_Widg
EAPI void _elm_widget_item_translate(Elm_Widget_Item *item);
EAPI void _elm_widget_item_domain_part_text_translatable_set(Elm_Widget_Item *item, const char *part, const char *domain, Eina_Bool translatable);
EAPI Evas_Object *elm_widget_item_track(Elm_Widget_Item *item);
EAPI void elm_widget_item_untrack(Elm_Widget_Item *item);
EAPI int elm_widget_item_track_get(const Elm_Widget_Item *item);
/**
* Function to operate on a given widget's scrollabe children when necessary.
* @warning free the returned list with eina_list_free().