popup: Added support for popup move. elm_popup_move.
authorAbhinandan Aryadipta <a.aryadipta@samsung.com>
Sun, 3 Nov 2013 14:01:19 +0000 (23:01 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Sun, 3 Nov 2013 14:03:32 +0000 (23:03 +0900)
Summary: Added support for popup move

Test Plan: elm_popup_move

Reviewers: seoz, singh.amitesh, tasn, Hermet

CC: raster
Differential Revision: https://phab.enlightenment.org/D247

legacy/elementary/ChangeLog
legacy/elementary/NEWS
legacy/elementary/src/bin/test_popup.c
legacy/elementary/src/lib/elc_popup.c
legacy/elementary/src/lib/elc_popup_eo.h
legacy/elementary/src/lib/elc_popup_legacy.h

index 66e4536..434f65f 100644 (file)
         * genlist , gengrid: Add ELM_OBJECT_MULTIPLE_SELECT_MODE_WITH_CONTROL.
         It disallow multiple selection when clicked without control pressed although
         multiple selection is enabled.
+
+2013-10-03  Abhinandan Aryadipta (aryarockstar)
+
+        * Popup - Added elm_popup_move() api.
index 4ba58bf..fece1e7 100644 (file)
@@ -102,6 +102,7 @@ Additions:
    * Add "virtualkeypad,size,changed" callback on virtualkeypad min size change for conformant.
    * Add elm_slider_step_get(), elm_slider_step_set() for slider.
    * Add ELM_OBJECT_MULTIPLE_SELECT_MODE_WITH_CONTROL select mode for genlist/gengrid.
+   * Add support elm_popup_move() for popup.
 
 Improvements:
 
index fa2d06e..945c3df 100644 (file)
@@ -22,6 +22,35 @@ _popup_close_cb(void *data, Evas_Object *obj EINA_UNUSED,
 }
 
 static void
+_popup_move_cb(void *data, Evas_Object *obj EINA_UNUSED,
+               void *event_info EINA_UNUSED)
+{
+   static int k=0;
+
+   if (k == 0)
+     elm_popup_move(data, -10, 50);//negative x
+   else if (k == 1)
+     elm_popup_move(data, 40, -100);//negative y
+   else if (k == 2)
+     elm_popup_move(data, 0, 0);//zero x zero y
+   else if (k == 3)
+     elm_popup_move(data, 40, 50);
+   else if (k == 4)
+     elm_popup_move(data, 80, 100);
+   else if (k == 5)
+     elm_popup_move(data, 120, 150);
+   else if (k == 6)
+     elm_popup_move(data, 160, 200);
+   else if (k == 7)
+     elm_popup_move(data, 500, 9999);//excess y
+   else
+     elm_popup_move(data, 9999, 500);//excess x
+   k++;
+   if (k > 8)
+     k = 0;
+}
+
+static void
 _g_popup_response_cb(void *data, Evas_Object *obj EINA_UNUSED,
              void *event_info EINA_UNUSED)
 {
@@ -467,6 +496,33 @@ _popup_transparent_cb(void *data, Evas_Object *obj EINA_UNUSED,
 }
 
 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)
 {
    evas_object_del(data);
@@ -543,6 +599,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);
index f873cff..c5b5c98 100644 (file)
@@ -1755,6 +1755,45 @@ _orient_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
 }
 
 EAPI void
+elm_popup_move(Evas_Object *obj,
+               Evas_Coord x, Evas_Coord y)
+{
+   ELM_POPUP_CHECK(obj);
+   eo_do(obj, elm_obj_popup_move(x, y));
+}
+
+static void
+_move(Eo *obj, void *_pd, va_list *list)
+{
+   Evas_Coord x = va_arg(*list, Evas_Coord);
+   Evas_Coord y = va_arg(*list, Evas_Coord);
+   Evas_Coord tw, th, w, h;
+   Evas_Object *top;
+   Elm_Popup_Smart_Data *sd = _pd;
+
+   top = elm_widget_top_get(obj);
+   if (!top)
+     {
+        ERR("The top parent is NULL! : popup=%p", obj);
+        return;
+     }
+
+   evas_object_geometry_get(top, NULL, NULL, &tw, &th);
+   evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+
+   if (x < 0) x = 0;
+   if (y < 0) y = 0;
+   if ((x > (tw - w)) && (tw - w > 0))
+     x = tw - w;
+   if ((y > (th - h)) && (th - h > 0))
+     y = th - h;
+   if ((x > tw) || (y > th) || (w > tw) || (h > th))
+     elm_notify_align_set(sd->notify, 0.5, 0.5);
+   else
+     elm_notify_align_set(sd->notify, ((double)x/(double)tw), ((double)y/(double)th));
+}
+
+EAPI void
 elm_popup_timeout_set(Evas_Object *obj,
                       double timeout)
 {
@@ -1921,6 +1960,7 @@ _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_MOVE), _move),
         EO_OP_FUNC_SENTINEL
   };
    eo_class_funcs_set(klass, func_desc);
@@ -1937,6 +1977,7 @@ 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_MOVE, "Move the popup relative to its top parent."),
      EO_OP_DESCRIPTION_SENTINEL
 };
 static const Eo_Class_Description class_desc = {
index 6d09109..75bf885 100644 (file)
@@ -20,6 +20,7 @@ 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_MOVE,
    ELM_OBJ_POPUP_SUB_ID_LAST
 };
 
@@ -138,6 +139,19 @@ 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_move
+ * @since 1.8
+ *
+ * @brief Move the popup relative to its top parent
+ *
+ * @param[in] x
+ * @param[in] y
+ *
+ * @see elm_popup_move
+ */
+#define elm_obj_popup_move(x, y) ELM_OBJ_POPUP_ID(ELM_OBJ_POPUP_SUB_ID_MOVE), EO_TYPECHECK(Evas_Coord, x), EO_TYPECHECK(Evas_Coord, y)
 /**
  * @}
  */
index 0f2d08f..2530ba0 100644 (file)
@@ -136,3 +136,18 @@ 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);
+
+/**
+ * @since 1.8
+ *
+ * @brief Move the popup relative to its top parent
+ *
+ * @param obj popup object
+ * @param x X position to move the popup object to, in canvas units,
+ * with relative to its top parent object.
+ * @param y Y position to move the popup object to, in canvas units,
+ * with relative to its top parent object.
+ *
+ * @ingroup Popup
+ */
+EAPI void elm_popup_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);