From: Hyoyoung Chang <hyoyoung@gmail.com>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 7 Mar 2012 16:22:58 +0000 (16:22 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 7 Mar 2012 16:22:58 +0000 (16:22 +0000)
Subject: [E-devel] [patch] elm_genlist - add item_select_mode_set/get

I added two apis for item selecting mode.
It almost same with elm_genlist_select_mode.

+EAPI void
+elm_genlist_item_select_mode_set(Elm_Object_Item *it,
+                                 Elm_Object_Select_Mode_Type mode)
+EAPI Elm_Object_Select_Mode_Type
+elm_genlist_item_select_mode_get(const Elm_Object_Item *it)

And display_only apis is unfied with item_select_mode.

+EINA_DEPRECATED EAPI void
elm_genlist_item_display_only_set(Elm_Object_Item *it, Eina_Bool
display_only);
+EINA_DEPRECATED EAPI Eina_Bool
elm_genlist_item_display_only_get(const Elm_Object_Item *it);

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

src/bin/test_genlist.c
src/examples/genlist_example_04.c
src/lib/elm_deprecated.h
src/lib/elm_gen_common.h
src/lib/elm_general.h
src/lib/elm_gengrid.h
src/lib/elm_genlist.c
src/lib/elm_genlist.h

index 9df322b..1aed887 100644 (file)
@@ -1574,7 +1574,7 @@ test_genlist8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
                                                  ELM_GENLIST_ITEM_GROUP,
                                                  gl_sel/* func */,
                                                  (void *)(long)(i * 10)/* func data */);
-             elm_genlist_item_display_only_set(git, EINA_TRUE);
+             elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
           }
         else if (git)
           {
@@ -1703,7 +1703,8 @@ test_genlist9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
    git = elm_genlist_item_append(gl, &itc_group,
                                  (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
                                  NULL/* func data */);
-   elm_genlist_item_display_only_set(git, EINA_TRUE);
+   elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
    elm_genlist_item_append(gl, itc1,
                            (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
                            NULL/* func data */);
@@ -1716,7 +1717,8 @@ test_genlist9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in
    git = elm_genlist_item_append(gl, &itc_group,
                                  (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */,
                                  NULL/* func data */);
-   elm_genlist_item_display_only_set(git, EINA_TRUE);
+   elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
    elm_genlist_item_append(gl, itc1,
                            (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_TREE, gl4_sel/* func */,
                            NULL/* func data */);
index fcbcf04..553bfa2 100644 (file)
@@ -322,7 +322,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__)
                                                  (void *)(long)nitems++, NULL,
                                                  ELM_GENLIST_ITEM_GROUP,
                                                  _item_sel_cb, NULL);
-             elm_genlist_item_display_only_set(glg, EINA_TRUE);
+             elm_genlist_item_select_mode_set(git, ELM_OBJECT_DISPLAY_ONLY_SELECT);
           }
         else
           {
index bf10045..7a7e78f 100644 (file)
@@ -6162,6 +6162,39 @@ EINA_DEPRECATED EAPI Eina_Bool         elm_web_navigate_possible(Evas_Object *ob
 EINA_DEPRECATED EAPI void                          elm_genlist_compress_mode_set(Evas_Object *obj, Eina_Bool compress);
 
 /**
+ * Sets the display only state of an item.
+ *
+ * @param it The item
+ * @param display_only @c EINA_TRUE if the item is display only, @c
+ * EINA_FALSE otherwise.
+ *
+ * A display only item cannot be selected or unselected. It is for
+ * display only and not selecting or otherwise clicking, dragging
+ * etc. by the user, thus finger size rules will not be applied to
+ * this item.
+ *
+ * It's good to set group index items to display only state.
+ *
+ * @see elm_genlist_item_display_only_get()
+ *
+ * @deprecated elm_genlist_item_display_only_set()
+ */
+EINA_DEPRECATED EAPI void                          elm_genlist_item_display_only_set(Elm_Object_Item *it, Eina_Bool display_only);
+
+/**
+ * Get the display only state of an item
+ *
+ * @param it The item
+ * @return @c EINA_TRUE if the item is display only, @c
+ * EINA_FALSE otherwise.
+ *
+ * @see elm_genlist_item_display_only_set()
+ *
+ * @deprecated elm_genlist_item_display_only_get()
+ */
+EINA_DEPRECATED EAPI Eina_Bool                     elm_genlist_item_display_only_get(const Elm_Object_Item *it);
+
+/**
  * Get whether the compress mode is enabled.
  *
  * @param obj The genlist object
index 45601c3..b349ef2 100644 (file)
@@ -51,6 +51,7 @@ struct Elm_Gen_Item
    Ecore_Cb                  unsel_cb, unhighlight_cb, unrealize_cb;
 
    int                       position;
+   Elm_Object_Select_Mode    select_mode;
 
    Eina_Bool                 position_update : 1;
    Eina_Bool                 want_unrealize : 1;
index 4d04ff2..39fd1bd 100644 (file)
@@ -99,7 +99,7 @@ typedef enum
    ELM_OBJECT_SELECT_MODE_DEFAULT = 0, /**< default select mode */
    ELM_OBJECT_SELECT_MODE_ALWAYS, /**< always select mode */
    ELM_OBJECT_SELECT_MODE_NONE, /**< no select mode */
-
+   ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY, /**< no select mode with no finger size rule*/
    ELM_OBJECT_SELECT_MODE_MAX
 } Elm_Object_Select_Mode;
 
index b344d0f..e4b86aa 100644 (file)
  * Grid cells will only have their selection smart callbacks called
  * when firstly getting selected. Any further clicks will do
  * nothing, unless you enable the "always select mode", with
- * elm_gengrid_always_select_mode_set(), thus making every click to
- * issue selection callbacks. elm_gengrid_no_select_mode_set() will
+ * elm_gengrid_select_mode_set() as ELM_OBJECT_ALWAYS_SELECT,
+ * thus making every click to issue selection callbacks.
+ * elm_gengrid_select_mode_set() as ELM_OBJECT_NO_SELECT will
  * turn off the ability to select items entirely in the widget and
  * they will neither appear selected nor call the selection smart
  * callbacks.
index 860018c..26d1f52 100644 (file)
@@ -691,7 +691,8 @@ _item_highlight(Elm_Gen_Item *it)
        (it->wd->no_highlight) ||
        (it->generation < it->wd->generation) ||
        (it->highlighted) || elm_widget_item_disabled_get(it) ||
-       (it->display_only) || (it->item->mode_view))
+       (it->select_mode == ELM_OBJECT_SELECT_MODE_NONE) || (it->item->mode_view) ||
+       (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
      return;
    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");
@@ -990,7 +991,7 @@ _mouse_move(void        *data,
           }
         return;
      }
-   if (!it->display_only)
+   if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
      elm_coords_finger_size_adjust(1, &minw, 1, &minh);
    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
    x = ev->cur.canvas.x - x;
@@ -1056,7 +1057,8 @@ _long_press(void *data)
    Eina_List *list, *l;
 
    it->long_timer = NULL;
-   if (elm_widget_item_disabled_get(it) || (it->dragging) || (it->display_only))
+   if (elm_widget_item_disabled_get(it) || (it->dragging) ||
+       (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
      return ECORE_CALLBACK_CANCEL;
    it->wd->longpressed = EINA_TRUE;
    evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
@@ -1095,7 +1097,8 @@ _swipe(Elm_Gen_Item *it)
    int i, sum = 0;
 
    if (!it) return;
-   if ((it->display_only) || elm_widget_item_disabled_get(it)) return;
+   if ((it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
+       elm_widget_item_disabled_get(it)) return;
    it->wd->swipe = EINA_FALSE;
    for (i = 0; i < it->wd->movements; i++)
      {
@@ -1303,7 +1306,8 @@ _mouse_down(void        *data,
    it->wd->wasselected = it->selected;
    _item_highlight(it);
    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
-     if ((!elm_widget_item_disabled_get(it)) && (!it->display_only))
+     if ((!elm_widget_item_disabled_get(it)) &&
+         (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
        {
           evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
           evas_object_smart_callback_call(WIDGET(it), SIG_ACTIVATED, it);
@@ -1412,7 +1416,8 @@ _mouse_up(void        *data,
                _item_block_unrealize(it->item->block);
           }
      }
-   if (elm_widget_item_disabled_get(it) || (dragged) || (it->display_only))
+   if (elm_widget_item_disabled_get(it) || (dragged) ||
+       (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
      return;
    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
    if (it->wd->multi)
@@ -2102,12 +2107,12 @@ _item_realize(Elm_Gen_Item *it,
           {
              Evas_Coord mw = -1, mh = -1;
 
-             if (!it->display_only)
+             if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
              if (it->wd->mode == ELM_LIST_COMPRESS) mw = it->wd->prev_viewport_w;
              edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw,
                                                   mh);
-             if (!it->display_only)
+             if (it->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
                elm_coords_finger_size_adjust(1, &mw, 1, &mh);
              it->item->w = it->item->minw = mw;
              it->item->h = it->item->minh = mh;
@@ -4801,30 +4806,33 @@ elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it)
    return ((Elm_Gen_Item *)it)->item->expanded_depth;
 }
 
-EAPI void
+EINA_DEPRECATED EAPI void
 elm_genlist_item_display_only_set(Elm_Object_Item  *it,
                                   Eina_Bool         display_only)
 {
    ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
-   Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
    display_only = !!display_only;
-   if (_it->display_only == display_only) return;
-   if (_it->generation < _it->wd->generation) return;
-   _it->display_only = display_only;
-   _it->item->mincalcd = EINA_FALSE;
-   _it->item->updateme = EINA_TRUE;
-   if (_it->item->block) _it->item->block->updateme = EINA_TRUE;
-   if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
-   _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
+
+   if (display_only)
+     elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+   else
+     {
+        Elm_Object_Select_Mode oldmode = elm_genlist_item_select_mode_get(it);
+        if (oldmode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
+          elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
+     }
 }
 
-EAPI Eina_Bool
+EINA_DEPRECATED EAPI Eina_Bool
 elm_genlist_item_display_only_get(const Elm_Object_Item *it)
 {
    ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
    Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
    if (_it->generation < _it->wd->generation) return EINA_FALSE;
-   return _it->display_only;
+   Elm_Object_Select_Mode oldmode = elm_genlist_item_select_mode_get(it);
+   if (oldmode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
+     return EINA_TRUE;
+   return EINA_FALSE;
 }
 
 static Eina_Bool _elm_genlist_item_compute_coordinates(
@@ -5714,6 +5722,38 @@ elm_genlist_highlight_mode_get(const Evas_Object *obj)
    return !wd->no_highlight;
 }
 
+EAPI void
+elm_genlist_item_select_mode_set(Elm_Object_Item *it,
+                                 Elm_Object_Select_Mode mode)
+{
+   ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+   Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
+   if (!_it) return;
+   if (_it->generation < _it->wd->generation) return;
+   if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
+     return;
+   if (_it->select_mode != mode)
+     _it->select_mode = mode;
+
+   if (_it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
+     {
+        _it->item->mincalcd = EINA_FALSE;
+        _it->item->updateme = EINA_TRUE;
+        if (_it->item->block) _it->item->block->updateme = EINA_TRUE;
+        if (_it->wd->update_job) ecore_job_del(_it->wd->update_job);
+        _it->wd->update_job = ecore_job_add(_update_job, _it->wd);
+     }
+}
+
+EAPI Elm_Object_Select_Mode
+elm_genlist_item_select_mode_get(const Elm_Object_Item *it)
+{
+   ELM_OBJ_ITEM_CHECK_OR_RETURN(it, ELM_OBJECT_SELECT_MODE_MAX);
+   Elm_Gen_Item *_it = (Elm_Gen_Item *)it;
+   if (!_it) return ELM_OBJECT_SELECT_MODE_MAX;
+   return _it->select_mode;
+}
+
 /* for gengrid as of now */
 void
 _elm_genlist_page_relative_set(Evas_Object *obj,
index 9e4d668..dd38564 100644 (file)
  *
  * Items will only call their selection func and callback when first becoming
  * selected. Any further clicks will do nothing, unless you enable always
- * select with elm_genlist_always_select_mode_set(). This means even if
- * selected, every click will make the selected callbacks be called.
- * elm_genlist_no_select_mode_set() will turn off the ability to select
- * items entirely and they will neither appear selected nor call selected
- * callback functions.
+ * select with elm_genlist_select_mode_set() as ELM_OBJECT_ALWAYS_SELECT.
+ * This means even if selected, every click will make the selected callbacks
+ * be called. elm_genlist_select_mode_set() as ELM_OBJECT_NO_SELECT will
+ * turn off the ability to select items entirely and they will neither
+ * appear selected nor call selected callback functions.
  *
  * Remember that you can create new styles and add your own theme augmentation
  * per application with elm_theme_extension_add(). If you absolutely must
@@ -1505,41 +1505,6 @@ EAPI Eina_Bool                     elm_genlist_item_expanded_get(const Elm_Objec
 EAPI int                           elm_genlist_item_expanded_depth_get(const Elm_Object_Item *it);
 
 /**
- * Sets the display only state of an item.
- *
- * @param it The item
- * @param display_only @c EINA_TRUE if the item is display only, @c
- * EINA_FALSE otherwise.
- *
- * A display only item cannot be selected or unselected. It is for
- * display only and not selecting or otherwise clicking, dragging
- * etc. by the user, thus finger size rules will not be applied to
- * this item.
- *
- * It's good to set group index items to display only state.
- *
- * @see elm_genlist_item_display_only_get()
- *
- * @ingroup Genlist
- */
-//XXX: elm_genlist_item_no_select_mode_set()?
-EAPI void                          elm_genlist_item_display_only_set(Elm_Object_Item *it, Eina_Bool display_only);
-
-/**
- * Get the display only state of an item
- *
- * @param it The item
- * @return @c EINA_TRUE if the item is display only, @c
- * EINA_FALSE otherwise.
- *
- * @see elm_genlist_item_display_only_set()
- *
- * @ingroup Genlist
- */
-//XXX: elm_genlist_item_no_select_mode_get()?
-EAPI Eina_Bool                     elm_genlist_item_display_only_get(const Elm_Object_Item *it);
-
-/**
  * Unset all contents fetched by the item class
  *
  * @param it The item
@@ -1853,5 +1818,49 @@ EAPI void               elm_genlist_highlight_mode_set(Evas_Object *obj, Eina_Bo
 EAPI Eina_Bool          elm_genlist_highlight_mode_get(const Evas_Object *obj);
 
 /**
+ * Set the genlist item's select mode.
+ *
+ * @param it The genlist item object
+ * @param mode The select mode
+ *
+ * elm_genlist_select_mode_set() changes item's select mode.
+ * - ELM_OBJECT_NORMAL_SELECT : The item will only call their selection func and
+ *      callback when first becoming selected. Any further clicks will
+ *      do nothing, unless you set always select mode.
+ * - ELM_OBJECT_ALWAYS_SELECT : This means that, even if selected,
+ *      every click will make the selected callbacks be called.
+ * - ELM_OBJECT_NO_SELECT : This will turn off the ability to select the item
+ *      entirely and they will neither appear selected nor call selected
+ *      callback functions.
+ * - ELM_OBJECT_DISPLAY_ONLY_SELECT : This will apply no-finger-size rule with
+ *      with ELM_OBJECT_NO_SELECT. No-finger-size rule makes an item can be
+ *      smaller than lower limit. In some touch or small screen devices,
+ *      clickable objects should be bigger than human touch point device
+ *      (your finger). So it is enabled, the item can be smaller than
+ *      predefined finger-size value. And the item will be updated.
+ *
+ * @see elm_genlist_item_select_mode_get()
+ *
+ * @ingroup Genlist
+ */
+EAPI void
+elm_genlist_item_select_mode_set(Elm_Object_Item *it,
+                                 Elm_Object_Select_Mode mode);
+
+/**
+ * Get the genlist item's select mode.
+ *
+ * @param it The genlist item object
+ * @return The select mode
+ * (If getting mode is failed, it returns ELM_OBJECT_SELECT_MODE_MAX)
+ *
+ * @see elm_genlist_item_select_mode_set()
+ *
+ * @ingroup Genlist
+ */
+EAPI Elm_Object_Select_Mode
+elm_genlist_item_select_mode_get(const Elm_Object_Item *it);
+
+/**
  * @}
  */