[Genlist] Add _elm_genlist_item_state_update & elm_genlist_item_flags_get
authorJung Chanwook <joey.jung@samsung.com>
Fri, 17 Feb 2012 02:32:14 +0000 (11:32 +0900)
committerJung Chanwook <joey.jung@samsung.com>
Fri, 17 Feb 2012 02:32:14 +0000 (11:32 +0900)
Change-Id: Iddec8c369d8b4d6cb31f842148211a1a94035b4b

src/lib/elm_genlist.c
src/lib/elm_genlist.h

index f52a259..e8582fe 100644 (file)
@@ -175,7 +175,6 @@ struct _Elm_Genlist_Item
    Eina_Bool                     selected : 1;
    Eina_Bool                     highlighted : 1;
    Eina_Bool                     expanded : 1;
-   Eina_Bool                     disabled : 1;
    Eina_Bool                     display_only : 1;
    Eina_Bool                     mincalcd : 1;
    Eina_Bool                     queued : 1;
@@ -1791,6 +1790,74 @@ _item_cache_find(Elm_Genlist_Item *it)
 }
 
 static void
+_elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
+{
+   if (itc)
+     {
+        if (it->selected != itc->selected)
+          {
+             if (it->selected)
+               {
+                  edje_object_signal_emit(VIEW(it),
+                                          "elm,state,selected", "elm");
+                  if (it->edit_obj)
+                    edje_object_signal_emit(it->edit_obj,
+                                            "elm,state,selected", "elm");
+               }
+          }
+        if (elm_widget_item_disabled_get(it) != itc->disabled)
+          {
+             if (elm_widget_item_disabled_get(it))
+               {
+                  edje_object_signal_emit(VIEW(it),
+                                          "elm,state,disabled", "elm");
+                  if (it->edit_obj)
+                    edje_object_signal_emit(it->edit_obj,
+                                            "elm,state,disabled", "elm");
+               }
+          }
+        if (it->expanded != itc->expanded)
+          {
+             if (it->expanded)
+               {
+                  edje_object_signal_emit(VIEW(it),
+                                          "elm,state,expanded", "elm");
+                  if (it->edit_obj)
+                    edje_object_signal_emit(it->edit_obj,
+                                            "elm,state,expanded", "elm");
+               }
+          }
+     }
+   else
+     {
+        if (it->selected)
+          {
+             edje_object_signal_emit(VIEW(it),
+                                     "elm,state,selected", "elm");
+             if (it->edit_obj)
+               edje_object_signal_emit(it->edit_obj,
+                                       "elm,state,selected", "elm");
+          }
+        if (elm_widget_item_disabled_get(it))
+          {
+             edje_object_signal_emit(VIEW(it),
+                                     "elm,state,disabled", "elm");
+             if (it->edit_obj)
+               edje_object_signal_emit(it->edit_obj,
+                                       "elm,state,disabled", "elm");
+          }
+        if (it->expanded)
+          {
+             edje_object_signal_emit(VIEW(it),
+                                     "elm,state,expanded", "elm");
+             if (it->edit_obj)
+               edje_object_signal_emit(it->edit_obj,
+                                       "elm,state,expanded", "elm");
+          }
+     }
+}
+
+static void
 _content_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Elm_Genlist_Item *it = data;
@@ -1872,7 +1939,7 @@ _item_mode_content_realize(Elm_Genlist_Item *it,
                   elm_widget_sub_object_add(WIDGET(it), ic);
                   if (it->mode_view || it->wd->edit_mode)
                     {
-                       if (it->disabled)
+                       if (elm_widget_item_disabled_get(it))
                          elm_widget_disabled_set(ic, EINA_TRUE);
                     }
                   else if (it->renamed)
@@ -2130,64 +2197,11 @@ _item_realize(Elm_Genlist_Item *it,
         evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MULTI_MOVE,
                                        _multi_move, it);
 
+        _elm_genlist_item_state_update(it, itc);
+
         if ((!it->edit_obj) &&(it->wd->edit_mode) &&
             (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->itc->edit_item_style))
           _effect_item_realize(it, EINA_FALSE);
-
-        if (itc)
-          {
-             if ((it->selected) && (it->selected != itc->selected))
-               {
-                  edje_object_signal_emit(VIEW(it),
-                                          "elm,state,selected", "elm");
-                  if (it->edit_obj)
-                    edje_object_signal_emit(it->edit_obj,
-                                            "elm,state,selected", "elm");
-               }
-             if ((it->disabled) && (it->disabled != itc->disabled))
-               {
-                  edje_object_signal_emit(VIEW(it),
-                                          "elm,state,disabled", "elm");
-                  if (it->edit_obj)
-                    edje_object_signal_emit(it->edit_obj,
-                                            "elm,state,disabled", "elm");
-               }
-             if ((it->expanded) && (it->expanded != itc->expanded))
-               {
-                  edje_object_signal_emit(VIEW(it),
-                                          "elm,state,expanded", "elm");
-                  if (it->edit_obj)
-                    edje_object_signal_emit(it->edit_obj,
-                                            "elm,state,expanded", "elm");
-               }
-          }
-        else
-          {
-             if (it->selected)
-               {
-                  edje_object_signal_emit(VIEW(it),
-                                          "elm,state,selected", "elm");
-                  if (it->edit_obj)
-                    edje_object_signal_emit(it->edit_obj,
-                                            "elm,state,selected", "elm");
-               }
-             if (it->disabled)
-               {
-                  edje_object_signal_emit(VIEW(it),
-                                          "elm,state,disabled", "elm");
-                  if (it->edit_obj)
-                    edje_object_signal_emit(it->edit_obj,
-                                            "elm,state,disabled", "elm");
-               }
-             if (it->expanded)
-               {
-                  edje_object_signal_emit(VIEW(it),
-                                          "elm,state,expanded", "elm");
-                  if (it->edit_obj)
-                    edje_object_signal_emit(it->edit_obj,
-                                            "elm,state,expanded", "elm");
-               }
-          }
      }
 
    if ((calc) && (it->wd->homogeneous) &&
@@ -2573,12 +2587,9 @@ _item_block_position(Item_Block *itb,
 
         vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
                                    cvx, cvy, cvw, cvh));
-        if ((itb->realized))
+        if ((itb->realized) && (!it->realized))
           {
-             if (vis)
-               {
-                  if (!it->realized) _item_realize(it, in, EINA_FALSE);
-               }
+             if (vis) _item_realize(it, in, EINA_FALSE);
           }
         if (it->realized)
           {
@@ -2714,7 +2725,7 @@ _calc_job(void *data)
 {
    Widget_Data *wd = data;
    Item_Block *itb, *chb = NULL;
-   Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0;
+   Evas_Coord minw = -1, minh = 0, y = 0, ow, dy = 0, vw;
    Evas_Coord pan_w = 0, pan_h = 0;
    int in = 0;
    double t0, t;
@@ -2724,6 +2735,8 @@ _calc_job(void *data)
 
    t0 = ecore_time_get();
    evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
+   elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, NULL);
+
    if (wd->w != ow)
      wd->w = ow;
 
@@ -2764,9 +2777,9 @@ _calc_job(void *data)
              minw = itb->minw;
              minw_change = EINA_TRUE;
           }
-        if (minw > wd->w)
+        if (minw > vw)
           {
-             minw = wd->w;
+             minw = vw;
              minw_change = EINA_TRUE;
           }
         itb->w = minw;
@@ -2801,7 +2814,7 @@ _calc_job(void *data)
            evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
         _sizing_eval(wd->obj);
 #ifdef ANCHOR_ITEM
-        if ((wd->anchor_item) && (wd->anchor_item->block) && (wd->auto_scroll_enabled))
+        if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scroll_enabled))
           {
              Elm_Genlist_Item *it;
              Evas_Coord it_y;
@@ -3424,7 +3437,7 @@ _mode_item_realize(Elm_Genlist_Item *it)
                   edje_object_part_swallow(it->mode_view, key, ic);
                   evas_object_show(ic);
                   elm_widget_sub_object_add(WIDGET(it), ic);
-                  if (it->disabled)
+                  if (elm_widget_item_disabled_get(it))
                     elm_widget_disabled_set(ic, EINA_TRUE);
                }
           }
@@ -3965,7 +3978,7 @@ _queue_process(Widget_Data *wd)
           {
              showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
              it->block->changed = 0;
-             if(wd->pan_changed)
+             if (wd->pan_changed)
                {
                   if (wd->calc_job) ecore_job_del(wd->calc_job);
                   wd->calc_job = NULL;
@@ -4708,7 +4721,6 @@ elm_genlist_item_disabled_set(Elm_Object_Item *it,
 EAPI Eina_Bool
 elm_genlist_item_disabled_get(const Elm_Object_Item *it)
 {
-   if (((Elm_Genlist_Item *) it)->delete_me) return EINA_FALSE;
    return elm_object_item_disabled_get(it);
 }
 
@@ -5619,6 +5631,14 @@ elm_genlist_reorder_mode_get(const Evas_Object *obj)
    return wd->reorder_mode;
 }
 
+EAPI Elm_Genlist_Item_Flags
+elm_genlist_item_flags_get(const Elm_Object_Item *it)
+{
+   ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_GENLIST_ITEM_MAX);
+   Elm_Genlist_Item *_it = (Elm_Genlist_Item *) it;
+   return _it->flags;
+}
+
 /* for gengrid as of now */
 void
 _elm_genlist_page_relative_set(Evas_Object *obj,
@@ -6195,7 +6215,7 @@ _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
    if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
    else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
 
-   if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
+   if (elm_widget_item_disabled_get(it)) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
    else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
 
 
@@ -6219,7 +6239,7 @@ _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
                        edje_object_part_swallow(it->edit_obj, key, ic);
                        evas_object_show(ic);
                        elm_widget_sub_object_add(WIDGET(it), ic);
-                       if (it->disabled)
+                       if (elm_widget_item_disabled_get(it))
                          elm_widget_disabled_set(ic, EINA_TRUE);
                     }
                }
index 0cb3670..7548101 100644 (file)
  *
  * @ingroup Genlist
  */
-   typedef enum _Elm_Genlist_Item_Flags
-     {
-        ELM_GENLIST_ITEM_NONE = 0, /**< simple item */
-        ELM_GENLIST_ITEM_SUBITEMS = (1 << 0), /**< may expand and have child items */
-        ELM_GENLIST_ITEM_GROUP = (1 << 1) /**< index of a group of items */
-     } Elm_Genlist_Item_Flags;
+typedef enum _Elm_Genlist_Item_Flags
+{
+   ELM_GENLIST_ITEM_NONE = 0, /**< simple item */
+   ELM_GENLIST_ITEM_SUBITEMS = (1 << 0), /**< may expand and have child items */
+   ELM_GENLIST_ITEM_GROUP = (1 << 1), /**< index of a group of items */
+
+   ELM_GENLIST_ITEM_MAX = (1 << 2)
+} Elm_Genlist_Item_Flags;
+
    typedef enum _Elm_Genlist_Item_Field_Flags
      {
         ELM_GENLIST_ITEM_FIELD_ALL = 0,
@@ -865,7 +868,7 @@ EAPI Elm_Object_Item             *elm_genlist_item_direct_sorted_insert(Evas_Obj
 
 /* operations to retrieve existing items */
 /**
- * Get the selectd item in the genlist.
+ * Get the selected item in the genlist.
  *
  * @param obj The genlist object
  * @return The selected item, or NULL if none is selected.
@@ -955,7 +958,7 @@ EAPI Eina_List                    *elm_genlist_realized_items_get(const Evas_Obj
 /**
  * Get the item that is at the x, y canvas coords.
  *
- * @param obj The gelinst object.
+ * @param obj The genlist object.
  * @param x The input x coordinate
  * @param y The input y coordinate
  * @param posret The position relative to the item returned here
@@ -1138,7 +1141,7 @@ EAPI Eina_Bool                     elm_genlist_item_selected_get(const Elm_Objec
  * has been expanded/contracted.
  *
  * Calling this function won't show or hide any child of this item (if it is
- * a parent). You must manually delete and create them on the callbacks fo
+ * a parent). You must manually delete and create them on the callbacks of
  * the "expanded" or "contracted" signals.
  *
  * @see elm_genlist_item_expanded_get()
@@ -1315,7 +1318,7 @@ EAPI void                          elm_genlist_item_middle_show(Elm_Object_Item
 EAPI void                          elm_genlist_item_middle_bring_in(Elm_Object_Item *it);
 
 /**
- * Tells genlist to "orphan" contents fetchs by the item class
+ * Tells genlist to "orphan" contents fetched by the item class
  *
  * @param it The item
  *
@@ -1396,7 +1399,7 @@ EAPI void                          elm_genlist_item_fields_update(Elm_Object_Ite
  * @param it The item
  * @param itc The item class for the item
  *
- * This sets another class fo the item, changing the way that it is
+ * This sets another class of the item, changing the way that it is
  * displayed. After changing the item class, elm_genlist_item_update() is
  * called on the item @p it.
  *
@@ -1512,7 +1515,7 @@ EAPI const char                   *elm_genlist_item_tooltip_style_get(const Elm_
  * @param disable If EINA_TRUE, size restrictions are disabled
  * @return EINA_FALSE on failure, EINA_TRUE on success
  *
- * This function allows a tooltip to expand beyond its parant window's canvas.
+ * This function allows a tooltip to expand beyond its parent window's canvas.
  * It will instead be limited only by the size of the display.
  */
 EAPI Eina_Bool                     elm_genlist_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable);
@@ -1523,7 +1526,7 @@ EAPI Eina_Bool                     elm_genlist_item_tooltip_window_mode_set(Elm_
  * @return If EINA_TRUE, size restrictions are disabled
  *
  * This function returns whether a tooltip is allowed to expand beyond
- * its parant window's canvas.
+ * its parent window's canvas.
  * It will instead be limited only by the size of the display.
  */
 EAPI Eina_Bool                     elm_genlist_item_tooltip_window_mode_get(const Elm_Object_Item *it);
@@ -1784,6 +1787,19 @@ EAPI void                          elm_genlist_reorder_mode_set(Evas_Object *obj
  */
 EAPI Eina_Bool                     elm_genlist_reorder_mode_get(const Evas_Object *obj);
 
+/**
+ * Get the Item's Flags
+ *
+ * @param item The genlist item
+ * @return The item flags.
+ *
+ * This function returns the item's type. Normally the item's type.
+ * If it failed, return value is ELM_GENLIST_ITEM_MAX
+ *
+ * @ingroup Genlist
+ */
+EAPI Elm_Genlist_Item_Flags        elm_genlist_item_flags_get(const Elm_Object_Item *it);
+
    EAPI void               elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode) EINA_ARG_NONNULL(1);
    EAPI Eina_Bool          elm_genlist_edit_mode_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
    EAPI void               elm_genlist_item_rename_mode_set(Elm_Object_Item *it, Eina_Bool renamed) EINA_ARG_NONNULL(1);