From: cnook <kimcinoo@gmail.com>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 13 Dec 2011 03:38:27 +0000 (03:38 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 13 Dec 2011 03:38:27 +0000 (03:38 +0000)
As the title, attached patch has followings.

  1) Using Calculated Value: The _update_arrow(); had used
  evas_object_geometry_get(); internally for getting its base size.
  But the _calc_base_geometry(); already got the base size which
  is more accurate.

  2) Getting Size From The Style Also: If the ctxpopup has content
  which is composed using the style (means, the size of
  content can get from *.edc file only), then ctxpopup does not
  come properly. So resolving this, the patch is using a box,
  and add a RESIZE callback to the box. When the box is resized,
  the callback calls elm_box_recalculate();

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@66130 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elc_ctxpopup.c

index fa57ab2..87c209e 100644 (file)
@@ -64,7 +64,7 @@ static void _adjust_pos_y(Evas_Coord_Point *pos,
                           Evas_Coord_Rectangle *hover_area);
 static Elm_Ctxpopup_Direction _calc_base_geometry(Evas_Object *obj,
                                                   Evas_Coord_Rectangle *rect);
-static void _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir);
+static void _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir, Evas_Coord_Rectangle rect);
 static void _sizing_eval(Evas_Object *obj);
 static void _shift_base_by_arrow(Evas_Object *arrow,
                                  Elm_Ctxpopup_Direction dir,
@@ -504,11 +504,10 @@ _calc_base_geometry(Evas_Object *obj, Evas_Coord_Rectangle *rect)
 }
 
 static void
-_update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir)
+_update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir, Evas_Coord_Rectangle base_size)
 {
    Evas_Coord x, y;
    Evas_Coord_Rectangle arrow_size;
-   Evas_Coord_Rectangle base_size;
    Widget_Data *wd;
    double drag;
 
@@ -518,8 +517,6 @@ _update_arrow(Evas_Object *obj, Elm_Ctxpopup_Direction dir)
    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
    evas_object_geometry_get(wd->arrow, NULL, NULL, &arrow_size.w,
                             &arrow_size.h);
-   evas_object_geometry_get(wd->base, &base_size.x, &base_size.y,
-                            &base_size.w, &base_size.h);
 
    edje_object_part_unswallow(wd->base, wd->arrow);
 
@@ -677,7 +674,7 @@ _sizing_eval(Evas_Object *obj)
    //Base
    wd->dir = _calc_base_geometry(obj, &rect);
    _show_signal_emit(obj, wd->dir);
-   _update_arrow(obj, wd->dir);
+   _update_arrow(obj, wd->dir, rect);
    _shift_base_by_arrow(wd->arrow, wd->dir, &rect);
 
    //resize scroller according to final size.
@@ -1027,6 +1024,19 @@ _ctxpopup_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
 }
 
 static void
+_content_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
+                 void *event_info __UNUSED__)
+{
+   Widget_Data *wd;
+
+   wd = elm_widget_data_get(data);
+   if (!wd) return;
+
+   elm_box_recalculate(wd->box);
+   _sizing_eval(data);
+}
+
+static void
 _scroller_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj,
                  void *event_info __UNUSED__)
 {
@@ -1499,7 +1509,20 @@ elm_ctxpopup_item_disabled_get(const Elm_Object_Item *it)
 EAPI void
 elm_ctxpopup_content_set(Evas_Object *obj, Evas_Object *content)
 {
-   elm_object_content_set(obj, content);
+   Widget_Data *wd;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   wd->box = elm_box_add(obj);
+   evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
+                                    EVAS_HINT_EXPAND);
+   evas_object_show(content);
+
+   elm_box_pack_end(wd->box, content);
+
+   evas_object_event_callback_add(content, EVAS_CALLBACK_RESIZE,
+                                  _content_resize, obj);
+   elm_object_content_set(obj, wd->box);
 }
 
 EAPI Evas_Object *