From: Thiep Ha Date: Tue, 9 Jan 2018 06:34:12 +0000 (+0900) Subject: selection: add efl_selection interface X-Git-Tag: submit/sandbox/upgrade/efl120/20180319.053334~258 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dadc260232cf05fa7e12a8dfa71659de38e19ef5;p=platform%2Fupstream%2Fefl.git selection: add efl_selection interface Efl_Selection is the object interface for selection api of elm_cnp. It allows get, set, clear, check selection. --- diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index c42f042..b7e00d7 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -97,6 +97,7 @@ elm_public_eolian_files = \ lib/elementary/efl_access_window.eo \ lib/elementary/efl_config_global.eo \ lib/elementary/elm_code_widget.eo \ + lib/elementary/efl_selection.eo \ $(NULL) # More public files -- FIXME @@ -771,6 +772,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/efl_ui_pan.c \ lib/elementary/tizen_vector.c \ lib/elementary/efl_selection_manager.c \ + lib/elementary/efl_selection.c \ $(NULL) diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index 9dcb9ef..8ffd13d 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -328,6 +328,7 @@ EAPI extern Elm_Version *elm_version; # include "efl_selection_types.eot.h" # include "efl_ui_dnd_types.eot.h" # include +# include "efl_selection.eo.h" #endif /* include deprecated calls last of all */ diff --git a/src/lib/elementary/efl_selection.c b/src/lib/elementary/efl_selection.c new file mode 100644 index 0000000..9f086e3 --- /dev/null +++ b/src/lib/elementary/efl_selection.c @@ -0,0 +1,62 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define EFL_SELECTION_MANAGER_BETA + +#include +#include "elm_priv.h" + +#define MY_CLASS EFL_SELECTION_MIXIN +#define MY_CLASS_NAME "Efl.Selection" + +static inline Eo* +_selection_manager_get(Eo *obj) +{ + Eo *top = elm_widget_top_get(obj); + if (!top) + { + top = obj; + } + Eo *sel_man = efl_key_data_get(top, "__selection_manager"); + if (!sel_man) + { + sel_man = efl_add(EFL_SELECTION_MANAGER_CLASS, top); + efl_key_data_set(top, "__selection_manager", sel_man); + } + return sel_man; +} + +EOLIAN static void +_efl_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format, + void *data_func_data, Efl_Selection_Data_Ready data_func, Eina_Free_Cb data_func_free_cb, unsigned int seat) +{ + Eo *sel_man = _selection_manager_get(obj); + efl_selection_manager_selection_get(sel_man, obj, type, format, + data_func_data, data_func, + data_func_free_cb, seat); +} + +EOLIAN static Eina_Future * +_efl_selection_selection_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, unsigned int seat) +{ + Eo *sel_man = _selection_manager_get(obj); + return efl_selection_manager_selection_set(sel_man, obj, type, format, data, seat); +} + +EOLIAN static void +_efl_selection_selection_clear(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat) +{ + Eo *sel_man = _selection_manager_get(obj); + efl_selection_manager_selection_clear(sel_man, obj, type, seat); +} + +EOLIAN static Eina_Bool +_efl_selection_has_owner(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat) +{ + Eo *sel_man = _selection_manager_get(obj); + return efl_selection_manager_selection_has_owner(sel_man, obj, type, seat); +} + + +#include "efl_selection.eo.c" diff --git a/src/lib/elementary/efl_selection.eo b/src/lib/elementary/efl_selection.eo new file mode 100644 index 0000000..2f83656 --- /dev/null +++ b/src/lib/elementary/efl_selection.eo @@ -0,0 +1,45 @@ +import efl_selection_types; + +mixin Efl.Selection { + [[Efl Selection class]] + data: null; + methods { + selection_set { + [[Set the selection data to the object]] + params { + @in type: Efl.Selection.Type; [[Selection Type]] + @in format: Efl.Selection.Format; [[Selection Format]] + @in data: Eina.Slice; + @in seat: uint;[[Specified seat for multiple seats case.]] + } + return: ptr(Eina.Future); [[Future for tracking when the selection is lost]] + } + selection_get { + [[Get the data from the object that has selection]] + params { + @in type: Efl.Selection.Type; [[Selection Type]] + @in format: Efl.Selection.Format; [[Selection Format]] + @in data_func: Efl.Selection.Data_Ready; [[Data ready function pointer]] + @in seat: uint;[[Specified seat for multiple seats case.]] + } + } + selection_clear { + [[Clear the selection data from the object]] + params { + @in type: Efl.Selection.Type; [[Selection Type]] + @in seat: uint; [[Specified seat for multiple seats case.]] + } + } + has_owner { + [[Determine whether the selection data has owner]] + params { + @in type: Efl.Selection.Type; [[Selection type]] + @in seat: uint; [[Specified seat for multiple seats case.]] + } + return: bool; [[EINA_TRUE if there is object owns selection, otherwise EINA_FALSE]] + } + } + events { + selection,changed; [[Called when display server's selection has changed]] + } +} diff --git a/src/lib/elementary/efl_selection_manager.c b/src/lib/elementary/efl_selection_manager.c index 23bde3b..6aaf9d8 100644 --- a/src/lib/elementary/efl_selection_manager.c +++ b/src/lib/elementary/efl_selection_manager.c @@ -753,7 +753,7 @@ _x11_fixes_selection_notify(void *data, int t EINA_UNUSED, void *event) e.type = type; e.seat = 1; /* under x11 this is always the default seat */ e.exist = !!ev->owner; - //efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e); + efl_event_callback_call(sel->owner, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e); //ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, NULL, NULL); return ECORE_CALLBACK_RENEW; @@ -2512,7 +2512,7 @@ _wl_selection_changed(void *data, int type EINA_UNUSED, void *event) e.display = ecore_wl2_display_connect(ecore_wl2_display_name_get(ev->display)); e.exist = !!ecore_wl2_dnd_selection_get(seat); //ecore_event_add(ELM_CNP_EVENT_SELECTION_CHANGED, e, _wl_selection_changed_free, ev->display); - //efl_event_callback_call(sel->request_obj, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e); + efl_event_callback_call(sel->request_obj, EFL_SELECTION_EVENT_SELECTION_CHANGED, &e); return ECORE_CALLBACK_RENEW; } diff --git a/src/lib/elementary/efl_ui_widget.eo b/src/lib/elementary/efl_ui_widget.eo index 2e66331..77a0794 100644 --- a/src/lib/elementary/efl_ui_widget.eo +++ b/src/lib/elementary/efl_ui_widget.eo @@ -17,7 +17,7 @@ struct Efl.Ui.Widget.Focus_State { abstract Efl.Ui.Widget (Efl.Canvas.Group, Efl.Access, Efl.Access.Component, Efl.Ui.Focus.User, Efl.Part, Efl.Ui.Focus.Object, Efl.Ui.Base, Efl.Ui.Cursor, Efl.Access.Widget.Action, - Efl.Ui.Translatable) + Efl.Ui.Translatable, Efl.Selection) { [[Elementary widget abstract class]] legacy_prefix: elm_widget;