From f767e8bea4b817ca900221d98b432f28488d07a9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 30 May 2017 23:13:02 +0900 Subject: [PATCH] edje: Move part drag APIs to efl_part This moves all part_drag APIs to legacy and implements them for EO using efl_part(). All parts now support these APIs, even if they are not draggable. Making this more fine grained would probably be much extra work for little gain. This creates a new interface Efl.Ui.Drag. --- src/Makefile_Efl.am | 2 + src/lib/edje/Edje_Common.h | 23 --- src/lib/edje/Edje_Legacy.h | 253 +++++++++++++++++++++++++++ src/lib/edje/edje_legacy.c | 67 +++++++ src/lib/edje/edje_object.eo | 176 +------------------ src/lib/edje/edje_part.c | 70 +++++++- src/lib/edje/edje_private.h | 13 ++ src/lib/edje/edje_types.eot | 8 - src/lib/edje/edje_util.c | 44 ++--- src/lib/edje/efl_canvas_layout_internal.eo | 12 +- src/lib/efl/Efl.h | 3 + src/lib/efl/interfaces/efl_interfaces_main.c | 1 + src/lib/efl/interfaces/efl_ui_drag.eo | 163 +++++++++++++++++ src/lib/efl/interfaces/efl_ui_types.eot | 7 + src/lib/elementary/elm_spinner.c | 6 +- src/lib/evas/canvas/efl_ui_draggable.eo | 1 + src/tests/emotion/emotion_test_main-eo.c | 12 +- 17 files changed, 621 insertions(+), 240 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_ui_drag.eo create mode 100644 src/lib/efl/interfaces/efl_ui_types.eot diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 60041ed..dbf968e 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -44,6 +44,7 @@ efl_eolian_files = \ lib/efl/interfaces/efl_vpath_file.eo \ lib/efl/interfaces/efl_vpath_core.eo \ lib/efl/interfaces/efl_vpath_file_core.eo \ + lib/efl/interfaces/efl_ui_drag.eo \ lib/efl/interfaces/efl_ui_spin.eo \ lib/efl/interfaces/efl_ui_progress.eo \ lib/efl/interfaces/efl_ui_view.eo \ @@ -68,6 +69,7 @@ efl_eolian_files = \ efl_eolian_type_files = \ lib/efl/interfaces/efl_gfx_types.eot \ + lib/efl/interfaces/efl_ui_types.eot \ lib/efl/interfaces/efl_input_types.eot \ lib/efl/interfaces/efl_types.eot \ lib/efl/interfaces/efl_text_types.eot \ diff --git a/src/lib/edje/Edje_Common.h b/src/lib/edje/Edje_Common.h index baa6846..3a1ec21 100644 --- a/src/lib/edje/Edje_Common.h +++ b/src/lib/edje/Edje_Common.h @@ -1449,29 +1449,6 @@ typedef enum _Edje_Aspect_Control */ /** - * @defgroup Edje_Part_Drag Edje Drag - * @ingroup Edje_Object_Part - * - * @brief Functions that deal with dragable parts. - * - * To create a movable part it must be declared as dragable - * in EDC file. To do so, one must define a "dragable" block inside - * the "part" block. - * - * These functions are used to set dragging properties to a - * part or get dragging information about it. - * - * @see @ref tutorial_edje_drag - * - * - * @{ - */ - -/** - * @} - */ - -/** * @defgroup Edje_Part_Box Edje Box Part * @ingroup Edje_Object_Part * diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h index 3a802d4..891fd7c 100644 --- a/src/lib/edje/Edje_Legacy.h +++ b/src/lib/edje/Edje_Legacy.h @@ -1019,5 +1019,258 @@ EAPI Eina_Bool edje_object_color_class_get(const Evas_Object *obj, const char * */ EAPI void edje_object_part_text_select_allow_set(const Edje_Object *obj, const char *part, Eina_Bool allow); +/** + * @defgroup Edje_Part_Drag Edje Drag + * @ingroup Edje_Object_Part + * + * @brief Functions that deal with dragable parts. + * + * To create a movable part it must be declared as dragable + * in EDC file. To do so, one must define a "dragable" block inside + * the "part" block. + * + * These functions are used to set dragging properties to a + * part or get dragging information about it. + * + * @see @ref tutorial_edje_drag * + * + * @{ + */ + +/** Dragable properties values */ +typedef Efl_Ui_Drag_Dir Edje_Drag_Dir; +/** Not dragable */ +#define EDJE_DRAG_DIR_NONE EFL_UI_DRAG_DIR_NONE +/** Dragable horizontally */ +#define EDJE_DRAG_DIR_X EFL_UI_DRAG_DIR_X +/** Dragable verically */ +#define EDJE_DRAG_DIR_Y EFL_UI_DRAG_DIR_Y +/** Dragable in both directions */ +#define EDJE_DRAG_DIR_XY EFL_UI_DRAG_DIR_XY + + +/** + * @brief Sets the dragable object location. + * + * Places the dragable object at the given location. + * + * Values for dx and dy are real numbers that range from 0 to 1, representing + * the relative position to the dragable area on that axis. + * + * This value means, for the vertical axis, that 0.0 will be at the top if the + * first parameter of @c y in the dragable part theme is 1, and at bottom if it + * is -1. + * + * For the horizontal axis, 0.0 means left if the first parameter of @c x in + * the dragable part theme is 1, and right if it is -1. + * + * See also @ref edje_object_part_drag_value_get() + * + * @param[in] part The part name + * @param[in] dx The x value + * @param[in] dy The y value + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_value_set(Edje_Object *obj, const char * part, double dx, double dy); + +/** + * @brief Gets the dragable object location. + * + * Values for dx and dy are real numbers that range from 0 to 1, representing + * the relative position to the dragable area on that axis. + * + * See also @ref edje_object_part_drag_value_set() + * + * Gets the drag location values. + * + * @param[in] part The part name + * @param[out] dx The x value + * @param[out] dy The y value + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_value_get(const Edje_Object *obj, const char * part, double *dx, double *dy); + +/** + * @brief Sets the dragable object size. + * + * Values for dw and dh are real numbers that range from 0 to 1, representing + * the relative size of the dragable area on that axis. + * + * Sets the size of the dragable object. + * + * See also @ref edje_object_part_drag_size_get() + * + * @param[in] part The part name + * @param[in] dw The drag width + * @param[in] dh The drag height + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_size_set(Edje_Object *obj, const char * part, double dw, double dh); + +/** + * @brief Gets the dragable object size. + * + * Gets the dragable object size. + * + * See also @ref edje_object_part_drag_size_set() + * + * @param[in] part The part name + * @param[out] dw The drag width + * @param[out] dh The drag height + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_size_get(const Edje_Object *obj, const char * part, double *dw, double *dh); + +/** + * @brief Determines dragable directions. + * + * The dragable directions are defined in the EDC file, inside the @ref + * dragable section, by the attributes @c x and @c y. See the @ref edcref for + * more information. + * + * @param[in] part The part name + * + * @return #EDJE_DRAG_DIR_NONE: Not dragable #EDJE_DRAG_DIR_X: Dragable in X + * direction #EDJE_DRAG_DIR_Y: Dragable in Y direction #EDJE_DRAG_DIR_XY: + * Dragable in X & Y directions + * + * @ingroup Edje_Object + */ +EAPI Edje_Drag_Dir edje_object_part_drag_dir_get(const Edje_Object *obj, const char * part); + +/** + * @brief Sets the drag step increment. + * + * Sets the x,y step increments for a dragable object. + * + * Values for dx and dy are real numbers that range from 0 to 1, representing + * the relative size of the dragable area on that axis by which the part will + * be moved. + * + * See also @ref edje_object_part_drag_step_get() + * + * @param[in] part The part name + * @param[in] dx The x step amount + * @param[in] dy The y step amount + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_step_set(Edje_Object *obj, const char * part, double dx, double dy); + +/** + * @brief Gets the drag step increment values. + * + * Gets the x and y step increments for the dragable object. + * + * See also @ref edje_object_part_drag_step_set() + * + * @param[in] part The part name + * @param[out] dx The x step amount + * @param[out] dy The y step amount + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_step_get(const Edje_Object *obj, const char * part, double *dx, double *dy); + +/** + * @brief Steps the dragable x,y steps. + * + * Steps x,y where the step increment is the amount set by + * @ref edje_object_part_drag_step_set(). + * + * Values for dx and dy are real numbers that range from 0 to 1. + * + * See also @ref edje_object_part_drag_page() + * + * @param[in] part The part name + * @param[in] dx The x step + * @param[in] dy The y step + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_step(Edje_Object *obj, const char *part, double dx, double dy); + +/** + * @brief Sets the page step increments. + * + * Sets the x,y page step increment values. + * + * Values for dx and dy are real numbers that range from 0 to 1, representing + * the relative size of the dragable area on that axis by which the part will + * be moved. + * + * See also @ref edje_object_part_drag_page_get() + * + * @param[in] part The part name + * @param[in] dx The x page step increment + * @param[in] dy The y page step increment + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_page_set(Edje_Object *obj, const char * part, double dx, double dy); + +/** + * @brief Gets the page step increments. + * + * Gets the x,y page step increments for the dragable object. + * + * See also @ref edje_object_part_drag_page_set() + * + * @param[in] part The part name + * @param[out] dx The x page step increment + * @param[out] dy The y page step increment + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_page_get(const Edje_Object *obj, const char * part, double *dx, double *dy); + +/** + * @brief Pages x,y steps. + * + * Pages x,y where the increment is defined by + * @ref edje_object_part_drag_page_set(). + * + * Values for dx and dy are real numbers that range from 0 to 1. + * + * @warning Paging is bugged! + * + * See also @ref edje_object_part_drag_step() + * + * @param[in] part The part name + * @param[in] dx The x step + * @param[in] dy The y step + * + * @return @c true on success, @c false otherwise + * + * @ingroup Edje_Object + */ +EAPI Eina_Bool edje_object_part_drag_page(Edje_Object *obj, const char *part, double dx, double dy); + +/** + * @} + */ + #include "edje_object.eo.legacy.h" #include "edje_edit.eo.legacy.h" diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c index c2608ae..f1e8ba4 100644 --- a/src/lib/edje/edje_legacy.c +++ b/src/lib/edje/edje_legacy.c @@ -132,3 +132,70 @@ edje_object_part_external_content_get(const Edje_Object *obj, const char *part, Edje *ed = _edje_fetch(obj); return _edje_object_part_external_content_get(ed, part, content); } + +/* Legacy part drag APIs */ +EAPI Edje_Drag_Dir +edje_object_part_drag_dir_get(const Evas_Object *obj, const char *part) +{ + return efl_ui_drag_dir_get(efl_part(obj, part)); +} + +EAPI Eina_Bool +edje_object_part_drag_value_set(Evas_Object *obj, const char *part, double dx, double dy) +{ + return efl_ui_drag_value_set(efl_part(obj, part), dx, dy); +} + +EAPI Eina_Bool +edje_object_part_drag_value_get(const Evas_Object *obj, const char *part, double *dx, double *dy) +{ + return efl_ui_drag_value_get(efl_part(obj, part), dx, dy); +} + +EAPI Eina_Bool +edje_object_part_drag_size_set(Evas_Object *obj, const char *part, double dw, double dh) +{ + return efl_ui_drag_size_set(efl_part(obj, part), dw, dh); +} + +EAPI Eina_Bool +edje_object_part_drag_size_get(const Evas_Object *obj, const char *part, double *dw, double *dh) +{ + return efl_ui_drag_size_get(efl_part(obj, part), dw, dh); +} + +EAPI Eina_Bool +edje_object_part_drag_step_set(Evas_Object *obj, const char *part, double dx, double dy) +{ + return efl_ui_drag_step_set(efl_part(obj, part), dx, dy); +} + +EAPI Eina_Bool +edje_object_part_drag_step_get(const Evas_Object *obj, const char *part, double *dx, double *dy) +{ + return efl_ui_drag_step_get(efl_part(obj, part), dx, dy); +} + +EAPI Eina_Bool +edje_object_part_drag_page_set(Evas_Object *obj, const char *part, double dx, double dy) +{ + return efl_ui_drag_page_set(efl_part(obj, part), dx, dy); +} + +EAPI Eina_Bool +edje_object_part_drag_page_get(const Evas_Object *obj, const char *part, double *dx, double *dy) +{ + return efl_ui_drag_page_get(efl_part(obj, part), dx, dy); +} + +EAPI Eina_Bool +edje_object_part_drag_step(Evas_Object *obj, const char *part, double dx, double dy) +{ + return efl_ui_drag_step_move(efl_part(obj, part), dx, dy); +} + +EAPI Eina_Bool +edje_object_part_drag_page(Evas_Object *obj, const char *part, double dx, double dy) +{ + return efl_ui_drag_page_move(efl_part(obj, part), dx, dy); +} diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo index ec7947d..d40a6a3 100644 --- a/src/lib/edje/edje_object.eo +++ b/src/lib/edje/edje_object.eo @@ -827,7 +827,7 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, [[Checks if a part exists in a given Edje object's group definition. This function returns if a given part exists in the Edje group - bound to this object (with @Efl.File.set()). + bound to this object (with @Efl.File.file.set()). This call is useful, for example, when one could expect or not a given GUI element, depending on the theme applied to the object. @@ -843,180 +843,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, } } - /* DRAG PART APIS BEGIN ---------------------------------------------- */ - // FIXME: "dragable" or "draggable"? Only EFL uses "dragable"... - @property part_drag_value { - [[The dragable object relative location. - - Some parts in Edje can be dragged along the X/Y axes, if the part - contains a "dragable" section (in EDC). For instance, scroll bars - can be dragable objects. - - $dx and $dy are real numbers that range from 0 to 1, representing - the relative position to the dragable area on that axis. - - This value means, for the vertical axis, that 0.0 will be at the top - if the first parameter of $y in the dragable part theme is 1, and at - the bottom if it is -1. - - For the horizontal axis, 0.0 means left if the first parameter of $x - in the dragable part theme is 1, and right if it is -1. - ]] - set { - [[Sets the dragable object location. - - This places the dragable object at the given location. - ]] - return: bool; [[$true on success, $false otherwise]] - } - get { - [[Gets the dragable object location.]] - return: bool; [[$true on success, $false otherwise]] - } - keys { - part: string; [[The part name]] - } - values { - dx: double; [[The x relative position, from 0 to 1.]] - dy: double; [[The y relative position, from 0 to 1.]] - } - } - @property part_drag_size { - [[The dragable object relative size. - - Values for $dw and $dh are real numbers that range from 0 to 1, - representing the relative size of the dragable area on that axis. - - For instance a scroll bar handle size may depend on much large is - the scroller's content. - ]] - set { - [[Sets the size of the dragable object.]] - return: bool; [[$true on success, $false otherwise]] - } - get { - [[Gets the size of the dradgable object.]] - return: bool; [[$true on success, $false otherwise]] - } - keys { - part: string; [[The part name]] - } - values { - dw: double; [[The drag relative width, from 0 to 1.]] - dh: double; [[The drag relative height, from 0 to 1.]] - } - } - @property part_drag_dir { - [[Determines the dragable directions (read-only). - - The dragable directions are defined in the EDC file, inside the - "dragable" section, by the attributes $x and $y. See the EDC - reference documentation for more information. - ]] - get { - [[Gets the dragable direction.]] - return: Edje.Drag_Dir; [[#EDJE_DRAG_DIR_NONE: Not dragable - #EDJE_DRAG_DIR_X: dragable in X direction - #EDJE_DRAG_DIR_Y: dragable in Y direction - #EDJE_DRAG_DIR_XY: dragable in X & Y directions]] - } - keys { - part: string; [[The part name]] - } - } - @property part_drag_step { - [[The drag step increment. - - Values for $dx and $dy are real numbers that range from 0 to 1, - representing the relative size of the dragable area on that axis by - which the part will be moved. - - This differs from @.part_drag_page in that this is meant to - represent a unit increment, like a single line for example. - - See also @.part_drag_page. - ]] - set { - [[Sets the x,y step increments for a dragable object.]] - return: bool; [[$true on success, $false otherwise]] - } - get { - [[Gets the x and y step increments for the dragable object.]] - return: bool; [[$true on success, $false otherwise]] - } - keys { - part: string; [[The part name]] - } - values { - dx: double; [[The x step relative amount, from 0 to 1.]] - dy: double; [[The y step relative amount, from 0 to 1.]] - } - } - part_drag_step { - [[Moves the dragable by $dx,$dy steps. - - This moves the dragable part by $dx,$dy steps where the step - increment is the amount set by @.part_drag_step.set(). - - $dx and $dy can be positive or negative numbers, integer values are - recommended. - ]] - return: bool; [[$true on success, $false otherwise]] - params { - @in part: string; [[The part name]] - @in dx: double; [[The number of steps horizontally.]] - @in dy: double; [[The number of steps vertically.]] - } - } - @property part_drag_page { - [[The page step increments. - - Values for $dx and $dy are real numbers that range from 0 to 1, - representing the relative size of the dragable area on that axis by - which the part will be moved. - - This differs from @.part_drag_step in that this is meant to be a - larger step size, basically an entire page as opposed to a single - or couple of lines. - - See also @.part_drag_step. - ]] - set { - [[Sets the x,y page step increment values.]] - return: bool; [[$true on success, $false otherwise]] - } - get { - [[Gets the x,y page step increments for the dragable object.]] - return: bool; [[$true on success, $false otherwise]] - } - keys { - part: string; [[The part name]] - } - values { - dx: double; [[The x page step increment]] - dy: double; [[The y page step increment]] - } - } - part_drag_page { - [[Moves the dragable by $dx,$dy pages. - - This moves the dragable by $dx,$dy pages where the increment is - defined by @.part_drag_page.set(). - - $dx and $dy can be positive or negative numbers, integer values are - recommended. - - Warning: Paging is bugged! - ]] - return: bool; [[$true on success, $false otherwise]] - params { - @in part: string; [[The part name]] - @in dx: double; [[The number of pages horizontally.]] - @in dy: double; [[The number of pages vertically.]] - } - } - /* DRAG PART APIS END ------------------------------------------------ */ - /* TEXT PART APIS BEGIN ---------------------------------------------- */ @property text_change_cb { set { diff --git a/src/lib/edje/edje_part.c b/src/lib/edje/edje_part.c index b4049ed..deeb0d1 100644 --- a/src/lib/edje/edje_part.c +++ b/src/lib/edje/edje_part.c @@ -40,7 +40,7 @@ _efl_canvas_layout_internal_efl_object_finalize(Eo *obj, Efl_Canvas_Layout_Inter } EOLIAN void -_efl_canvas_layout_internal_efl_gfx_geometry_get(Eo *obj EINA_UNUSED, Efl_Canvas_Layout_Internal_Data *pd, int *x, int *y, int *w, int *h) +_efl_canvas_layout_internal_efl_gfx_geometry_get(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, int *x, int *y, int *w, int *h) { Edje_Real_Part *rp = pd->rp; @@ -61,7 +61,7 @@ _efl_canvas_layout_internal_efl_gfx_geometry_get(Eo *obj EINA_UNUSED, Efl_Canvas } EOLIAN static void -_efl_canvas_layout_internal_state_get(Eo *obj EINA_UNUSED, Efl_Canvas_Layout_Internal_Data *pd, const char **name, double *val) +_efl_canvas_layout_internal_state_get(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, const char **name, double *val) { const char *str; @@ -71,4 +71,70 @@ _efl_canvas_layout_internal_state_get(Eo *obj EINA_UNUSED, Efl_Canvas_Layout_Int RETURN_VOID; } +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_value_set(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double dx, double dy) +{ + RETURN_VAL(_edje_object_part_drag_value_set(pd->ed, pd->part, dx, dy)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_value_get(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double *dx, double *dy) +{ + RETURN_VAL(_edje_object_part_drag_value_get(pd->ed, pd->part, dx, dy)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_size_set(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double dw, double dh) +{ + RETURN_VAL(_edje_object_part_drag_size_set(pd->ed, pd->part, dw, dh)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_size_get(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double *dw, double *dh) +{ + RETURN_VAL(_edje_object_part_drag_size_get(pd->ed, pd->part, dw, dh)); +} + +EOLIAN static Efl_Ui_Drag_Dir +_efl_canvas_layout_internal_efl_ui_drag_drag_dir_get(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd) +{ + RETURN_VAL(_edje_object_part_drag_dir_get(pd->ed, pd->part)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_step_set(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double dx, double dy) +{ + RETURN_VAL(_edje_object_part_drag_step_set(pd->ed, pd->part, dx, dy)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_step_get(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double *dx, double *dy) +{ + RETURN_VAL(_edje_object_part_drag_step_get(pd->ed, pd->part, dx, dy)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_step_move(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double dx, double dy) +{ + RETURN_VAL(_edje_object_part_drag_step(pd->ed, pd->part, dx, dy)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_page_set(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double dx, double dy) +{ + RETURN_VAL(_edje_object_part_drag_page_set(pd->ed, pd->part, dx, dy)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_page_get(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double *dx, double *dy) +{ + RETURN_VAL(_edje_object_part_drag_page_get(pd->ed, pd->part, dx, dy)); +} + +EOLIAN static Eina_Bool +_efl_canvas_layout_internal_efl_ui_drag_drag_page_move(Eo *obj, Efl_Canvas_Layout_Internal_Data *pd, double dx, double dy) +{ + RETURN_VAL(_edje_object_part_drag_page(pd->ed, pd->part, dx, dy)); +} + #include "efl_canvas_layout_internal.eo.c" diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 79dddb5..11d3055 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -3095,6 +3095,19 @@ void _edje_real_part_ignore_flags_set(Edje *ed, Edje_Real_Part *rp, Evas_Event_F Evas_Event_Flags _edje_real_part_mask_flags_get(Edje *ed, Edje_Real_Part *rp); void _edje_real_part_mask_flags_set(Edje *ed, Edje_Real_Part *rp, Evas_Event_Flags mask_flags); +/* part drag apis */ +Edje_Drag_Dir _edje_object_part_drag_dir_get(Edje *ed, const char *part); +Eina_Bool _edje_object_part_drag_value_set(Edje *ed, const char *part, double dx, double dy); +Eina_Bool _edje_object_part_drag_value_get(Edje *ed, const char *part, double *dx, double *dy); +Eina_Bool _edje_object_part_drag_size_set(Edje *ed, const char *part, double dw, double dh); +Eina_Bool _edje_object_part_drag_size_get(Edje *ed, const char *part, double *dw, double *dh); +Eina_Bool _edje_object_part_drag_step_set(Edje *ed, const char *part, double dx, double dy); +Eina_Bool _edje_object_part_drag_step_get(Edje *ed, const char *part, double *dx, double *dy); +Eina_Bool _edje_object_part_drag_page_set(Edje *ed, const char *part, double dx, double dy); +Eina_Bool _edje_object_part_drag_page_get(Edje *ed, const char *part, double *dx, double *dy); +Eina_Bool _edje_object_part_drag_step(Edje *ed, const char *part, double dx, double dy); +Eina_Bool _edje_object_part_drag_page(Edje *ed, const char *part, double dx, double dy); + /* part proxy */ Eo *_edje_other_internal_proxy_get(Edje_Object *obj, Edje *ed, Edje_Real_Part *rp); diff --git a/src/lib/edje/edje_types.eot b/src/lib/edje/edje_types.eot index 9d7478b..2820bec 100644 --- a/src/lib/edje/edje_types.eot +++ b/src/lib/edje/edje_types.eot @@ -9,14 +9,6 @@ enum Edje.Cursor { user_extra [[User extra cursor state]] } -enum Edje.Drag_Dir { - [[Dragable properties values]] - none = 0, [[Not dragable value]] - x = 1, [[X dragable value]] - y = 2, [[Y dragable value]] - xy = 3 [[X and Y dragable value]] -} - enum Edje.Text.Autocapital_Type { [[All Text auto capital mode type values]] none, [[None mode value]] diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index 847fa61..252a4e4 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -4003,8 +4003,8 @@ _edje_object_part_state_get(Edje *ed, const char *part, double *val_ret) return ret; } -EOLIAN Edje_Drag_Dir -_edje_object_part_drag_dir_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) +Edje_Drag_Dir +_edje_object_part_drag_dir_get(Edje *ed, const char *part) { Edje_Drag_Dir ret; Edje_Real_Part *rp; @@ -4026,8 +4026,8 @@ _edje_object_part_drag_dir_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) return ret; } -EOLIAN Eina_Bool -_edje_object_part_drag_value_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double dx, double dy) +Eina_Bool +_edje_object_part_drag_value_set(Edje *ed, const char *part, double dx, double dy) { Edje_Real_Part *rp; Edje_User_Defined *eud; @@ -4079,8 +4079,8 @@ _edje_object_part_drag_value_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part } /* FIXME: Should this be x and y instead of dx/dy? */ -EOLIAN Eina_Bool -_edje_object_part_drag_value_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double *dx, double *dy) +Eina_Bool +_edje_object_part_drag_value_get(Edje *ed, const char *part, double *dx, double *dy) { Edje_Real_Part *rp; double ddx, ddy; @@ -4112,8 +4112,8 @@ _edje_object_part_drag_value_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_size_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double dw, double dh) +Eina_Bool +_edje_object_part_drag_size_set(Edje *ed, const char *part, double dw, double dh) { Edje_Real_Part *rp; Edje_User_Defined *eud; @@ -4163,8 +4163,8 @@ _edje_object_part_drag_size_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_size_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double *dw, double *dh) +Eina_Bool +_edje_object_part_drag_size_get(Edje *ed, const char *part, double *dw, double *dh) { Edje_Real_Part *rp; @@ -4191,8 +4191,8 @@ _edje_object_part_drag_size_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_step_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double dx, double dy) +Eina_Bool +_edje_object_part_drag_step_set(Edje *ed, const char *part, double dx, double dy) { Edje_Real_Part *rp; Edje_User_Defined *eud; @@ -4235,8 +4235,8 @@ _edje_object_part_drag_step_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_step_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double *dx, double *dy) +Eina_Bool +_edje_object_part_drag_step_get(Edje *ed, const char *part, double *dx, double *dy) { Edje_Real_Part *rp; @@ -4263,8 +4263,8 @@ _edje_object_part_drag_step_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_page_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double dx, double dy) +Eina_Bool +_edje_object_part_drag_page_set(Edje *ed, const char *part, double dx, double dy) { Edje_Real_Part *rp; Edje_User_Defined *eud; @@ -4307,8 +4307,8 @@ _edje_object_part_drag_page_set(Eo *obj EINA_UNUSED, Edje *ed, const char *part, return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_page_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double *dx, double *dy) +Eina_Bool +_edje_object_part_drag_page_get(Edje *ed, const char *part, double *dx, double *dy) { Edje_Real_Part *rp; @@ -4335,8 +4335,8 @@ _edje_object_part_drag_page_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part, return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_step(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double dx, double dy) +Eina_Bool +_edje_object_part_drag_step(Edje *ed, const char *part, double dx, double dy) { Edje_Real_Part *rp; FLOAT_T px, py; @@ -4387,8 +4387,8 @@ _edje_object_part_drag_step(Eo *obj EINA_UNUSED, Edje *ed, const char *part, dou return EINA_TRUE; } -EOLIAN Eina_Bool -_edje_object_part_drag_page(Eo *obj EINA_UNUSED, Edje *ed, const char *part, double dx, double dy) +Eina_Bool +_edje_object_part_drag_page(Edje *ed, const char *part, double dx, double dy) { Edje_Real_Part *rp; FLOAT_T px, py; diff --git a/src/lib/edje/efl_canvas_layout_internal.eo b/src/lib/edje/efl_canvas_layout_internal.eo index 74a1d3a..c06613f 100644 --- a/src/lib/edje/efl_canvas_layout_internal.eo +++ b/src/lib/edje/efl_canvas_layout_internal.eo @@ -1,5 +1,5 @@ /* FIXME: Rename to Efl.Canvas.Layout.Part */ -class Efl.Canvas.Layout_Internal (Efl.Object, Efl.Gfx) +class Efl.Canvas.Layout_Internal (Efl.Object, Efl.Gfx, Efl.Ui.Drag) { [[Common class for part proxy objects for $Efl.Canvas.Layout. @@ -28,5 +28,15 @@ class Efl.Canvas.Layout_Internal (Efl.Object, Efl.Gfx) implements { Efl.Object.finalize; Efl.Gfx.geometry { get; } + Efl.Ui.Drag.drag_value { set; get; } + Efl.Ui.Drag.drag_size { set; get; } + Efl.Ui.Drag.drag_dir { get; } + Efl.Ui.Drag.drag_step { set; get; } + Efl.Ui.Drag.drag_step_move; + Efl.Ui.Drag.drag_page { set; get; } + Efl.Ui.Drag.drag_page_move; + } + events { + /* FIXME: Are there really no events? */ } } diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index c428a2d..2310890 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -65,6 +65,7 @@ typedef struct tm Efl_Time; /* Data types */ #include "interfaces/efl_gfx_types.eot.h" +#include "interfaces/efl_ui_types.eot.h" typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; /* Interfaces */ @@ -81,6 +82,7 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; #include "interfaces/efl_text_properties.eo.h" #include "interfaces/efl_orientation.eo.h" #include "interfaces/efl_flipable.eo.h" +#include "interfaces/efl_ui_drag.eo.h" #include "interfaces/efl_ui_spin.eo.h" #include "interfaces/efl_ui_progress.eo.h" #include "interfaces/efl_ui_item.eo.h" @@ -152,6 +154,7 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command; #ifndef EFL_NOLEGACY_API_SUPPORT #include "interfaces/efl_gfx_types.eot.h" +#include "interfaces/efl_ui_types.eot.h" #include "interfaces/efl_input_types.eot.h" #include "interfaces/efl_gfx_fill.eo.legacy.h" #include "interfaces/efl_gfx.eo.legacy.h" diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 209f9e4..6e3f75c 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -48,6 +48,7 @@ #include "interfaces/efl_animator.eo.c" #include "interfaces/efl_orientation.eo.c" #include "interfaces/efl_flipable.eo.c" +#include "interfaces/efl_ui_drag.eo.c" #include "interfaces/efl_ui_spin.eo.c" #include "interfaces/efl_ui_progress.eo.c" #include "interfaces/efl_ui_menu.eo.c" diff --git a/src/lib/efl/interfaces/efl_ui_drag.eo b/src/lib/efl/interfaces/efl_ui_drag.eo new file mode 100644 index 0000000..6fcd1f9 --- /dev/null +++ b/src/lib/efl/interfaces/efl_ui_drag.eo @@ -0,0 +1,163 @@ +/* FIXME: "dragable" is not as common as "draggable" outside EFL... */ + +import efl_ui_types; + +interface Efl.Ui.Drag +{ + [[Common interface for draggable objects and parts. + + @since 1.20 + ]] + methods { + @property drag_value { + [[The dragable object relative location. + + Some parts in Edje can be dragged along the X/Y axes, if the part + contains a "dragable" section (in EDC). For instance, scroll bars + can be dragable objects. + + $dx and $dy are real numbers that range from 0 to 1, representing + the relative position to the dragable area on that axis. + + This value means, for the vertical axis, that 0.0 will be at the top + if the first parameter of $y in the dragable part theme is 1, and at + the bottom if it is -1. + + For the horizontal axis, 0.0 means left if the first parameter of $x + in the dragable part theme is 1, and right if it is -1. + ]] + set { + [[Sets the dragable object location. + + This places the dragable object at the given location. + ]] + return: bool; [[$true on success, $false otherwise]] + } + get { + [[Gets the dragable object location.]] + return: bool; [[$true on success, $false otherwise]] + } + values { + dx: double; [[The x relative position, from 0 to 1.]] + dy: double; [[The y relative position, from 0 to 1.]] + } + } + @property drag_size { + [[The dragable object relative size. + + Values for $dw and $dh are real numbers that range from 0 to 1, + representing the relative size of the dragable area on that axis. + + For instance a scroll bar handle size may depend on much large is + the scroller's content. + ]] + set { + [[Sets the size of the dragable object.]] + return: bool; [[$true on success, $false otherwise]] + } + get { + [[Gets the size of the dradgable object.]] + return: bool; [[$true on success, $false otherwise]] + } + values { + dw: double; [[The drag relative width, from 0 to 1.]] + dh: double; [[The drag relative height, from 0 to 1.]] + } + } + @property drag_dir { + [[Determines the dragable directions (read-only). + + The dragable directions are defined in the EDC file, inside the + "dragable" section, by the attributes $x and $y. See the EDC + reference documentation for more information. + ]] + get { + [[Gets the dragable direction.]] + return: Efl.Ui.Drag.Dir; [[The direction(s) premitted for drag.]] + } + } + @property drag_step { + [[The drag step increment. + + Values for $dx and $dy are real numbers that range from 0 to 1, + representing the relative size of the dragable area on that axis by + which the part will be moved. + + This differs from @.drag_page in that this is meant to + represent a unit increment, like a single line for example. + + See also @.drag_page. + ]] + set { + [[Sets the x,y step increments for a dragable object.]] + return: bool; [[$true on success, $false otherwise]] + } + get { + [[Gets the x and y step increments for the dragable object.]] + return: bool; [[$true on success, $false otherwise]] + } + values { + dx: double; [[The x step relative amount, from 0 to 1.]] + dy: double; [[The y step relative amount, from 0 to 1.]] + } + } + drag_step_move { + [[Moves the dragable by $dx,$dy steps. + + This moves the dragable part by $dx,$dy steps where the step + increment is the amount set by @.drag_step.set(). + + $dx and $dy can be positive or negative numbers, integer values are + recommended. + ]] + return: bool; [[$true on success, $false otherwise]] + params { + @in dx: double; [[The number of steps horizontally.]] + @in dy: double; [[The number of steps vertically.]] + } + } + @property drag_page { + [[The page step increments. + + Values for $dx and $dy are real numbers that range from 0 to 1, + representing the relative size of the dragable area on that axis by + which the part will be moved. + + This differs from @.drag_step in that this is meant to be a + larger step size, basically an entire page as opposed to a single + or couple of lines. + + See also @.drag_step. + ]] + set { + [[Sets the x,y page step increment values.]] + return: bool; [[$true on success, $false otherwise]] + } + get { + [[Gets the x,y page step increments for the dragable object.]] + return: bool; [[$true on success, $false otherwise]] + } + values { + dx: double; [[The x page step increment]] + dy: double; [[The y page step increment]] + } + } + drag_page_move { + [[Moves the dragable by $dx,$dy pages. + + This moves the dragable by $dx,$dy pages where the increment is + defined by @.drag_page.set(). + + $dx and $dy can be positive or negative numbers, integer values are + recommended. + + Warning: Paging is bugged! + ]] + return: bool; [[$true on success, $false otherwise]] + params { + @in dx: double; [[The number of pages horizontally.]] + @in dy: double; [[The number of pages vertically.]] + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_ui_types.eot b/src/lib/efl/interfaces/efl_ui_types.eot new file mode 100644 index 0000000..275d82f --- /dev/null +++ b/src/lib/efl/interfaces/efl_ui_types.eot @@ -0,0 +1,7 @@ +enum Efl.Ui.Drag.Dir { + [[Permitted directions for dragging objects.]] + none = 0, [[Not draggable in any direction.]] + x = 1, [[Draggable horizontally.]] + y = 2, [[Draggable vertically.]] + xy = 3 [[Draggable in both directions.]] +} diff --git a/src/lib/elementary/elm_spinner.c b/src/lib/elementary/elm_spinner.c index c3921f3..6df1449 100644 --- a/src/lib/elementary/elm_spinner.c +++ b/src/lib/elementary/elm_spinner.c @@ -321,12 +321,12 @@ _drag_cb(void *data, if (sd->button_layout) { if (!strncmp(style, "vertical", 8)) - edje_obj_part_drag_value_get((Eo *)wd->resize_obj, "elm.dragable.slider", NULL, &pos); + efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable.slider"), NULL, &pos); else - edje_obj_part_drag_value_get((Eo *)wd->resize_obj, "elm.dragable.slider", &pos, NULL); + efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable.slider"), &pos, NULL); } else - edje_obj_part_drag_value_get((Eo *)wd->resize_obj, "elm.dragable.slider", &pos, NULL); + efl_ui_drag_value_get(efl_part(wd->resize_obj, "elm.dragable.slider"), &pos, NULL); if (sd->drag_prev_pos != 0) sd->drag_val_step = pow((pos - sd->drag_prev_pos), 2); diff --git a/src/lib/evas/canvas/efl_ui_draggable.eo b/src/lib/evas/canvas/efl_ui_draggable.eo index 16ea1a1..c3b8a68 100644 --- a/src/lib/evas/canvas/efl_ui_draggable.eo +++ b/src/lib/evas/canvas/efl_ui_draggable.eo @@ -1,3 +1,4 @@ +/* FIXME: Edje Drag and this Dnd Draggable have confusingly similar names! */ interface Efl.Ui.Draggable () { [[Efl UI draggable interface]] diff --git a/src/tests/emotion/emotion_test_main-eo.c b/src/tests/emotion/emotion_test_main-eo.c index b096137..fd8a513 100644 --- a/src/tests/emotion/emotion_test_main-eo.c +++ b/src/tests/emotion/emotion_test_main-eo.c @@ -306,7 +306,7 @@ video_obj_time_changed(Evas_Object *obj, Evas_Object *edje) pos = emotion_object_position_get(obj); len = emotion_object_play_length_get(obj); scale = (len > 0.0) ? pos / len : 0.0; - edje_obj_part_drag_value_set(edje, "video_progress", scale, 0.0); + efl_ui_drag_value_set(efl_part(edje, "video_progress"), scale, 0.0); lh = len / 3600; lm = len / 60 - (lh * 60); @@ -461,7 +461,7 @@ video_obj_signal_jump_cb(void *data, Evas_Object *o, const char *emission EINA_U double len; double x, y; - edje_obj_part_drag_value_get(o, source, &x, &y); + efl_ui_drag_value_get(efl_part(o, source), &x, &y); len = emotion_object_play_length_get(ov); emotion_object_position_set(ov, x * len); } @@ -474,7 +474,7 @@ video_obj_signal_alpha_cb(void *data, Evas_Object *o, const char *emission EINA_ double x, y; char buf[256]; - edje_obj_part_drag_value_get(o, source, &x, &y); + efl_ui_drag_value_get(efl_part(o, source), &x, &y); alpha = 255 * y; efl_gfx_color_set(ov, alpha, alpha, alpha, alpha); snprintf(buf, sizeof(buf), "alpha %.0f", alpha); @@ -488,7 +488,7 @@ video_obj_signal_vol_cb(void *data, Evas_Object *o, const char *emission EINA_UN double vol; char buf[256]; - edje_obj_part_drag_value_get(o, source, NULL, &vol); + efl_ui_drag_value_get(efl_part(o, source), NULL, &vol); emotion_object_audio_volume_set(ov, vol); snprintf(buf, sizeof(buf), "vol %.2f", vol); edje_obj_part_text_set(o, "video_volume_txt", buf); @@ -641,9 +641,9 @@ init_video_object(const char *module_filename, const char *filename) edje_obj_signal_callback_add(oe, "frame_resize", "start", video_obj_signal_frame_resize_start_cb, oe); edje_obj_signal_callback_add(oe, "frame_resize", "stop", video_obj_signal_frame_resize_stop_cb, oe); edje_obj_signal_callback_add(oe, "mouse, move", "*", video_obj_signal_frame_move_cb, oe); - edje_obj_part_drag_value_set(oe, "video_alpha", 0.0, 1.0); + efl_ui_drag_value_set(efl_part(oe, "video_alpha"), 0.0, 1.0); edje_obj_part_text_set(oe, "video_alpha_txt", "alpha 255"); - edje_obj_part_drag_value_set(oe, "video_volume", 0.0, 0.5); + efl_ui_drag_value_set(efl_part(oe, "video_volume"), 0.0, 0.5); edje_obj_part_text_set(oe, "video_volume_txt", "vol 0.50"); edje_obj_signal_emit(oe, "video_state", "play"); efl_gfx_visible_set(oe, EINA_TRUE); -- 2.7.4