From ad8a9d95873c05474905eb498b9d6b5118b9e866 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 6 Feb 2025 18:01:50 +0100 Subject: [PATCH] docs(xml): reorganize and extend the XML docs --- .../other-components/xml/animations.rst | 6 + docs/details/other-components/xml/api.rst | 275 ++++++++++++++++++ .../xml/component_library.rst | 147 ++++++++++ .../other-components/xml/components.rst | 136 +++++++++ docs/details/other-components/xml/consts.rst | 69 +++++ docs/details/other-components/xml/events.rst | 7 + docs/details/other-components/xml/fonts.rst | 90 ++++++ docs/details/other-components/xml/images.rst | 78 +++++ docs/details/other-components/xml/index.rst | 29 ++ docs/details/other-components/xml/intro.rst | 178 ++++++++++++ docs/details/other-components/xml/preview.rst | 40 +++ docs/details/other-components/xml/project.rst | 47 +++ docs/details/other-components/xml/screens.rst | 53 ++++ docs/details/other-components/xml/styles.rst | 136 +++++++++ .../details/other-components/xml/subjects.rst | 7 + docs/details/other-components/xml/syntax.rst | 115 ++++++++ .../other-components/xml/translations.rst | 7 + docs/details/other-components/xml/view.rst | 7 + docs/details/other-components/xml/widgets.rst | 101 +++++++ src/font/lv_font.c | 6 + src/font/lv_font.h | 5 +- src/font/lv_font_montserrat_14.c | 1 - src/others/xml/lv_xml.c | 109 +------ src/others/xml/lv_xml_component.c | 10 +- .../xml/parsers/lv_xml_buttonmatrix_parser.c | 1 + .../xml/parsers/lv_xml_buttonmatrix_parser.h | 6 +- tests/src/test_cases/xml/test_xml_style.c | 24 +- 27 files changed, 1559 insertions(+), 131 deletions(-) create mode 100644 docs/details/other-components/xml/animations.rst create mode 100644 docs/details/other-components/xml/api.rst create mode 100644 docs/details/other-components/xml/component_library.rst create mode 100644 docs/details/other-components/xml/components.rst create mode 100644 docs/details/other-components/xml/consts.rst create mode 100644 docs/details/other-components/xml/events.rst create mode 100644 docs/details/other-components/xml/fonts.rst create mode 100644 docs/details/other-components/xml/images.rst create mode 100644 docs/details/other-components/xml/index.rst create mode 100644 docs/details/other-components/xml/intro.rst create mode 100644 docs/details/other-components/xml/preview.rst create mode 100644 docs/details/other-components/xml/project.rst create mode 100644 docs/details/other-components/xml/screens.rst create mode 100644 docs/details/other-components/xml/styles.rst create mode 100644 docs/details/other-components/xml/subjects.rst create mode 100644 docs/details/other-components/xml/syntax.rst create mode 100644 docs/details/other-components/xml/translations.rst create mode 100644 docs/details/other-components/xml/view.rst create mode 100644 docs/details/other-components/xml/widgets.rst 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 + + + + + + + + + + + + + +