elc_popup: Adjust popup size when its parent is resized
authorJee-Yong Um <conr2d@gmail.com>
Tue, 10 Mar 2015 07:21:16 +0000 (16:21 +0900)
committerChunEon Park <hermet@hermet.pe.kr>
Tue, 10 Mar 2015 07:21:16 +0000 (16:21 +0900)
Summary:
When parent is resized, popup keeps its original size.
This patch makes popup have proper size in proportion to parent's size.

T2082

Test Plan: You can check the effect of this patch in "elementary_test popup".

Reviewers: seoz, Hermet

Subscribers: stefan_schmidt, J5lx, seoz

Differential Revision: https://phab.enlightenment.org/D2121

src/lib/elc_popup.c
src/lib/elm_widget_popup.h

index 6683f4b..8696310 100644 (file)
@@ -43,6 +43,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
 };
 
 static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
+static void _parent_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED);
 
 static const Elm_Action key_actions[] = {
    {"move", _key_action_move},
@@ -194,6 +195,7 @@ _elm_popup_evas_object_smart_del(Eo *obj, Elm_Popup_Data *sd)
 {
    unsigned int i;
 
+   evas_object_event_callback_del_full(sd->parent, EVAS_CALLBACK_RESIZE, _parent_resize_cb, obj);
 
    evas_object_smart_callback_del
      (sd->notify, "block,clicked", _block_clicked_cb);
@@ -1416,8 +1418,18 @@ _elm_popup_evas_object_smart_add(Eo *obj, Elm_Popup_Data *priv)
    _visuals_set(obj);
 }
 
+static void
+_parent_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+   Evas_Coord w, h;
+   Evas_Object *popup = data;
+
+   evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+   evas_object_resize(popup, w, h);
+}
+
 EOLIAN static void
-_elm_popup_elm_widget_parent_set(Eo *obj, Elm_Popup_Data *sd EINA_UNUSED, Evas_Object *parent)
+_elm_popup_elm_widget_parent_set(Eo *obj, Elm_Popup_Data *sd, Evas_Object *parent)
 {
    Evas_Coord x, y, w, h;
    evas_object_geometry_get(parent, &x, &y, &w, &h);
@@ -1429,6 +1441,9 @@ _elm_popup_elm_widget_parent_set(Eo *obj, Elm_Popup_Data *sd EINA_UNUSED, Evas_O
      }
    evas_object_move(obj, x, y);
    evas_object_resize(obj, w, h);
+
+   sd->parent = parent;
+   evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _parent_resize_cb, obj);
 }
 
 EOLIAN static void
index 04c044d..6ffee43 100644 (file)
@@ -42,6 +42,7 @@ struct _Elm_Popup_Data
    Evas_Object          *spacer;
    Evas_Object          *scr;
    Evas_Object          *content;
+   Evas_Object          *parent; /**< Pointer to remove _parent_resize_cb when popup is deleted. */
    Eina_List            *items;
    const char           *title_text;
    Action_Area_Data     *buttons[ELM_POPUP_ACTION_BUTTON_MAX];