diff --git a/docs/details/other-components/xml/animations.rst b/docs/details/other-components/xml/animations.rst new file mode 100644 index 000000000..949dc7c63 --- /dev/null +++ b/docs/details/other-components/xml/animations.rst @@ -0,0 +1,6 @@ +.. _xml_animation: + +========== +Animations +========== + diff --git a/docs/details/other-components/xml/api.rst b/docs/details/other-components/xml/api.rst new file mode 100644 index 000000000..116154dee --- /dev/null +++ b/docs/details/other-components/xml/api.rst @@ -0,0 +1,275 @@ +.. _xml_api: + +=== +API +=== + +The ```` tag can be used in ````s and ````, although each supports slightly different features. + +Properties +********** + +Inside ```` elements, ```` elements can be defined to describe the arguments. + +For **widgets**, all properties are optional. +If a property is not set on an instance of a widget, it simply won't be applied, +and the created widget's default value will be used (e.g., ``text`` for a label's text). + +For **components**, all properties are mandatory; however, default values can be defined +to be used when a property is not set. + +If a property has only one parameter (which is usually the case), a shorthand can be applied as shown below. + +For example: + +.. code-block:: xml + + + + + + + + + +When a property is used, all parameters are set as a single attribute value. For example: + +.. code-block:: xml + + + +For **widgets**, each property corresponds to a setter function. +The ``name`` in ```` is used to build the name of the setter function like this: + +.. code-block:: c + + _set_(lv_obj_t * obj, , , ...); + +For **components**, the exported code contains only a single ``create`` function +to which all the properties need to be passed: + +.. code-block:: c + + _create(lv_obj_t * parent, , , ...); + +```` elements have an optional ```` boolean attribute. +By default, it is ``false``, but if set to ``true``, the given property will be applied after all children are created. +A practical example is setting the current tab of a tab view, which cannot be set before the tabs are created. +This feature is not supported yet. + +```` +************ + +Can be used only for widgets. + +Used to define new enum types for a given widget. + +It should contain ```` elements to define the possible options. + +Example: + +.. code-block:: xml + + + + + + + + + + + + + +Note that the enum values are not important because: + +1. When the code is exported, the enum names will be used, and the compiler will substitute the values. +2. When loaded from XML, the widget's XML parser should convert the enum names to C enum fields. + +```` +************* + +Also applies only to widgets. + +Elements are used to describe sub-widgets or internal parts of widgets. +Examples include the list of a dropdown, the tabs of a tab view, or the series of a chart. + +Elements can have ```` and ```` definitions. ```` elements are mandatory (default values are supported) +as they are used to create the element, whereas ```` elements are optional as they are mapped to setter functions. + +An element in a ```` can be referenced like this: ````. +The widget name and the element name are separated by a ``-``, so ``-`` is not allowed in widget and +element names (only ``_`` can be used). + +Example: + +.. code-block:: xml + + + +An important attribute of elements is ``access``. The possible values are: + +- ``add``: Create any number of elements dynamically (e.g., chart series). +- ``get``: Get a pointer to an implicitly created widget or any data (e.g., list of the dropdown). +- ``set``: Select specific parts of the widget with indexes (e.g., table cells). + +Elements with ``access="add"`` or ``access="get"`` can have a custom data type defined using ``type="my_data"``. +In these cases, no children can be added. If the ``type`` is ``lv_obj``, the element can have children. + +It is not yet possible to describe the ```` of elements in XML; only the API can be defined. +The actual implementation needs to be done in C. + +``access="add"`` +---------------- + +The element is explicitly created with an ``add`` function, e.g., ``lv_tabview_add_tab(obj, "Title");``. + +```` elements defined directly inside the ```` are passed to the ``add`` function as arguments. + +Example: + +.. code-block:: xml + + + + + + + + + + + + + +