On Wed, 21 Mar 2012 15:32:41 +0100 Leif Middelschulte
<leif.middelschu...@gmail.com> said:

> Hello there,
> 
> thanks to mike, I switched from elm_list to elm_genlist for my little
> project, for which I need to scroll to the bottom most element of a
> list, once it's realized.
> 
> Turns out that genlist can't do this, while elm_list can _if_ you
> iterate the main loop once.
> 
> Code that demonstrates it is attached.

wtf? why are u bringing in the item when its realized? the behavior is totally
bunk as a result. add all the items then just bring in  the last one.
elm_genlist_item_show() works just fine. bring_in has a bug. attached code that
works with item_show.

-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    ras...@rasterman.com

#include <Elementary.h>

#define EXPAND(o) evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND)
#define FILL(o) evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL)

static Evas_Object *_item_content_get(void *data, Evas_Object *obj, const char *part);
static void _on_done(void *data, Evas_Object *obj, void *event_info);

static Elm_Genlist_Item_Class genlist_class = { .item_style = "default", .func.content_get = _item_content_get, .func.del = NULL};

static Evas_Object *list;

static void _btn_add_cb(void *data, Evas_Object *obj, void *event_info)
{
   elm_genlist_item_append(list, &genlist_class, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
}


static Evas_Object *_item_content_get(void *data, Evas_Object *obj, const char *part)
{
   Evas_Object *label;
   char timebuf[256];
   double ts;

   if (strcmp(part, "elm.swallow.icon"))
     return NULL;

   printf("called for part %s\n", part);

   label = elm_label_add(obj);
   evas_object_show(label);
   EXPAND(label);

   ts = ecore_time_get();
   strftime(timebuf, sizeof(timebuf), "[%H:%M:%S]",
         localtime((time_t[]){ ts }));
   elm_object_text_set(label, timebuf);

   return label;
}

int main(int argc, char *argv[])
{
   Evas_Object *win, *box;
   Evas_Object *btn;
   unsigned int j;
   Elm_Object_Item *li = NULL;

   elm_init(argc, argv);

   win = elm_win_util_standard_add("Elm Playground", "Elm Playground - List append test");
   evas_object_show(win);
   evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);

   box = elm_box_add(win);
   evas_object_show(box);
   EXPAND(box);
   FILL(box);

   btn = elm_button_add(box);
   evas_object_show(btn);
   elm_object_text_set(btn, "Add item");
   evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
   evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.0);
   evas_object_smart_callback_add(btn, "clicked", _btn_add_cb, NULL);
   elm_box_pack_end(box, btn);

   list = elm_genlist_add(box);
   evas_object_show(list);
   EXPAND(list);
   FILL(list);
   
   for (j = 0; j < 20; j++)
     {
        li = elm_genlist_item_append(list, &genlist_class, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
     }
   elm_genlist_item_show(li, ELM_GENLIST_ITEM_SCROLLTO_IN);
   
   elm_box_pack_end(box, list);

   elm_win_resize_object_add(win, box);
   evas_object_resize(win, 200, 400);

   elm_run();

   elm_shutdown();

   return 0;
}

   static void
_on_done(void *data, Evas_Object *obj, void *event_info)
{
   elm_exit();
}
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to