efl.evas.Smart Class

class efl.evas.Smart

Bases: object

An abstract class that defines the behavior of the SmartObject.

Parameters

clipped (bool) – Make this Smart use a clipped class, ignoring the provided callback methods, except calculate() and resize().

New in version 1.14.

static delete(obj)

Called in order to remove object from canvas and deallocate its resources.

Usually you delete object’s children here.

static member_add(obj, Object child)

Called when children is added to object.

static member_del(obj, Object child)

Called when children is removed from object.

static move(obj, int x, int y)

Called in order to move object to given position.

Usually you move children here.

static resize(obj, int w, int h)

Called in order to resize object.

static show(obj)

Called in order to show the given element.

Usually you call the same function on children.

static hide(obj)

Called in order to hide the given element.

Usually you call the same function on children.

static color_set(obj, int r, int g, int b, int a)

Called in order to change object color.

static clip_set(obj, Eo clip)

Called in order to limit object’s visible area.

static clip_unset(obj)

Called in order to unlimit object’s visible area.

static calculate(obj)

Called before object is used for rendering and it is marked as dirty/changed with changed().

callback_description_find(name)
callback_descriptions_get()

efl.evas.SmartObject Class

class efl.evas.SmartObject(Canvas canvas, Smart smart, **kwargs)

Bases: efl.evas.Object

Smart Evas Objects.

Smart objects are user-defined Evas components, often used to group multiple basic elements, associate an object with a clip and deal with them as an unit. See evas documentation for more details.

Pay attention that just creating an object within the SmartObject doesn’t make it a member! You must do member_add() or use one of the provided factories to ensure that. Failing to do so will leave created objects on different layer and no stacking will be done for you.

Note

If you redefine object’s __init__(), you MUST call your parent! Failing to do so will result in objects that just work from Python and not from C, for instance, adding your object to Edje swallow that clips or set color it will not behave as expected.

Parameters
  • canvas (Canvas) – Evas canvas for this object

  • smart (Smart) – Smart prototype

Changed in version 1.14: API was broken because this class had some “hackish” behavior which could no longer be supported because of changes in Cython 0.21.1

The abstract methods are now in a separate class Smart which should be instantiated and passed to this classes constructor as parameter smart

calculate()
callback_add(name, func, *args, **kargs)

Add a callback for the smart event specified by event.

Parameters
  • name – Event name

  • func

    What to callback. Should have the signature:

    function(object, event_info, *args, **kargs)
    

Raises

TypeError – if func is not callable.

Warning

event_info will always be a python object, if the signal is provided by a C-only class, it will crash.

callback_call(name, event_info=None)

Call any smart callbacks for event.

Parameters
  • name – the event name

  • event_info – an event specific info to pass to the callback.

This should be called internally in the smart object when some specific event has occurred. The documentation for the smart object should include a list of possible events and what type of event_info to expect.

Attention

event_info will always be a python object.

callback_del(name, func)

Remove a smart callback.

Removes a callback that was added by callback_add().

Parameters
  • name – event name

  • func – what to callback, should have be previously registered.

Precond

event and func must be used as parameter for callback_add().

Raises

ValueError – if there was no func connected with this event.

callback_description_find(name, search_class=True, search_instance=True)

Find callback description for callback given in name.

or None if not found.

Parameters
  • name (string) – name of desired callback, must not be None.

  • search_class (bool) – whether to search in class descriptions

  • search_instance (bool) – whether to search in instance descriptions

Returns

reference to description if found, None if not found.

callback_descriptions_get(get_class=True, get_instance=True)

Retrieve a smart object’s known smart callback descriptions

This call searches for registered callback descriptions for both instance and class of the given smart object. These lists will be sorted by name.

Note

If just class descriptions are of interest, try Smart.callbacks_descriptions_get() instead.

Parameters
  • get_class (bool) – Get class descriptions

  • get_instance (bool) – Get instance descriptions

Returns

A tuple with two lists, for both class and instance descriptions.

Return type

tuple

callback_descriptions_set(descriptions)

Set an smart object instance’s smart callbacks descriptions.

Returns

True on success, False on failure.

These descriptions are hints to be used by introspection and are not enforced in any way.

It will not be checked if instance callbacks descriptions have the same name as respective possibly registered in the smart object class. Both are kept in different arrays and users of callbacks_descriptions_get() should handle this case as they wish.

Note

While instance callbacks descriptions are possible, they are not recommended. Use class callbacks descriptions instead as they make you smart object user’s life simpler and will use less memory, as descriptions and arrays will be shared among all instances.

Parameters

descriptions – A list with SmartCbDescription descriptions. List elements won’t be modified at run time, but references to them and their contents will be made, so this array should be kept alive during the whole object’s lifetime.

changed()

Mark object as changed, so it’s calculate() will be called.

If an object is changed and it provides a calculate() method, it will be called from Canvas.render(), what we call pre-render calculate.

This can be used to postpone heavy calculations until you need to display the object, example: layout calculations.

member_add(child)

Set an evas object as a member of this object.

Members will automatically be stacked and layered with the smart object. The various stacking function will operate on members relative to the other members instead of the entire canvas.

Non-member objects can not interleave a smart object’s members.

Note

if child is already member of another SmartObject, it will be deleted from that membership and added to this object.

static member_del(child)

Removes a member object from a smart object.

Attention

this will actually map to C API as evas_object_smart_member_del(child), so the object will loose it’s parent event if the object is not part of this object.

members
Return type

tuple of Object

members_get()
move_children_relative(dx, dy)

Moves all children objects relative to a given offset.

This will make each of object’s children to move, from where they before, with those delta values (offsets) on both directions.

Note

This is most useful on custom Smart.move() functions.

Note

Clipped smart objects already make use of this function on their Smart.move() function definition.

Parameters
  • dx – horizontal offset (delta).

  • dy – vertical offset (delta).

need_recalculate

The need_recalculate flag of given smart object.

If this flag is set then calculate() callback (method) of the given smart object will be called, if one is provided, during render phase usually evas_render(). After this step, this flag will be automatically unset.

If no calculate() is provided, this flag will be left unchanged.

Note

Just setting this flag will not make scene dirty and evas_render() will have no effect. To do that, use evas_object_smart_changed(), that will automatically call this function with 1 as parameter.

Note

This flag will be unset during the render phase, after calculate() is called if one is provided. If no calculate() is provided, then the flag will be left unchanged after render phase.

need_recalculate_get()
need_recalculate_set(value)
smart_get()