this commit marks step one of The Gengrid & Genlist Unification Project. these poor widget brothers were separated at birth, never knowing that they were almost exactly the same.
from here, it should be trivial to continually move more and more code into elm_gen.c and reduce duplication. ideally we should be aiming for an elm_gen_* api where you differentiate between list/grid with style or something since the apis are almost identical SVN revision: 64245
This commit is contained in:
parent
0766bdaf33
commit
35c8f40547
|
@ -7901,6 +7901,32 @@ extern "C" {
|
|||
* @}
|
||||
*/
|
||||
|
||||
typedef struct Elm_Gen_Item Elm_Gen_Item;
|
||||
typedef struct _Elm_Gen_Item_Class Elm_Gen_Item_Class;
|
||||
typedef struct _Elm_Gen_Item_Class_Func Elm_Gen_Item_Class_Func; /**< Class functions for gen item classes. */
|
||||
typedef char *(*Elm_Gen_Item_Label_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< Label fetching class function for gen item classes. */
|
||||
typedef Evas_Object *(*Elm_Gen_Item_Icon_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< Icon fetching class function for gen item classes. */
|
||||
typedef Eina_Bool (*Elm_Gen_Item_State_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< State fetching class function for gen item classes. */
|
||||
typedef void (*Elm_Gen_Item_Del_Cb) (void *data, Evas_Object *obj); /**< Deletion class function for gen item classes. */
|
||||
|
||||
/**
|
||||
* @struct _Elm_Gen_Item_Class
|
||||
*
|
||||
* Gen item class definition. See @ref Gen_Item_Class for
|
||||
* field details.
|
||||
*/
|
||||
struct _Elm_Gen_Item_Class
|
||||
{
|
||||
const char *item_style;
|
||||
struct _Elm_Gen_Item_Class_Func
|
||||
{
|
||||
Elm_Gen_Item_Label_Get_Cb label_get;
|
||||
Elm_Gen_Item_Icon_Get_Cb icon_get;
|
||||
Elm_Gen_Item_State_Get_Cb state_get;
|
||||
Elm_Gen_Item_Del_Cb del;
|
||||
} func;
|
||||
}; /**< #Elm_Gen_Item_Class member definitions */
|
||||
|
||||
/**
|
||||
* @defgroup Gengrid Gengrid (Generic grid)
|
||||
*
|
||||
|
@ -8112,8 +8138,10 @@ extern "C" {
|
|||
*/
|
||||
|
||||
typedef struct _Elm_Gengrid_Item_Class Elm_Gengrid_Item_Class; /**< Gengrid item class definition structs */
|
||||
typedef struct _Elm_Gengrid_Item_Class_Func Elm_Gengrid_Item_Class_Func; /**< Class functions for gengrid item classes. */
|
||||
#define Elm_Gengrid_Item_Class Elm_Gen_Item_Class
|
||||
typedef struct _Elm_Gengrid_Item Elm_Gengrid_Item; /**< Gengrid item handles */
|
||||
#define Elm_Gengrid_Item Elm_Gen_Item /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */
|
||||
typedef struct _Elm_Gengrid_Item_Class_Func Elm_Gengrid_Item_Class_Func; /**< Class functions for gengrid item classes. */
|
||||
typedef char *(*Elm_Gengrid_Item_Label_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< Label fetching class function for gengrid item classes. */
|
||||
typedef Evas_Object *(*Elm_Gengrid_Item_Icon_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< Icon fetching class function for gengrid item classes. */
|
||||
typedef Eina_Bool (*Elm_Gengrid_Item_State_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< State fetching class function for gengrid item classes. */
|
||||
|
@ -8136,7 +8164,7 @@ extern "C" {
|
|||
Elm_Gengrid_Item_Del_Cb del;
|
||||
} func;
|
||||
}; /**< #Elm_Gengrid_Item_Class member definitions */
|
||||
|
||||
#define Elm_Gengrid_Item_Class_Func Elm_Gen_Item_Class_Func
|
||||
/**
|
||||
* Add a new gengrid widget to the given parent Elementary
|
||||
* (container) object
|
||||
|
@ -18109,7 +18137,9 @@ extern "C" {
|
|||
ELM_GENLIST_ITEM_GROUP = (1 << 1) /**< index of a group of items */
|
||||
} Elm_Genlist_Item_Flags;
|
||||
typedef struct _Elm_Genlist_Item_Class Elm_Genlist_Item_Class; /**< Genlist item class definition structs */
|
||||
#define Elm_Genlist_Item_Class Elm_Gen_Item_Class
|
||||
typedef struct _Elm_Genlist_Item Elm_Genlist_Item; /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */
|
||||
#define Elm_Genlist_Item Elm_Gen_Item /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */
|
||||
typedef struct _Elm_Genlist_Item_Class_Func Elm_Genlist_Item_Class_Func; /**< Class functions for genlist item class */
|
||||
typedef char *(*Elm_Genlist_Item_Label_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< Label fetching class function for genlist item classes. */
|
||||
typedef Evas_Object *(*Elm_Genlist_Item_Icon_Get_Cb) (void *data, Evas_Object *obj, const char *part); /**< Icon fetching class function for genlist item classes. */
|
||||
|
@ -18129,7 +18159,7 @@ extern "C" {
|
|||
struct _Elm_Genlist_Item_Class
|
||||
{
|
||||
const char *item_style; /**< style of this class. */
|
||||
struct
|
||||
struct Elm_Genlist_Item_Class_Func
|
||||
{
|
||||
Elm_Genlist_Item_Label_Get_Cb label_get; /**< Label fetching class function for genlist item classes.*/
|
||||
Elm_Genlist_Item_Icon_Get_Cb icon_get; /**< Icon fetching class function for genlist item classes. */
|
||||
|
@ -18137,7 +18167,7 @@ extern "C" {
|
|||
Elm_Genlist_Item_Del_Cb del; /**< Deletion class function for genlist item classes. */
|
||||
} func;
|
||||
};
|
||||
|
||||
#define Elm_Genlist_Item_Class_Func Elm_Gen_Item_Class_Func
|
||||
/**
|
||||
* Add a new genlist widget to the given parent Elementary
|
||||
* (container) object
|
||||
|
|
|
@ -72,6 +72,8 @@ elm_flip.c \
|
|||
elm_flipselector.c \
|
||||
elm_font.c \
|
||||
elm_frame.c \
|
||||
elm_gen.c \
|
||||
elm_gen.h \
|
||||
elm_gengrid.c \
|
||||
elm_genlist.c \
|
||||
elm_gesture_layer.c \
|
||||
|
|
|
@ -0,0 +1,310 @@
|
|||
#include <Elementary.h>
|
||||
#include <Elementary_Cursor.h>
|
||||
#include "elm_priv.h"
|
||||
#include "elm_gen.h"
|
||||
|
||||
struct _Widget_Data
|
||||
{
|
||||
Eina_Inlist_Sorted_State *state;
|
||||
Evas_Object *obj;
|
||||
Eina_List *selected;
|
||||
Eina_List *group_items;
|
||||
Eina_Inlist *items; /* inlist of all items */
|
||||
Elm_Gen_Item *reorder_it; /* item currently being repositioned */
|
||||
Ecore_Job *calc_job;
|
||||
int walking;
|
||||
};
|
||||
|
||||
static const char *
|
||||
_item_label_hook(Elm_Gen_Item *it, const char *part)
|
||||
{
|
||||
if (!it->itc->func.label_get) return NULL;
|
||||
return edje_object_part_text_get(VIEW(it), part);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static Eina_Bool
|
||||
_deselect_all_items(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
while (wd->selected)
|
||||
elm_gengrid_item_selected_set(wd->selected->data, EINA_FALSE);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_multi_select_left(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
|
||||
Elm_Gengrid_Item *prev = elm_gengrid_item_prev_get(wd->last_selected_item);
|
||||
if (!prev) return EINA_TRUE;
|
||||
if (elm_gengrid_item_selected_get(prev))
|
||||
{
|
||||
elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
|
||||
wd->last_selected_item = prev;
|
||||
elm_gengrid_item_show(wd->last_selected_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_gengrid_item_selected_set(prev, EINA_TRUE);
|
||||
elm_gengrid_item_show(prev);
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_multi_select_right(Widget_Data *wd)
|
||||
{
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
|
||||
Elm_Gengrid_Item *next = elm_gengrid_item_next_get(wd->last_selected_item);
|
||||
if (!next) return EINA_TRUE;
|
||||
if (elm_gengrid_item_selected_get(next))
|
||||
{
|
||||
elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE);
|
||||
wd->last_selected_item = next;
|
||||
elm_gengrid_item_show(wd->last_selected_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_gengrid_item_selected_set(next, EINA_TRUE);
|
||||
elm_gengrid_item_show(next);
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_multi_select_up(Widget_Data *wd)
|
||||
{
|
||||
unsigned int i;
|
||||
Eina_Bool r = EINA_TRUE;
|
||||
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
|
||||
for (i = 0; (r) && (i < wd->nmax); i++)
|
||||
r &= _item_multi_select_left(wd);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_multi_select_down(Widget_Data *wd)
|
||||
{
|
||||
unsigned int i;
|
||||
Eina_Bool r = EINA_TRUE;
|
||||
|
||||
if (!wd->selected) return EINA_FALSE;
|
||||
|
||||
for (i = 0; (r) && (i < wd->nmax); i++)
|
||||
r &= _item_multi_select_right(wd);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_single_select_up(Widget_Data *wd)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
Elm_Gengrid_Item *prev;
|
||||
|
||||
if (!wd->selected)
|
||||
{
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
|
||||
while ((prev) && (prev->delete_me))
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
|
||||
elm_gengrid_item_selected_set(prev, EINA_TRUE);
|
||||
elm_gengrid_item_show(prev);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
|
||||
|
||||
if (!prev) return EINA_FALSE;
|
||||
|
||||
for (i = 1; i < wd->nmax; i++)
|
||||
{
|
||||
Elm_Gengrid_Item *tmp = elm_gengrid_item_prev_get(prev);
|
||||
if (!tmp) return EINA_FALSE;
|
||||
prev = tmp;
|
||||
}
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
||||
elm_gengrid_item_selected_set(prev, EINA_TRUE);
|
||||
elm_gengrid_item_show(prev);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_single_select_down(Widget_Data *wd)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
Elm_Gengrid_Item *next;
|
||||
|
||||
if (!wd->selected)
|
||||
{
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
|
||||
while ((next) && (next->delete_me))
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
|
||||
elm_gengrid_item_selected_set(next, EINA_TRUE);
|
||||
elm_gengrid_item_show(next);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
else next = elm_gengrid_item_next_get(wd->last_selected_item);
|
||||
|
||||
if (!next) return EINA_FALSE;
|
||||
|
||||
for (i = 1; i < wd->nmax; i++)
|
||||
{
|
||||
Elm_Gengrid_Item *tmp = elm_gengrid_item_next_get(next);
|
||||
if (!tmp) return EINA_FALSE;
|
||||
next = tmp;
|
||||
}
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
||||
elm_gengrid_item_selected_set(next, EINA_TRUE);
|
||||
elm_gengrid_item_show(next);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_single_select_left(Widget_Data *wd)
|
||||
{
|
||||
Elm_Gengrid_Item *prev;
|
||||
if (!wd->selected)
|
||||
{
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(wd->items->last);
|
||||
while ((prev) && (prev->delete_me))
|
||||
prev = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
|
||||
}
|
||||
else prev = elm_gengrid_item_prev_get(wd->last_selected_item);
|
||||
|
||||
if (!prev) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
||||
elm_gengrid_item_selected_set(prev, EINA_TRUE);
|
||||
elm_gengrid_item_show(prev);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_single_select_right(Widget_Data *wd)
|
||||
{
|
||||
Elm_Gengrid_Item *next;
|
||||
if (!wd->selected)
|
||||
{
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(wd->items);
|
||||
while ((next) && (next->delete_me))
|
||||
next = ELM_GENGRID_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
|
||||
}
|
||||
else next = elm_gengrid_item_next_get(wd->last_selected_item);
|
||||
|
||||
if (!next) return EINA_FALSE;
|
||||
|
||||
_deselect_all_items(wd);
|
||||
|
||||
elm_gengrid_item_selected_set(next, EINA_TRUE);
|
||||
elm_gengrid_item_show(next);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
elm_gen_item_unrealize(Elm_Gen_Item *it,
|
||||
Eina_Bool calc,
|
||||
Ecore_Cb extra_cb)
|
||||
{
|
||||
Evas_Object *icon;
|
||||
|
||||
if (!it->realized) return;
|
||||
if (it->wd->reorder_it == it) return;
|
||||
evas_event_freeze(evas_object_evas_get(WIDGET(it)));
|
||||
if (!calc)
|
||||
evas_object_smart_callback_call(WIDGET(it), "unrealized", it);
|
||||
if (it->long_timer)
|
||||
{
|
||||
ecore_timer_del(it->long_timer);
|
||||
it->long_timer = NULL;
|
||||
}
|
||||
|
||||
elm_widget_stringlist_free(it->labels);
|
||||
it->labels = NULL;
|
||||
elm_widget_stringlist_free(it->icons);
|
||||
it->icons = NULL;
|
||||
elm_widget_stringlist_free(it->states);
|
||||
it->states = NULL;
|
||||
|
||||
EINA_LIST_FREE(it->icon_objs, icon)
|
||||
evas_object_del(icon);
|
||||
|
||||
if (extra_cb) extra_cb(it);
|
||||
|
||||
it->realized = EINA_FALSE;
|
||||
it->want_unrealize = EINA_FALSE;
|
||||
evas_event_thaw(evas_object_evas_get(WIDGET(it)));
|
||||
evas_event_thaw_eval(evas_object_evas_get(WIDGET(it)));
|
||||
}
|
||||
|
||||
void
|
||||
elm_gen_item_del_notserious(Elm_Gen_Item *it)
|
||||
{
|
||||
elm_widget_item_pre_notify_del(it);
|
||||
it->delete_me = EINA_TRUE;
|
||||
if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
|
||||
|
||||
if (it->itc->func.del)
|
||||
it->itc->func.del((void *)it->base.data, WIDGET(it));
|
||||
}
|
||||
|
||||
void
|
||||
elm_gen_item_del_serious(Elm_Gen_Item *it, Ecore_Cb job)
|
||||
{
|
||||
elm_widget_item_pre_notify_del(it);
|
||||
if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
|
||||
it->delete_me = EINA_TRUE;
|
||||
if ((!it->delete_me) && (it->itc->func.del))
|
||||
it->itc->func.del((void *)it->base.data, WIDGET(it));
|
||||
it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
|
||||
if (it->tooltip.del_cb)
|
||||
it->tooltip.del_cb((void *)it->tooltip.data, WIDGET(it), it);
|
||||
it->wd->walking -= it->walking;
|
||||
if (it->long_timer) ecore_timer_del(it->long_timer);
|
||||
if (it->group)
|
||||
it->wd->group_items = eina_list_remove(it->wd->group_items, it);
|
||||
|
||||
if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
|
||||
it->wd->calc_job = ecore_job_add(job, it->wd);
|
||||
free(it->item);
|
||||
it->item = NULL;
|
||||
elm_widget_item_del(it);
|
||||
}
|
||||
|
||||
Elm_Gen_Item *
|
||||
elm_gen_item_new(Widget_Data *wd,
|
||||
const Elm_Gen_Item_Class *itc,
|
||||
const void *data,
|
||||
Elm_Gen_Item *parent,
|
||||
Evas_Smart_Cb func,
|
||||
const void *func_data)
|
||||
{
|
||||
Elm_Gen_Item *it;
|
||||
|
||||
it = elm_widget_item_new(wd->obj, Elm_Gen_Item);
|
||||
if (!it) return NULL;
|
||||
it->wd = wd;
|
||||
it->itc = itc;
|
||||
it->base.data = data;
|
||||
it->parent = parent;
|
||||
it->func.func = func;
|
||||
it->func.data = func_data;
|
||||
|
||||
elm_widget_item_text_get_hook_set(it, _item_label_hook);
|
||||
return it;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
#include <Elementary.h>
|
||||
#include <Elementary_Cursor.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
typedef struct Elm_Gen_Item_Type Elm_Gen_Item_Type;
|
||||
typedef struct Elm_Gen_Item_Tooltip Elm_Gen_Item_Tooltip;
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
struct Elm_Gen_Item_Tooltip
|
||||
{
|
||||
const void *data;
|
||||
Elm_Tooltip_Item_Content_Cb content_cb;
|
||||
Evas_Smart_Cb del_cb;
|
||||
const char *style;
|
||||
Eina_Bool free_size : 1;
|
||||
};
|
||||
|
||||
struct Elm_Gen_Item
|
||||
{
|
||||
ELM_WIDGET_ITEM;
|
||||
EINA_INLIST;
|
||||
Widget_Data *wd;
|
||||
Elm_Gen_Item_Type *item;
|
||||
const Elm_Gen_Item_Class *itc;
|
||||
Evas_Coord x, y, dx, dy;
|
||||
Evas_Object *spacer;
|
||||
Elm_Gen_Item *parent;
|
||||
Eina_List *labels, *icons, *states, *icon_objs;
|
||||
Ecore_Timer *long_timer;
|
||||
int relcount;
|
||||
int walking;
|
||||
const char *mouse_cursor;
|
||||
|
||||
struct
|
||||
{
|
||||
Evas_Smart_Cb func;
|
||||
const void *data;
|
||||
} func;
|
||||
|
||||
Elm_Gen_Item_Tooltip tooltip;
|
||||
|
||||
Eina_Bool want_unrealize : 1;
|
||||
Eina_Bool display_only : 1;
|
||||
Eina_Bool realized : 1;
|
||||
Eina_Bool selected : 1;
|
||||
Eina_Bool highlighted : 1;
|
||||
Eina_Bool disabled : 1;
|
||||
Eina_Bool dragging : 1;
|
||||
Eina_Bool delete_me : 1;
|
||||
Eina_Bool down : 1;
|
||||
Eina_Bool group : 1;
|
||||
Eina_Bool reorder : 1;
|
||||
};
|
||||
|
||||
Elm_Gen_Item *
|
||||
elm_gen_item_new(Widget_Data *wd,
|
||||
const Elm_Gen_Item_Class *itc,
|
||||
const void *data,
|
||||
Elm_Gen_Item *parent,
|
||||
Evas_Smart_Cb func,
|
||||
const void *func_data);
|
||||
|
||||
void
|
||||
elm_gen_item_unrealize(Elm_Gen_Item *it,
|
||||
Eina_Bool calc,
|
||||
Ecore_Cb extra_cb);
|
||||
void
|
||||
elm_gen_item_del_serious(Elm_Gen_Item *it, Ecore_Cb job);
|
||||
|
||||
void
|
||||
elm_gen_item_del_notserious(Elm_Gen_Item *it);
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue