2012/3/22 Carsten Haitzler <ras...@rasterman.com>:
> On Thu, 22 Mar 2012 12:15:58 +0100 Leif Middelschulte
> <leif.middelschu...@gmail.com> said:
>
>> 2012/3/22 Carsten Haitzler <ras...@rasterman.com>:
>> > 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.
>> That's my fault. I misunderstood the meaning of "realized" in the
>> context. I thought elements would be immediately added and that the
>> "realized" callback would be called once they were really added (since
>> it's async).
>> I came to this conclusion because of the error I noticed in elm_list
>> (newly added item couldn't be scrolled to, because it (maybe) wasn't
>> there yet).
>>
>> Anyway, is there an event, to register for that, that makes it
>> possible to scroll the newly added element?
>
> the code as i attached it. use show or bring_in - your choice. i fixed the bug
> in svn.
thanks for almost fixing the issue ;-)
What I want:
- Be able to scroll through the list
- Scroll to a new element, when it's appended
But the code you provided hides the issue a bit and doesn't work as
you probably think it does.
I attached the code to expose it.
>
> --
> ------------- Codito, ergo sum - "I code, therefore I am" --------------
> The Rasterman (Carsten Haitzler) ras...@rasterman.com
>
--
Leif
#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 _item_content_free(void *data, Evas_Object *obj);
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 = _item_content_free};
static Evas_Object *list;
static int i = 0;
static void _btn_add_cb(void *data, Evas_Object *obj, void *event_info)
{
Elm_Object_Item *li = NULL;
int *d;
d = malloc(sizeof(int));
*d = i++;
li = elm_genlist_item_append(list, &genlist_class, d, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_bring_in(li, ELM_GENLIST_ITEM_SCROLLTO_IN);
}
static void _btn_add_iterate_cb(void *data, Evas_Object *obj, void *event_info)
{
Elm_Object_Item *li = NULL;
int *d;
d = malloc(sizeof(int));
*d = i++;
li = elm_genlist_item_append(list, &genlist_class, d, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
ecore_main_loop_iterate();
elm_genlist_item_bring_in(li, ELM_GENLIST_ITEM_SCROLLTO_IN);
}
static void _item_content_free(void *data, Evas_Object *obj)
{
free(data);
}
static Evas_Object *_item_content_get(void *data, Evas_Object *obj, const char *part)
{
Evas_Object *label;
int *n = (int*)data;
char buf[256];
if (!n || 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);
snprintf(buf, sizeof(buf), "Item %i", *n);
elm_object_text_set(label, buf);
return label;
}
int main(int argc, char *argv[])
{
Evas_Object *win, *box;
Evas_Object *btn;
int *d;
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, Bring in");
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);
btn = elm_button_add(box);
evas_object_show(btn);
elm_object_text_set(btn, "Add, Iterate, Bring in");
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_iterate_cb, NULL);
elm_box_pack_end(box, btn);
list = elm_genlist_add(box);
evas_object_show(list);
EXPAND(list);
FILL(list);
for (i = 0; i < 20; i++)
{
d = malloc(sizeof(int));
*d = i;
li = elm_genlist_item_append(list, &genlist_class, d, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
}
elm_genlist_item_bring_in(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