[Popup] Adding elm_popup_align_set and elm_popup_align_get api

Summary: Added support for popup align set

Test Plan: elm_popup_align_set, elm_popup_align_get, elementary_test -to popup

Reviewers: seoz, singh.amitesh

Differential Revision: https://phab.enlightenment.org/D321
This commit is contained in:
abhi 2013-12-02 16:10:53 +09:00 committed by Carsten Haitzler (Rasterman)
parent 8531b7aeed
commit c2c1b87f6f
6 changed files with 161 additions and 0 deletions

View File

@ -1660,6 +1660,10 @@
position. This actually reduces the mapbuf calculation time muchly in
case of complex layout.
2013-09-30 Abhinandan Aryadipta (aryarockstar)
* Popup: Added elm_popup_align_set() and elm_popup_align_get() APIs.
2013-10-01 Ryuan Choi (ryuan)
* fileselector: Add the configuration fileselector_double_tap_navigation_enable.

View File

@ -113,6 +113,7 @@ Additions:
* Add elm_menu_item_subitems_clear().
* Add the configuration fileselector_double_tap_navigation_enable.
* Add "activated" smart callback for fileselector.
* Add elm_popup_align_set() and elm_popup_align_get().
* Add elm_object_item_signal_emit support in hoversel. This works only when the item is created.
* Add elm_fileselector_multi_select_set/get() and elm_fileselector_selected_paths_get to support multi-selection.
* Add elm_fileselector_hidden_visible_set/get() to show or hide hidden files/directories.

View File

@ -3,9 +3,25 @@
#endif
#include <Elementary.h>
#define POPUP_POINT_MAX 6
typedef struct
{
double x;
double y;
}Evas_Rel_Coord_Point;
static Evas_Object *g_popup = NULL;
static int times = 0;
static Evas_Rel_Coord_Point _popup_point[POPUP_POINT_MAX] =
{
{ 0.01, 0.01 },
{ 0.2, 0.2 },
{ 0.5, 0.5 },
{ 0.99, 0.01 },
{ 0.01, 0.99 },
{ 0.99, 0.99 }
};
static void
_response_cb(void *data EINA_UNUSED, Evas_Object *obj,
@ -21,6 +37,23 @@ _popup_close_cb(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_del(data);
}
static void
_popup_move_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
static int k = 0;
double h = -1, v = -1;
elm_popup_align_set(data, _popup_point[k].x, _popup_point[k].y);
elm_popup_align_get(data, &h, &v);
printf("elm_popup_align_get :: Aligned: %lf %lf\n", h, v);
k++;
if (k >= POPUP_POINT_MAX)
k = 0;
}
static void
_g_popup_response_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@ -497,6 +530,33 @@ _popup_transparent_cb(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_show(popup);
}
static void
_popup_transparent_move_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *popup;
Evas_Object *btn, *btn1;
popup = elm_popup_add(data);
elm_object_style_set(popup, "transparent");
elm_object_text_set(popup, "This Popup has transparent background");
// popup buttons
btn = elm_button_add(popup);
elm_object_text_set(btn, "Move");
elm_object_part_content_set(popup, "button1", btn);
evas_object_smart_callback_add(btn, "clicked", _popup_move_cb, popup);
btn1 = elm_button_add(popup);
elm_object_text_set(btn1, "Close");
elm_object_part_content_set(popup, "button2", btn1);
evas_object_smart_callback_add(btn1, "clicked", _popup_close_cb, popup);
// popup show should be called after adding all the contents and the buttons
// of popup to set the focus into popup's contents correctly.
evas_object_show(popup);
}
static void
_list_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@ -578,6 +638,8 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
_popup_center_text_3button_add_remove_button_cb, win);
elm_list_item_append(list, "popup-transparent", NULL, NULL,
_popup_transparent_cb, win);
elm_list_item_append(list, "popup-transparent-move", NULL, NULL,
_popup_transparent_move_cb, win);
elm_list_item_append(list, "popup-center-title + list content + 1 button",
NULL, NULL, _popup_center_title_list_content_1button_cb,
win);

View File

@ -1755,6 +1755,40 @@ _orient_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
*ret = (Elm_Popup_Orient)_elm_notify_orient_get(sd->notify);
}
EAPI void
elm_popup_align_set(Evas_Object *obj, double horizontal, double vertical)
{
ELM_POPUP_CHECK(obj);
eo_do(obj, elm_obj_popup_align_set(horizontal, vertical));
}
static void
_align_set(Eo *obj, void *_pd, va_list *list)
{
double horizontal = va_arg(*list, double);
double vertical = va_arg(*list, double);
Elm_Popup_Smart_Data *sd = _pd;
elm_notify_align_set(sd->notify, horizontal, vertical);
}
EAPI void
elm_popup_align_get(const Evas_Object *obj, double *horizontal, double *vertical)
{
ELM_POPUP_CHECK(obj);
eo_do((Eo *) obj, elm_obj_popup_align_get(horizontal, vertical));
}
static void
_align_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
{
double *horizontal = va_arg(*list, double *);
double *vertical = va_arg(*list, double *);
Elm_Popup_Smart_Data *sd = _pd;
elm_notify_align_get(sd->notify, horizontal, vertical);
}
EAPI void
elm_popup_timeout_set(Evas_Object *obj,
double timeout)
@ -1922,6 +1956,8 @@ _class_constructor(Eo_Class *klass)
EO_OP_FUNC(ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ALLOW_EVENTS_SET), _allow_events_set),
EO_OP_FUNC(ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ALLOW_EVENTS_GET), _allow_events_get),
EO_OP_FUNC(ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ITEM_APPEND), _item_append),
EO_OP_FUNC(ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ALIGN_SET), _align_set),
EO_OP_FUNC(ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ALIGN_GET), _align_get),
EO_OP_FUNC_SENTINEL
};
eo_class_funcs_set(klass, func_desc);
@ -1938,6 +1974,8 @@ static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(ELM_OBJ_POPUP_SUB_ID_ALLOW_EVENTS_SET, "Sets whether events should be passed to by a click outside."),
EO_OP_DESCRIPTION(ELM_OBJ_POPUP_SUB_ID_ALLOW_EVENTS_GET, "Returns value indicating whether allow event is enabled or not."),
EO_OP_DESCRIPTION(ELM_OBJ_POPUP_SUB_ID_ITEM_APPEND, "Add a new item to a Popup object."),
EO_OP_DESCRIPTION(ELM_OBJ_POPUP_SUB_ID_ALIGN_SET, "Set the popup alignment relative to its parent."),
EO_OP_DESCRIPTION(ELM_OBJ_POPUP_SUB_ID_ALIGN_GET, "Return the popup alignment relative to its parent."),
EO_OP_DESCRIPTION_SENTINEL
};
static const Eo_Class_Description class_desc = {

View File

@ -20,6 +20,8 @@ enum
ELM_OBJ_POPUP_SUB_ID_ALLOW_EVENTS_SET,
ELM_OBJ_POPUP_SUB_ID_ALLOW_EVENTS_GET,
ELM_OBJ_POPUP_SUB_ID_ITEM_APPEND,
ELM_OBJ_POPUP_SUB_ID_ALIGN_SET,
ELM_OBJ_POPUP_SUB_ID_ALIGN_GET,
ELM_OBJ_POPUP_SUB_ID_LAST
};
@ -138,6 +140,32 @@ enum
* @see elm_popup_item_append
*/
#define elm_obj_popup_item_append(label, icon, func, data, ret) ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ITEM_APPEND), EO_TYPECHECK(const char *, label), EO_TYPECHECK(Evas_Object *, icon), EO_TYPECHECK(Evas_Smart_Cb, func), EO_TYPECHECK(const void *, data), EO_TYPECHECK(Elm_Object_Item **, ret)
/**
* @def elm_obj_popup_align_set
* @since 1.8
*
* @brief Set the alignment of the popup object relative to its parent
*
* @param[in] horizontal
* @param[in] vertical
*
* @see elm_popup_align_set
*/
#define elm_obj_popup_align_set(horizontal, vertical) ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ALIGN_SET), EO_TYPECHECK(double, horizontal), EO_TYPECHECK(double, vertical)
/**
* @def elm_obj_popup_align_get
* @since 1.8
*
* @brief Return the alignment of the popup object relative to its parent
*
* @param[out] horizontal
* @param[out] vertical
*
* @see elm_popup_align_get
*/
#define elm_obj_popup_align_get(horizontal, vertical) ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_ALIGN_GET), EO_TYPECHECK(double *, horizontal), EO_TYPECHECK(double *, vertical)
/**
* @}
*/

View File

@ -136,3 +136,31 @@ EAPI Eina_Bool elm_popup_allow_events_get(const Evas_Object *obj);
* and item(s) can be there in a popup content area.
*/
EAPI Elm_Object_Item *elm_popup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1);
/**
* @brief Set the alignment of the popup object
*
* @param obj popup object
* @param horizontal The horizontal alignment of the popup
* @param vertical The vertical alignment of the popup
*
* Sets the alignment in which the popup will appear in its parent.
*
* @since 1.9
* @ingroup Popup
*/
EAPI void elm_popup_align_set(Evas_Object *obj, double horizontal, double vertical);
/**
* @brief Get the alignment of the popup object
* @param obj The popup object
* @param horizontal The horizontal alignment of the popup
* @param vertical The vertical alignment of the popup
*
* @see elm_popup_align_set()
*
* @since 1.9
* @ingroup Popup
*/
EAPI void elm_popup_align_get(const Evas_Object *obj, double *horizontal, double *vertical);