forked from enlightenment/efl
efl_ui_list: make it work with item_container
This also refactors the example a little bit. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9385
This commit is contained in:
parent
a6543fb68f
commit
59d684284b
|
@ -30,7 +30,7 @@ _list_selected(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||||
Eo *item = ev->info, *tmp;
|
Eo *item = ev->info, *tmp;
|
||||||
printf("list item [%p:%d] is %s\n", item, efl_ui_item_index_get(item), (efl_ui_item_selected_get(item)? "selected" : "unselected"));
|
printf("list item [%p:%d] is %s\n", item, efl_ui_item_index_get(item), (efl_ui_item_selected_get(item)? "selected" : "unselected"));
|
||||||
|
|
||||||
Eina_Iterator *selects = efl_ui_list_selected_items_get(list);
|
Eina_Iterator *selects = efl_ui_item_container_selected_items_get(list);
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(selects, tmp)
|
EINA_ITERATOR_FOREACH(selects, tmp)
|
||||||
printf("selected [%p:%d] ", tmp, efl_ui_item_index_get(tmp));
|
printf("selected [%p:%d] ", tmp, efl_ui_item_index_get(tmp));
|
||||||
|
@ -82,18 +82,18 @@ _anim_radio_changed(void *data, const Efl_Event *ev EINA_UNUSED)
|
||||||
static void
|
static void
|
||||||
_scrl_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
_scrl_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Efl_Ui_List_Item *item = efl_ui_list_last_selected_item_get(priv_d.list);
|
Efl_Ui_List_Item *item = efl_ui_item_container_last_selected_item_get(priv_d.list);
|
||||||
printf("show [%d:%p] [%d]\n", efl_ui_item_index_get(item), item, priv_d.anim);
|
printf("show [%d:%p] [%d]\n", efl_ui_item_index_get(item), item, priv_d.anim);
|
||||||
efl_ui_list_item_scroll(priv_d.list, item, priv_d.anim);
|
efl_ui_item_container_item_scroll(priv_d.list, item, priv_d.anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_scrl_align_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
_scrl_align_btn_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Efl_Ui_List_Item *item = efl_ui_list_last_selected_item_get(priv_d.list);
|
Efl_Ui_List_Item *item = efl_ui_item_container_last_selected_item_get(priv_d.list);
|
||||||
double align = efl_ui_range_value_get(priv_d.slider);
|
double align = efl_ui_range_value_get(priv_d.slider);
|
||||||
printf("show [%d:%p] [%.2lf], [%d]\n", efl_ui_item_index_get(item), item, align, priv_d.anim);
|
printf("show [%d:%p] [%.2lf], [%d]\n", efl_ui_item_index_get(item), item, align, priv_d.anim);
|
||||||
efl_ui_list_item_scroll_align(priv_d.list, item, align, priv_d.anim);
|
efl_ui_item_container_item_scroll_align(priv_d.list, item, align, priv_d.anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI_MAIN int
|
EAPI_MAIN int
|
||||||
|
@ -108,10 +108,12 @@ elm_main(int argc EINA_UNUSED, char **argv)
|
||||||
char buf[256];
|
char buf[256];
|
||||||
Eina_Bool placeholder = EINA_FALSE;
|
Eina_Bool placeholder = EINA_FALSE;
|
||||||
|
|
||||||
win = elm_win_util_standard_add("list", "list");
|
|
||||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
|
||||||
elm_win_autodel_set(win, EINA_TRUE);
|
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
|
||||||
efl_gfx_entity_size_set(win, EINA_SIZE2D(400, 800));
|
efl_text_set(efl_added, "Efl.Ui.List"),
|
||||||
|
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
|
||||||
|
|
||||||
|
|
||||||
wbox = efl_add(EFL_UI_BOX_CLASS, win);
|
wbox = efl_add(EFL_UI_BOX_CLASS, win);
|
||||||
efl_ui_layout_orientation_set(wbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
|
efl_ui_layout_orientation_set(wbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
|
||||||
|
@ -286,8 +288,10 @@ elm_main(int argc EINA_UNUSED, char **argv)
|
||||||
efl_ui_radio_state_value_set(radio, 1);
|
efl_ui_radio_state_value_set(radio, 1);
|
||||||
efl_pack_end(rbox, radio);
|
efl_pack_end(rbox, radio);
|
||||||
efl_pack_end(bbox, rbox);
|
efl_pack_end(bbox, rbox);
|
||||||
|
efl_ui_radio_group_selected_value_set(rbox, 0);
|
||||||
efl_event_callback_add(rbox, EFL_UI_RADIO_GROUP_EVENT_VALUE_CHANGED, _anim_radio_changed, rbox);
|
efl_event_callback_add(rbox, EFL_UI_RADIO_GROUP_EVENT_VALUE_CHANGED, _anim_radio_changed, rbox);
|
||||||
|
|
||||||
|
|
||||||
rbox = efl_add(EFL_UI_BOX_CLASS, bbox);
|
rbox = efl_add(EFL_UI_BOX_CLASS, bbox);
|
||||||
efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
|
efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,89 +1,9 @@
|
||||||
import efl_ui_list_item;
|
import efl_ui_list_item;
|
||||||
|
|
||||||
class @beta Efl.Ui.List extends Efl.Ui.Layout_Base implements
|
class @beta Efl.Ui.List extends Efl.Ui.Item_Container
|
||||||
Efl.Ui.Scrollable_Interactive,
|
|
||||||
Efl.Ui.Scrollbar,
|
|
||||||
Efl.Pack_Linear, Efl.Pack_Layout,
|
|
||||||
Efl.Ui.Selectable,
|
|
||||||
Efl.Ui.Multi_Selectable,
|
|
||||||
Efl.Gfx.Arrangement
|
|
||||||
{
|
{
|
||||||
[[Simple list widget with Pack interface.]]
|
[[Simple list widget with Pack interface.]]
|
||||||
methods {
|
|
||||||
item_scroll {
|
|
||||||
[[scroll move the item to show in the viewport.]]
|
|
||||||
params {
|
|
||||||
@in item: Efl.Ui.List_Item; [[Target item.]]
|
|
||||||
@in animation: bool; [[Boolean value for animation of scroll move.]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
item_scroll_align {
|
|
||||||
[[scroll move the item to show at the align position of the viewport.]]
|
|
||||||
params {
|
|
||||||
@in item: Efl.Ui.List_Item; [[Target item.]]
|
|
||||||
@in align: double; [[align value in Viewport.]]
|
|
||||||
@in animation: bool; [[Boolean value for animation of scroll move.]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@property last_selected_item {
|
|
||||||
[[Property data of last selected item.]]
|
|
||||||
get {}
|
|
||||||
values {
|
|
||||||
return: Efl.Ui.List_Item; [[last selected item of list.]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selected_items_get {
|
|
||||||
[[Get the selected items iterator. The iterator sequence will be decided by selection.]]
|
|
||||||
return: iterator<Efl.Ui.List_Item> @owned @no_unused; [[Iterator covered by selected items list.
|
|
||||||
user have to free the iterator after used.]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
implements {
|
implements {
|
||||||
//Efl.Object
|
|
||||||
Efl.Object.constructor;
|
Efl.Object.constructor;
|
||||||
Efl.Object.finalize;
|
|
||||||
Efl.Object.invalidate;
|
|
||||||
|
|
||||||
//Efl.Canvas
|
|
||||||
Efl.Canvas.Group.group_calculate;
|
|
||||||
|
|
||||||
//Efl.Container
|
|
||||||
Efl.Container.content_iterate;
|
|
||||||
Efl.Container.content_count;
|
|
||||||
|
|
||||||
//Efl.Ui.Layout_Orientable.orientation { get; set; } //TODO
|
|
||||||
|
|
||||||
//Efl.Ui.Widget
|
|
||||||
Efl.Ui.Widget.theme_apply;
|
|
||||||
|
|
||||||
//Efl.Ui.Focus
|
|
||||||
//Efl.Ui.Focus.Object.on_focus_update;
|
|
||||||
|
|
||||||
//Efl.Pack
|
|
||||||
Efl.Pack.pack_clear;
|
|
||||||
Efl.Pack.unpack_all;
|
|
||||||
Efl.Pack.unpack;
|
|
||||||
Efl.Pack.pack;
|
|
||||||
Efl.Pack_Linear.pack_begin;
|
|
||||||
Efl.Pack_Linear.pack_end;
|
|
||||||
Efl.Pack_Linear.pack_before;
|
|
||||||
Efl.Pack_Linear.pack_after;
|
|
||||||
Efl.Pack_Linear.pack_at;
|
|
||||||
Efl.Pack_Linear.pack_content_get;
|
|
||||||
Efl.Pack_Linear.pack_unpack_at;
|
|
||||||
Efl.Pack_Linear.pack_index_get;
|
|
||||||
Efl.Pack_Layout.layout_update;
|
|
||||||
Efl.Pack_Layout.layout_request;
|
|
||||||
Efl.Gfx.Arrangement.content_padding { get; set; }
|
|
||||||
|
|
||||||
//Efl.Ui.Scrollable
|
|
||||||
Efl.Ui.Scrollable_Interactive.match_content { set; }
|
|
||||||
|
|
||||||
//Efl.Ui.Multi_Selectable
|
|
||||||
Efl.Ui.Multi_Selectable.select_mode {get; set;}
|
|
||||||
}
|
|
||||||
composite {
|
|
||||||
Efl.Ui.Scrollable_Interactive;
|
|
||||||
Efl.Ui.Scrollbar;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
#ifndef EFL_UI_LIST_PRIVATE_H
|
|
||||||
#define EFL_UI_LIST_PRIVATE_H
|
|
||||||
|
|
||||||
#include "Elementary.h"
|
|
||||||
|
|
||||||
typedef struct _Efl_Ui_List_Data
|
|
||||||
{
|
|
||||||
// Eo Objects
|
|
||||||
Eo *box; /* Internal box for Efl.Pack support */
|
|
||||||
Eo *pan; /* Internal pan for scroll */
|
|
||||||
Eo *smanager; /* Scroll Manager for support scroll with pan */
|
|
||||||
|
|
||||||
struct {
|
|
||||||
Efl_Ui_List_Item *item; /* Scroll target item */
|
|
||||||
double align; /* Item scroll aligned position.
|
|
||||||
-1 is for default case of scroll in */
|
|
||||||
Eina_Bool anim : 1; /* boolean data for animation on scroll */
|
|
||||||
} scroll; /* Item scroll values for deferred operation */
|
|
||||||
|
|
||||||
Eina_List *items; /* All item list for internal maintaining */
|
|
||||||
Eina_List *selected; /* Selected items list */
|
|
||||||
Efl_Ui_List_Item *last_selected; /* latest selected item */
|
|
||||||
|
|
||||||
Efl_Ui_Select_Mode select_mode; /* Select mode for items
|
|
||||||
with single or multiple seleciton */
|
|
||||||
|
|
||||||
// Boolean Data
|
|
||||||
Eina_Bool freeze_want : 1; /* Flag for Scroll freezing */
|
|
||||||
Eina_Bool match_content_w: 1; /* Flag for size matching on content width.
|
|
||||||
it will disable horizontal scroll */
|
|
||||||
Eina_Bool match_content_h: 1; /* Flag for size matching on content height.
|
|
||||||
it will disable vertical scroll */
|
|
||||||
Eina_Bool pan_resized : 1; /* Flag for pan resized.
|
|
||||||
This value is used for checking scroll is
|
|
||||||
calculated after initialized */
|
|
||||||
} Efl_Ui_List_Data;
|
|
||||||
|
|
||||||
typedef struct _Item_Iterator
|
|
||||||
{
|
|
||||||
Eina_Iterator iterator;
|
|
||||||
Eina_List *list;
|
|
||||||
Eina_Iterator *real_iterator;
|
|
||||||
Eo *object;
|
|
||||||
} Item_Iterator;
|
|
||||||
|
|
||||||
|
|
||||||
#define EFL_UI_LIST_DATA_GET(o, pd) \
|
|
||||||
Efl_Ui_List_Data * pd = efl_data_scope_safe_get(o, EFL_UI_LIST_CLASS)
|
|
||||||
|
|
||||||
#define EFL_UI_LIST_DATA_GET_OR_RETURN(o, ptr, ...) \
|
|
||||||
EFL_UI_LIST_DATA_GET(o, ptr); \
|
|
||||||
if (EINA_UNLIKELY(!ptr)) \
|
|
||||||
{ \
|
|
||||||
ERR("No widget data for object %p (%s)", \
|
|
||||||
o, evas_object_type_get(o)); \
|
|
||||||
return __VA_ARGS__; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define EFL_UI_LIST_CHECK(obj) \
|
|
||||||
if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_LIST_CLASS))) \
|
|
||||||
return
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -355,7 +355,6 @@ elementary_headers_unstable = [
|
||||||
'efl_ui_video_private.h',
|
'efl_ui_video_private.h',
|
||||||
'efl_ui_item_private.h',
|
'efl_ui_item_private.h',
|
||||||
'efl_ui_list_item_private.h',
|
'efl_ui_list_item_private.h',
|
||||||
'efl_ui_list_private.h',
|
|
||||||
'efl_ui_grid_item_private.h',
|
'efl_ui_grid_item_private.h',
|
||||||
'efl_ui_list_view_private.h',
|
'efl_ui_list_view_private.h',
|
||||||
'efl_ui_list_view_seg_array.h',
|
'efl_ui_list_view_seg_array.h',
|
||||||
|
|
Loading…
Reference in New Issue