Tizen Native API  6.0
Smart Object Functions

Functions dealing with Evas smart objects (instances).

Smart objects are groupings of primitive Evas objects that behave as a cohesive group. For instance, a file manager icon may be a smart object composed of an image object, a text label and two rectangles that appear behind the image and text when the icon is selected. As a smart object, the normal Evas object API could be used on the icon object.

Besides that, generally smart objects implement a specific API, so that users interact with its own custom features. The API takes form of explicit exported functions one may call and smart callbacks.

Smart events and callbacks

Smart objects can elect events (smart events, from now on) occurring inside of them to be reported back to their users via callback functions (smart callbacks). This way, you can extend Evas' own object events. They are defined by an event string that identifies them uniquely. There's also a function prototype definition for the callback functions: #Evas_Smart_Cb.

When defining an Evas_Smart_Class, smart object implementors are strongly encouraged to properly set the Evas_Smart_Class::callbacks callbacks description array, so that the users of the smart object can have introspection on its events API at run time.

See some examples of this group of functions.

See also:
Smart Functions for class definitions.

Functions

void evas_smart_legacy_type_register (const char *type, const Efl_Class *klass)
void evas_smart_objects_calculate (Eo *obj)
Eina_Bool evas_smart_objects_calculating_get (const Eo *obj)
 Get if the canvas is currently calculating smart objects.
Evas_Objectevas_object_smart_add (Evas *e, Evas_Smart *s)
void evas_object_smart_member_add (Evas_Object *obj, Evas_Object *smart_obj)
void evas_object_smart_member_del (Evas_Object *obj)
void evas_object_smart_callback_add (Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data)
void evas_object_smart_callback_priority_add (Evas_Object *obj, const char *event, Evas_Callback_Priority priority, Evas_Smart_Cb func, const void *data)
void * evas_object_smart_callback_del (Evas_Object *obj, const char *event, Evas_Smart_Cb func)
void * evas_object_smart_callback_del_full (Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data)
void evas_object_smart_callback_call (Evas_Object *obj, const char *event, void *event_info)
const void * evas_object_smart_interface_get (const Evas_Object *obj, const char *name)
void * evas_object_smart_interface_data_get (const Evas_Object *obj, const Evas_Smart_Interface *iface)
Eina_Bool evas_object_smart_type_check (const Evas_Object *obj, const char *type)
 Checks whether a given smart object or any of its smart object parents is of a given smart class.
Eina_Bool evas_object_smart_type_check_ptr (const Evas_Object *obj, const char *type)
 Checks whether a given smart object or any of its smart object parents is of a given smart class, using pointer comparison.
Eina_Bool evas_object_smart_callbacks_descriptions_set (Evas_Object *obj, const Evas_Smart_Cb_Description *descriptions)
 Set an smart object instance's smart callbacks descriptions.
void evas_object_smart_callbacks_descriptions_get (const Evas_Object *obj, const Evas_Smart_Cb_Description ***class_descriptions, unsigned int *class_count, const Evas_Smart_Cb_Description ***instance_descriptions, unsigned int *instance_count)
 Retrieve an smart object's know smart callback descriptions (both instance and class ones).
void evas_object_smart_callback_description_find (const Evas_Object *obj, const char *name, const Evas_Smart_Cb_Description **class_description, const Evas_Smart_Cb_Description **instance_description)
 Find callback description for callback called name or null if not found.
Evas_Smart * evas_object_smart_smart_get (const Evas_Object *obj)
 Get the Evas_Smart from which obj smart object was created.
void evas_object_smart_data_set (Evas_Object *obj, void *data)
 Store a pointer to user data for a given smart object.
void * evas_object_smart_data_get (const Evas_Object *obj)
 Retrieves the pointer to user data for a given smart object.
Evas_Objectevas_object_smart_clipped_clipper_get (const Evas_Object *obj)
 Get the clipper object for the given clipped smart object.
Eina_Listevas_object_smart_members_get (const Evas_Object *obj)
 Retrieves the list of the member objects of a given Evas smart object.
void evas_object_smart_need_recalculate_set (Evas_Object *obj, Eina_Bool value)
 Set or unset the flag signalling that a given smart object needs to get recalculated.
Eina_Bool evas_object_smart_need_recalculate_get (const Evas_Object *obj)
 Get the value of the flag signalling that a given smart object needs to get recalculated.
Eina_Iteratorevas_object_smart_iterator_new (const Evas_Object *obj)
 Retrieves an iterator of the member objects of a given Evas smart object.
void evas_object_smart_calculate (Evas_Object *obj)
 Call the calculate() smart function immediately on a given smart object.
void evas_object_smart_changed (Evas_Object *obj)
 Mark smart object as changed, dirty.
void evas_object_smart_move_children_relative (Evas_Object *obj, Evas_Coord dx, Evas_Coord dy)
 Moves all children objects of a given smart object relative to a given offset.

Function Documentation

Evas_Object* evas_object_smart_add ( Evas e,
Evas_Smart *  s 
)

Instantiates a new smart object described by s.

Parameters:
ethe canvas on which to add the object
sthe #Evas_Smart describing the smart object
Returns:
a new Evas_Object handle

This is the function one should use when defining the public function adding an instance of the new smart object to a given canvas. It will take care of setting all of its internals to work as they should, if the user set things properly, as seem on the EVAS_SMART_SUBCLASS_NEW, for example.

Since :
2.3
Examples:
evas-smart-interface.c, and evas-smart-object.c.

Call the calculate() smart function immediately on a given smart object.

This will force immediate calculations (see Evas_Smart_Class) needed for renderization of this object and, besides, unset the flag on it telling it needs recalculation for the next rendering phase.

See also evas_object_smart_need_recalculate_set

Since :
3.0
void evas_object_smart_callback_add ( Evas_Object obj,
const char *  event,
Evas_Smart_Cb  func,
const void *  data 
)

Add (register) a callback function to the smart event specified by event on the smart object obj.

Parameters:
obja smart object
eventthe event's name string
functhe callback function
datauser data to be passed to the callback function

Smart callbacks look very similar to Evas callbacks, but are implemented as smart object's custom ones.

This function adds a function callback to an smart object when the event named event occurs in it. The function is func.

In the event of a memory allocation error during addition of the callback to the object, evas_alloc_error() should be used to determine the nature of the error, if any, and the program should sensibly try and recover.

A smart callback function must have the ::Evas_Smart_Cb prototype definition. The first parameter (data) in this definition will have the same value passed to evas_object_smart_callback_add() as the data parameter, at runtime. The second parameter obj is a handle to the object on which the event occurred. The third parameter, event_info, is a pointer to data which is totally dependent on the smart object's implementation and semantic for the given event.

There is an infrastructure for introspection on smart objects' events (see evas_smart_callbacks_descriptions_get()), but no internal smart objects on Evas implement them yet.

See also:
Smart events and callbacks for more details.
evas_object_smart_callback_del()
Since :
2.3
Examples:
actionslider_example_01.c, bg_example_03.c, box_example_02.c, bubble_example_01.c, button_example_00.c, button_example_01.c, calendar_example_05.c, calendar_example_06.c, check_example_01.c, codegen_example.c, colorselector_example_01.c, combobox_example_01.c, ctxpopup_example_01.c, dayselector_example.c, diskselector_example_02.c, efl_thread_1.c, efl_thread_2.c, efl_thread_3.c, efl_thread_4.c, efl_thread_5.c, entry_example.c, evas-smart-interface.c, evas-smart-object.c, fileselector_button_example.c, fileselector_entry_example.c, fileselector_example.c, flip_example_01.c, flipselector_example.c, general_funcs_example.c, gengrid_example.c, genlist_example_02.c, genlist_example_04.c, genlist_example_05.c, glview_example_01.c, hover_example_01.c, hoversel_example_01.c, index_example_01.c, index_example_02.c, inwin_example.c, layout_example_01.c, layout_example_03.c, list_example_03.c, map_example_01.c, map_example_02.c, map_example_03.c, mapbuf_example.c, menu_example_01.c, naviframe_example.c, notify_example_01.c, panes_example.c, photocam_example_01.c, popup_example_01.c, popup_example_02.c, popup_example_03.c, prefs_example_01.c, prefs_example_02.c, prefs_example_03.c, progressbar_example.c, radio_example_01.c, slider_example.c, slideshow_example.c, spinner_example.c, theme_example_01.c, theme_example_02.c, thumb_example_01.c, transit_example_03.c, transit_example_04.c, web_example_02.c, and win_example.c.
void evas_object_smart_callback_call ( Evas_Object obj,
const char *  event,
void *  event_info 
)

Call a given smart callback on the smart object obj.

Parameters:
objthe smart object
eventthe event's name string
event_infopointer to an event specific struct or information to pass to the callback functions registered on this smart event

This should be called internally, from the smart object's own code, when some specific event has occurred and the implementor wants is to pertain to the object's events API (see Smart events and callbacks). The documentation for the smart object should include a list of possible events and what type of event_info to expect for each of them. Also, when defining an Evas_Smart_Class, smart object implementors are strongly encouraged to properly set the Evas_Smart_Class::callbacks callbacks description array, so that the users of the smart object can have introspection on its events API at run time.

Since :
2.3
Examples:
evas-smart-interface.c, and evas-smart-object.c.
void* evas_object_smart_callback_del ( Evas_Object obj,
const char *  event,
Evas_Smart_Cb  func 
)

Delete (unregister) a callback function from the smart event specified by event on the smart object obj.

Parameters:
obja smart object
eventthe event's name string
functhe callback function
Returns:
the data pointer

This function removes the first added smart callback on the object obj matching the event name event and the registered function pointer func. If the removal is successful it will also return the data pointer that was passed to evas_object_smart_callback_add() (that will be the same as the parameter) when the callback(s) was(were) added to the canvas. If not successful NULL will be returned.

See also:
evas_object_smart_callback_add() for more details.
Since :
2.3
void* evas_object_smart_callback_del_full ( Evas_Object obj,
const char *  event,
Evas_Smart_Cb  func,
const void *  data 
)

Delete (unregister) a callback function from the smart event specified by event on the smart object obj.

Parameters:
obja smart object
eventthe event's name string
functhe callback function
datathe data pointer that was passed to the callback
Returns:
the data pointer

This function removes the first added smart callback on the object obj matching the event name event, the registered function pointer func and the callback data pointer data. If the removal is successful it will also return the data pointer that was passed to evas_object_smart_callback_add() (that will be the same as the parameter) when the callback(s) was(were) added to the canvas. If not successful NULL will be returned. A common use would be to remove an exact match of a callback

See also:
evas_object_smart_callback_add() for more details.
Since (EFL) :
1.2
Note:
To delete all smart event callbacks which match type and func, use evas_object_smart_callback_del().
Since :
2.3
void evas_object_smart_callback_description_find ( const Evas_Object obj,
const char *  name,
const Evas_Smart_Cb_Description **  class_description,
const Evas_Smart_Cb_Description **  instance_description 
)

Find callback description for callback called name or null if not found.

If parameter is null, no search will be done on instance descriptions.

Parameters:
[in]namename of desired callback, must not be null. The search have a special case for name being the same pointer as registered with Evas_Smart_Cb_Description, one can use it to avoid excessive use of strcmp().
[out]class_descriptionpointer to return class description or null if not found. If parameter is null, no search will be done on class descriptions.
[out]instance_descriptionpointer to return instance description.
Since :
3.0
void evas_object_smart_callback_priority_add ( Evas_Object obj,
const char *  event,
Evas_Callback_Priority  priority,
Evas_Smart_Cb  func,
const void *  data 
)

Add (register) a callback function to the smart event specified by event on the smart object obj. Except for the priority field, it's exactly the same as evas_object_smart_callback_add

Parameters:
obja smart object
eventthe event's name string
priorityThe priority of the callback, lower values called first.
functhe callback function
datauser data to be passed to the callback function
See also:
evas_object_smart_callback_add
Since (EFL) :
1.1
Since :
3.0
void evas_object_smart_callbacks_descriptions_get ( const Evas_Object obj,
const Evas_Smart_Cb_Description ***  class_descriptions,
unsigned int *  class_count,
const Evas_Smart_Cb_Description ***  instance_descriptions,
unsigned int *  instance_count 
)

Retrieve an smart object's know smart callback descriptions (both instance and class ones).

This call searches for registered callback descriptions for both instance and class of the given smart object. These arrays will be sorted by Evas_Smart_Cb_Description.name and also null terminated, so both class_count and instance_count can be ignored, if the caller wishes so. The terminator null is not counted in these values.

Note:
If just class descriptions are of interest, try evas_smart_callbacks_descriptions_get() instead.
Use null pointers on the descriptions/counters you're not interested in: they'll be ignored by the function.

evas_smart_callbacks_descriptions_get().

Parameters:
[out]class_descriptionsWhere to store class callbacks descriptions array, if any is known. If no descriptions are known, null is returned.
[out]class_countReturns how many class callbacks descriptions are known.
[out]instance_descriptionsWhere to store instance callbacks descriptions array, if any is known. If no descriptions are known, null is returned.
[out]instance_countReturns how many instance callbacks descriptions are known.
Since :
2.3
Examples:
evas-smart-interface.c, and evas-smart-object.c.

Set an smart object instance's smart callbacks descriptions.

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 evas_object_smart_callbacks_descriptions_get() should handle this case as they wish.

Note:
Because descriptions must be null terminated, and because a null name makes little sense, too, Evas_Smart_Cb_Description.name must not be null.
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:
[in]descriptionsnull terminated array with Evas_Smart_Cb_Description descriptions. Array 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.
Returns:
true on success, false on failure.
Since :
2.3

Mark smart object as changed, dirty.

This will flag the given object as needing recalculation, forcefully. As an effect, on the next rendering cycle its calculate() (see Evas_Smart_Class) smart function will be called.

See also evas_object_smart_need_recalculate_set and evas_object_smart_calculate.

Since :
2.3
Examples:
evas-aspect-hints.c, evas-smart-interface.c, and evas-smart-object.c.

Get the clipper object for the given clipped smart object.

Use this function if you want to change any of this clipper's properties, like colors.

Since :
3.0
Examples:
evas-smart-interface.c, and evas-smart-object.c.
void* evas_object_smart_data_get ( const Evas_Object obj)

Retrieves the pointer to user data for a given smart object.

This data is stored independently of the one set by evas_object_data_set(), naturally.

See also evas_object_smart_data_set.

Parameters:
[in]objThe object
Returns:
A pointer to user data.
Since :
2.3
void evas_object_smart_data_set ( Evas_Object obj,
void *  data 
)

Store a pointer to user data for a given smart object.

This data is stored independently of the one set by evas_object_data_set(), naturally.

See also evas_object_smart_data_get.

Parameters:
[in]objThe object
[in]dataA pointer to user data.
Since :
2.3
void* evas_object_smart_interface_data_get ( const Evas_Object obj,
const Evas_Smart_Interface iface 
)

Retrieve an Evas smart object interface's private data.

Parameters:
objAn Evas smart object.
ifaceThe given object's interface handle.
Since (EFL) :
1.7
Returns:
The object interface's private data blob pointer, if found, NULL otherwise.
Since :
3.0
Examples:
evas-smart-interface.c.
const void* evas_object_smart_interface_get ( const Evas_Object obj,
const char *  name 
)

Retrieve an Evas smart object's interface, by name string pointer.

Parameters:
objAn Evas smart object.
nameName string of the desired interface, which must be the same pointer used at the interface's declarion, when creating the smart object obj.
Since (EFL) :
1.7
Returns:
The interface's handle pointer, if found, NULL otherwise.
Since :
3.0
Examples:
evas-smart-interface.c.

Retrieves an iterator of the member objects of a given Evas smart object.

See also evas_object_smart_member_add and evas_object_smart_member_del

Returns:
Returns the iterator of the member objects of obj.
Since (EFL) :
1.8
Since :
3.0
void evas_object_smart_member_add ( Evas_Object obj,
Evas_Object smart_obj 
)

Set an Evas object as a member of a given smart object.

Parameters:
objThe member object
smart_objThe smart object

Members will automatically be stacked and layered together with the smart object. The various stacking functions will operate on members relative to the other members instead of the entire canvas, since they now live on an exclusive layer (see evas_object_stack_above(), for more details).

Any smart_obj object's specific implementation of the member_add() smart function will take place too, naturally.

See also:
evas_object_smart_member_del()
evas_object_smart_members_get()
Since :
2.3
Examples:
evas-smart-interface.c, and evas-smart-object.c.

Removes a member object from a given smart object.

Parameters:
objthe member object

This removes a member object from a smart object, if it was added to any. The object will still be on the canvas, but no longer associated with whichever smart object it was associated with.

See also:
evas_object_smart_member_add() for more details
evas_object_smart_members_get()
Since :
2.3
Examples:
evas-smart-interface.c, and evas-smart-object.c.

Retrieves the list of the member objects of a given Evas smart object.

The returned list should be freed with eina_list_free() when you no longer need it.

This function will return null when a non-smart object is passed.

See also evas_object_smart_member_add, evas_object_smart_member_del and evas_object_smart_iterator_new.

Returns:
Returns the list of the member objects of obj.
Since (EFL) :
1.7
Since :
2.3
void evas_object_smart_move_children_relative ( Evas_Object obj,
Evas_Coord  dx,
Evas_Coord  dy 
)

Moves all children objects of a given smart object relative to a given offset.

This will make each of obj 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.
Clipped smart objects already make use of this function on their move smart function definition.
Parameters:
[in]dxHorizontal offset (delta).
[in]dyVertical offset (delta).
Since :
3.0

Get the value of the flag signalling that a given smart object needs to get recalculated.

Note:
this flag will be unset during the rendering phase, when the calculate() smart function is called, if one is provided. If it's not provided, then the flag will be left unchanged after the rendering phase.

See also evas_object_smart_need_recalculate_set, for more details.

Returns:
whether one wants to set ($true) or to unset ($false) the flag.
Since :
3.0

Set or unset the flag signalling that a given smart object needs to get recalculated.

If this flag is set, then the calculate() smart function of obj will be called, if one is provided, during rendering phase of Evas (see evas_render()), after which this flag will be automatically unset.

If that smart function is not provided for the given object, this flag will be left unchanged.

Note:
just setting this flag will not make the canvas' whole scene dirty, by itself, and evas_render() will have no effect. To force that, use evas_object_smart_changed(), that will also call this function automatically, with true as parameter.

See also evas_object_smart_need_recalculate_get, evas_object_smart_calculate and evas_smart_objects_calculate().

Parameters:
[in]valuewhether one wants to set ($true) or to unset ($false) the flag.
Since :
3.0
Evas_Smart* evas_object_smart_smart_get ( const Evas_Object obj)

Get the Evas_Smart from which obj smart object was created.

Returns:
the Evas_Smart handle or null, on errors.
Since :
3.0
Eina_Bool evas_object_smart_type_check ( const Evas_Object obj,
const char *  type 
)

Checks whether a given smart object or any of its smart object parents is of a given smart class.

If obj is not a smart object, this call will fail immediately.

The checks use smart classes names and string comparison. There is a version of this same check using pointer comparison, since a smart class' name is a single string in Evas.

See also evas_object_smart_type_check_ptr.

Parameters:
[in]typeThe name (type) of the smart class to check for.
Since :
2.3
Examples:
evas-smart-interface.c, and evas-smart-object.c.
Eina_Bool evas_object_smart_type_check_ptr ( const Evas_Object obj,
const char *  type 
)

Checks whether a given smart object or any of its smart object parents is of a given smart class, using pointer comparison.

Parameters:
[in]typeThe type (name string) to check for. Must be the name.
Returns:
true if obj or any of its parents is of type type, false otherwise.
Since :
3.0
void evas_smart_legacy_type_register ( const char *  type,
const Efl_Class *  klass 
)

Registers an object type and its associated class. LEGACY MECHANISM SUPPORT.

This function is invoked in the class constructor of smart classes. It will add the type and the class into a hash table that will then be used to check the type of an object. This function has been implemented to support legacy mechanism that checks objects types by name. USE IT ONLY FOR LEGACY SUPPORT. Otherwise, it is HIGHLY recommended to use efl_isa.

Parameters:
typeThe type (name string) to add.
klassThe class to associate to the type.
See also:
efl_isa
Since :
3.0
void evas_smart_objects_calculate ( Eo *  obj)

Call user-provided calculate smart functions and unset the flag signalling that the object needs to get recalculated to all smart objects in the canvas.

Since :
2.3
Examples:
map_example_01.c, map_example_02.c, and map_example_03.c.

Get if the canvas is currently calculating smart objects.

Parameters:
[in]objThe object.
Returns:
true if currently calculating smart objects.