From dec36ddb69ff8e698b928c276aeb780b8dbb25d7 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 3 Jul 2025 12:59:54 +0200 Subject: [PATCH] docs(xml): restructure and extend the XML docs (#8495) --- docs/src/details/auxiliary-modules/index.rst | 1 - .../auxiliary-modules/xml/components.rst | 163 ------------ .../details/auxiliary-modules/xml/index.rst | 32 --- .../details/auxiliary-modules/xml/screens.rst | 123 --------- .../details/auxiliary-modules/xml/view.rst | 7 - .../details/auxiliary-modules/xml/widgets.rst | 120 --------- .../xml => xml/build_ui/assets}/fonts.rst | 61 +++-- .../xml => xml/build_ui/assets}/images.rst | 52 ++-- .../src/details/xml/build_ui/assets/index.rst | 13 + .../xml => xml/build_ui}/events.rst | 64 +++++ docs/src/details/xml/build_ui/index.rst | 16 ++ .../build_ui/main_tags}/animations.rst | 0 .../xml => xml/build_ui/main_tags}/api.rst | 34 +-- .../xml => xml/build_ui/main_tags}/consts.rst | 31 --- .../details/xml/build_ui/main_tags/index.rst | 16 ++ .../build_ui/main_tags}/preview.rst | 14 +- .../xml => xml/build_ui/main_tags}/styles.rst | 0 .../details/xml/build_ui/main_tags/view.rst | 51 ++++ .../xml/build_ui/root_elements/components.rst | 244 ++++++++++++++++++ .../xml/build_ui/root_elements/index.rst | 14 + .../xml/build_ui/root_elements/screens.rst | 107 ++++++++ .../xml/build_ui/root_elements/widgets.rst | 180 +++++++++++++ .../xml => xml/build_ui}/subjects.rst | 6 +- .../xml => xml/build_ui}/translation.rst | 9 +- docs/src/details/xml/index.rst | 14 + .../{auxiliary-modules => }/xml/license.rst | 31 ++- .../overview}/component_library.rst | 37 +-- docs/src/details/xml/overview/index.rst | 15 ++ .../xml => xml/overview}/intro.rst | 122 ++++----- .../xml => xml/overview}/project.rst | 3 +- .../xml => xml/overview}/syntax.rst | 30 ++- .../{auxiliary-modules => }/xml/test.rst | 6 +- docs/src/index.rst | 1 + src/others/translation/lv_translation.c | 2 +- xmls/lv_table.xml | 6 +- 35 files changed, 928 insertions(+), 697 deletions(-) delete mode 100644 docs/src/details/auxiliary-modules/xml/components.rst delete mode 100644 docs/src/details/auxiliary-modules/xml/index.rst delete mode 100644 docs/src/details/auxiliary-modules/xml/screens.rst delete mode 100644 docs/src/details/auxiliary-modules/xml/view.rst delete mode 100644 docs/src/details/auxiliary-modules/xml/widgets.rst rename docs/src/details/{auxiliary-modules/xml => xml/build_ui/assets}/fonts.rst (73%) rename docs/src/details/{auxiliary-modules/xml => xml/build_ui/assets}/images.rst (54%) create mode 100644 docs/src/details/xml/build_ui/assets/index.rst rename docs/src/details/{auxiliary-modules/xml => xml/build_ui}/events.rst (54%) create mode 100644 docs/src/details/xml/build_ui/index.rst rename docs/src/details/{auxiliary-modules/xml => xml/build_ui/main_tags}/animations.rst (100%) rename docs/src/details/{auxiliary-modules/xml => xml/build_ui/main_tags}/api.rst (88%) rename docs/src/details/{auxiliary-modules/xml => xml/build_ui/main_tags}/consts.rst (50%) create mode 100644 docs/src/details/xml/build_ui/main_tags/index.rst rename docs/src/details/{auxiliary-modules/xml => xml/build_ui/main_tags}/preview.rst (72%) rename docs/src/details/{auxiliary-modules/xml => xml/build_ui/main_tags}/styles.rst (100%) create mode 100644 docs/src/details/xml/build_ui/main_tags/view.rst create mode 100644 docs/src/details/xml/build_ui/root_elements/components.rst create mode 100644 docs/src/details/xml/build_ui/root_elements/index.rst create mode 100644 docs/src/details/xml/build_ui/root_elements/screens.rst create mode 100644 docs/src/details/xml/build_ui/root_elements/widgets.rst rename docs/src/details/{auxiliary-modules/xml => xml/build_ui}/subjects.rst (97%) rename docs/src/details/{auxiliary-modules/xml => xml/build_ui}/translation.rst (88%) create mode 100644 docs/src/details/xml/index.rst rename docs/src/details/{auxiliary-modules => }/xml/license.rst (50%) rename docs/src/details/{auxiliary-modules/xml => xml/overview}/component_library.rst (75%) create mode 100644 docs/src/details/xml/overview/index.rst rename docs/src/details/{auxiliary-modules/xml => xml/overview}/intro.rst (62%) rename docs/src/details/{auxiliary-modules/xml => xml/overview}/project.rst (93%) rename docs/src/details/{auxiliary-modules/xml => xml/overview}/syntax.rst (86%) rename docs/src/details/{auxiliary-modules => }/xml/test.rst (99%) diff --git a/docs/src/details/auxiliary-modules/index.rst b/docs/src/details/auxiliary-modules/index.rst index 8659e72df6..48ec21f2b8 100644 --- a/docs/src/details/auxiliary-modules/index.rst +++ b/docs/src/details/auxiliary-modules/index.rst @@ -20,4 +20,3 @@ Auxiliary Modules snapshot test translation - xml/index diff --git a/docs/src/details/auxiliary-modules/xml/components.rst b/docs/src/details/auxiliary-modules/xml/components.rst deleted file mode 100644 index 6bbe9c8914..0000000000 --- a/docs/src/details/auxiliary-modules/xml/components.rst +++ /dev/null @@ -1,163 +0,0 @@ -.. _xml_components: - -========== -Components -========== - -Overview -******** - -```` the following child elements: - -- ````, -- ````, -- ````, and -- ````. - -Unlike Widgets (which are always compiled into the application), Components can either: - -1. be loaded at runtime from XML, or -2. be exported to C code and compiled with the application. - - - -Usage from Exported Code -************************ - -From each Component XML file, a C and H file is exported with a single function inside: - -.. code-block:: c - - lv_obj_t * component_name_create(lv_obj_t * parent, ...api properties...); - -where 'component_name' (in the function above) is replaced by the Component's XML -file name. - -When a Component is used in another Component's XML code and the code is exported, -this ``create`` function will be called. This means that Components do not have a -detailed set/get API but can be created with a fixed set of parameters. - -If the user needs to access or modify values dynamically, it is recommended to use a -:ref:`Subject `. - -The user can also call these ``..._create()`` functions at any time from application code. - - - -Usage from XML -************** - - -Registration ------------- - -Once a Component is created (e.g., ``my_button``), it can be registered by calling either: - -- ``lv_xml_component_register_from_file("A:lvgl/examples/others/xml/my_button.xml");`` -- ``lv_xml_component_register_from_data("my_button", xml_data_of_my_button);`` - -These registration functions process the XML data and store relevant information internally. -This is required to make LVGL recognize the Component by name. - -Note that the "A:" in the above path is a file system "driver identifier letter" from -:ref:`file_system` and used accordingly. See that documentation for details. - -When loaded from a file, the file name is used as the Component name. - - -Instantiation -------------- - -After registration, a new instance of any registered Component can be created with: - -.. code-block:: c - - lv_obj_t * obj = lv_xml_create(lv_screen_active(), "my_button", NULL); - -The created Widget is a normal LVGL Widget that can be used like any other manually-created Widget. - -The last parameter can be ``NULL`` or an attribute list, like this: - -.. code-block:: c - - /* Can be local */ - char * my_button_attrs[] = { - "x", "10", - "y", "-10", - "align", "bottom_left", - "btn_text", "New button", - NULL, NULL, - }; - - lv_obj_t * btn1 = lv_xml_create(lv_screen_active(), "my_button", my_button_attrs); - - - -Parameters -********** - -The properties of child elements can be adjusted, such as: - -.. code-block:: xml - - - -These parameters can be set to a fixed value. However, with the help of ```` -elements inside the ```` tag, they can also be passed when an instance is -created. Only the whole property can be passed, but not individual ```` -elements. - -Additionally, when a Component is created, it can use the extended Widget's attributes -(see ```` in the code examples below). - -This means that Components inherit the API of the extended Widget as well. - -The following example demonstrates parameter passing and the use of the -``text`` label property on a Component: - -.. code-block:: xml - - - - - - -.. code-block:: xml - - - - - - - -

-

- - - -.. code-block:: c - - lv_xml_component_register_from_file("A:path/to/h3.xml"); - lv_xml_component_register_from_file("A:path/to/red_button.xml"); - - /* Creates a button with "None" text */ - lv_xml_create(lv_screen_active(), "red_button", NULL); - - /* Use attributes to set the button text */ - const char * attrs[] = { - "btn_text", "Click here", - NULL, NULL, - }; - lv_xml_create(lv_screen_active(), "red_button", attrs); - - - -Example -******* - -.. include:: ../../../examples/others/xml/index.rst - - - -API -*** diff --git a/docs/src/details/auxiliary-modules/xml/index.rst b/docs/src/details/auxiliary-modules/xml/index.rst deleted file mode 100644 index 64aa44fae5..0000000000 --- a/docs/src/details/auxiliary-modules/xml/index.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. _xml_component: - -==================== -XML - Declarative UI -==================== - -.. toctree:: - :class: toctree-1-deep - :maxdepth: 1 - - intro - component_library - project - syntax - - components - screens - widgets - - preview - api - styles - consts - view - fonts - images - events - subjects - animations - translation - test - license diff --git a/docs/src/details/auxiliary-modules/xml/screens.rst b/docs/src/details/auxiliary-modules/xml/screens.rst deleted file mode 100644 index 76de2dd59d..0000000000 --- a/docs/src/details/auxiliary-modules/xml/screens.rst +++ /dev/null @@ -1,123 +0,0 @@ -.. _xml_screens: - -======= -Screens -======= - -Overview -******** - -.. |nbsp| unicode:: U+000A0 .. NO-BREAK SPACE - :trim: - -Screens work very similarly to Components. Both can be: - -- Loaded from XML -- Contain Widgets and Components as children -- Have ```` -- Have ```` -- Have a ```` - -However, Screens **cannot** have an ````. - -It's also possible to define ```` which -will make the screen created automatically. - - - -Usage -***** - -Each XML file describes a :ref:`Screen `. The name of the XML file will -also be the name of the Screen. - -In the ``project.xml`` file, multiple ```` elements can be defined. In the -UI |nbsp| Editor, when a Screen is being developed, the user can select from all the -defined displays in the Preview, and the Screen will be shown with the given -resolution and color depth. - -This is useful for verifying responsive designs. - -This example illustrates a screen in XML: - -.. code-block:: xml - - - - - - - -