Commit f83645b4 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Rework lists' way of signaling empty content

parent 55bf8814
......@@ -130,7 +130,7 @@ typedef struct list_view
void (*pf_clear)(list_sys* p_sys);
const void* (*pf_get_item)(list_view_item* p_list_item);
void (*pf_set_item)(list_view_item* p_list_item, void* p_item);
Evas_Object* (*pf_get_list)(list_sys* p_sys);
Evas_Object* (*pf_get_widget)(list_sys* p_sys);
} list_view;
#endif /* INTERFACE_H_ */
......@@ -102,6 +102,7 @@ audio_list_artist_view_append_item(list_sys *p_sys, void* p_data)
/* */
elm_object_item_del_cb_set(it, free_list_item_data);
p_sys->p_view_cb->pf_updated(p_sys->p_view_cb->p_sys, false);
list_view_toggle_empty(p_sys, false);
return ali;
}
......
......@@ -36,8 +36,6 @@
struct list_sys
{
LIST_VIEW_COMMON
Evas_Object* p_box;
Evas_Object* p_empty_label;
};
struct list_view_item
......@@ -48,24 +46,6 @@ struct list_view_item
Elm_Object_Item* p_object_item;
};
void
audio_list_song_check_empty(list_sys *p_sys)
{
//TODO improve me
unsigned int count = elm_genlist_items_count(p_sys->p_list);
if (count == 0) {
elm_box_unpack_all(p_sys->p_box);
elm_box_pack_end(p_sys->p_box, p_sys->p_empty_label);
evas_object_show(p_sys->p_empty_label);
evas_object_hide(p_sys->p_list);
} else {
elm_box_unpack_all(p_sys->p_box);
elm_box_pack_end(p_sys->p_box, p_sys->p_list);
evas_object_hide(p_sys->p_empty_label);
evas_object_show(p_sys->p_list);
}
}
static void
free_list_item_data(void *data, Evas_Object *obj, void *event_info)
{
......@@ -169,8 +149,7 @@ audio_list_song_view_append_item(list_sys *p_sys, void* p_data)
/* */
elm_object_item_del_cb_set(it, free_list_item_data);
audio_list_song_check_empty(p_sys);
p_sys->p_view_cb->pf_updated(p_sys->p_view_cb->p_sys, false);
list_view_toggle_empty(p_sys, false);
return ali;
}
......@@ -184,18 +163,8 @@ audio_list_song_view_create(application* p_app, interface* p_intf, Evas_Object*
if (p_sys == NULL)
return NULL;
/* Box container */
p_sys->p_box = elm_box_add(p_parent);
evas_object_size_hint_weight_set(p_sys->p_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(p_sys->p_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(p_sys->p_box);
/* Empty list label */
p_sys->p_empty_label = elm_label_add(p_sys->p_box);
elm_object_text_set(p_sys->p_empty_label, "No audio content to show");
/* Setup common parts */
list_view_common_setup(p_view, p_sys, p_intf, p_view_cb, p_sys->p_box);
list_view_common_setup(p_view, p_sys, p_intf, p_view_cb, p_parent);
/* Connect genlist callbacks */
p_sys->p_default_item_class->func.text_get = genlist_text_get_cb;
......@@ -211,7 +180,6 @@ audio_list_song_view_create(application* p_app, interface* p_intf, Evas_Object*
p_sys->p_ctrl = audio_controller_create(p_app, p_view);
media_library_controller_refresh(p_sys->p_ctrl);
audio_list_song_check_empty(p_sys);
return p_view;
}
......@@ -91,7 +91,7 @@ create_audio_list_type(view_sys *av, audio_view_type type )
LOGD("Recycling View %i", type);
}
Evas_Object* p_list = p_view->pf_get_list(p_view->p_sys);
Evas_Object* p_list = p_view->pf_get_widget(p_view->p_sys);
Elm_Object_Item *it = elm_naviframe_item_push(av->nf_toolbar, "", NULL, NULL, p_list, NULL);
elm_naviframe_item_title_enabled_set(it, EINA_FALSE, EINA_FALSE);
evas_object_show(p_list);
......
......@@ -38,6 +38,7 @@ static void
list_view_clear(list_sys* p_list)
{
elm_genlist_clear(p_list->p_list);
list_view_toggle_empty(p_list, true);
}
static void
......@@ -49,9 +50,32 @@ list_view_destroy(list_sys* p_list)
}
static Evas_Object*
list_view_get_genlist(list_sys* p_list)
list_view_get_widget(list_sys* p_list)
{
return p_list->p_list;
return p_list->p_container;
}
void
list_view_toggle_empty(list_sys* p_list_sys, bool b_empty)
{
if (p_list_sys->b_empty == b_empty)
return;
p_list_sys->b_empty = b_empty;
Evas_Object* p_list = p_list_sys->p_list;
if (b_empty)
{
elm_box_unpack_all(p_list_sys->p_container);
elm_box_pack_end(p_list_sys->p_container, p_list_sys->p_empty_label);
evas_object_show(p_list_sys->p_empty_label);
evas_object_hide(p_list);
}
else
{
elm_box_unpack_all(p_list_sys->p_container);
elm_box_pack_end(p_list_sys->p_container, p_list);
evas_object_show(p_list);
evas_object_hide(p_list_sys->p_empty_label);
}
}
void
......@@ -60,8 +84,15 @@ list_view_common_setup(list_view* p_view, list_sys* p_list, interface* p_intf, v
p_list->p_intf = p_intf;
p_list->p_view_cb = p_view_cb;
/* Container box */
p_list->p_container = elm_box_add(p_parent);
/* Empty list label */
p_list->p_empty_label = elm_label_add(p_list->p_container);
elm_object_text_set(p_list->p_empty_label, "No content to display");
/* Create genlist */
p_list->p_list = elm_genlist_add(p_parent);
p_list->p_list = elm_genlist_add(p_list->p_container);
elm_scroller_single_direction_set(p_list->p_list, ELM_SCROLLER_SINGLE_DIRECTION_HARD);
elm_genlist_homogeneous_set(p_list->p_list, EINA_TRUE);
elm_genlist_mode_set(p_list->p_list, ELM_LIST_COMPRESS);
......@@ -73,5 +104,8 @@ list_view_common_setup(list_view* p_view, list_sys* p_list, interface* p_intf, v
/* Setup common callbacks */
p_view->pf_del = &list_view_destroy;
p_view->pf_clear = &list_view_clear;
p_view->pf_get_list = &list_view_get_genlist;
p_view->pf_get_widget = &list_view_get_widget;
/* Ensure the initial update takes place (keep in mind that b_empty is 0 initialized) */
list_view_toggle_empty(p_list, true);
}
......@@ -34,9 +34,15 @@
media_library_controller* p_ctrl; \
interface* p_intf; \
Elm_Genlist_Item_Class* p_default_item_class; \
view_sys_cb* p_view_cb;
view_sys_cb* p_view_cb; \
Evas_Object* p_container; \
Evas_Object* p_empty_label; \
bool b_empty;
void
list_view_common_setup(list_view* p_view, list_sys* p_list, interface* p_intf, view_sys_cb* p_view_cb, Evas_Object* p_parent);
void
list_view_toggle_empty(list_sys* p_view, bool b_empty);
#endif // LIST_VIEW_PRIVATE_H_
......@@ -49,28 +49,8 @@ struct list_view_item
struct list_sys
{
LIST_VIEW_COMMON
Evas_Object* p_box;
Evas_Object* p_empty_label;
};
static void
genlist_update_empty_view(list_sys *p_sys)
{
//TODO improve me
unsigned int count = elm_genlist_items_count(p_sys->p_list);
if (count == 0) {
elm_box_unpack_all(p_sys->p_box);
elm_box_pack_end(p_sys->p_box, p_sys->p_empty_label);
evas_object_show(p_sys->p_empty_label);
evas_object_hide(p_sys->p_list);
} else {
elm_box_unpack_all(p_sys->p_box);
elm_box_pack_end(p_sys->p_box, p_sys->p_list);
evas_object_hide(p_sys->p_empty_label);
evas_object_show(p_sys->p_list);
}
}
void
genlist_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
{
......@@ -214,8 +194,7 @@ video_view_append_item(list_sys *p_list, void* p_data)
}
/* */
elm_object_item_del_cb_set(vli->p_object_item, free_list_item);
genlist_update_empty_view(p_list);
p_list->p_view_cb->pf_updated(p_list->p_view_cb->p_sys, false);
list_view_toggle_empty(p_list, false);
return vli;
}
......@@ -230,13 +209,8 @@ video_view_list_create(interface *p_intf, Evas_Object *p_parent, view_sys_cb* p_
if (p_sys == NULL)
return NULL;
p_sys->p_box = p_parent;
/* Empty list label */
p_sys->p_empty_label = elm_label_add(p_sys->p_box);
elm_object_text_set(p_sys->p_empty_label, "No video content to show");
list_view_common_setup(p_view, p_sys, p_intf, p_view_cb, p_sys->p_box);
list_view_common_setup(p_view, p_sys, p_intf, p_view_cb, p_parent);
/* Genlist class */
p_sys->p_default_item_class->func.text_get = genlist_text_get_cb;
......@@ -257,8 +231,6 @@ video_view_list_create(interface *p_intf, Evas_Object *p_parent, view_sys_cb* p_
p_sys->p_ctrl = video_controller_create(intf_get_application(p_intf), p_view);
genlist_update_empty_view(p_sys);
return p_view;
}
......@@ -102,6 +102,7 @@ video_view_has_menu(view_sys *p_view_sys)
static void
video_video_content_updated_cb(view_sys* p_view_sys, bool b_empty)
{
}
interface_view*
......@@ -120,16 +121,9 @@ create_video_view(interface *intf, Evas_Object *parent)
view->pf_event = video_view_callback;
view->pf_has_menu = video_view_has_menu;
p_sys->p_list = video_view_list_create(intf, parent, p_sys->p_view_cb);
/* Box container */
Evas_Object *box = elm_box_add(parent);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(box);
p_sys->p_list = video_view_list_create(intf, box, p_sys->p_view_cb);
view->view = box;
view->view = p_sys->p_list->pf_get_widget(p_sys->p_list->p_sys);
/* */
return view;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment