+#include <assert.h>
+
#include <Elementary.h>
#include <Elementary_Cursor.h>
#include "elm_priv.h"
+#include "els_scroller.h"
#define SWIPE_MOVES 12
#define MAX_ITEMS_PER_BLOCK 32
-
-/**
- * @defgroup Genlist Genlist
- *
- * The aim was to have more expansive list than the simple list in
- * Elementary that could have more flexible items and allow many more entries
- * while still being fast and low on memory usage. At the same time it was
- * also made to be able to do tree structures. But the price to pay is more
- * complex when it comes to usage. If all you want is a simple list with
- * icons and a single label, use the normal List object.
- *
- * Genlist has a fairly large API, mostly because it's relatively complex,
- * trying to be both expansive, powerful and efficient. First we will begin
- * an overview on the theory behind genlist.
- *
- * Evas tracks every object you create. Every time it processes an event
- * (mouse move, down, up etc.) it needs to walk through objects and find out
- * what event that affects. Even worse every time it renders display updates,
- * in order to just calculate what to re-draw, it needs to walk through many
- * many many objects. Thus, the more objects you keep active, the more
- * overhead Evas has in just doing its work. It is advisable to keep your
- * active objects to the minimum working set you need. Also remember that
- * object creation and deletion carries an overhead, so there is a
- * middle-ground, which is not easily determined. But don't keep massive lists
- * of objects you can't see or use. Genlist does this with list objects. It
- * creates and destroys them dynamically as you scroll around. It groups them
- * into blocks so it can determine the visibility etc. of a whole block at
- * once as opposed to having to walk the whole list. This 2-level list allows
- * for very large numbers of items to be in the list (tests have used up to
- * 2,000,000 items). Also genlist employs a queue for adding items. As items
- * may be different sizes, every item added needs to be calculated as to its
- * size and thus this presents a lot of overhead on populating the list, this
- * genlist employs a queue. Any item added is queued and spooled off over
- * time, actually appearing some time later, so if your list has many members
- * you may find it takes a while for them to all appear, with your process
- * consuming a lot of CPU while it is busy spooling.
- *
- * Genlist also implements a tree structure, but it does so with callbacks to
- * the application, with the application filling in tree structures when
- * requested (allowing for efficient building of a very deep tree that could
- * even be used for file-management). See the above smart signal callbacks for
- * details.
- *
- * An item in the genlist world can have 0 or more text labels (they can be
- * regular text or textblock - that's up to the style to determine), 0 or
- * more icons (which are simply objects swallowed into the genlist item) and
- * 0 or more boolean states that can be used for check, radio or other
- * indicators by the edje theme style. An item may be one of several styles
- * (Elementary provides 4 by default - "default", "double_label", "group_index"
- * and "icon_top_text_bottom", but this can be extended by system or
- * application custom themes/overlays/extensions).
- *
- * In order to implement the ability to add and delete items on the fly,
- * Genlist implements a class/callback system where the application provides
- * a structure with information about that type of item (genlist may contain
- * multiple different items with different classes, states and styles).
- * Genlist will call the functions in this struct (methods) when an item is
- * "realized" (that is created dynamically while scrolling). All objects will
- * simply be deleted when no longer needed with evas_object_del(). The
- * Elm_Genlist_Item_Class structure contains the following members:
- *
- * item_style - This is a constant string and simply defines the name of the
- * item style. It must be specified and the default should be "default".
- *
- * func.label_get - This function is called when an actual item object is
- * created. The data parameter is the data parameter passed to
- * elm_genlist_item_append() and related item creation functions. The obj
- * parameter is the genlist object and the part parameter is the string name
- * of the text part in the edje design that is listed as one of the possible
- * labels that can be set. This function must return a strudup()'ed string as
- * the caller will free() it when done.
- *
- * func.icon_get - This function is called when an actual item object is
- * created. The data parameter is the data parameter passed to
- * elm_genlist_item_append() and related item creation functions. The obj
- * parameter is the genlist object and the part parameter is the string name
- * of the icon part in the edje design that is listed as one of the possible
- * icons that can be set. This must return NULL for no object or a valid
- * object. The object will be deleted by genlist on shutdown or when the item
- * is unrealized.
- *
- * func.state_get - This function is called when an actual item object is
- * created. The data parameter is the data parameter passed to
- * elm_genlist_item_append() and related item creation functions. The obj
- * parameter is the genlist object and the part parameter is the string name
- * of the state part in the edje design that is listed as one of the possible
- * states that can be set. Return 0 for false or 1 for true. Genlist will
- * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
- * true (the default is false), where XXX is the name of the part.
- *
- * func.del - This is called when elm_genlist_item_del() is called on an
- * item, elm_genlist_clear() is called on the genlist, or
- * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
- * intended for use when actual genlist items are deleted, so any backing
- * data attached to the item (e.g. its data parameter on creation) can be
- * deleted.
- *
- * Items can be added by several calls. All of them return a Elm_Genlist_Item
- * handle that is an internal member inside the genlist. They all take a data
- * parameter that is meant to be used for a handle to the applications
- * internal data (eg the struct with the original item data). The parent
- * parameter is the parent genlist item this belongs to if it is a tree or
- * an indexed group, and NULL if there is no parent. The flags can be a bitmask
- * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
- * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
- * is displayed as an item that is able to expand and have child items.
- * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
- * displayed at the top until the next group comes. The func parameter is a
- * convenience callback that is called when the item is selected and the data
- * parameter will be the func_data parameter, obj be the genlist object and
- * event_info will be the genlist item.
- *
- * elm_genlist_item_append() appends an item to the end of the list, or if
- * there is a parent, to the end of all the child items of the parent.
- * elm_genlist_item_prepend() is the same but prepends to the beginning of
- * the list or children list. elm_genlist_item_insert_before() inserts at
- * item before another item and elm_genlist_item_insert_after() inserts after
- * the indicated item.
- *
- * The application can clear the list with elm_genlist_clear() which deletes
- * all the items in the list and elm_genlist_item_del() will delete a specific
- * item. elm_genlist_item_subitems_clear() will clear all items that are
- * children of the indicated parent item.
- *
- * If the application wants multiple items to be able to be selected,
- * elm_genlist_multi_select_set() can enable this. If the list is
- * single-selection only (the default), then elm_genlist_selected_item_get()
- * will return the selected item, if any, or NULL I none is selected. If the
- * list is multi-select then elm_genlist_selected_items_get() will return a
- * list (that is only valid as long as no items are modified (added, deleted,
- * selected or unselected)).
- *
- * To help inspect list items you can jump to the item at the top of the list
- * with elm_genlist_first_item_get() which will return the item pointer, and
- * similarly elm_genlist_last_item_get() gets the item at the end of the list.
- * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
- * and previous items respectively relative to the indicated item. Using
- * these calls you can walk the entire item list/tree. Note that as a tree
- * the items are flattened in the list, so elm_genlist_item_parent_get() will
- * let you know which item is the parent (and thus know how to skip them if
- * wanted).
- *
- * There are also convenience functions. elm_genlist_item_genlist_get() will
- * return the genlist object the item belongs to. elm_genlist_item_show()
- * will make the scroller scroll to show that specific item so its visible.
- * elm_genlist_item_data_get() returns the data pointer set by the item
- * creation functions.
- *
- * If an item changes (state of boolean changes, label or icons change),
- * then use elm_genlist_item_update() to have genlist update the item with
- * the new state. Genlist will re-realize the item thus call the functions
- * in the _Elm_Genlist_Item_Class for that item.
- *
- * To programmatically (un)select an item use elm_genlist_item_selected_set().
- * To get its selected state use elm_genlist_item_selected_get(). Similarly
- * to expand/contract an item and get its expanded state, use
- * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
- * again to make an item disabled (unable to be selected and appear
- * differently) use elm_genlist_item_disabled_set() to set this and
- * elm_genlist_item_disabled_get() to get the disabled state.
- *
- * In general to indicate how the genlist should expand items horizontally to
- * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
- * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
- * mode means that if items are too wide to fit, the scroller will scroll
- * horizontally. Otherwise items are expanded to fill the width of the
- * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
- * to the viewport width and limited to that size. This can be combined with
- * a different style that uses edjes' ellipsis feature (cutting text off like
- * this: "tex...").
- *
- * Items will only call their selection func and callback when first becoming
- * selected. Any further clicks will do nothing, unless you enable always
- * select with elm_genlist_always_select_mode_set(). This means even if
- * selected, every click will make the selected callbacks be called.
- * elm_genlist_no_select_mode_set() will turn off the ability to select
- * items entirely and they will neither appear selected nor call selected
- * callback functions.
- *
- * Remember that you can create new styles and add your own theme augmentation
- * per application with elm_theme_extension_add(). If you absolutely must
- * have a specific style that overrides any theme the user or system sets up
- * you can use elm_theme_overlay_add() to add such a file.
- *
- * Signals that you can add callbacks for are:
- *
- * "clicked,double" - This is called when a user has double-clicked an item. The
- * event_info parameter is the genlist item that was double-c
- * licked.
- * "selected" - This is called when a user has made an item selected. The
- * event_info parameter is the genlist item that was selected.
- * "unselected" - This is called when a user has made an item unselected. The
- * event_info parameter is the genlist item that was unselected.
- * "expanded" - This is called when elm_genlist_item_expanded_set() is called
- * and the item is now meant to be expanded. The event_info
- * parameter is the genlist item that was indicated to expand. It
- * is the job of this callback to then fill in the child items.
- * "contracted" - This is called when elm_genlist_item_expanded_set() is called
- * and the item is now meant to be contracted. The event_info
- * parameter is the genlist item that was indicated to contract.
- * It is the job of this callback to then delete the child items.
- * "expand,request" - This is called when a user has indicated they want to
- * expand a tree branch item. The callback should decide if
- * the item can expand (has any children) and then call
- * elm_genlist_item_expanded_set() appropriately to set the
- * state. The event_info parameter is the genlist item that
- * was indicated to expand.
- * "contract,request" - This is called when a user has indicated they want to
- * contract a tree branch item. The callback should decide
- * if the item can contract (has any children) and then
- * call elm_genlist_item_expanded_set() appropriately to
- * set the state. The event_info parameter is the genlist
- * item that was indicated to contract.
- * "realized" - This is called when the item in the list is created as a real
- * evas object. event_info parameter is the genlist item that was
- * created. The object may be deleted at any time, so it is up to
- * the caller to not use the object pointer from
- * elm_genlist_item_object_get() in a way where it may point to
- * freed objects.
- * "unrealized" - This is called just before an item is unrealized. After this
- * call icon objects provided will be deleted and the item object
- * itself delete or be put into a floating cache.
- * "drag,start,up" - This is called when the item in the list has been dragged
- * (not scrolled) up.
- * "drag,start,down" - This is called when the item in the list has been dragged
- * (not scrolled) down.
- * "drag,start,left" - This is called when the item in the list has been dragged
- * (not scrolled) left.
- * "drag,start,right" - This is called when the item in the list has been
- * dragged (not scrolled) right.
- * "drag,stop" - This is called when the item in the list has stopped being
- * dragged.
- * "drag" - This is called when the item in the list is being dragged.
- * "longpressed" - This is called when the item is pressed for a certain amount
- * of time. By default it's 1 second.
- * "scroll,edge,top" - This is called when the genlist is scrolled until the
- * top edge.
- * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
- * bottom edge.
- * "scroll,edge,left" - This is called when the genlist is scrolled until the
- * left edge.
- * "scroll,edge,right" - This is called when the genlist is scrolled until the
- * right edge.
- * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
- * left.
- * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
- * right.
- * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
- * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
- * down.
- * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
- * out.
- * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
- */
+#define REORDER_EFFECT_TIME 0.5
typedef struct _Widget_Data Widget_Data;
typedef struct _Item_Block Item_Block;
struct _Widget_Data
{
- Evas_Object *obj, *scr, *pan_smart;
- Eina_Inlist *items, *blocks;
- Eina_List *group_items;
- Pan *pan;
- Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
+ Eina_Inlist_Sorted_State *state;
+ Evas_Object *obj; /* the genlist object */
+ Evas_Object *scr; /* a smart scroller object which is used internally in genlist */
+ Evas_Object *pan_smart; /* "elm_genlist_pan" evas smart object. this is an extern pan of smart scroller(scr). */
+ Eina_Inlist *items; /* inlist of all items */
+ Eina_Inlist *blocks; /* inlist of all blocks. a block consists of a certain number of items. maximum number of items in a block is 'max_items_per_block'. */
+ Eina_List *group_items; /* list of groups index items */
+ Pan *pan; /* pan_smart object's smart data */
+ Evas_Coord pan_x, pan_y, reorder_old_pan_y, w, h, minw, minh, realminw, prev_viewport_w;
Ecore_Job *calc_job, *update_job;
- Ecore_Idler *queue_idler;
- Ecore_Idler *must_recalc_idler;
+ Ecore_Idle_Enterer *queue_idle_enterer;
+ Ecore_Idler *must_recalc_idler;
Eina_List *queue, *selected;
- Elm_Genlist_Item *show_item;
- Elm_Genlist_Item *last_selected_item;
- Eina_Inlist *item_cache;
- Elm_Genlist_Item *anchor_item;
+ Elm_Genlist_Item *show_item, *anchor_item, *mode_item, *reorder_rel, *expanded_item;
+ Elm_Genlist_Item *last_selected_item; /* the last selected item. */
+ Elm_Genlist_Item *reorder_it; /* an item which is longpressed and in the moving state. */
+ Eina_Inlist *item_cache; /* an inlist of edje object item cache. */
Evas_Coord anchor_y;
+ Evas_Coord reorder_start_y; /* reorder item's initial y coordinate in the pan. */
Elm_List_Mode mode;
- Ecore_Timer *multi_timer;
+ Ecore_Timer *multi_timer, *scr_hold_timer;
+ Ecore_Animator *reorder_move_animator;
+ const char *mode_type;
+ unsigned int start_time;
Evas_Coord prev_x, prev_y, prev_mx, prev_my;
Evas_Coord cur_x, cur_y, cur_mx, cur_my;
Eina_Bool mouse_down : 1;
Eina_Bool homogeneous : 1;
Eina_Bool clear_me : 1;
Eina_Bool swipe : 1;
+ Eina_Bool reorder_mode : 1;
+ Eina_Bool reorder_pan_move : 1;
+ Eina_Bool auto_scroll_enabled : 1;
+ Eina_Bool pan_resized : 1;
struct
{
Evas_Coord x, y;
} history[SWIPE_MOVES];
int multi_device;
int item_cache_count;
- int item_cache_max;
+ int item_cache_max; /* maximum number of cached items */
int movements;
int walking;
int item_width;
int item_height;
int group_item_width;
int group_item_height;
- int max_items_per_block;
- double longpress_timeout;
+ int max_items_per_block; /* maximum number of items per block */
+ double longpress_timeout; /* longpress timeout. this value comes from _elm_config by default. this can be changed by elm_genlist_longpress_timeout_set() */
};
struct _Item_Block
EINA_INLIST;
int count;
int num;
+ int reorder_offset;
Widget_Data *wd;
Eina_List *items;
Evas_Coord x, y, w, h, minw, minh;
Evas_Object *spacer;
Eina_List *labels, *icons, *states, *icon_objs;
+ Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
Ecore_Timer *long_timer;
Ecore_Timer *swipe_timer;
Evas_Coord dx, dy;
- Evas_Coord scrl_x, scrl_y;
+ Evas_Coord scrl_x, scrl_y, old_scrl_y;
Elm_Genlist_Item *rel;
+ Evas_Object *mode_view;
struct
{
Elm_Tooltip_Item_Content_Cb content_cb;
Evas_Smart_Cb del_cb;
const char *style;
+ Eina_Bool free_size : 1;
} tooltip;
const char *mouse_cursor;
Eina_Bool dragging : 1;
Eina_Bool updateme : 1;
Eina_Bool nocache : 1;
+ Eina_Bool stacking_even : 1;
+ Eina_Bool nostacking : 1;
+ Eina_Bool move_effect_enabled : 1;
};
struct _Item_Cache
const char *item_style; // it->itc->item_style
Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
Eina_Bool compress : 1; // it->wd->compress
- Eina_Bool odd : 1; // in & 0x1
Eina_Bool selected : 1; // it->selected
Eina_Bool disabled : 1; // it->disabled
static void _show_region_hook(void *data,
Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
-static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
+static void _item_realize(Elm_Genlist_Item *it,
+ int in,
+ Eina_Bool calc);
+static void _item_unrealize(Elm_Genlist_Item *it,
+ Eina_Bool calc);
static void _item_block_unrealize(Item_Block *itb);
static void _calc_job(void *data);
static void _on_focus_hook(void *data,
const char *source);
static Eina_Bool _deselect_all_items(Widget_Data *wd);
static void _pan_calculate(Evas_Object *obj);
+static void _pan_max_get(Evas_Object *obj,
+ Evas_Coord *x,
+ Evas_Coord *y);
+static void _item_position(Elm_Genlist_Item *it,
+ Evas_Object *obj,
+ Evas_Coord it_x,
+ Evas_Coord it_y);
+static void _mode_item_realize(Elm_Genlist_Item *it);
+static void _mode_item_unrealize(Elm_Genlist_Item *it);
+static void _item_mode_set(Elm_Genlist_Item *it);
+static void _item_mode_unset(Widget_Data *wd);
+static void _group_items_recalc(void *data);
+static void _item_move_after(Elm_Genlist_Item *it,
+ Elm_Genlist_Item *after);
+static void _item_move_before(Elm_Genlist_Item *it,
+ Elm_Genlist_Item *before);
+static void _item_auto_scroll(Widget_Data *wd);
static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
+static const char SIG_ACTIVATED[] = "activated";
+static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
+static const char SIG_SELECTED[] = "selected";
+static const char SIG_UNSELECTED[] = "unselected";
+static const char SIG_EXPANDED[] = "expanded";
+static const char SIG_CONTRACTED[] = "contracted";
+static const char SIG_EXPAND_REQUEST[] = "expand,request";
+static const char SIG_CONTRACT_REQUEST[] = "contract,request";
+static const char SIG_REALIZED[] = "realized";
+static const char SIG_UNREALIZED[] = "unrealized";
+static const char SIG_DRAG_START_UP[] = "drag,start,up";
+static const char SIG_DRAG_START_DOWN[] = "drag,start,down";
+static const char SIG_DRAG_START_LEFT[] = "drag,start,left";
+static const char SIG_DRAG_START_RIGHT[] = "drag,start,right";
+static const char SIG_DRAG_STOP[] = "drag,stop";
+static const char SIG_DRAG[] = "drag";
+static const char SIG_LONGPRESSED[] = "longpressed";
+static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
+static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
+static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
+static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
+static const char SIG_SCROLL_EDGE_TOP[] = "scroll,edge,top";
+static const char SIG_SCROLL_EDGE_BOTTOM[] = "scroll,edge,bottom";
+static const char SIG_SCROLL_EDGE_LEFT[] = "scroll,edge,left";
+static const char SIG_SCROLL_EDGE_RIGHT[] = "scroll,edge,right";
+static const char SIG_MULTI_SWIPE_LEFT[] = "multi,swipe,left";
+static const char SIG_MULTI_SWIPE_RIGHT[] = "multi,swipe,right";
+static const char SIG_MULTI_SWIPE_UP[] = "multi,swipe,up";
+static const char SIG_MULTI_SWIPE_DOWN[] = "multi,swipe,down";
+static const char SIG_MULTI_PINCH_OUT[] = "multi,pinch,out";
+static const char SIG_MULTI_PINCH_IN[] = "multi,pinch,in";
+static const char SIG_SWIPE[] = "swipe";
+
+static const Evas_Smart_Cb_Description _signals[] = {
+ {SIG_CLICKED_DOUBLE, ""},
+ {SIG_ACTIVATED, ""},
+ {SIG_SELECTED, ""},
+ {SIG_UNSELECTED, ""},
+ {SIG_EXPANDED, ""},
+ {SIG_CONTRACTED, ""},
+ {SIG_EXPAND_REQUEST, ""},
+ {SIG_CONTRACT_REQUEST, ""},
+ {SIG_REALIZED, ""},
+ {SIG_UNREALIZED, ""},
+ {SIG_DRAG_START_UP, ""},
+ {SIG_DRAG_START_DOWN, ""},
+ {SIG_DRAG_START_LEFT, ""},
+ {SIG_DRAG_START_RIGHT, ""},
+ {SIG_DRAG_STOP, ""},
+ {SIG_DRAG, ""},
+ {SIG_LONGPRESSED, ""},
+ {SIG_SCROLL_ANIM_START, ""},
+ {SIG_SCROLL_ANIM_STOP, ""},
+ {SIG_SCROLL_DRAG_START, ""},
+ {SIG_SCROLL_DRAG_STOP, ""},
+ {SIG_SCROLL_EDGE_TOP, ""},
+ {SIG_SCROLL_EDGE_BOTTOM, ""},
+ {SIG_SCROLL_EDGE_LEFT, ""},
+ {SIG_SCROLL_EDGE_RIGHT, ""},
+ {SIG_MULTI_SWIPE_LEFT, ""},
+ {SIG_MULTI_SWIPE_RIGHT, ""},
+ {SIG_MULTI_SWIPE_UP, ""},
+ {SIG_MULTI_SWIPE_DOWN, ""},
+ {SIG_MULTI_PINCH_OUT, ""},
+ {SIG_MULTI_PINCH_IN, ""},
+ {SIG_SWIPE, ""},
+ {NULL, NULL}
+};
+
+static Eina_Compare_Cb _elm_genlist_item_compare_cb;
+static Eina_Compare_Cb _elm_genlist_item_compare_data_cb;
+
static Eina_Bool
_event_hook(Evas_Object *obj,
Evas_Object *src __UNUSED__,
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
Evas_Event_Key_Down *ev = event_info;
Widget_Data *wd = elm_widget_data_get(obj);
+ Evas_Coord pan_max_x = 0, pan_max_y = 0;
if (!wd) return EINA_FALSE;
if (!wd->items) return EINA_FALSE;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
else
y += page_y;
}
- else if(((!strcmp(ev->keyname, "Return")) ||
+ else if (((!strcmp(ev->keyname, "Return")) ||
(!strcmp(ev->keyname, "KP_Enter")) ||
(!strcmp(ev->keyname, "space")))
&& (!wd->multi) && (wd->selected))
{
- Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
+ it = elm_genlist_selected_item_get(obj);
elm_genlist_item_expanded_set(it,
!elm_genlist_item_expanded_get(it));
+ evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
}
else if (!strcmp(ev->keyname, "Escape"))
{
else return EINA_FALSE;
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ _pan_max_get(wd->pan_smart, &pan_max_x, &pan_max_y);
+ if (x < 0) x = 0;
+ if (x > pan_max_x) x = pan_max_x;
+ if (y < 0) y = 0;
+ if (y > pan_max_y) y = pan_max_y;
elm_smart_scroller_child_pos_set(wd->scr, x, y);
return EINA_TRUE;
}
_deselect_all_items(Widget_Data *wd)
{
if (!wd->selected) return EINA_FALSE;
- while(wd->selected)
+ while (wd->selected)
elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
return EINA_TRUE;
if (!wd) return;
if (elm_widget_focus_get(obj))
{
- edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
+ elm_object_signal_emit(wd->obj, "elm,action,focus", "elm");
evas_object_focus_set(wd->obj, EINA_TRUE);
if ((wd->selected) && (!wd->last_selected_item))
wd->last_selected_item = eina_list_data_get(wd->selected);
}
else
{
- edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
+ elm_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->obj, EINA_FALSE);
}
}
_item_cache_zero(wd);
if (wd->calc_job) ecore_job_del(wd->calc_job);
if (wd->update_job) ecore_job_del(wd->update_job);
+ if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
+ if (wd->mode_type) eina_stringshare_del(wd->mode_type);
+ if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
free(wd);
}
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
+ elm_genlist_clear(obj);
evas_object_del(wd->pan_smart);
wd->pan_smart = NULL;
- elm_genlist_clear(obj);
}
static void
Widget_Data *wd = elm_widget_data_get(obj);
Item_Block *itb;
if (!wd) return;
+ evas_event_freeze(evas_object_evas_get(wd->obj));
_item_cache_zero(wd);
_elm_widget_mirrored_reload(obj);
_mirrored_set(obj, elm_widget_mirrored_get(obj));
if (wd->calc_job) ecore_job_del(wd->calc_job);
wd->calc_job = ecore_job_add(_calc_job, wd);
_sizing_eval(obj);
+ evas_event_thaw(evas_object_evas_get(wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(wd->obj));
}
static void
}
static void
+_translate_hook(Evas_Object *obj)
+{
+ evas_object_smart_callback_call(obj, "language,changed", NULL);
+}
+
+static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
_item_highlight(Elm_Genlist_Item *it)
{
const char *selectraise;
- if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) || (it->disabled) || (it->display_only)) return;
+ if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
+ (it->disabled) || (it->display_only) || (it->mode_view))
+ return;
edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
selectraise = edje_object_data_get(it->base.view, "selectraise");
if ((selectraise) && (!strcmp(selectraise, "on")))
}
static void
+_item_unhighlight(Elm_Genlist_Item *it)
+{
+ const char *stacking, *selectraise;
+ if ((it->delete_me) || (!it->highlighted)) return;
+ edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
+ stacking = edje_object_data_get(it->base.view, "stacking");
+ selectraise = edje_object_data_get(it->base.view, "selectraise");
+ if (!it->nostacking)
+ {
+ if ((it->order_num_in & 0x1) ^ it->stacking_even) evas_object_lower(it->base.view);
+ else evas_object_raise(it->base.view);
+ }
+ it->highlighted = EINA_FALSE;
+}
+
+static void
_item_block_del(Elm_Genlist_Item *it)
{
Eina_Inlist *il;
}
else
{
- if (itb->count < 16)
+ if (itb->count < itb->wd->max_items_per_block/2)
{
il = EINA_INLIST_GET(itb);
Item_Block *itbp = (Item_Block *)(il->prev);
Item_Block *itbn = (Item_Block *)(il->next);
- if ((itbp) && ((itbp->count + itb->count) < 48))
+ if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
{
Elm_Genlist_Item *it2;
EINA_INLIST_GET(itb));
free(itb);
}
- else if ((itbn) && ((itbn->count + itb->count) < 48))
+ else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
{
while (itb->items)
{
static void
_item_del(Elm_Genlist_Item *it)
{
+ Evas_Object *tob = it->wd->obj;
+
+ evas_event_freeze(evas_object_evas_get(tob));
elm_widget_item_pre_notify_del(it);
elm_genlist_item_subitems_clear(it);
it->wd->walking -= it->walking;
if (it->tooltip.del_cb)
it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
+ evas_event_thaw(evas_object_evas_get(tob));
+ evas_event_thaw_eval(evas_object_evas_get(tob));
+
elm_widget_item_del(it);
}
static void
_item_select(Elm_Genlist_Item *it)
{
- if ((it->wd->no_select) || (it->delete_me)) return;
+ Evas_Object *parent = it->base.widget;
+
+ if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
if (it->selected)
{
if (it->wd->always_select) goto call;
it->selected = EINA_TRUE;
it->wd->selected = eina_list_append(it->wd->selected, it);
call:
+ evas_object_ref(parent);
it->walking++;
it->wd->walking++;
- if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
+ if (it->func.func) it->func.func((void *)it->func.data, parent, it);
if (!it->delete_me)
- evas_object_smart_callback_call(it->base.widget, "selected", it);
+ evas_object_smart_callback_call(parent, SIG_SELECTED, it);
it->walking--;
it->wd->walking--;
if ((it->wd->clear_me) && (!it->wd->walking))
- elm_genlist_clear(it->base.widget);
+ {
+ elm_genlist_clear(parent);
+ goto end;
+ }
else
{
if ((!it->walking) && (it->delete_me))
{
if (!it->relcount) _item_del(it);
+ goto end;
}
}
it->wd->last_selected_item = it;
+
+end:
+ evas_object_unref(parent);
}
static void
_item_unselect(Elm_Genlist_Item *it)
{
- const char *stacking, *selectraise;
-
- if ((it->delete_me) || (!it->highlighted)) return;
- edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
- stacking = edje_object_data_get(it->base.view, "stacking");
- selectraise = edje_object_data_get(it->base.view, "selectraise");
- if ((selectraise) && (!strcmp(selectraise, "on")))
- {
- if ((stacking) && (!strcmp(stacking, "below")))
- evas_object_lower(it->base.view);
- }
- it->highlighted = EINA_FALSE;
- if (it->selected)
- {
- it->selected = EINA_FALSE;
- it->wd->selected = eina_list_remove(it->wd->selected, it);
- evas_object_smart_callback_call(it->base.widget, "unselected", it);
- }
+ if ((it->delete_me) || (!it->selected)) return;
+ it->selected = EINA_FALSE;
+ it->wd->selected = eina_list_remove(it->wd->selected, it);
+ evas_object_smart_callback_call(it->base.widget, SIG_UNSELECTED, it);
}
static void
Elm_Genlist_Item *it = data;
Evas_Event_Mouse_Move *ev = event_info;
Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
+ Evas_Coord ox, oy, ow, oh, it_scrl_y, y_pos;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
{
{
it->wd->on_hold = EINA_TRUE;
if (!it->wd->wasselected)
- _item_unselect(it);
+ {
+ _item_unhighlight(it);
+ _item_unselect(it);
+ }
}
}
if (it->wd->multitouched)
ecore_timer_del(it->long_timer);
it->long_timer = NULL;
}
- evas_object_smart_callback_call(it->base.widget, "drag", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_DRAG, it);
return;
}
if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
ecore_timer_del(it->long_timer);
it->long_timer = NULL;
}
+ if ((it->wd->reorder_mode) && (it->wd->reorder_it))
+ {
+ evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
+ it_scrl_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
+
+ if (!it->wd->reorder_start_y)
+ it->wd->reorder_start_y = it->block->y + it->y;
+
+ if (it_scrl_y < oy)
+ y_pos = oy;
+ else if (it_scrl_y + it->wd->reorder_it->h > oy + oh)
+ y_pos = oy + oh - it->wd->reorder_it->h;
+ else
+ y_pos = it_scrl_y;
+
+ _item_position(it, it->base.view, it->scrl_x, y_pos);
+
+ if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
+ it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
+ }
return;
}
if (!it->display_only)
it->long_timer = NULL;
}
if (!it->wd->wasselected)
- _item_unselect(it);
+ {
+ _item_unhighlight(it);
+ _item_unselect(it);
+ }
if (dy < 0)
{
if (ady > adx)
evas_object_smart_callback_call(it->base.widget,
- "drag,start,up", it);
+ SIG_DRAG_START_UP, it);
else
{
if (dx < 0)
evas_object_smart_callback_call(it->base.widget,
- "drag,start,left", it);
+ SIG_DRAG_START_LEFT, it);
else
evas_object_smart_callback_call(it->base.widget,
- "drag,start,right", it);
+ SIG_DRAG_START_RIGHT, it);
}
}
else
{
if (ady > adx)
evas_object_smart_callback_call(it->base.widget,
- "drag,start,down", it);
+ SIG_DRAG_START_DOWN, it);
else
{
if (dx < 0)
evas_object_smart_callback_call(it->base.widget,
- "drag,start,left", it);
+ SIG_DRAG_START_LEFT, it);
else
evas_object_smart_callback_call(it->base.widget,
- "drag,start,right", it);
+ SIG_DRAG_START_RIGHT, it);
}
}
}
static Eina_Bool
_long_press(void *data)
{
- Elm_Genlist_Item *it = data;
+ Elm_Genlist_Item *it = data, *it_tmp;
+ Eina_List *list, *l;
it->long_timer = NULL;
if ((it->disabled) || (it->dragging) || (it->display_only))
return ECORE_CALLBACK_CANCEL;
it->wd->longpressed = EINA_TRUE;
- evas_object_smart_callback_call(it->base.widget, "longpressed", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_LONGPRESSED, it);
+ if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
+ {
+ it->wd->reorder_it = it;
+ it->wd->reorder_start_y = 0;
+
+ evas_object_raise(it->base.view);
+ elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
+ elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_FALSE);
+
+ list = elm_genlist_realized_items_get(it->wd->obj);
+ EINA_LIST_FOREACH(list, l, it_tmp)
+ {
+ if (it != it_tmp) _item_unselect(it_tmp);
+ }
+ if (elm_genlist_item_expanded_get(it))
+ {
+ elm_genlist_item_expanded_set(it, EINA_FALSE);
+ return ECORE_CALLBACK_RENEW;
+ }
+ edje_object_signal_emit(it->base.view, "elm,state,reorder,enabled", "elm");
+ }
return ECORE_CALLBACK_CANCEL;
}
sum /= it->wd->movements;
if (abs(sum - it->wd->history[0].x) <= 10) return;
- evas_object_smart_callback_call(it->base.widget, "swipe", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_SWIPE, it);
}
static Eina_Bool
{
if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
evas_object_smart_callback_call(it->base.widget,
- "multi,swipe,right", it);
+ SIG_MULTI_SWIPE_RIGHT, it);
else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
evas_object_smart_callback_call(it->base.widget,
- "multi,swipe,left", it);
+ SIG_MULTI_SWIPE_LEFT, it);
else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
evas_object_smart_callback_call(it->base.widget,
- "multi,pinch,out", it);
+ SIG_MULTI_PINCH_OUT, it);
else
evas_object_smart_callback_call(it->base.widget,
- "multi,pinch,in", it);
+ SIG_MULTI_PINCH_IN, it);
}
else
{
if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
evas_object_smart_callback_call(it->base.widget,
- "multi,swipe,down", it);
+ SIG_MULTI_SWIPE_DOWN, it);
else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
evas_object_smart_callback_call(it->base.widget,
- "multi,swipe,up", it);
+ SIG_MULTI_SWIPE_UP, it);
else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
evas_object_smart_callback_call(it->base.widget,
- "multi,pinch,out", it);
+ SIG_MULTI_PINCH_OUT, it);
else
evas_object_smart_callback_call(it->base.widget,
- "multi,pinch,in", it);
+ SIG_MULTI_PINCH_IN, it);
}
}
it->wd->multi_timeout = EINA_FALSE;
it->wd->multitouched = EINA_TRUE;
it->wd->prev_mx = ev->canvas.x;
it->wd->prev_my = ev->canvas.y;
- if (!it->wd->wasselected) _item_unselect(it);
+ if (!it->wd->wasselected)
+ {
+ _item_unhighlight(it);
+ _item_unselect(it);
+ }
it->wd->wasselected = EINA_FALSE;
it->wd->longpressed = EINA_FALSE;
if (it->long_timer)
if (it->dragging)
{
it->dragging = EINA_FALSE;
- evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
}
if (it->swipe_timer)
{
if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
if ((!it->disabled) && (!it->display_only))
{
- evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
- evas_object_smart_callback_call(it->base.widget, "clicked", it); // will be removed
+ evas_object_smart_callback_call(it->base.widget, SIG_CLICKED_DOUBLE, it);
+ evas_object_smart_callback_call(it->base.widget, SIG_ACTIVATED, it);
}
if (it->long_timer) ecore_timer_del(it->long_timer);
if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
it->wd->mouse_down = EINA_FALSE;
if (it->wd->multitouched)
{
+ if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unhighlight(it);
if (it->wd->multi_down) return;
_multi_touch_gesture_eval(data);
return;
if (it->dragging)
{
it->dragging = EINA_FALSE;
- evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_DRAG_STOP, it);
dragged = 1;
}
if (it->swipe_timer)
it->wd->on_hold = EINA_FALSE;
return;
}
+ if ((it->wd->reorder_mode) && (it->wd->reorder_it))
+ {
+ Evas_Coord it_scrl_y = ev->canvas.y - it->wd->reorder_it->dy;
+
+ if (it->wd->reorder_rel && (it->wd->reorder_it->parent == it->wd->reorder_rel->parent))
+ {
+ if (it_scrl_y <= it->wd->reorder_rel->scrl_y)
+ _item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
+ else
+ _item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
+ }
+ else
+ {
+ if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
+ it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
+ }
+ edje_object_signal_emit(it->base.view, "elm,state,reorder,disabled", "elm");
+ it->wd->reorder_it = it->wd->reorder_rel = NULL;
+ elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
+ elm_smart_scroller_bounce_allow_set(it->wd->scr, EINA_FALSE, EINA_TRUE);
+ }
if (it->wd->longpressed)
{
it->wd->longpressed = EINA_FALSE;
if (!it->wd->wasselected)
- _item_unselect(it);
+ {
+ _item_unhighlight(it);
+ _item_unselect(it);
+ }
it->wd->wasselected = EINA_FALSE;
return;
}
_item_highlight(it);
_item_select(it);
}
- else _item_unselect(it);
+ else
+ {
+ _item_unhighlight(it);
+ _item_unselect(it);
+ }
}
else
{
Widget_Data *wd = it->wd;
if (wd)
{
- while (wd->selected) _item_unselect(wd->selected->data);
+ while (wd->selected)
+ {
+ _item_unhighlight(wd->selected->data);
+ _item_unselect(wd->selected->data);
+ }
}
}
else
Elm_Genlist_Item *it2;
EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
- if (it2 != it) _item_unselect(it2);
+ if (it2 != it)
+ {
+ _item_unhighlight(it2);
+ _item_unselect(it2);
+ }
//_item_highlight(it);
//_item_select(it);
}
Elm_Genlist_Item *it = data;
if (it->expanded)
- evas_object_smart_callback_call(it->base.widget, "contract,request", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
else
- evas_object_smart_callback_call(it->base.widget, "expand,request", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
}
static void
Elm_Genlist_Item *it = data;
if (!it->expanded)
- evas_object_smart_callback_call(it->base.widget, "expand,request", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_EXPAND_REQUEST, it);
}
static void
Elm_Genlist_Item *it = data;
if (it->expanded)
- evas_object_smart_callback_call(it->base.widget, "contract,request", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_CONTRACT_REQUEST, it);
+}
+
+static Eina_Bool
+_scr_hold_timer_cb(void *data)
+{
+ if (!data) return ECORE_CALLBACK_CANCEL;
+ Widget_Data *wd = data;
+ elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
+ wd->scr_hold_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_mode_finished_signal_cb(void *data,
+ Evas_Object *obj,
+ const char *emission __UNUSED__,
+ const char *source __UNUSED__)
+{
+ if (!data) return;
+ if (!obj) return;
+ Elm_Genlist_Item *it = data;
+ if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
+ char buf[1024];
+ Evas *te = evas_object_evas_get(obj);
+
+ evas_event_freeze(te);
+ it->nocache = EINA_FALSE;
+ _mode_item_unrealize(it);
+ if (it->group_item)
+ evas_object_raise(it->group_item->base.view);
+ snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
+ edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
+ evas_event_thaw(te);
+ evas_event_thaw_eval(te);
}
static void
_item_cache_clean(Widget_Data *wd)
{
+ evas_event_freeze(evas_object_evas_get(wd->obj));
while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
{
Item_Cache *itc;
if (itc->item_style) eina_stringshare_del(itc->item_style);
free(itc);
}
+ evas_event_thaw(evas_object_evas_get(wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(wd->obj));
}
static void
{
Item_Cache *itc;
+ evas_event_freeze(evas_object_evas_get(it->wd->obj));
if (it->wd->item_cache_max <= 0)
{
evas_object_del(it->base.view);
it->base.view = NULL;
evas_object_del(it->spacer);
it->spacer = NULL;
+ evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
return;
}
itc->item_style = eina_stringshare_add(it->itc->item_style);
if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
itc->compress = (it->wd->compress);
- itc->odd = (it->order_num_in & 0x1);
itc->selected = it->selected;
itc->disabled = it->disabled;
itc->expanded = it->expanded;
evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
_multi_move, it);
_item_cache_clean(it->wd);
+ evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
}
static Item_Cache *
_item_cache_find(Elm_Genlist_Item *it)
{
Item_Cache *itc;
- Eina_Bool tree = 0, odd;
+ Eina_Bool tree = 0;
if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
- odd = (it->order_num_in & 0x1);
EINA_INLIST_FOREACH(it->wd->item_cache, itc)
{
if ((itc->selected) || (itc->disabled) || (itc->expanded))
continue;
if ((itc->tree == tree) &&
- (itc->odd == odd) &&
(itc->compress == it->wd->compress) &&
(!strcmp(it->itc->item_style, itc->item_style)))
{
}
static void
+_elm_genlist_item_odd_even_update(Elm_Genlist_Item *it)
+{
+ if (!it->nostacking)
+ {
+ if ((it->order_num_in & 0x1) ^ it->stacking_even)
+ evas_object_lower(it->base.view);
+ else
+ evas_object_raise(it->base.view);
+ }
+
+ if (it->order_num_in & 0x1)
+ edje_object_signal_emit(it->base.view, "elm,state,odd", "elm");
+ else
+ edje_object_signal_emit(it->base.view, "elm,state,even", "elm");
+}
+
+static void
+_elm_genlist_item_state_update(Elm_Genlist_Item *it, Item_Cache *itc)
+{
+ if (itc)
+ {
+ if (it->selected != itc->selected)
+ {
+ if (it->selected)
+ edje_object_signal_emit(it->base.view,
+ "elm,state,selected", "elm");
+ }
+ if (it->disabled != itc->disabled)
+ {
+ if (it->disabled)
+ edje_object_signal_emit(it->base.view,
+ "elm,state,disabled", "elm");
+ }
+ if (it->expanded != itc->expanded)
+ {
+ if (it->expanded)
+ edje_object_signal_emit(it->base.view,
+ "elm,state,expanded", "elm");
+ }
+ }
+ else
+ {
+ if (it->selected)
+ edje_object_signal_emit(it->base.view,
+ "elm,state,selected", "elm");
+ if (it->disabled)
+ edje_object_signal_emit(it->base.view,
+ "elm,state,disabled", "elm");
+ if (it->expanded)
+ edje_object_signal_emit(it->base.view,
+ "elm,state,expanded", "elm");
+ }
+}
+
+static void
_item_cache_free(Item_Cache *itc)
{
if (itc->spacer) evas_object_del(itc->spacer);
free(itc);
}
+static const char *
+_item_label_hook(Elm_Genlist_Item *it, const char *part)
+{
+ if (!it->itc->func.label_get) return NULL;
+ return edje_object_part_text_get(it->base.view, part);
+}
+
+static void
+_item_del_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+{
+ Elm_Genlist_Item *it = event_info;
+ if (!it) return;
+ if (it->wd->last_selected_item == it)
+ it->wd->last_selected_item = NULL;
+}
+
+static void
+_item_label_realize(Elm_Genlist_Item *it,
+ Evas_Object *target,
+ Eina_List **source)
+{
+ if (it->itc->func.label_get)
+ {
+ const Eina_List *l;
+ const char *key;
+
+ *source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
+ EINA_LIST_FOREACH(*source, l, key)
+ {
+ char *s = it->itc->func.label_get
+ ((void *)it->base.data, it->base.widget, key);
+
+ if (s)
+ {
+ edje_object_part_text_set(target, key, s);
+ free(s);
+ }
+ else
+ {
+ edje_object_part_text_set(target, key, "");
+ }
+ }
+ }
+}
+
+static Eina_List *
+_item_icon_realize(Elm_Genlist_Item *it,
+ Evas_Object *target,
+ Eina_List **source)
+{
+ Eina_List *res = NULL;
+
+ if (it->itc->func.icon_get)
+ {
+ const Eina_List *l;
+ const char *key;
+
+ *source = elm_widget_stringlist_get(edje_object_data_get(target, "icons"));
+ EINA_LIST_FOREACH(*source, l, key)
+ {
+ Evas_Object *ic = it->itc->func.icon_get
+ ((void *)it->base.data, it->base.widget, key);
+
+ if (ic)
+ {
+ res = eina_list_append(res, ic);
+ edje_object_part_swallow(target, key, ic);
+ evas_object_show(ic);
+ elm_widget_sub_object_add(it->base.widget, ic);
+ if (it->disabled)
+ elm_widget_disabled_set(ic, EINA_TRUE);
+ }
+ }
+ }
+
+ return res;
+}
+
+static void
+_item_state_realize(Elm_Genlist_Item *it,
+ Evas_Object *target,
+ Eina_List **source)
+{
+ if (it->itc->func.state_get)
+ {
+ const Eina_List *l;
+ const char *key;
+ char buf[4096];
+
+ *source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
+ EINA_LIST_FOREACH(*source, l, key)
+ {
+ Eina_Bool on = it->itc->func.state_get
+ ((void *)it->base.data, it->base.widget, key);
+
+ if (on)
+ {
+ snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
+ edje_object_signal_emit(target, buf, "elm");
+ }
+ else
+ {
+ snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
+ edje_object_signal_emit(target, buf, "elm");
+ }
+ }
+ }
+}
+
static void
_item_realize(Elm_Genlist_Item *it,
int in,
Eina_Bool calc)
{
Elm_Genlist_Item *it2;
- const char *stacking;
const char *treesize;
char buf[1024];
int depth, tsize = 20;
Item_Cache *itc = NULL;
- if ((it->realized) || (it->delete_me)) return;
+ if (it->delete_me) return;
+ //evas_event_freeze(evas_object_evas_get(it->wd->obj));
+ if (it->realized)
+ {
+ if (it->order_num_in != in)
+ {
+ it->order_num_in = in;
+ _elm_genlist_item_odd_even_update(it);
+ _elm_genlist_item_state_update(it, NULL);
+ }
+ //evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
+ return;
+ }
it->order_num_in = in;
if (it->nocache)
}
else
{
+ const char *stacking_even;
+ const char *stacking;
+
it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
edje_object_scale_set(it->base.view,
elm_widget_scale_get(it->base.widget) *
if (it->wd->compress)
strncat(buf, "_compress", sizeof(buf) - strlen(buf));
- if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
strncat(buf, "/", sizeof(buf) - strlen(buf));
strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
_elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
elm_widget_style_get(it->base.widget));
+
+ stacking_even = edje_object_data_get(it->base.view, "stacking_even");
+ if (!stacking_even) stacking_even = "above";
+ it->stacking_even = !!strcmp("above", stacking_even);
+
+ stacking = edje_object_data_get(it->base.view, "stacking");
+ if (!stacking) stacking = "yes";
+ it->nostacking = !!strcmp("yes", stacking);
+
edje_object_mirrored_set(it->base.view,
elm_widget_mirrored_get(it->base.widget));
it->spacer =
evas_object_color_set(it->spacer, 0, 0, 0, 0);
elm_widget_sub_object_add(it->base.widget, it->spacer);
}
+
+ _elm_genlist_item_odd_even_update(it);
+
for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
{
if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
"elm", _signal_expand, it);
edje_object_signal_callback_add(it->base.view, "elm,action,contract",
"elm", _signal_contract, it);
- stacking = edje_object_data_get(it->base.view, "stacking");
- if (stacking)
- {
- if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
- else if (!strcmp(stacking, "above"))
- evas_object_raise(it->base.view);
- }
evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
_mouse_down, it);
evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
_multi_up, it);
evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
_multi_move, it);
- if (itc)
- {
- if (it->selected != itc->selected)
- {
- if (it->selected)
- edje_object_signal_emit(it->base.view,
- "elm,state,selected", "elm");
- }
- if (it->disabled != itc->disabled)
- {
- if (it->disabled)
- edje_object_signal_emit(it->base.view,
- "elm,state,disabled", "elm");
- }
- if (it->expanded != itc->expanded)
- {
- if (it->expanded)
- edje_object_signal_emit(it->base.view,
- "elm,state,expanded", "elm");
- }
- }
- else
- {
- if (it->selected)
- edje_object_signal_emit(it->base.view,
- "elm,state,selected", "elm");
- if (it->disabled)
- edje_object_signal_emit(it->base.view,
- "elm,state,disabled", "elm");
- if (it->expanded)
- edje_object_signal_emit(it->base.view,
- "elm,state,expanded", "elm");
- }
+
+ _elm_genlist_item_state_update(it, itc);
}
- if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
+ if ((calc) && (it->wd->homogeneous) &&
+ ((it->wd->item_width) ||
+ ((it->wd->item_width) && (it->wd->group_item_width))))
{
/* homogenous genlist shortcut */
if (!it->mincalcd)
}
else
{
- if (it->itc->func.label_get)
- {
- const Eina_List *l;
- const char *key;
-
- it->labels =
- elm_widget_stringlist_get(edje_object_data_get(it->base.view,
- "labels"));
- EINA_LIST_FOREACH(it->labels, l, key)
- {
- char *s = it->itc->func.label_get
- ((void *)it->base.data, it->base.widget, l->data);
-
- if (s)
- {
- edje_object_part_text_set(it->base.view, l->data, s);
- free(s);
- }
- else if (itc)
- edje_object_part_text_set(it->base.view, l->data, "");
- }
- }
- if (it->itc->func.icon_get)
- {
- const Eina_List *l;
- const char *key;
-
- it->icons =
- elm_widget_stringlist_get(edje_object_data_get(it->base.view,
- "icons"));
- EINA_LIST_FOREACH(it->icons, l, key)
- {
- Evas_Object *ic = it->itc->func.icon_get
- ((void *)it->base.data, it->base.widget, l->data);
-
- if (ic)
- {
- it->icon_objs = eina_list_append(it->icon_objs, ic);
- edje_object_part_swallow(it->base.view, key, ic);
- evas_object_show(ic);
- elm_widget_sub_object_add(it->base.widget, ic);
- }
- }
- }
- if (it->itc->func.state_get)
- {
- const Eina_List *l;
- const char *key;
+ /* FIXME: If you see that assert, please notify us and we
+ will clean our mess */
+ assert(eina_list_count(it->icon_objs) == 0);
- it->states =
- elm_widget_stringlist_get(edje_object_data_get(it->base.view,
- "states"));
- EINA_LIST_FOREACH(it->states, l, key)
- {
- Eina_Bool on = it->itc->func.state_get
- ((void *)it->base.data, it->base.widget, l->data);
+ _item_label_realize(it, it->base.view, &it->labels);
+ it->icon_objs = _item_icon_realize(it, it->base.view, &it->icons);
+ _item_state_realize(it, it->base.view, &it->states);
- if (on)
- {
- snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
- edje_object_signal_emit(it->base.view, buf, "elm");
- }
- else if (itc)
- {
- snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
- edje_object_signal_emit(it->base.view, buf, "elm");
- }
- }
- }
if (!it->mincalcd)
{
Evas_Coord mw = -1, mh = -1;
- if (it->wd->height_for_width) mw = it->wd->w;
-
if (!it->display_only)
elm_coords_finger_size_adjust(1, &mw, 1, &mh);
if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
it->tooltip.content_cb,
it->tooltip.data, NULL);
elm_widget_item_tooltip_style_set(it, it->tooltip.style);
+ elm_widget_item_tooltip_size_restrict_disable(it, it->tooltip.free_size);
}
if (it->mouse_cursor)
it->want_unrealize = EINA_FALSE;
if (itc) _item_cache_free(itc);
- if (!calc) evas_object_smart_callback_call(it->base.widget, "realized", it);
+ //evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ //evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
+ if (!calc)
+ evas_object_smart_callback_call(it->base.widget, SIG_REALIZED, it);
+ edje_object_message_signal_process(it->base.view);
}
static void
-_item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
+_item_unrealize(Elm_Genlist_Item *it,
+ Eina_Bool calc)
{
Evas_Object *icon;
if (!it->realized) return;
- if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
+ if (it->wd->reorder_it == it) return;
+ evas_event_freeze(evas_object_evas_get(it->wd->obj));
+ if (!calc)
+ evas_object_smart_callback_call(it->base.widget, SIG_UNREALIZED, it);
if (it->long_timer)
{
ecore_timer_del(it->long_timer);
}
else
{
- edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
+ edje_object_mirrored_set(it->base.view,
+ elm_widget_mirrored_get(it->base.widget));
+ edje_object_scale_set(it->base.view,
+ elm_widget_scale_get(it->base.widget)
+ * _elm_config->scale);
_item_cache_add(it);
}
elm_widget_stringlist_free(it->labels);
EINA_LIST_FREE(it->icon_objs, icon)
evas_object_del(icon);
+ _mode_item_unrealize(it);
it->states = NULL;
it->realized = EINA_FALSE;
it->want_unrealize = EINA_FALSE;
+ evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
}
static Eina_Bool
_item_block_recalc(Item_Block *itb,
int in,
- int qadd,
- int norender)
+ Eina_Bool qadd)
{
const Eina_List *l;
Elm_Genlist_Item *it;
Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
Evas_Coord y = 0;
+ //evas_event_freeze(evas_object_evas_get(itb->wd->obj));
itb->num = in;
EINA_LIST_FOREACH(itb->items, l, it)
{
itb->minw = minw;
itb->minh = minh;
itb->changed = EINA_FALSE;
- /* force an evas norender to garbage collect deleted objects */
- if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
+ //evas_event_thaw(evas_object_evas_get(itb->wd->obj));
+ //evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
return showme;
}
static void
-_item_block_realize(Item_Block *itb,
- int in,
- int full)
+_item_block_realize(Item_Block *itb)
{
- const Eina_List *l;
- Elm_Genlist_Item *it;
-
if (itb->realized) return;
- EINA_LIST_FOREACH(itb->items, l, it)
- {
- if (it->delete_me) continue;
- if (full) _item_realize(it, in, EINA_FALSE);
- in++;
- }
itb->realized = EINA_TRUE;
itb->want_unrealize = EINA_FALSE;
}
Eina_Bool dragging = EINA_FALSE;
if (!itb->realized) return;
+ evas_event_freeze(evas_object_evas_get(itb->wd->obj));
EINA_LIST_FOREACH(itb->items, l, it)
{
if (it->flags != ELM_GENLIST_ITEM_GROUP)
}
else
itb->want_unrealize = EINA_FALSE;
+ evas_event_thaw(evas_object_evas_get(itb->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
+}
+
+static int
+_get_space_for_reorder_item(Elm_Genlist_Item *it)
+{
+ Evas_Coord rox, roy, row, roh, oy, oh;
+ Eina_Bool top = EINA_FALSE;
+ Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
+ if (!reorder_it) return 0;
+
+ evas_object_geometry_get(it->wd->pan_smart, NULL, &oy, NULL, &oh);
+ evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
+
+ if ((it->wd->reorder_start_y < it->block->y) &&
+ (roy - oy + (roh / 2) >= it->block->y - it->wd->pan_y))
+ {
+ it->block->reorder_offset = it->wd->reorder_it->h * -1;
+ if (it->block->count == 1)
+ it->wd->reorder_rel = it;
+ }
+ else if ((it->wd->reorder_start_y >= it->block->y) &&
+ (roy - oy + (roh / 2) <= it->block->y - it->wd->pan_y))
+ {
+ it->block->reorder_offset = it->wd->reorder_it->h;
+ }
+ else
+ it->block->reorder_offset = 0;
+
+ it->scrl_y += it->block->reorder_offset;
+
+ top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
+ rox, roy + (roh / 2), row, 1));
+ if (top)
+ {
+ it->wd->reorder_rel = it;
+ it->scrl_y += it->wd->reorder_it->h;
+ return it->wd->reorder_it->h;
+ }
+ else
+ return 0;
+}
+
+static Eina_Bool
+_reorder_move_animator_cb(void *data)
+{
+ Elm_Genlist_Item *it = data;
+ Eina_Bool down = EINA_FALSE;
+ double t;
+ int y, dy = it->h / 10 * _elm_config->scale, diff;
+
+ t = ((0.0 > (t = ecore_loop_time_get()-it->wd->start_time)) ? 0.0 : t);
+
+ if (t <= REORDER_EFFECT_TIME) y = (1 * sin((t / REORDER_EFFECT_TIME) * (M_PI / 2)) * dy);
+ else y = dy;
+
+ diff = abs(it->old_scrl_y - it->scrl_y);
+ if (diff > it->h) y = diff / 2;
+
+ if (it->old_scrl_y < it->scrl_y)
+ {
+ it->old_scrl_y += y;
+ down = EINA_TRUE;
+ }
+ else if (it->old_scrl_y > it->scrl_y)
+ {
+ it->old_scrl_y -= y;
+ down = EINA_FALSE;
+ }
+ _item_position(it, it->base.view, it->scrl_x, it->old_scrl_y);
+ _group_items_recalc(it->wd);
+
+ if ((it->wd->reorder_pan_move) ||
+ (down && it->old_scrl_y >= it->scrl_y) ||
+ (!down && it->old_scrl_y <= it->scrl_y))
+ {
+ it->old_scrl_y = it->scrl_y;
+ it->move_effect_enabled = EINA_FALSE;
+ it->wd->reorder_move_animator = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+static void
+_item_position(Elm_Genlist_Item *it,
+ Evas_Object *view,
+ Evas_Coord it_x,
+ Evas_Coord it_y)
+{
+ if (!it) return;
+ if (!view) return;
+
+ evas_event_freeze(evas_object_evas_get(it->wd->obj));
+ evas_object_resize(view, it->w, it->h);
+ evas_object_move(view, it_x, it_y);
+ evas_object_show(view);
+ evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
}
static void
Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
int vis;
+ evas_event_freeze(evas_object_evas_get(itb->wd->obj));
evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
&cvw, &cvh);
EINA_LIST_FOREACH(itb->items, l, it)
{
if (it->delete_me) continue;
+ else if (it->wd->reorder_it == it) continue;
it->x = 0;
it->y = y;
it->w = itb->w;
{
if (vis)
{
+ if (it->wd->reorder_mode)
+ y += _get_space_for_reorder_item(it);
git = it->group_item;
if (git)
{
git->scrl_y = (it->scrl_y + it->h) - git->h;
git->want_realize = EINA_TRUE;
}
- evas_object_resize(it->base.view, it->w, it->h);
- evas_object_move(it->base.view,
- it->scrl_x, it->scrl_y);
- evas_object_show(it->base.view);
+ if ((it->wd->reorder_it) && (it->old_scrl_y != it->scrl_y))
+ {
+ if (!it->move_effect_enabled)
+ {
+ it->move_effect_enabled = EINA_TRUE;
+ it->wd->reorder_move_animator =
+ ecore_animator_add(
+ _reorder_move_animator_cb, it);
+ }
+ }
+ if (!it->move_effect_enabled)
+ {
+ if (it->mode_view)
+ _item_position(it, it->mode_view, it->scrl_x,
+ it->scrl_y);
+ else
+ _item_position(it, it->base.view, it->scrl_x,
+ it->scrl_y);
+ it->old_scrl_y = it->scrl_y;
+ }
}
else
{
}
y += it->h;
}
+ evas_event_thaw(evas_object_evas_get(itb->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
}
static void
Eina_List *l;
Elm_Genlist_Item *git;
+ evas_event_freeze(evas_object_evas_get(wd->obj));
EINA_LIST_FOREACH(wd->group_items, l, git)
{
if (git->want_realize)
_item_unrealize(git, EINA_FALSE);
}
}
+ evas_event_thaw(evas_object_evas_get(wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(wd->obj));
}
static Eina_Bool
_calc_job(void *data)
{
Widget_Data *wd = data;
- Item_Block *itb;
+ Item_Block *itb, *chb = NULL;
Evas_Coord minw = -1, minh = 0, y = 0, ow;
- Item_Block *chb = NULL;
- int in = 0, minw_change = 0;
- Eina_Bool changed = EINA_FALSE;
+ int in = 0;
double t0, t;
+ Eina_Bool minw_change = EINA_FALSE;
Eina_Bool did_must_recalc = EINA_FALSE;
if (!wd) return;
t0 = ecore_time_get();
evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
if (wd->w != ow)
- {
- wd->w = ow;
- // if (wd->height_for_width) changed = EINA_TRUE;
- }
+ wd->w = ow;
+ evas_event_freeze(evas_object_evas_get(wd->obj));
EINA_INLIST_FOREACH(wd->blocks, itb)
{
Eina_Bool showme = EINA_FALSE;
{
if (itb->realized) _item_block_unrealize(itb);
}
- if ((itb->changed) || (changed) ||
- ((itb->must_recalc) && (!did_must_recalc)))
+ if ((itb->changed) || ((itb->must_recalc) && (!did_must_recalc)))
{
- if ((changed) || (itb->must_recalc))
+ if (itb->must_recalc)
{
Eina_List *l;
Elm_Genlist_Item *it;
itb->must_recalc = EINA_FALSE;
}
if (itb->realized) _item_block_unrealize(itb);
- showme = _item_block_recalc(itb, in, 0, 1);
+ showme = _item_block_recalc(itb, in, EINA_FALSE);
chb = itb;
}
itb->y = y;
else if ((!itb->must_recalc) && (minw < itb->minw))
{
minw = itb->minw;
- minw_change = 1;
+ minw_change = EINA_TRUE;
}
itb->w = minw;
itb->h = itb->minh;
wd->minh = minh;
evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
_sizing_eval(wd->obj);
- if ((wd->anchor_item) && (wd->anchor_item->block))
+ if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scroll_enabled))
{
Elm_Genlist_Item *it;
Evas_Coord it_y;
}
wd->calc_job = NULL;
evas_object_smart_changed(wd->pan_smart);
+ evas_event_thaw(evas_object_evas_get(wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(wd->obj));
}
static void
Widget_Data *wd = data;
Eina_List *l2;
Item_Block *itb;
- int num, num0, position = 0, recalc = 0;
+ int num, num0;
+ Eina_Bool position = EINA_FALSE, recalc = EINA_FALSE;
if (!wd) return;
wd->update_job = NULL;
num = 0;
+
+ evas_event_freeze(evas_object_evas_get(wd->obj));
EINA_INLIST_FOREACH(wd->blocks, itb)
{
Evas_Coord itminw, itminh;
continue;
}
num0 = num;
- recalc = 0;
+ recalc = EINA_FALSE;
EINA_LIST_FOREACH(itb->items, l2, it)
{
if (it->updateme)
{
_item_unrealize(it, EINA_FALSE);
_item_realize(it, num, EINA_FALSE);
- position = 1;
+ position = EINA_TRUE;
}
else
{
_item_unrealize(it, EINA_TRUE);
}
if ((it->minw != itminw) || (it->minh != itminh))
- recalc = 1;
+ recalc = EINA_TRUE;
}
num++;
}
itb->updateme = EINA_FALSE;
if (recalc)
{
- position = 1;
+ position = EINA_TRUE;
itb->changed = EINA_TRUE;
- _item_block_recalc(itb, num0, 0, 1);
+ _item_block_recalc(itb, num0, EINA_FALSE);
_item_block_position(itb, num0);
}
}
if (wd->calc_job) ecore_job_del(wd->calc_job);
wd->calc_job = ecore_job_add(_calc_job, wd);
}
+ evas_event_thaw(evas_object_evas_get(wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(wd->obj));
}
static void
Pan *sd = evas_object_smart_data_get(obj);
Item_Block *itb;
+ if (!sd) return;
// Evas_Coord ow, oh;
// evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
// ow = sd->wd->minw - ow;
}
}
done:
- evas_object_smart_changed(obj);
+ if (!sd->wd->reorder_move_animator) evas_object_smart_changed(obj);
}
static void
{
Pan *sd = evas_object_smart_data_get(obj);
+ if (!sd) return;
if (x) *x = sd->wd->pan_x;
if (y) *y = sd->wd->pan_y;
}
Pan *sd = evas_object_smart_data_get(obj);
Evas_Coord ow, oh;
+ if (!sd) return;
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
ow = sd->wd->minw - ow;
if (ow < 0) ow = 0;
{
Pan *sd = evas_object_smart_data_get(obj);
+ if (!sd) return;
if (w) *w = sd->wd->minw;
if (h) *h = sd->wd->minh;
}
_pan_resize_job(void *data)
{
Pan *sd = data;
+ if (!sd) return;
_sizing_eval(sd->wd->obj);
sd->resize_job = NULL;
}
Pan *sd = evas_object_smart_data_get(obj);
Evas_Coord ow, oh;
+ if (!sd) return;
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
if ((ow == w) && (oh == h)) return;
if ((sd->wd->height_for_width) && (ow != w))
{
+ /* fix me later */
if (sd->resize_job) ecore_job_del(sd->resize_job);
sd->resize_job = ecore_job_add(_pan_resize_job, sd);
}
+ sd->wd->pan_resized = EINA_TRUE;
+ evas_object_smart_changed(obj);
+ if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
+ sd->wd->calc_job = NULL;
+/* OLD
if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
+ */
}
static void
Elm_Genlist_Item *git;
Eina_List *l;
+ if (!sd) return;
+ evas_event_freeze(evas_object_evas_get(obj));
+
+ if (sd->wd->pan_resized)
+ {
+ _calc_job(sd->wd);
+ sd->wd->pan_resized = EINA_FALSE;
+ }
+
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
EINA_LIST_FOREACH(sd->wd->group_items, l, git)
cvx, cvy, cvw, cvh))
{
if ((!itb->realized) || (itb->changed))
- _item_block_realize(itb, in, 0);
+ _item_block_realize(itb);
_item_block_position(itb, in);
}
else
}
in += itb->count;
}
- _group_items_recalc(sd->wd);
+ if ((!sd->wd->reorder_it) || (sd->wd->reorder_pan_move))
+ _group_items_recalc(sd->wd);
+ if ((sd->wd->reorder_mode) && (sd->wd->reorder_it))
+ {
+ if (sd->wd->pan_y != sd->wd->reorder_old_pan_y)
+ sd->wd->reorder_pan_move = EINA_TRUE;
+ else sd->wd->reorder_pan_move = EINA_FALSE;
+ evas_object_raise(sd->wd->reorder_it->base.view);
+ sd->wd->reorder_old_pan_y = sd->wd->pan_y;
+ sd->wd->start_time = ecore_loop_time_get();
+ }
+ _item_auto_scroll(sd->wd);
+ evas_event_thaw(evas_object_evas_get(obj));
+ evas_event_thaw_eval(evas_object_evas_get(obj));
}
static void
{
Pan *sd = evas_object_smart_data_get(obj);
+ if (!sd) return;
if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
}
}
static void
+_scr_anim_start(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
+}
+
+static void
+_scr_anim_stop(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
+}
+
+static void
+_scr_drag_start(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
+}
+
+static void
+_scr_drag_stop(void *data,
+ Evas_Object *obj __UNUSED__,
+ void *event_info __UNUSED__)
+{
+ evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
+}
+
+static void
_scroll_edge_left(void *data,
Evas_Object *scr __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *obj = data;
- evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
+ evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_LEFT, NULL);
}
static void
void *event_info __UNUSED__)
{
Evas_Object *obj = data;
- evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
+ evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_RIGHT, NULL);
}
static void
void *event_info __UNUSED__)
{
Evas_Object *obj = data;
- evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
+ evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_TOP, NULL);
}
static void
void *event_info __UNUSED__)
{
Evas_Object *obj = data;
- evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
+ evas_object_smart_callback_call(obj, SIG_SCROLL_EDGE_BOTTOM, NULL);
+}
+
+static void
+_mode_item_realize(Elm_Genlist_Item *it)
+{
+ char buf[1024];
+
+ if ((it->mode_view) || (it->delete_me)) return;
+
+ evas_event_freeze(evas_object_evas_get(it->wd->obj));
+ it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
+ edje_object_scale_set(it->mode_view,
+ elm_widget_scale_get(it->base.widget) *
+ _elm_config->scale);
+ evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
+ elm_widget_sub_object_add(it->base.widget, it->mode_view);
+
+ strncpy(buf, "item", sizeof(buf));
+ if (it->wd->compress)
+ strncat(buf, "_compress", sizeof(buf) - strlen(buf));
+
+ if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
+ strncat(buf, "/", sizeof(buf) - strlen(buf));
+ strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
+
+ _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
+ elm_widget_style_get(it->base.widget));
+ edje_object_mirrored_set(it->mode_view,
+ elm_widget_mirrored_get(it->base.widget));
+
+ /* signal callback add */
+ evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
+ _mouse_down, it);
+ evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
+ _mouse_up, it);
+ evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
+ _mouse_move, it);
+
+ /* label_get, icon_get, state_get */
+ /* FIXME: If you see that assert, please notify us and we
+ will clean our mess */
+ assert(eina_list_count(it->mode_icon_objs) == 0);
+
+ _item_label_realize(it, it->mode_view, &it->mode_labels);
+ it->mode_icon_objs = _item_icon_realize(it,
+ it->mode_view,
+ &it->mode_icons);
+ _item_state_realize(it, it->mode_view, &it->mode_states);
+
+ edje_object_part_swallow(it->mode_view,
+ edje_object_data_get(it->mode_view, "mode_part"),
+ it->base.view);
+
+ it->want_unrealize = EINA_FALSE;
+ evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
+}
+
+static void
+_mode_item_unrealize(Elm_Genlist_Item *it)
+{
+ Widget_Data *wd = it->wd;
+ Evas_Object *icon;
+ if (!it->mode_view) return;
+
+ evas_event_freeze(evas_object_evas_get(it->wd->obj));
+ elm_widget_stringlist_free(it->mode_labels);
+ it->mode_labels = NULL;
+ elm_widget_stringlist_free(it->mode_icons);
+ it->mode_icons = NULL;
+ elm_widget_stringlist_free(it->mode_states);
+
+ EINA_LIST_FREE(it->mode_icon_objs, icon)
+ evas_object_del(icon);
+
+ edje_object_part_unswallow(it->mode_view, it->base.view);
+ evas_object_smart_member_add(it->base.view, wd->pan_smart);
+ evas_object_del(it->mode_view);
+ it->mode_view = NULL;
+
+ if (wd->mode_item == it)
+ wd->mode_item = NULL;
+ evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
+}
+
+static void
+_item_mode_set(Elm_Genlist_Item *it)
+{
+ if (!it) return;
+ Widget_Data *wd = it->wd;
+ if (!wd) return;
+ char buf[1024];
+
+ wd->mode_item = it;
+ it->nocache = EINA_TRUE;
+
+ if (wd->scr_hold_timer)
+ {
+ ecore_timer_del(wd->scr_hold_timer);
+ wd->scr_hold_timer = NULL;
+ }
+ elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
+ wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
+
+ evas_event_freeze(evas_object_evas_get(it->wd->obj));
+ _mode_item_realize(it);
+ if (it->group_item)
+ evas_object_raise(it->group_item->base.view);
+ _item_position(it, it->mode_view, it->scrl_x, it->scrl_y);
+ evas_event_thaw(evas_object_evas_get(it->wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
+
+ snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
+ edje_object_signal_emit(it->mode_view, buf, "elm");
+}
+
+static void
+_item_mode_unset(Widget_Data *wd)
+{
+ if (!wd) return;
+ if (!wd->mode_item) return;
+ char buf[1024], buf2[1024];
+ Elm_Genlist_Item *it;
+
+ it = wd->mode_item;
+ it->nocache = EINA_TRUE;
+
+ snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
+ snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
+
+ edje_object_signal_emit(it->mode_view, buf, "elm");
+ edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
+
+ wd->mode_item = NULL;
+}
+
+static void
+_item_auto_scroll(Widget_Data *wd)
+{
+ if (!wd) return;
+ Elm_Genlist_Item *it;
+ Eina_List *l;
+ Evas_Coord ox, oy, ow, oh;
+
+ if ((wd->expanded_item) && (wd->auto_scroll_enabled))
+ {
+ evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
+ if (wd->expanded_item->scrl_y > (oh + oy) / 2)
+ {
+ EINA_LIST_FOREACH(wd->expanded_item->items, l, it)
+ elm_genlist_item_bring_in(it);
+ }
+ wd->auto_scroll_enabled = EINA_FALSE;
+ }
}
-/**
- * Add a new Genlist object
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Genlist
- */
EAPI Evas_Object *
elm_genlist_add(Evas_Object *parent)
{
elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_event_hook_set(obj, _event_hook);
elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
+ elm_widget_translate_hook_set(obj, _translate_hook);
wd->scr = elm_smart_scroller_add(e);
elm_smart_scroller_widget_set(wd->scr, obj);
_elm_config->thumbscroll_bounce_enable);
elm_widget_resize_object_set(obj, wd->scr);
+ evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
+ evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
+ evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
+ evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
obj);
&minw, &minh);
evas_object_size_hint_min_set(obj, minw, minh);
+ evas_object_smart_callbacks_descriptions_set(obj, _signals);
+
_mirrored_set(obj, elm_widget_mirrored_get(obj));
_sizing_eval(obj);
return obj;
it->func.data = func_data;
it->mouse_cursor = NULL;
it->expanded_depth = 0;
+ elm_widget_item_text_get_hook_set(it, _item_label_hook);
+ elm_widget_item_del_cb_set(it, _item_del_hook);
+
+ if (it->parent)
+ {
+ if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
+ it->group_item = parent;
+ else if (it->parent->group_item)
+ it->group_item = it->parent->group_item;
+ }
return it;
}
}
static int
-_queue_process(Widget_Data *wd,
- int norender)
+_queue_process(Widget_Data *wd)
{
int n;
Eina_Bool showme = EINA_FALSE;
double t0, t;
t0 = ecore_time_get();
+ //evas_event_freeze(evas_object_evas_get(wd->obj));
for (n = 0; (wd->queue) && (n < 128); n++)
{
Elm_Genlist_Item *it;
t = ecore_time_get();
if (it->block->changed)
{
- showme = _item_block_recalc(it->block, it->block->num, 1,
- norender);
+ showme = _item_block_recalc(it->block, it->block->num, EINA_TRUE);
it->block->changed = 0;
}
if (showme) it->block->showme = EINA_TRUE;
if ((t - t0) > (ecore_animator_frametime_get())) break;
}
}
+ //evas_event_thaw(evas_object_evas_get(wd->obj));
+ //evas_event_thaw_eval(evas_object_evas_get(wd->obj));
return n;
}
static Eina_Bool
-_item_idler(void *data)
+_idle_process(void *data, Eina_Bool *wakeup)
{
Widget_Data *wd = data;
//static double q_start = 0.0;
//if (q_start == 0.0) q_start = ecore_time_get();
//xxx
-
- if (_queue_process(wd, 1) > 0)
- {
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- wd->calc_job = ecore_job_add(_calc_job, wd);
- }
+ if (_queue_process(wd) > 0) *wakeup = EINA_TRUE;
if (!wd->queue)
{
//xxx
//printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
//xxx
- wd->queue_idler = NULL;
return ECORE_CALLBACK_CANCEL;
}
return ECORE_CALLBACK_RENEW;
}
+static Eina_Bool
+_item_idle_enterer(void *data)
+{
+ Widget_Data *wd = data;
+ Eina_Bool wakeup = EINA_FALSE;
+ Eina_Bool ok = _idle_process(data, &wakeup);
+
+ if (wakeup)
+ {
+ // wake up mainloop
+ if (wd->calc_job) ecore_job_del(wd->calc_job);
+ wd->calc_job = ecore_job_add(_calc_job, wd);
+ }
+ if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
+ return ok;
+}
+
static void
_item_queue(Widget_Data *wd,
Elm_Genlist_Item *it)
if (it->queued) return;
it->queued = EINA_TRUE;
wd->queue = eina_list_append(wd->queue, it);
+// FIXME: why does a freeze then thaw here cause some genlist
+// elm_genlist_item_append() to be much much slower?
+// evas_event_freeze(evas_object_evas_get(wd->obj));
while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
{
- if (wd->queue_idler)
+ if (wd->queue_idle_enterer)
{
- ecore_idler_del(wd->queue_idler);
- wd->queue_idler = NULL;
+ ecore_idle_enterer_del(wd->queue_idle_enterer);
+ wd->queue_idle_enterer = NULL;
}
- _queue_process(wd, 0);
- }
- if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
-}
-
-/**
- * Append item to the end of the genlist
- *
- * This appends the given item to the end of the list or the end of
- * the children if the parent is given.
- *
- * @param obj The genlist object
- * @param itc The item class for the item
- * @param data The item data
- * @param parent The parent item, or NULL if none
- * @param flags Item flags
- * @param func Convenience function called when item selected
- * @param func_data Data passed to @p func above.
- * @return A handle to the item added or NULL if not possible
- *
- * @ingroup Genlist
- */
+ _queue_process(wd);
+ }
+// evas_event_thaw(evas_object_evas_get(wd->obj));
+// evas_event_thaw_eval(evas_object_evas_get(wd->obj));
+ if (!wd->queue_idle_enterer)
+ wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
+}
+
+static int
+_elm_genlist_item_compare_data(const void *data, const void *data1)
+{
+ const Elm_Genlist_Item *item = data;
+ const Elm_Genlist_Item *item1 = data1;
+
+ return _elm_genlist_item_compare_data_cb(item->base.data, item1->base.data);
+}
+
+static int
+_elm_genlist_item_compare(const void *data, const void *data1)
+{
+ const Elm_Genlist_Item *item, *item1;
+ item = ELM_GENLIST_ITEM_FROM_INLIST(data);
+ item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
+ return _elm_genlist_item_compare_cb(item, item1);
+}
+
+static int
+_elm_genlist_item_list_compare(const void *data, const void *data1)
+{
+ const Elm_Genlist_Item *item = data;
+ const Elm_Genlist_Item *item1 = data1;
+ return _elm_genlist_item_compare_cb(item, item1);
+}
+
+static void
+_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
+{
+ if (!it) return;
+ if (!after) return;
+
+ it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
+ _item_block_del(it);
+
+ it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
+ it->rel = after;
+ it->rel->relcount++;
+ it->before = EINA_FALSE;
+ if (after->group_item) it->group_item = after->group_item;
+ _item_queue(it->wd, it);
+
+ // TODO: change this to smart callback
+ if (it->itc->func.moved)
+ it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
+}
+
+static void
+_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
+{
+ if (!it) return;
+ if (!before) return;
+
+ it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
+ _item_block_del(it);
+ it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
+ it->rel = before;
+ it->rel->relcount++;
+ it->before = EINA_TRUE;
+ if (before->group_item) it->group_item = before->group_item;
+ _item_queue(it->wd, it);
+
+ // TODO: change this to smart callback
+ if (it->itc->func.moved)
+ it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
+}
+
EAPI Elm_Genlist_Item *
elm_genlist_item_append(Evas_Object *obj,
const Elm_Genlist_Item_Class *itc,
EINA_INLIST_GET(it2));
it->rel = it2;
it->rel->relcount++;
-
- if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
- it->group_item = parent;
- else if (it->parent->group_item)
- it->group_item = it->parent->group_item;
}
it->before = EINA_FALSE;
_item_queue(wd, it);
return it;
}
-/**
- * Prepend item at start of the genlist
- *
- * This adds an item to the beginning of the list or beginning of the
- * children of the parent if given.
- *
- * @param obj The genlist object
- * @param itc The item class for the item
- * @param data The item data
- * @param parent The parent item, or NULL if none
- * @param flags Item flags
- * @param func Convenience function called when item selected
- * @param func_data Data passed to @p func above.
- * @return A handle to the item added or NULL if not possible
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_item_prepend(Evas_Object *obj,
const Elm_Genlist_Item_Class *itc,
return it;
}
-/**
- * Insert item before another in the genlist
- *
- * This inserts an item before another in the list. It will be in the
- * same tree level or group as the item it is inseted before.
- *
- * @param obj The genlist object
- * @param itc The item class for the item
- * @param data The item data
- * @param before The item to insert before
- * @param flags Item flags
- * @param func Convenience function called when item selected
- * @param func_data Data passed to @p func above.
- * @return A handle to the item added or NULL if not possible
- *
- * @ingroup Genlist
- */
+EAPI Elm_Genlist_Item *
+elm_genlist_item_insert_after(Evas_Object *obj,
+ const Elm_Genlist_Item_Class *itc,
+ const void *data,
+ Elm_Genlist_Item *parent,
+ Elm_Genlist_Item *after,
+ Elm_Genlist_Item_Flags flags,
+ Evas_Smart_Cb func,
+ const void *func_data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
+ func_data);
+ if (!it) return NULL;
+ /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
+
+ if (!it->parent)
+ {
+ if ((flags & ELM_GENLIST_ITEM_GROUP) &&
+ (after->flags & ELM_GENLIST_ITEM_GROUP))
+ wd->group_items = eina_list_append_relative(wd->group_items, it,
+ after);
+ }
+ else
+ {
+ it->parent->items = eina_list_append_relative(it->parent->items, it,
+ after);
+ }
+ wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
+ EINA_INLIST_GET(after));
+ it->rel = after;
+ it->rel->relcount++;
+ it->before = EINA_FALSE;
+ _item_queue(wd, it);
+ return it;
+}
+
EAPI Elm_Genlist_Item *
elm_genlist_item_insert_before(Evas_Object *obj,
const Elm_Genlist_Item_Class *itc,
Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
func_data);
if (!it) return NULL;
- if (it->parent)
+ /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
+
+ if (!it->parent)
+ {
+ if ((flags & ELM_GENLIST_ITEM_GROUP) &&
+ (before->flags & ELM_GENLIST_ITEM_GROUP))
+ wd->group_items = eina_list_prepend_relative(wd->group_items, it,
+ before);
+ }
+ else
{
it->parent->items = eina_list_prepend_relative(it->parent->items, it,
before);
return it;
}
-/**
- * Insert an item after another in the genlst
- *
- * This inserts an item after another in the list. It will be in the
- * same tree level or group as the item it is inseted after.
- *
- * @param obj The genlist object
- * @param itc The item class for the item
- * @param data The item data
- * @param after The item to insert after
- * @param flags Item flags
- * @param func Convenience function called when item selected
- * @param func_data Data passed to @p func above.
- * @return A handle to the item added or NULL if not possible
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
-elm_genlist_item_insert_after(Evas_Object *obj,
- const Elm_Genlist_Item_Class *itc,
- const void *data,
- Elm_Genlist_Item *parent,
- Elm_Genlist_Item *after,
- Elm_Genlist_Item_Flags flags,
- Evas_Smart_Cb func,
- const void *func_data)
+elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
+ const Elm_Genlist_Item_Class *itc,
+ const void *data,
+ Elm_Genlist_Item *parent,
+ Elm_Genlist_Item_Flags flags,
+ Eina_Compare_Cb comp,
+ Evas_Smart_Cb func,
+ const void *func_data)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
+ Elm_Genlist_Item *rel = NULL;
Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
func_data);
if (!it) return NULL;
- wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
- EINA_INLIST_GET(after));
+
+ _elm_genlist_item_compare_cb = comp;
+
if (it->parent)
{
- it->parent->items = eina_list_append_relative(it->parent->items, it,
- after);
+ Eina_List *l;
+ int cmp_result;
+
+ l = eina_list_search_sorted_near_list(it->parent->items,
+ _elm_genlist_item_list_compare, it,
+ &cmp_result);
+ if (l)
+ rel = eina_list_data_get(l);
+ else
+ rel = it->parent;
+
+ if (cmp_result >= 0)
+ {
+ it->parent->items = eina_list_prepend_relative_list(it->parent->items, it, l);
+ wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
+ it->before = EINA_FALSE;
+ }
+ else if (cmp_result < 0)
+ {
+ it->parent->items = eina_list_append_relative_list(it->parent->items, it, l);
+ wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
+ it->before = EINA_TRUE;
+ }
}
- it->rel = after;
- it->rel->relcount++;
- it->before = EINA_FALSE;
+ else
+ {
+ if (!wd->state)
+ {
+ wd->state = eina_inlist_sorted_state_new();
+ }
+
+ if (flags & ELM_GENLIST_ITEM_GROUP)
+ wd->group_items = eina_list_append(wd->group_items, it);
+
+ wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it),
+ _elm_genlist_item_compare, wd->state);
+
+ if (EINA_INLIST_GET(it)->next)
+ {
+ rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
+ it->before = EINA_TRUE;
+ }
+ else if (EINA_INLIST_GET(it)->prev)
+ {
+ rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
+ it->before = EINA_FALSE;
+ }
+ }
+
+ if (rel)
+ {
+ it->rel = rel;
+ it->rel->relcount++;
+ }
+
_item_queue(wd, it);
+
return it;
}
-/**
- * Clear the genlist
- *
- * This clears all items in the list, leaving it empty.
- *
- * @param obj The genlist object
- *
- * @ingroup Genlist
- */
+EAPI Elm_Genlist_Item *
+elm_genlist_item_sorted_insert(Evas_Object *obj,
+ const Elm_Genlist_Item_Class *itc,
+ const void *data,
+ Elm_Genlist_Item *parent,
+ Elm_Genlist_Item_Flags flags,
+ Eina_Compare_Cb comp,
+ Evas_Smart_Cb func,
+ const void *func_data)
+{
+ _elm_genlist_item_compare_data_cb = comp;
+
+ return elm_genlist_item_direct_sorted_insert(obj, itc, data, parent, flags,
+ _elm_genlist_item_compare_data, func, func_data);
+}
+
EAPI void
elm_genlist_clear(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
+ if (wd->state)
+ {
+ eina_inlist_sorted_state_free(wd->state);
+ wd->state = NULL;
+ }
if (wd->walking > 0)
{
Elm_Genlist_Item *it;
}
return;
}
+ evas_event_freeze(evas_object_evas_get(wd->obj));
while (wd->items)
{
Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
ecore_job_del(wd->calc_job);
wd->calc_job = NULL;
}
- if (wd->queue_idler)
+ if (wd->queue_idle_enterer)
{
- ecore_idler_del(wd->queue_idler);
- wd->queue_idler = NULL;
+ ecore_idle_enterer_del(wd->queue_idle_enterer);
+ wd->queue_idle_enterer = NULL;
}
if (wd->must_recalc_idler)
{
eina_list_free(wd->selected);
wd->selected = NULL;
}
+ if (wd->reorder_move_animator)
+ {
+ ecore_animator_del(wd->reorder_move_animator);
+ wd->reorder_move_animator = NULL;
+ }
wd->show_item = NULL;
wd->pan_x = 0;
wd->pan_y = 0;
+ wd->reorder_old_pan_y = 0;
wd->minw = 0;
wd->minh = 0;
if (wd->pan_smart)
evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
}
_sizing_eval(obj);
+ elm_smart_scroller_child_region_show(wd->scr, 0, 0, 0, 0);
+ evas_event_thaw(evas_object_evas_get(wd->obj));
+ evas_event_thaw_eval(evas_object_evas_get(wd->obj));
}
-/**
- * Enable or disable multi-select in the genlist
- *
- * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
- * the list. This allows more than 1 item to be selected.
- *
- * @param obj The genlist object
- * @param multi Multi-select enable/disable
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_multi_select_set(Evas_Object *obj,
Eina_Bool multi)
wd->multi = multi;
}
-/**
- * Gets if multi-select in genlist is enable or disable
- *
- * @param obj The genlist object
- * @return Multi-select enable/disable
- * (EINA_TRUE = enabled/EINA_FALSE = disabled)
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_multi_select_get(const Evas_Object *obj)
{
return wd->multi;
}
-/**
- * Get the selectd item in the genlist
- *
- * This gets the selected item in the list (if multi-select is enabled
- * only the first item in the list is selected - which is not very
- * useful, so see elm_genlist_selected_items_get() for when
- * multi-select is used).
- *
- * If no item is selected, NULL is returned.
- *
- * @param obj The genlist object
- * @return The selected item, or NULL if none.
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_selected_item_get(const Evas_Object *obj)
{
return NULL;
}
-/**
- * Get a list of selected items in the genlist
- *
- * This returns a list of the selected items. This list pointer is
- * only valid so long as no items are selected or unselected (or
- * unselected implicitly by deletion). The list contains
- * Elm_Genlist_Item pointers.
- *
- * @param obj The genlist object
- * @return The list of selected items, nor NULL if none are selected.
- *
- * @ingroup Genlist
- */
EAPI const Eina_List *
elm_genlist_selected_items_get(const Evas_Object *obj)
{
return wd->selected;
}
-/**
- * Get a list of realized items in genlist
- *
- * This returns a list of the realized items in the genlist. The list
- * contains Elm_Genlist_Item pointers. The list must be freed by the
- * caller when done with eina_list_free(). The item pointers in the
- * list are only valid so long as those items are not deleted or the
- * genlist is not deleted.
- *
- * @param obj The genlist object
- * @return The list of realized items, nor NULL if none are realized.
- *
- * @ingroup Genlist
- */
EAPI Eina_List *
elm_genlist_realized_items_get(const Evas_Object *obj)
{
return list;
}
-/**
- * Get the item that is at the x, y canvas coords
- *
- * This returns the item at the given coordinates (which are canvas
- * relative not object-relative). If an item is at that coordinate,
- * that item handle is returned, and if @p posret is not NULL, the
- * integer pointed to is set to a value of -1, 0 or 1, depending if
- * the coordinate is on the upper portion of that item (-1), on the
- * middle section (0) or on the lower part (1). If NULL is returned as
- * an item (no item found there), then posret may indicate -1 or 1
- * based if the coordinate is above or below all items respectively in
- * the genlist.
- *
- * @param it The item
- * @param x The input x coordinate
- * @param y The input y coordinate
- * @param posret The position relative to the item returned here
- * @return The item at the coordinates or NULL if none
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_at_xy_item_get(const Evas_Object *obj,
Evas_Coord x,
return NULL;
}
-/**
- * Get the first item in the genlist
- *
- * This returns the first item in the list.
- *
- * @param obj The genlist object
- * @return The first item, or NULL if none
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_first_item_get(const Evas_Object *obj)
{
return it;
}
-/**
- * Get the last item in the genlist
- *
- * This returns the last item in the list.
- *
- * @return The last item, or NULL if none
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_last_item_get(const Evas_Object *obj)
{
return it;
}
-/**
- * Get the next item in the genlist
- *
- * This returns the item after the item @p it.
- *
- * @param it The item
- * @return The item after @p it, or NULL if none
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_item_next_get(const Elm_Genlist_Item *it)
{
return (Elm_Genlist_Item *)it;
}
-/**
- * Get the previous item in the genlist
- *
- * This returns the item before the item @p it.
- *
- * @param it The item
- * @return The item before @p it, or NULL if none
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
{
return (Elm_Genlist_Item *)it;
}
-/**
- * Get the genlist object from an item
- *
- * This returns the genlist object itself that an item belongs to.
- *
- * @param it The item
- * @return The genlist object
- *
- * @ingroup Genlist
- */
EAPI Evas_Object *
elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
{
return it->base.widget;
}
-/**
- * Get the parent item of the given item
- *
- * This returns the parent item of the item @p it given.
- *
- * @param it The item
- * @return The parent of the item or NULL if none
- *
- * @ingroup Genlist
- */
EAPI Elm_Genlist_Item *
elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
{
return it->parent;
}
-/**
- * Clear all sub-items (children) of the given item
- *
- * This clears all items that are children (or their descendants) of the
- * given item @p it.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
{
elm_genlist_item_del(it2);
}
-/**
- * Set the selected state of an item
- *
- * This sets the selected state (1 selected, 0 not selected) of the given
- * item @p it.
- *
- * @param it The item
- * @param selected The selected state
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_selected_set(Elm_Genlist_Item *it,
Eina_Bool selected)
ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
Widget_Data *wd = elm_widget_data_get(it->base.widget);
if (!wd) return;
- if (it->delete_me) return;
+ if ((it->delete_me) || (it->disabled)) return;
selected = !!selected;
if (it->selected == selected) return;
if (!wd->multi)
{
while (wd->selected)
- _item_unselect(wd->selected->data);
+ {
+ _item_unhighlight(wd->selected->data);
+ _item_unselect(wd->selected->data);
+ }
}
_item_highlight(it);
_item_select(it);
}
else
- _item_unselect(it);
-}
-
-/**
- * Get the selected state of an item
- *
- * This gets the selected state of an item (1 selected, 0 not selected).
- *
- * @param it The item
- * @return The selected state
- *
- * @ingroup Genlist
- */
+ {
+ _item_unhighlight(it);
+ _item_unselect(it);
+ }
+}
+
EAPI Eina_Bool
elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
{
return it->selected;
}
-/**
- * Sets the expanded state of an item (if it's a parent)
- *
- * This expands or contracts a parent item (thus showing or hiding the
- * children).
- *
- * @param it The item
- * @param expanded The expanded state (1 expanded, 0 not expanded).
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
Eina_Bool expanded)
ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
if (it->expanded == expanded) return;
it->expanded = expanded;
+ it->wd->expanded_item = it;
if (it->expanded)
{
if (it->realized)
edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
- evas_object_smart_callback_call(it->base.widget, "expanded", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_EXPANDED, it);
+ it->wd->auto_scroll_enabled = EINA_TRUE;
}
else
{
if (it->realized)
edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
- evas_object_smart_callback_call(it->base.widget, "contracted", it);
+ evas_object_smart_callback_call(it->base.widget, SIG_CONTRACTED, it);
+ it->wd->auto_scroll_enabled = EINA_FALSE;
}
}
-/**
- * Get the expanded state of an item
- *
- * This gets the expanded state of an item
- *
- * @param it The item
- * @return Thre expanded state
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
{
return it->expanded;
}
-/**
- * Get the depth of expanded item
- *
- * @param it The genlist item object
- * @return The depth of expanded item
- *
- * @ingroup Genlist
- */
EAPI int
elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
{
return it->expanded_depth;
}
-/**
- * Sets the disabled state of an item.
- *
- * A disabled item cannot be selected or unselected. It will also
- * change appearance to appear disabled. This sets the disabled state
- * (1 disabled, 0 not disabled).
- *
- * @param it The item
- * @param disabled The disabled state
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
Eina_Bool disabled)
{
ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
+ Eina_List *l;
+ Evas_Object *obj;
if (it->disabled == disabled) return;
if (it->delete_me) return;
- it->disabled = disabled;
+ it->disabled = !!disabled;
+ if (it->selected)
+ elm_genlist_item_selected_set(it, EINA_FALSE);
if (it->realized)
{
if (it->disabled)
edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
else
edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
+ EINA_LIST_FOREACH(it->icon_objs, l, obj)
+ elm_widget_disabled_set(obj, disabled);
}
}
-/**
- * Get the disabled state of an item
- *
- * This gets the disabled state of the given item.
- *
- * @param it The item
- * @return The disabled state
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
{
return it->disabled;
}
-/**
- * Sets the display only state of an item.
- *
- * A display only item cannot be selected or unselected. It is for
- * display only and not selecting or otherwise clicking, dragging
- * etc. by the user, thus finger size rules will not be applied to
- * this item.
- *
- * @param it The item
- * @param display_only The display only state
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
Eina_Bool display_only)
it->wd->update_job = ecore_job_add(_update_job, it->wd);
}
-/**
- * Get the display only state of an item
- *
- * This gets the display only state of the given item.
- *
- * @param it The item
- * @return The display only state
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
{
return it->display_only;
}
-/**
- * Show the given item
- *
- * This causes genlist to jump to the given item @p it and show it (by
- * scrolling), if it is not fully visible.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_show(Elm_Genlist_Item *it)
{
it->block->w, it->h);
}
-/**
- * Bring in the given item
- *
- * This causes genlist to jump to the given item @p it and show it (by
- * scrolling), if it is not fully visible. This may use animation to
- * do so and take a period of time
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_bring_in(Elm_Genlist_Item *it)
{
it->block->w, it->h);
}
-/**
- * Show the given item at the top
- *
- * This causes genlist to jump to the given item @p it and show it (by
- * scrolling), if it is not fully visible.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_top_show(Elm_Genlist_Item *it)
{
it->block->w, oh);
}
-/**
- * Bring in the given item at the top
- *
- * This causes genlist to jump to the given item @p it and show it (by
- * scrolling), if it is not fully visible. This may use animation to
- * do so and take a period of time
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
{
it->block->w, oh);
}
-/**
- * Show the given item at the middle
- *
- * This causes genlist to jump to the given item @p it and show it (by
- * scrolling), if it is not fully visible.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_middle_show(Elm_Genlist_Item *it)
{
it->h / 2, it->block->w, oh);
}
-/**
- * Bring in the given item at the middle
- *
- * This causes genlist to jump to the given item @p it and show it (by
- * scrolling), if it is not fully visible. This may use animation to
- * do so and take a period of time
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
{
it->block->w, oh);
}
-/**
- * Delete a given item
- *
- * This deletes the item from genlist and calls the genlist item del
- * class callback defined in the item class, if it is set. This clears all
- * subitems if it is a tree.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_del(Elm_Genlist_Item *it)
{
_item_del(it);
}
-/**
- * Set the data item from the genlist item
- *
- * This set the data value passed on the elm_genlist_item_append() and
- * related item addition calls. This function will also call
- * elm_genlist_item_update() so the item will be updated to reflect the
- * new data.
- *
- * @param it The item
- * @param data The new data pointer to set
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_data_set(Elm_Genlist_Item *it,
const void *data)
{
ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
elm_widget_item_data_set(it, data);
- elm_genlist_item_update(it);
}
-/**
- * Get the data item from the genlist item
- *
- * This returns the data value passed on the elm_genlist_item_append()
- * and related item addition calls and elm_genlist_item_data_set().
- *
- * @param it The item
- * @return The data pointer provided when created
- *
- * @ingroup Genlist
- */
EAPI void *
elm_genlist_item_data_get(const Elm_Genlist_Item *it)
{
return elm_widget_item_data_get(it);
}
-/**
- * Tells genlist to "orphan" icons fetchs by the item class
- *
- * This instructs genlist to release references to icons in the item,
- * meaning that they will no longer be managed by genlist and are
- * floating "orphans" that can be re-used elsewhere if the user wants
- * to.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
{
}
}
-/**
- * Get the real evas object of the genlist item
- *
- * This returns the actual evas object used for the specified genlist
- * item. This may be NULL as it may not be created, and may be deleted
- * at any time by genlist. Do not modify this object (move, resize,
- * show, hide etc.) as genlist is controlling it. This function is for
- * querying, emitting custom signals or hooking lower level callbacks
- * for events. Do not delete this object under any circumstances.
- *
- * @param it The item
- * @return The object pointer
- *
- * @ingroup Genlist
- */
EAPI const Evas_Object *
elm_genlist_item_object_get(const Elm_Genlist_Item *it)
{
return it->base.view;
}
-/**
- * Update the contents of an item
- *
- * This updates an item by calling all the item class functions again
- * to get the icons, labels and states. Use this when the original
- * item data has changed and the changes are desired to be reflected.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_update(Elm_Genlist_Item *it)
{
it->wd->update_job = ecore_job_add(_update_job, it->wd);
}
-/**
- * Update the item class of an item
- *
- * @param it The item
- * @parem itc The item class for the item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
const Elm_Genlist_Item_Class *itc)
elm_genlist_item_update(it);
}
+EAPI const Elm_Genlist_Item_Class *
+elm_genlist_item_item_class_get(const Elm_Genlist_Item *it)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
+ if (it->delete_me) return NULL;
+ return it->itc;
+}
+
static Evas_Object *
_elm_genlist_item_label_create(void *data,
- Evas_Object *obj,
+ Evas_Object *obj __UNUSED__,
+ Evas_Object *tooltip,
void *item __UNUSED__)
{
- Evas_Object *label = elm_label_add(obj);
+ Evas_Object *label = elm_label_add(tooltip);
if (!label)
return NULL;
elm_object_style_set(label, "tooltip");
- elm_label_label_set(label, data);
+ elm_object_text_set(label, data);
return label;
}
eina_stringshare_del(data);
}
-/**
- * Set the text to be shown in the genlist item.
- *
- * @param item Target item
- * @param text The text to set in the content
- *
- * Setup the text as tooltip to object. The item can have only one
- * tooltip, so any previous tooltip data is removed.
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
const char *text)
_elm_genlist_item_label_del_cb);
}
-/**
- * Set the content to be shown in the tooltip item
- *
- * Setup the tooltip to item. The item can have only one tooltip, so
- * any previous tooltip data is removed. @p func(with @p data) will be
- * called every time that need to show the tooltip and it should return a
- * valid Evas_Object. This object is then managed fully by tooltip
- * system and is deleted when the tooltip is gone.
- *
- * @param item the genlist item being attached by a tooltip.
- * @param func the function used to create the tooltip contents.
- * @param data what to provide to @a func as callback data/context.
- * @param del_cb called when data is not needed anymore, either when
- * another callback replaces @func, the tooltip is unset with
- * elm_genlist_item_tooltip_unset() or the owner @a item
- * dies. This callback receives as the first parameter the
- * given @a data, and @c event_info is the item.
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
Elm_Tooltip_Item_Content_Cb func,
item->tooltip.content_cb,
item->tooltip.data, NULL);
elm_widget_item_tooltip_style_set(item, item->tooltip.style);
+ elm_widget_item_tooltip_size_restrict_disable(item, item->tooltip.free_size);
}
return;
if (del_cb) del_cb((void *)data, NULL, NULL);
}
-/**
- * Unset tooltip from item
- *
- * @param item genlist item to remove previously set tooltip.
- *
- * Remove tooltip from item. The callback provided as del_cb to
- * elm_genlist_item_tooltip_content_cb_set() will be called to notify
- * it is not used anymore.
- *
- * @see elm_genlist_item_tooltip_content_cb_set()
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
{
item->tooltip.del_cb = NULL;
item->tooltip.content_cb = NULL;
item->tooltip.data = NULL;
+ item->tooltip.free_size = EINA_FALSE;
if (item->tooltip.style)
elm_genlist_item_tooltip_style_set(item, NULL);
}
-/**
- * Sets a different style for this item tooltip.
- *
- * @note before you set a style you should define a tooltip with
- * elm_genlist_item_tooltip_content_cb_set() or
- * elm_genlist_item_tooltip_text_set()
- *
- * @param item genlist item with tooltip already set.
- * @param style the theme style to use (default, transparent, ...)
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
const char *style)
if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
}
-/**
- * Get the style for this item tooltip.
- *
- * @param item genlist item with tooltip already set.
- * @return style the theme style in use, defaults to "default". If the
- * object does not have a tooltip set, then NULL is returned.
- *
- * @ingroup Genlist
- */
EAPI const char *
elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
{
return item->tooltip.style;
}
-/**
- * Set the cursor to be shown when mouse is over the genlist item
- *
- * @param item Target item
- * @param cursor the cursor name to be used.
- *
- * @see elm_object_cursor_set()
- * @ingroup Genlist
- */
+EAPI Eina_Bool
+elm_genlist_item_tooltip_size_restrict_disable(Elm_Genlist_Item *item, Eina_Bool disable)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
+ item->tooltip.free_size = disable;
+ if (item->base.view) return elm_widget_item_tooltip_size_restrict_disable(item, disable);
+ return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+elm_genlist_item_tooltip_size_restrict_disabled_get(const Elm_Genlist_Item *item)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
+ return item->tooltip.free_size;
+}
+
EAPI void
elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
const char *cursor)
if (item->base.view) elm_widget_item_cursor_set(item, cursor);
}
-/**
- * Get the cursor to be shown when mouse is over the genlist item
- *
- * @param item genlist item with cursor already set.
- * @return the cursor name.
- *
- * @ingroup Genlist
- */
EAPI const char *
elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
{
return elm_widget_item_cursor_get(item);
}
-/**
- * Unset the cursor to be shown when mouse is over the genlist item
- *
- * @param item Target item
- *
- * @see elm_object_cursor_unset()
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
{
item->mouse_cursor = NULL;
}
-/**
- * Sets a different style for this item cursor.
- *
- * @note before you set a style you should define a cursor with
- * elm_genlist_item_cursor_set()
- *
- * @param item genlist item with cursor already set.
- * @param style the theme style to use (default, transparent, ...)
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
const char *style)
elm_widget_item_cursor_style_set(item, style);
}
-/**
- * Get the style for this item cursor.
- *
- * @param item genlist item with cursor already set.
- * @return style the theme style in use, defaults to "default". If the
- * object does not have a cursor set, then NULL is returned.
- *
- * @ingroup Genlist
- */
EAPI const char *
elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
{
return elm_widget_item_cursor_style_get(item);
}
-/**
- * Set if the cursor set should be searched on the theme or should use
- * the provided by the engine, only.
- *
- * @note before you set if should look on theme you should define a
- * cursor with elm_object_cursor_set(). By default it will only look
- * for cursors provided by the engine.
- *
- * @param item widget item with cursor already set.
- * @param engine_only boolean to define it cursors should be looked
- * only between the provided by the engine or searched on widget's
- * theme as well.
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
Eina_Bool engine_only)
elm_widget_item_cursor_engine_only_set(item, engine_only);
}
-/**
- * Get the cursor engine only usage for this item cursor.
- *
- * @param item widget item with cursor already set.
- * @return engine_only boolean to define it cursors should be looked
- * only between the provided by the engine or searched on widget's
- * theme as well. If the object does not have a cursor set, then
- * EINA_FALSE is returned.
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
{
return elm_widget_item_cursor_engine_only_get(item);
}
-/**
- * This sets the horizontal stretching mode
- *
- * This sets the mode used for sizing items horizontally. Valid modes
- * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
- * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
- * the scroller will scroll horizontally. Otherwise items are expanded
- * to fill the width of the viewport of the scroller. If it is
- * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
- * limited to that size.
- *
- * @param obj The genlist object
- * @param mode The mode to use
- *
- * @ingroup Genlist
- */
EAPI void
-elm_genlist_horizontal_mode_set(Evas_Object *obj,
+elm_genlist_horizontal_set(Evas_Object *obj,
Elm_List_Mode mode)
{
ELM_CHECK_WIDTYPE(obj, widtype);
_sizing_eval(obj);
}
-/**
- * Gets the horizontal stretching mode
- *
- * @param obj The genlist object
- * @return The mode to use
- * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
- *
- * @ingroup Genlist
- */
+EAPI void
+elm_genlist_horizontal_mode_set(Evas_Object *obj,
+ Elm_List_Mode mode)
+{
+ elm_genlist_horizontal_set(obj, mode);
+}
+
EAPI Elm_List_Mode
-elm_genlist_horizontal_mode_get(const Evas_Object *obj)
+elm_genlist_horizontal_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
Widget_Data *wd = elm_widget_data_get(obj);
return wd->mode;
}
-/**
- * Set the always select mode.
- *
- * Items will only call their selection func and callback when first
- * becoming selected. Any further clicks will do nothing, unless you
- * enable always select with elm_genlist_always_select_mode_set().
- * This means even if selected, every click will make the selected
- * callbacks be called.
- *
- * @param obj The genlist object
- * @param always_select The always select mode
- * (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
+EAPI Elm_List_Mode
+elm_genlist_horizontal_mode_get(const Evas_Object *obj)
+{
+ return elm_genlist_horizontal_get(obj);
+}
+
EAPI void
elm_genlist_always_select_mode_set(Evas_Object *obj,
Eina_Bool always_select)
wd->always_select = always_select;
}
-/**
- * Get the always select mode.
- *
- * @param obj The genlist object
- * @return The always select mode
- * (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_always_select_mode_get(const Evas_Object *obj)
{
return wd->always_select;
}
-/**
- * Set no select mode
- *
- * This will turn off the ability to select items entirely and they
- * will neither appear selected nor call selected callback functions.
- *
- * @param obj The genlist object
- * @param no_select The no select mode
- * (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_no_select_mode_set(Evas_Object *obj,
Eina_Bool no_select)
wd->no_select = no_select;
}
-/**
- * Gets no select mode
- *
- * @param obj The genlist object
- * @return The no select mode
- * (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_no_select_mode_get(const Evas_Object *obj)
{
return wd->no_select;
}
-/**
- * Set compress mode
- *
- * This will enable the compress mode where items are "compressed"
- * horizontally to fit the genlist scrollable viewport width. This is
- * special for genlist. Do not rely on
- * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
- * work as genlist needs to handle it specially.
- *
- * @param obj The genlist object
- * @param compress The compress mode
- * (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_compress_mode_set(Evas_Object *obj,
Eina_Bool compress)
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->compress = compress;
+ if (!compress) elm_genlist_homogeneous_set(obj, EINA_FALSE);
}
-/**
- * Get the compress mode
- *
- * @param obj The genlist object
- * @return The compress mode
- * (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_compress_mode_get(const Evas_Object *obj)
{
return wd->compress;
}
-/**
- * Set height-for-width mode
- *
- * With height-for-width mode the item width will be fixed (restricted
- * to a minimum of) to the list width when calculating its size in
- * order to allow the height to be calculated based on it. This allows,
- * for instance, text block to wrap lines if the Edje part is
- * configured with "text.min: 0 1".
- *
- * @note This mode will make list resize slower as it will have to
- * recalculate every item height again whenever the list width
- * changes!
- *
- * @note When height-for-width mode is enabled, it also enables
- * compress mode (see elm_genlist_compress_mode_set()) and
- * disables homogeneous (see elm_genlist_homogeneous_set()).
- *
- * @param obj The genlist object
- * @param setting The height-for-width mode (EINA_TRUE = on,
- * EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_height_for_width_mode_set(Evas_Object *obj,
Eina_Bool height_for_width)
}
}
-/**
- * Get the height-for-width mode
- *
- * @param obj The genlist object
- * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
- * off)
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
{
return wd->height_for_width;
}
-/**
- * Set bounce mode
- *
- * This will enable or disable the scroller bounce mode for the
- * genlist. See elm_scroller_bounce_set() for details
- *
- * @param obj The genlist object
- * @param h_bounce Allow bounce horizontally
- * @param v_bounce Allow bounce vertically
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_bounce_set(Evas_Object *obj,
Eina_Bool h_bounce,
elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
}
-/**
- * Get the bounce mode
- *
- * @param obj The genlist object
- * @param h_bounce Allow bounce horizontally
- * @param v_bounce Allow bounce vertically
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_bounce_get(const Evas_Object *obj,
Eina_Bool *h_bounce,
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
-}
-
-/**
- * Set homogenous mode
- *
- * This will enable the homogeneous mode where items are of the same
- * height and width so that genlist may do the lazy-loading at its
- * maximum. This implies 'compressed' mode.
- *
- * @param obj The genlist object
- * @param homogeneous Assume the items within the genlist are of the
- * same height and width (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
+ elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
+}
+
EAPI void
elm_genlist_homogeneous_set(Evas_Object *obj,
Eina_Bool homogeneous)
wd->homogeneous = homogeneous;
}
-/**
- * Get the homogenous mode
- *
- * @param obj The genlist object
- * @return Assume the items within the genlist are of the same height
- * and width (EINA_TRUE = on, EINA_FALSE = off)
- *
- * @ingroup Genlist
- */
EAPI Eina_Bool
elm_genlist_homogeneous_get(const Evas_Object *obj)
{
return wd->homogeneous;
}
-/**
- * Set the maximum number of items within an item block
- *
- * This will configure the block count to tune to the target with
- * particular performance matrix.
- *
- * @param obj The genlist object
- * @param n Maximum number of items within an item block
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_block_count_set(Evas_Object *obj,
int n)
_item_cache_clean(wd);
}
-/**
- * Get the maximum number of items within an item block
- *
- * @param obj The genlist object
- * @return Maximum number of items within an item block
- *
- * @ingroup Genlist
- */
EAPI int
elm_genlist_block_count_get(const Evas_Object *obj)
{
return wd->max_items_per_block;
}
-/**
- * Set the timeout in seconds for the longpress event
- *
- * @param obj The genlist object
- * @param timeout timeout in seconds
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_longpress_timeout_set(Evas_Object *obj,
double timeout)
wd->longpress_timeout = timeout;
}
-/**
- * Get the timeout in seconds for the longpress event
- *
- * @param obj The genlist object
- * @return timeout in seconds
- *
- * @ingroup Genlist
- */
EAPI double
elm_genlist_longpress_timeout_get(const Evas_Object *obj)
{
return wd->longpress_timeout;
}
-/**
- * Set the scrollbar policy
- *
- * This sets the scrollbar visibility policy for the given genlist
- * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
- * made visible if it is needed, and otherwise kept hidden.
- * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
- * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
- * respectively for the horizontal and vertical scrollbars.
- *
- * @param obj The genlist object
- * @param policy_h Horizontal scrollbar policy
- * @param policy_v Vertical scrollbar policy
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_scroller_policy_set(Evas_Object *obj,
Elm_Scroller_Policy policy_h,
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
+ if ((!wd) || (!wd->scr)) return;
if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
(policy_v >= ELM_SCROLLER_POLICY_LAST))
return;
- if (wd->scr)
- elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
-}
-
-/**
- * Get the scrollbar policy
- *
- * @param obj The genlist object
- * @param policy_h Horizontal scrollbar policy
- * @param policy_v Vertical scrollbar policy
- *
- * @ingroup Genlist
- */
+ elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
+}
+
EAPI void
elm_genlist_scroller_policy_get(const Evas_Object *obj,
Elm_Scroller_Policy *policy_h,
if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
}
-/**
- * Update the contents of all realized items
- *
- * This updates all realized items by calling all the item class functions again
- * to get the icons, labels and states. Use this when the original
- * item data has changed and the changes are desired to be reflected.
- *
- * @param it The item
- *
- * @ingroup Genlist
- */
EAPI void
elm_genlist_realized_items_update(Evas_Object *obj)
{
EINA_LIST_FOREACH(list, l, it)
elm_genlist_item_update(it);
}
+
+EAPI void
+elm_genlist_item_mode_set(Elm_Genlist_Item *it,
+ const char *mode_type,
+ Eina_Bool mode_set)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
+ Widget_Data *wd = it->wd;
+ Eina_List *l;
+ Elm_Genlist_Item *it2;
+
+ if (!wd) return;
+ if (!mode_type) return;
+ if ((it->delete_me) || (it->disabled)) return;
+
+ if ((wd->mode_item == it) &&
+ (!strcmp(mode_type, wd->mode_type)) &&
+ (mode_set))
+ return;
+ if (!it->itc->mode_item_style) return;
+
+ if (wd->multi)
+ {
+ EINA_LIST_FOREACH(wd->selected, l, it2)
+ if (it2->realized)
+ elm_genlist_item_selected_set(it2, EINA_FALSE);
+ }
+ else
+ {
+ it2 = elm_genlist_selected_item_get(wd->obj);
+ if ((it2) && (it2->realized))
+ elm_genlist_item_selected_set(it2, EINA_FALSE);
+ }
+
+ if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
+ (mode_set) ||
+ ((it == wd->mode_item) && (!mode_set)))
+ _item_mode_unset(wd);
+
+ eina_stringshare_replace(&wd->mode_type, mode_type);
+ if (mode_set) _item_mode_set(it);
+}
+
+EAPI const char *
+elm_genlist_mode_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return wd->mode_type;
+}
+
+EAPI const Elm_Genlist_Item *
+elm_genlist_mode_item_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return wd->mode_item;
+}
+
+EAPI void
+elm_genlist_reorder_mode_set(Evas_Object *obj,
+ Eina_Bool reorder_mode)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ wd->reorder_mode = reorder_mode;
+}
+
+EAPI Eina_Bool
+elm_genlist_reorder_mode_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return EINA_FALSE;
+ return wd->reorder_mode;
+}