Dear All,

Hi~
Thanks for your response always!

I have changed the "elm_diskselector" based on your comments.
The "displayed item count" is described by using theme file.
And example source - example.tar.gz - have attached.
(If you have an example of the example :), then please inform and send me.)

By the way, I have something wondering about this way.
If several "elm_diskselector" are added with different "displayed item
count" on one same parent,
then several different theme file have to be existed. In this case, API
would be more efficient.

I would like to know more about your opinion. Thanks

Sincerely,
Shinwoo Kim.


2011/3/19 Daniel Juyung Seo <seojuyu...@gmail.com>

> Check the _theme_hook().
> :)
>
> Thanks.
> Daniel Juyung Seo (SeoZ)
>
> On Sat, Mar 19, 2011 at 1:53 PM, cnook <kimci...@gmail.com> wrote:
> > Dear All,
> >
> > Hi~
> >
> > Thanks for your response.
> >
> > I have tried to use "data.item" and edje_object_data_get() API. It works
> > fine. :)
> >
> > But I met a problem. When I use a new style for elm_diskselector,
> > edje_object_data_get() cannot retrieve "data.item" of new style.
> >
> > Only original (default) "data.item" value is retrieved.
> >
> > Would you please let me know what I forget?
> >
> > Thanks.
> >
> >
> > Sincerely,
> > Shinwoo Kim.
> >
> >
> > 2011/3/18 Daniel Juyung Seo <seojuyu...@gmail.com>
> >>
> >> +3 !
> >> Using group data in theme looks better because it reduces source-gui
> >> dependences.
> >>
> >> group { name: "xx";
> >>   data.item: "count" "3";
> >>
> >> You can fetch this data from c source using edje_object_data_get() API.
> >> Please check other widgets for a reference.
> >>
> >> I checked the patch very briefly and here are some comments.
> >>
> >> 1. Indentation.
> >> ex) line 250 in elm_diskselector.diff
> >>
> >> 2. Blank lines.
> >>   There are 2 blank lines at the end of diff file. 396, 397 lines.
> >>
> >> 3. Diff file.
> >>   I think there is no rule for this but you can merge two diff files
> >> to one diff file
> >>   because they are patches for a one feature and one
> library(elementary).
> >>
> >> 4. Sample code.
> >>   It will be better to have a sample code for a new feature in
> >> elementary_test.
> >>
> >> Other than that, looks ok :)
> >>
> >> Thanks.
> >> Daniel Juyung Seo (SeoZ)
> >>
> >> On Fri, Mar 18, 2011 at 5:57 AM, Tiago Falcao <
> develo...@tiagofalcao.com>
> >> wrote:
> >> > +2 !
> >> >
> >> > When had see this widget in first time, I imagined it with option to
> >> > many items but ever configured in theme.
> >> > If i'm right, this widget is a lot dependent of code and less of theme
> >> > :(
> >> >
> >> > What you thing about this, Shinwoo Kim?
> >> > Gustavo suggested the easiest way, use group data.
> >> >
> >> > Thanks.
> >> >
> >> >
> >> > On Thu, Mar 17, 2011 at 4:47 PM, Gustavo Sverzut Barbieri
> >> > <barbi...@profusion.mobi> wrote:
> >> >> On Thu, Mar 17, 2011 at 7:42 PM, Bruno Dilly <bdi...@profusion.mobi>
> >> >> wrote:
> >> >>> On Thu, Mar 17, 2011 at 10:45 AM, cnook <kimci...@gmail.com> wrote:
> >> >>>> Dear All,
> >> >>>
> >> >>> Hi Shinwoo Kim,
> >> >>>
> >> >>>>
> >> >>>> This is Shinwoo Kim, learned that I could contribute to EFL! :)
> >> >>>> I'm pleased to inform you that the patch for the
> "elm_diskselector".
> >> >>>>
> >> >>>> Until now, the "elm_diskselector" only display 3 items at once,
> >> >>>> if you accept this patch, the "elm_diskselector" can display more
> >> >>>> than 3
> >> >>>> items.
> >> >>>
> >> >>> Displaying more than 3 items is a nice improvement.
> >> >>> What do you think about the idea of getting the number of items to
> be
> >> >>> displayed from the theme ?
> >> >>>
> >> >>> Anyway, there is a typo on documentation (param num). Maybe a getter
> >> >>> could be useful as well.
> >> >>
> >> >> +1 to get it from theme!
> >> >>
> >> >> I did something similar for ephoto in some older version, it had
> >> >> couple of swallow parts defined, like "elm.swallow.p%d", and a
> >> >> data.item: "count" "3", thus it would fill 3 swallows.
> >> >>
> >> >> I believe this is something up to the theme as it has the knowledge
> on
> >> >> how to pack more items.
> >> >>
> >> >>
> >> >> --
> >> >> Gustavo Sverzut Barbieri
> >> >> http://profusion.mobi embedded systems
> >> >> --------------------------------------
> >> >> MSN: barbi...@gmail.com
> >> >> Skype: gsbarbieri
> >> >> Mobile: +55 (19) 9225-2202
> >> >>
> >> >>
> >> >>
> ------------------------------------------------------------------------------
> >> >> Colocation vs. Managed Hosting
> >> >> A question and answer guide to determining the best fit
> >> >> for your organization - today and in the future.
> >> >> http://p.sf.net/sfu/internap-sfd2d
> >> >> _______________________________________________
> >> >> enlightenment-devel mailing list
> >> >> enlightenment-devel@lists.sourceforge.net
> >> >> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Tiago Rezende Campos Falcão
> >> > http://www.tiagofalcao.com
> >> > --
> >> > ProFUSION | embedded systems
> >> > Computer Systems Laboratory - IC - Unicamp
> >> > Grupo Pró Software Livre - Unicamp
> >> > Laboratory of Information Systems - IC - Unicamp
> >> >
> >> >
> >> >
> ------------------------------------------------------------------------------
> >> > Colocation vs. Managed Hosting
> >> > A question and answer guide to determining the best fit
> >> > for your organization - today and in the future.
> >> > http://p.sf.net/sfu/internap-sfd2d
> >> > _______________________________________________
> >> > enlightenment-devel mailing list
> >> > enlightenment-devel@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >> >
> >
> >
>

Attachment: example.tar.gz
Description: GNU Zip compressed data

Index: src/lib/elm_diskselector.c
===================================================================
--- src/lib/elm_diskselector.c	(revision 57931)
+++ src/lib/elm_diskselector.c	(working copy)
@@ -19,6 +19,10 @@
 # define MAX(a, b) (((a) > (b)) ? (a) : (b))
 #endif
 
+#ifndef CEIL
+#define CEIL(a) (((a) % 2 != 0) ? ((a) / 2 + 1) : ((a) / 2))
+#endif
+
 typedef struct _Widget_Data Widget_Data;
 
 struct _Widget_Data
@@ -35,7 +39,9 @@
    Elm_Diskselector_Item *last;
    Eina_List *items;
    Eina_List *r_items;
-   int item_count, len_threshold, len_side;
+   Eina_List *over_items;
+   Eina_List *under_items;
+   int item_count, len_threshold, len_side, display_item_num;
    Ecore_Idler *idler;
    Ecore_Idler *check_idler;
    Eina_Bool init:1;
@@ -67,6 +73,8 @@
 static void _sub_del(void *data, Evas_Object * obj, void *event_info);
 static void _round_items_del(Widget_Data *wd);
 static void _scroller_move_cb(void *data, Evas_Object *obj, void *event_info);
+static void _item_click_cb(void *data, Evas_Object *obj, void *event_info);
+static void _selected_item_indicate(Elm_Diskselector_Item *it);
 
 static const char SIG_SELECTED[] = "selected";
 static const Evas_Smart_Cb_Description _signals[] = {
@@ -91,12 +99,12 @@
 
    evas_object_geometry_get(wd->scroller, NULL, NULL, &w, &h);
    if (wd->round)
-     evas_object_resize(wd->main_box, w / 3 * (wd->item_count + 4), h);
+     evas_object_resize(wd->main_box, w / wd->display_item_num * (wd->item_count + CEIL(wd->display_item_num) * 2), h);
    else
-     evas_object_resize(wd->main_box, w / 3 * (wd->item_count + 2), h);
+     evas_object_resize(wd->main_box, w / wd->display_item_num * (wd->item_count + CEIL(wd->display_item_num)), h);
 
    elm_smart_scroller_paging_set(wd->scroller, 0, 0,
-                                 (int)(w / 3), 0);
+                                 (int)(w / wd->display_item_num), 0);
 
    if (!wd->idler)
      wd->idler = ecore_idler_add(_move_scroller, data);
@@ -124,7 +132,10 @@
    evas_object_show(it->base.view);
 
    if (it->label)
+     {
         edje_object_part_text_set(it->base.view, "elm.text", it->label);
+        edje_object_signal_callback_add(it->base.view, "elm,action,click", "", _item_click_cb, it);
+     }
    if (it->icon)
      {
         evas_object_size_hint_min_set(it->icon, 24, 24);
@@ -153,6 +164,10 @@
    str = edje_object_data_get(wd->right_blank, "len_threshold");
    if (str) wd->len_threshold = atoi(str);
    else wd->len_threshold = 0;
+
+   str = edje_object_data_get(wd->right_blank, "display_count");
+   if (str) wd->display_item_num = atoi(str);
+   else wd->display_item_num = 3;
 }
 
 static void
@@ -167,6 +182,8 @@
 _del_pre_hook(Evas_Object * obj)
 {
    Elm_Diskselector_Item *it;
+   Eina_List *l;
+
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
 
@@ -199,6 +216,26 @@
         free(wd->first);
      }
 
+   EINA_LIST_FOREACH(wd->under_items, l, it)
+     {
+        if (it)
+          {
+             eina_stringshare_del(it->label);
+             evas_object_del(wd->first->base.view);
+             free(it);
+          }
+     }
+
+   EINA_LIST_FOREACH(wd->over_items, l, it)
+   {
+     if (it)
+        {
+           eina_stringshare_del(it->label);
+           evas_object_del(wd->first->base.view);
+           free(it);
+        }
+   }
+
    EINA_LIST_FREE(wd->items, it) _item_del(it);
    eina_list_free(wd->r_items);
 }
@@ -238,6 +275,10 @@
                                    elm_widget_style_get(obj));
           }
      }
+
+   if (wd->right_blank)
+     _elm_theme_object_set(obj, wd->right_blank, "diskselector", "item", elm_widget_style_get(obj));
+
    _theme_data_get(wd);
    _sizing_eval(obj);
 }
@@ -274,6 +315,7 @@
    if (!it) return;
    Widget_Data *wd = elm_widget_data_get(it->base.widget);
    wd->selected_item = it;
+   _selected_item_indicate(wd->selected_item);
    if (it->func) it->func((void *)it->base.data, it->base.widget, it);
    evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
 }
@@ -438,6 +480,45 @@
 }
 
 static void
+_selected_item_indicate(Elm_Diskselector_Item *it)
+{
+   Elm_Diskselector_Item *item;
+   Eina_List *l;
+   Widget_Data *wd;
+   wd = elm_widget_data_get(it->base.widget);
+
+   if (!wd) return;
+
+   EINA_LIST_FOREACH(wd->r_items, l, item)
+     {
+        if (strcmp(item->label, it->label) == 0) edje_object_signal_emit(item->base.view, "elm,state,selected", "elm");
+        else
+           edje_object_signal_emit(item->base.view, "elm,state,default", "elm");
+     }
+}
+
+static void
+_item_click_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Elm_Diskselector_Item *it = data;
+
+   if (!it) return;
+
+   Widget_Data *wd;
+   wd = elm_widget_data_get(it->base.widget);
+
+   if (!wd) return;
+
+   if (wd->selected_item != it)
+     {
+        wd->selected_item = it;
+        _selected_item_indicate(wd->selected_item);
+     }
+
+   if (it->func) it->func((void*) it->base.data, it->base.widget, it);
+}
+
+static void
 _scroller_move_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Evas_Coord x, y, w, h, bw;
@@ -449,13 +530,13 @@
    if (wd->round)
      {
         evas_object_geometry_get(wd->main_box, NULL, NULL, &bw, NULL);
-        if (x > w / 3 * (wd->item_count + 1))
-          elm_smart_scroller_child_region_show(wd->scroller,
-                                               x - w / 3 * wd->item_count,
+        if (x > w / wd->display_item_num * (wd->item_count + (wd->display_item_num % 2)))
+           elm_smart_scroller_child_region_show(wd->scroller,
+                                               x - w / wd->display_item_num * wd->item_count,
                                                y, w, h);
         else if (x < 0)
-          elm_smart_scroller_child_region_show(wd->scroller,
-                                               x + w / 3 * wd->item_count,
+           elm_smart_scroller_child_region_show(wd->scroller,
+                                               x + w / wd->display_item_num * wd->item_count,
                                                y, w, h);
      }
 }
@@ -522,7 +603,7 @@
      }
 
    evas_object_geometry_get(wd->scroller, NULL, &y, &w, &h);
-   elm_smart_scroller_child_region_show(wd->scroller, w / 3 * i, y, w, h);
+   elm_smart_scroller_child_region_show(wd->scroller, w / wd->display_item_num * i, y, w, h);
    _select_item(dit);
    if (wd->idler)
      {
@@ -549,6 +630,9 @@
 static void
 _round_items_del(Widget_Data *wd)
 {
+   Eina_List *l;
+   Elm_Diskselector_Item * it;
+
    _round_item_del(wd, wd->last);
    wd->last = NULL;
    _round_item_del(wd, wd->s_last);
@@ -557,6 +641,18 @@
    wd->second = NULL;
    _round_item_del(wd, wd->first);
    wd->first = NULL;
+
+   EINA_LIST_FOREACH(wd->under_items, l, it)
+     {
+        _round_item_del(wd, it);
+        it = NULL;
+     }
+
+   EINA_LIST_FOREACH(wd->over_items, l, it)
+     {
+        _round_item_del(wd, it);
+        it = NULL;
+     }
 }
 
 static void
@@ -564,7 +660,8 @@
 {
    Elm_Diskselector_Item *dit;
    Elm_Diskselector_Item *it;
-
+   Elm_Diskselector_Item *temp_it;
+   int i = 0;
    dit = it = eina_list_nth(wd->items, 0);
    if (!dit) return;
 
@@ -587,6 +684,16 @@
         wd->r_items = eina_list_append(wd->r_items, wd->second);
      }
 
+   // if more than 3 itmes should be displayed
+   for(i = 2; i < CEIL(wd->display_item_num); i++)
+     {
+        it = eina_list_nth(wd->items, i);
+        if (!it) it = dit;
+        temp_it = _item_new(it->base.widget, it->icon, it->label, it->func, it->base.data);
+        wd->over_items = eina_list_append(wd->over_items, temp_it);
+        wd->r_items = eina_list_append(wd->r_items, temp_it);
+     }
+
    it = eina_list_nth(wd->items, wd->item_count - 1);
    if (!it)
      it = dit;
@@ -608,6 +715,16 @@
         wd->s_last->node = it->node;
         wd->r_items = eina_list_prepend(wd->r_items, wd->s_last);
      }
+
+   // if more than 3 itmes should be displayed
+   for(i = 3; i <= CEIL(wd->display_item_num); i++)
+     {
+        it = eina_list_nth(wd->items, wd->item_count - i);
+        if (!it) it = dit;
+        temp_it = _item_new(it->base.widget, it->icon, it->label, it->func, it->base.data);
+        wd->under_items = eina_list_append(wd->under_items, temp_it);
+        wd->r_items = eina_list_prepend(wd->r_items, temp_it);
+     }
 }
 
 /**
@@ -735,6 +852,9 @@
 EAPI void
 elm_diskselector_round_set(Evas_Object * obj, Eina_Bool round)
 {
+   Eina_List *elist;
+   Elm_Diskselector_Item *it;
+
    ELM_CHECK_WIDTYPE(obj, widtype);
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
@@ -759,10 +879,19 @@
           elm_box_pack_start(wd->main_box, wd->last->base.view);
         if (wd->s_last)
           elm_box_pack_start(wd->main_box, wd->s_last->base.view);
+
+        // if more than 3 items should be displayed
+        EINA_LIST_FOREACH(wd->under_items, elist, it)
+           elm_box_pack_start(wd->main_box, it->base.view);
+
         if (wd->first)
           elm_box_pack_end(wd->main_box, wd->first->base.view);
         if (wd->second)
           elm_box_pack_end(wd->main_box, wd->second->base.view);
+
+        // if more than 3 items should be displayed
+        EINA_LIST_FOREACH(wd->over_items, elist, it)
+           elm_box_pack_end(wd->main_box, it->base.view);
      }
    else
      {
@@ -772,6 +901,8 @@
         eina_list_free(wd->r_items);
         wd->r_items = NULL;
      }
+
+   _selected_item_indicate(wd->selected_item);
    _sizing_eval(obj);
 }
 
@@ -1014,6 +1145,9 @@
 {
    ELM_DISKSELECTOR_ITEM_CHECK_OR_RETURN(it);
    Elm_Diskselector_Item *dit;
+   Elm_Diskselector_Item *item;
+   Eina_List *l;
+   int i = 0;
    Widget_Data *wd = elm_widget_data_get(it->base.widget);
    if (!wd) return;
 
@@ -1031,6 +1165,8 @@
           wd->selected_item = dit;
         else
           wd->selected_item = eina_list_nth(wd->items, 1);
+
+        _selected_item_indicate(wd->selected_item);
      }
 
    _item_del(it);
@@ -1044,6 +1180,12 @@
              evas_object_hide(wd->second->base.view);
              evas_object_hide(wd->last->base.view);
              evas_object_hide(wd->s_last->base.view);
+
+             EINA_LIST_FOREACH(wd->under_items, l, item)
+                evas_object_hide(item->base.view);
+
+             EINA_LIST_FOREACH(wd->over_items, l, item)
+                evas_object_hide(item->base.view);
           }
         else
           {
@@ -1061,6 +1203,15 @@
                   edje_object_part_text_set(wd->second->base.view, "elm.text",
                                             wd->second->label);
                }
+             // if more than 3 itmes should be displayed
+             for(i = 2; i < CEIL(wd->display_item_num); i++)
+               {
+                  dit = eina_list_nth(wd->items, i);
+                  item = eina_list_nth(wd->over_items, i - 2);
+                  eina_stringshare_replace(&item->label, dit->label);
+                  edje_object_part_text_set(item->base.view, "elm.text", item->label);
+               }
+
              dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 1);
              if (dit)
                {
@@ -1075,6 +1226,14 @@
                   edje_object_part_text_set(wd->s_last->base.view, "elm.text",
                                             wd->s_last->label);
                }
+             // if more than 3 itmes should be displayed
+             for(i = 3; i <= CEIL(wd->display_item_num); i++)
+               {
+                  dit = eina_list_nth(wd->items, wd->item_count - i);
+                  item = eina_list_nth(wd->under_items, i - 3);
+                  eina_stringshare_replace(&item->label, dit->label);
+                  edje_object_part_text_set(item->base.view, "elm.text", item->label);
+               }
           }
      }
    wd->check_idler = ecore_idler_add(_check_string, wd);
@@ -1156,7 +1315,10 @@
    if ((wd->selected_item == it) && (!selected))
      wd->selected_item = eina_list_data_get(wd->items);
    else
-     wd->selected_item = it;
+     {
+        wd->selected_item = it;
+        _selected_item_indicate(wd->selected_item);
+     }
 
    if (!wd->idler)
      ecore_idler_add(_move_scroller, it->base.widget);
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to