From: Enlightenment S. <no-...@en...> - 2012-07-31 22:06:43
|
Log: [elm] List now inheritable. Author: glima Date: 2012-07-31 15:06:36 -0700 (Tue, 31 Jul 2012) New Revision: 74688 Trac: http://trac.enlightenment.org/e/changeset/74688 Added: trunk/elementary/src/lib/elm_widget_list.h Modified: trunk/elementary/src/lib/Makefile.am trunk/elementary/src/lib/elm_list.c Modified: trunk/elementary/src/lib/Makefile.am =================================================================== --- trunk/elementary/src/lib/Makefile.am 2012-07-31 22:06:31 UTC (rev 74687) +++ trunk/elementary/src/lib/Makefile.am 2012-07-31 22:06:36 UTC (rev 74688) @@ -56,6 +56,7 @@ elm_widget_icon.h \ elm_widget_image.h \ elm_widget_layout.h \ +elm_widget_list.h \ elm_widget_map.h \ elm_widget_menu.h \ elm_widget_naviframe.h \ Modified: trunk/elementary/src/lib/elm_list.c =================================================================== --- trunk/elementary/src/lib/elm_list.c 2012-07-31 22:06:31 UTC (rev 74687) +++ trunk/elementary/src/lib/elm_list.c 2012-07-31 22:06:36 UTC (rev 74688) @@ -1,116 +1,9 @@ #include <Elementary.h> #include "elm_priv.h" -#include "elm_interface_scrollable.h" -#include "elm_widget_layout.h" +#include "elm_widget_list.h" -static const char LIST_SMART_NAME[] = "elm_list"; +EAPI const char ELM_LIST_SMART_NAME[] = "elm_list"; -#define SWIPE_MOVES 12 - -#define ELM_LIST_DATA_GET(o, sd) \ - Elm_List_Smart_Data * sd = evas_object_smart_data_get(o) - -#define ELM_LIST_DATA_GET_OR_RETURN(o, ptr) \ - ELM_LIST_DATA_GET(o, ptr); \ - if (!ptr) \ - { \ - CRITICAL("No widget data for object %p (%s)", \ - o, evas_object_type_get(o)); \ - return; \ - } - -#define ELM_LIST_DATA_GET_OR_RETURN_VAL(o, ptr, val) \ - ELM_LIST_DATA_GET(o, ptr); \ - if (!ptr) \ - { \ - CRITICAL("No widget data for object %p (%s)", \ - o, evas_object_type_get(o)); \ - return val; \ - } - -#define ELM_LIST_CHECK(obj) \ - if (!obj || !elm_widget_type_check((obj), LIST_SMART_NAME, __func__)) \ - return - -#define ELM_LIST_ITEM_CHECK(it) \ - ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \ - ELM_LIST_CHECK(it->base.widget); \ - if (((Elm_List_Item *)it)->deleted) \ - { \ - ERR("ERROR: " #it " has been DELETED.\n"); \ - return; \ - } - -#define ELM_LIST_ITEM_CHECK_OR_RETURN(it, ...) \ - ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \ - ELM_LIST_CHECK(it->base.widget) __VA_ARGS__; \ - if (((Elm_List_Item *)it)->deleted) \ - { \ - ERR("ERROR: " #it " has been DELETED.\n"); \ - return __VA_ARGS__; \ - } - -typedef struct _Elm_List_Smart_Data Elm_List_Smart_Data; -typedef struct _Elm_List_Item Elm_List_Item; - -struct _Elm_List_Smart_Data -{ - Elm_Layout_Smart_Data base; /* base widget smart data as - * first member obligatory, as - * we're inheriting from it */ - - Evas_Object *box, *hit_rect; - const Elm_Scrollable_Smart_Interface *s_iface; - - Eina_List *items, *selected, *to_delete; - Elm_Object_Item *last_selected_item; - Evas_Coord minw[2], minh[2]; - Elm_Object_Select_Mode select_mode; - int movements; - int walking; - Elm_List_Mode h_mode; - Elm_List_Mode mode; - - struct - { - Evas_Coord x, y; - } history[SWIPE_MOVES]; - - Eina_Bool was_selected : 1; - Eina_Bool fix_pending : 1; - Eina_Bool longpressed : 1; - Eina_Bool scr_minw : 1; - Eina_Bool scr_minh : 1; - Eina_Bool on_hold : 1; - Eina_Bool multi : 1; - Eina_Bool swipe : 1; -}; - -struct _Elm_List_Item -{ - ELM_WIDGET_ITEM; - - Elm_List_Smart_Data *sd; - - Ecore_Timer *swipe_timer; - Ecore_Timer *long_timer; - Evas_Object *icon, *end; - Evas_Smart_Cb func; - - const char *label; - Eina_List *node; - - Eina_Bool is_separator : 1; - Eina_Bool highlighted : 1; - Eina_Bool dummy_icon : 1; - Eina_Bool dummy_end : 1; - Eina_Bool selected : 1; - Eina_Bool deleted : 1; - Eina_Bool is_even : 1; - Eina_Bool fixed : 1; - Eina_Bool even : 1; -}; - static const char SIG_ACTIVATED[] = "activated"; static const char SIG_CLICKED_DOUBLE[] = "clicked,double"; static const char SIG_SELECTED[] = "selected"; @@ -149,8 +42,9 @@ static void _items_fix(Evas_Object *); EVAS_SMART_SUBCLASS_IFACE_NEW - (LIST_SMART_NAME, _elm_list, Elm_Layout_Smart_Class, Elm_Layout_Smart_Class, - elm_layout_smart_class_get, _smart_callbacks, _smart_interfaces); + (ELM_LIST_SMART_NAME, _elm_list, Elm_List_Smart_Class, + Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks, + _smart_interfaces); static inline void _elm_list_item_free(Elm_List_Item *it) @@ -1119,7 +1013,7 @@ if (!sd->was_selected) _item_unselect(it); } - if (sd->movements == SWIPE_MOVES) sd->swipe = EINA_TRUE; + if (sd->movements == ELM_LIST_SWIPE_MOVES) sd->swipe = EINA_TRUE; else { sd->history[sd->movements].x = ev->cur.canvas.x; @@ -1712,7 +1606,7 @@ } static void -_elm_list_smart_set_user(Elm_Layout_Smart_Class *sc) +_elm_list_smart_set_user(Elm_List_Smart_Class *sc) { ELM_WIDGET_CLASS(sc)->base.add = _elm_list_smart_add; ELM_WIDGET_CLASS(sc)->base.del = _elm_list_smart_del; @@ -1732,6 +1626,24 @@ ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_list_smart_sizing_eval; } +EAPI const Elm_List_Smart_Class * +elm_list_smart_class_get(void) +{ + static Elm_List_Smart_Class _sc = + ELM_LIST_SMART_CLASS_INIT_NAME_VERSION(ELM_LIST_SMART_NAME); + static const Elm_List_Smart_Class *class = NULL; + Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc; + + if (class) + return class; + + _elm_list_smart_set(&_sc); + esc->callbacks = _smart_callbacks; + class = &_sc; + + return class; +} + EAPI Evas_Object * elm_list_add(Evas_Object *parent) { |