This widget aims to position objects in a grid layout while actually creating and rendering only the visible ones, using the same idea as the Genlist: the user defines a class for each item, specifying functions that will be called at object creation, deletion, etc. When those items are selected by the user, a callback function is issued. Users may interact with a gengrid via the mouse (by clicking on items to select them and clicking on the grid’s viewport and swiping to pan the whole view) or via the keyboard, navigating through item with the arrow keys.
This widget supports the scrollable interface.
If you wish to control the scolling behaviour using these functions, inherit both the widget class and the Scrollable class using multiple inheritance, for example:
class ScrollableGenlist(Genlist, Scrollable):
def __init__(self, canvas, *args, **kwargs):
Genlist.__init__(self, canvas)
Gengrid may layout its items in one of two possible layouts:
When in “horizontal mode”, items will be placed in columns, from top to bottom and, when the space for a column is filled, another one is started on the right, thus expanding the grid horizontally, making for horizontal scrolling. When in “vertical mode” , though, items will be placed in rows, from left to right and, when the space for a row is filled, another one is started below, thus expanding the grid vertically (and making for vertical scrolling).
An item in a gengrid can have 0 or more texts (they can be regular text or textblock Evas objects - that’s up to the style to determine), 0 or more contents (which are simply objects swallowed into the gengrid item’s theming Edje object) and 0 or more boolean states, which have the behavior left to the user to define. The Edje part names for each of these properties will be looked up, in the theme file for the gengrid, under the Edje (string) data items named "texts", "contents" and "states", respectively. For each of those properties, if more than one part is provided, they must have names listed separated by spaces in the data fields. For the default gengrid item theme, we have one text part ("elm.text"), two content parts ("elm.swalllow.icon" and "elm.swallow.end") and no state parts.
A gengrid item may be at one of several styles. Elementary provides one by default - “default”, but this can be extended by system or application custom themes/overlays/extensions (see Theme for more details).
In order to have the ability to add and delete items on the fly, gengrid implements a class (callback) system where the application provides a structure with information about that type of item (gengrid may contain multiple different items with different classes, states and styles). Gengrid will call the functions in this struct (methods) when an item is “realized” (i.e., created dynamically, while the user is scrolling the grid). All objects will simply be deleted when no longer needed with delete(). The GengridItemClass class contains the following attributes and methods:
If the user wants to have multiple items selected at the same time, multi_select will permit it. If the gengrid is single-selection only (the default), then selected_item will return the selected item or None, if none is selected. If the gengrid is under multi-selection, then selected_items will return a list (that is only valid as long as no items are modified (added, deleted, selected or unselected) of child items on a gengrid.
If an item changes (internal (boolean) state, text or content changes), then use update() to have gengrid update the item with the new state. A gengrid will re-“realize” the item, thus calling the functions in the GengridItemClass set for that item.
To programmatically (un)select an item or get the selected state, use GengridItem.selected. To make an item disabled (unable to be selected and appear differently) or get the disabled state use GengridItem.disabled.
Grid cells will only have their selection smart callbacks called when firstly getting selected. Any further clicks will do nothing, unless you enable the “always select mode”, with select_mode as ELM_OBJECT_SELECT_MODE_ALWAYS, thus making every click to issue selection callbacks. select_mode as ELM_OBJECT_SELECT_MODE_NONE will turn off the ability to select items entirely in the widget and they will neither appear selected nor call the selection smart callbacks.
Remember that you can create new styles and add your own theme augmentation per application with Theme.extension_add. If you absolutely must have a specific style that overrides any theme the user or system sets up you can use Theme.extension_add to add such a file.
No scroll to
Scroll to the nearest viewport
Scroll to the top of viewport
Scroll to the middle of viewport
Default multiple select mode
New in version 1.10.
Disallow mutiple selection when clicked without control key pressed
New in version 1.10.
Value unknown
New in version 1.10.
Bases: efl.elementary.__init__.Object
This is the class that actually implements the widget.
Parameters: |
|
---|
This sets the alignment of the whole grid of items of a gengrid within its given viewport. By default, those values are both 0.5, meaning that the gengrid will have its items grid placed exactly in the middle of its viewport.
Note
If given alignment values are out of the cited ranges, they’ll be changed to the nearest boundary values on the valid ranges.
Type: | tuple of floats |
---|
Get the item that is at the x, y canvas coords.
Parameters: |
|
---|---|
Returns: | (GengridItem, int xposret, int yposret) |
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 xposret is not None, the integer pointed to is set to a value of -1, 0 or 1, depending if the coordinate is on the left portion of that item (-1), on the middle section (0) or on the right part (1). if yposret is not None, 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 None 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 gengrid.
New in version 1.8.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Called when an item is added, removed, resized or moved and when the gengrid is resized or gets “horizontal” property changes.
The user has right-clicked an item.
New in version 1.13.
Called when the item in the gengrid is being dragged.
Called when the item in the gengrid has been dragged (not scrolled) down.
Called when the item in the gengrid has been dragged (not scrolled) left.
Called when the item in the gengrid has been dragged (not scrolled) right.
Called when the item in the gengrid has been dragged (not scrolled) up.
Called when the item in the gengrid has stopped being dragged.
This is called when the gengrid is scrolled until the bottom edge.
This is called when the gengrid is scrolled until the left edge.
This is called when the gengrid is scrolled until the right edge.
This is called when the gengrid is scrolled until the top edge.
When the gengrid has received focus.
New in version 1.8.
an item in the list is highlighted. This is called when the user presses an item or keyboard selection is done so the item is physically highlighted. The event_info parameter is the item that was highlighted.
This is called when a gengrid item index is changed. Note that this callback is called while each item is being realized.
When the gengrid item has received focus.
New in version 1.10.
When a gengrid item movement has just started by keys.
New in version 1.10.
When a gengrid item movement just stopped in reorder mode.
New in version 1.10.
When the gengrid item has lost focus.
New in version 1.10.
This is called when the program’s language is changed. Call Gengrid.realized_items_update() if items text should be translated.
This is called when a gengrid item is moved by a user interaction in a reorder mode. The %c event_info parameter is the item that was moved.
This is called when the item in the gengrid has its implementing Evas object instantiated, de facto. event_info is the gengrid item that was created. The object may be deleted at any time, so it is highly advised to the caller not to use the object returned from GengridItem.object, because it may point to freed objects.
called when the content has been scrolled (moved).
This is called when scrolling animation has started.
This is called when scrolling animation has stopped.
called when dragging the content has started.
called when dragging the content has stopped.
When the gengrid has lost focus.
New in version 1.8.
an item in the list is unhighlighted. This is called when the user releases an item or keyboard selection is moved so the item is physically unhighlighted. The event_info parameter is the item that was unhighlighted.
This is called when the implementing Evas object for this item is deleted. event_info is the gengrid item that was deleted.
Remove all items from a given gengrid widget.
The fill state of the whole grid of items of a gengrid within its given viewport. By default, this value is False, meaning that if the first line of items grid’s isn’t filled, the items are centered with the alignment.
Type: | bool |
---|
Get the first item in the gengrid widget.
Type: | GengridItem |
---|
A gengrid, after creation, has still no information on the size to give to each of its cells. So, you most probably will end up with squares one “finger” wide, the default size. Use this function to force a custom size for you group items, making them as big as you wish.
This will turn on/off the highlight effect when items are selected and they will or will not be highlighted. The selected and clicked callback functions will still be called.
Highlight is enabled by default.
When in “horizontal mode” (True), items will be placed in columns, from top to bottom and, when the space for a column is filled, another one is started on the right, thus expanding the grid horizontally. When in “vertical mode” (False), though, items will be placed in rows, from left to right and, when the space for a row is filled, another one is started below, thus expanding the grid vertically.
Type: | bool |
---|
Append a new item (add as last item) to this gengrid.
Parameters: |
|
---|
Insert a new item after another item in this gengrid.
Parameters: |
|
---|
Insert a new item before another item in this gengrid.
Parameters: |
|
---|
Prepend a new item (add as first item) to this gengrid.
Parameters: |
|
---|
A gengrid, after creation, has still no information on the size to give to each of its cells. So, you most probably will end up with squares one finger wide, the default size. Use this property to force a custom size for you items, making them as big as you wish.
Return how many items are currently in a list.
Type: | int |
---|
Get the last item in the gengrid widget.
Type: | GengridItem |
---|
Multi-selection is the ability to have more than one item selected, on a given gengrid, simultaneously. When it is enabled, a sequence of clicks on different items will make them all selected, progressively. A click on an already selected item will unselect it. If interacting via the keyboard, multi-selection is enabled while holding the “Shift” key.
Note
By default, multi-selection is disabled on gengrids.
Type: | bool |
---|
Gengrid multi select mode.
(If getting mode is failed, it returns ELM_OBJECT_MULTI_SELECT_MODE_MAX)
See: | multi_select |
---|---|
Type: | Multi-select mode |
New in version 1.10.
Get the nth item, in a given gengrid widget, placed at position nth, in its internal items list
Parameters: | nth – The number of the item to grab (0 being the first) |
---|---|
Returns: | The item stored in the object at position nth or None, if there’s no item with that index (and on errors) |
New in version 1.8.
Gengrid widget’s scrolling page size, relative to its viewport size.
Type: | (float h_pagerel, float v_pagerel) |
---|
New in version 1.10.
Set a given gengrid widget’s scrolling page size
Type: | (int h_pagesize, int v_pagesize) |
---|
New in version 1.10.
This returns a tuple of the realized items in the gengrid.
See also
Type: | tuple of GengridItem |
---|
This updates all realized items by calling all the item class functions again to get the contents, texts and states. Use this when the original item data has changed and the changes are desired to be reflected.
To update just one item, use GengridItem.update()
See also
If a gengrid is set to allow reordering, a click held for more than 0.5 over a given item will highlight it specially, signaling the gengrid has entered the reordering state. From that time on, the user will be able to, while still holding the mouse button down, move the item freely in the gengrid’s viewport, replacing to said item to the locations it goes to. The replacements will be animated and, whenever the user releases the mouse button, the item being replaced gets a new definitive place in the grid.
Type: | bool |
---|
Enable the gengrid widget mode reordered with keys.
Parameters: | tween_mode (efl.ecore.Ecore_Pos_Map) – Position mappings for animation |
---|
New in version 1.10.
Stop the gengrid widget mode reorder.
New in version 1.10.
Set the order type.
This affect the way items are moved (when in reorder mode) with the keyboard arrows.
Type: | Reorder type |
---|
New in version 1.11.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Search gengrid item by given string.
This function uses globs (like “*.jpg”) for searching and takes search flags as last parameter. That is a bitfield with values to be ored together or 0 for no flags.
Parameters: |
|
---|---|
Returns: | The first item found |
Return type: |
New in version 1.11.
Item select mode in the gengrid widget. Possible values are:
selection func and callback when first becoming selected. Any further clicks will do nothing, unless you set always select mode.
every click will make the selected callbacks be called.
select items entirely and they will neither appear selected nor call selected callback functions.
This returns the selected item. If multi selection is enabled (multi_select), only the first item in the list is selected, which might not be very useful. For that case, see selected_items.
Type: | GengridItem |
---|
This returns a tuple of the selected items, in the order that they appear in the grid.
See also
Type: | tuple of GengridItem |
---|
Enable or disable mouse wheel to be used to scroll the gengrid.
Mouse wheel can be used for the user to scroll up and down the gengrid.
It’s enabled by default.
Type: | bool |
---|
New in version 1.10.
Bases: efl.elementary.__init__.ObjectItem
An item for the Gengrid widget.
Parameters: |
|
---|
Append a new item (add as last item) to this gengrid.
New in version 1.8.
This causes gengrid to jump to the item and show it (by scrolling), if it is not fully visible. This will use animation to do so and take a period of time to complete.
See also
Parameters: | type – Where to position the item in the viewport. |
---|
User data for the item.
Get the index of the item. It is only valid once displayed.
Insert a new item after another item in this gengrid.
Parameters: | after – a reference item to use, the new item will be inserted after it. |
---|
New in version 1.8.
Insert a new item before another item in this gengrid.
Parameters: | before – a reference item to use, the new item will be inserted before it. |
---|
New in version 1.8.
This returns the item placed after the item, on the container gengrid.
Prepend a new item (add as first item) to this gengrid.
New in version 1.8.
This returns the item placed before the item, on the container gengrid.
The selected state of an item. If multi-selection is not enabled on the containing gengrid and selected is True, any other previously selected items will get unselected in favor of a new one.
This causes gengrid to redraw its viewport’s contents to the region containing the given item, if it is not fully visible.
See also
Parameters: | type – Where to position the item in the viewport. |
---|
Insert a new item after another item in this gengrid.
Parameters: | after – a reference item to use, the new item will be inserted after it. |
---|
New in version 1.8.
This updates an item by calling all the item class functions again to get the contents, texts and states. Use this when the original item data has changed and you want the changes to be reflected.
Bases: object
Defines the behavior of each grid item.
This class should be created and handled to the Gengrid itself.
It may be subclassed, in this case the methods text_get(), content_get(), state_get() and delete() will be used.
It may also be instantiated directly, given getters to override as constructor parameters.
Parameters: |
|
---|
Note
In all these signatures, ‘obj’ means Gengrid and ‘item_data’ is the value given to Gengrid item append/prepend methods, it should represent your item model as you want.
To be called by Gengrid for each item to get its icon.
Parameters: |
|
---|---|
Returns: | icon object to be used and swallowed. |
Return type: | evas Object or None |
Free the C level struct.
New in version 1.8.
The style of this item class.
Increase the C level reference count.
New in version 1.8.
To be called by Gengrid for each item to get its state.
Parameters: |
|
---|---|
Returns: | boolean state to be used. |
Return type: | bool or None |
To be called by Gengrid for each item to get its label.
Parameters: |
|
---|---|
Returns: | label to be used. |
Return type: | str or None |
Decrease the C level reference count.
New in version 1.8.