diff --git a/docs/src/details/auxiliary-modules/xml/api.rst b/docs/src/details/auxiliary-modules/xml/api.rst
index 7d989cb631..d0333ad817 100644
--- a/docs/src/details/auxiliary-modules/xml/api.rst
+++ b/docs/src/details/auxiliary-modules/xml/api.rst
@@ -4,334 +4,314 @@
API
===
-The ```` tag can be a child of ```` and ```` tags, although
-each supports slightly different features.
+The ```` tag can be a child of ```` and ```` tags.
+The only common point is that both Widgets and Components support having
+```` (properties) in the ```` tag to describe their interface.
+However, as Widgets and Components work very differently (Widgets have C code,
+but Components are pure XML), even properties are interpreted differently.
-Properties
+Components
**********
-Inside ```` elements, ```` elements can be defined to describe the arguments.
+Overview
+--------
-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 for that property will be used (e.g., ``text``
-for a label's text).
+While Widgets can have complex ``set``/``get`` APIs, Components are very simple.
-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 syntax
-can be applied as shown below.
-
-For example:
+When their XML is converted to a C file, only a ``create`` function is generated,
+where all the ````s are arguments. 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:
+This generates the following C function:
.. code-block:: c
- _set_(lv_obj_t * obj, , , ...);
+ lv_obj_t * my_component_create(lv_obj_t * parent, int32_t prop1, const char * prop2);
-For **Components**, the exported code contains only a single ``create`` function
-to which all the properties are passed:
+These properties are set once (at creation time), and there are no specific
+``set`` functions to modify the property later. LVGL's general API can still be
+used to modify any widget in the component, but no dedicated API functions are generated.
-.. code-block:: c
+Referencing properties
+----------------------
- _create(lv_obj_t * parent, , , ...);
+````s are simply forwarded to widget or component APIs.
+For example, if a component has ````,
+it can be used in a label as ````.
-```` 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.
+In the generated code, these are passed as arguments in create/set functions.
+Default values
+--------------
+Since each property is passed as an argument to the create function, each must have a value.
+This can be ensured by:
-````
-*************
+- Setting them in the XML instance
+- Providing a default value, e.g., ````
-This tag is used only with Widgets. It is used to define new enum types for a given
-Widget. It should contain ```` elements to define possible options.
+Limitations
+-----------
-Example:
+Note that none of the Widget API features such as ````, ````, or ````
+can be used for Components. Only simple properties that are forwarded are supported.
+
+Example
+-------
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Widgets
+*******
+
+Properties
+----------
+
+Properties are the core part of describing a Widget's API.
+
+.. code-block:: xml
+
+
+
+
+
+Parameters
+----------
+
+Some properties take multiple parameters. For example:
+:cpp:expr:`lv_label_set_bind_text(label, subject, "%d °C");`
+
+It's described as:
+
+.. code-block:: xml
+
+
+
+
+
+
+
+
+And used as:
+
+.. code-block:: xml
+
+
+
+Parameters with the same name as the property can be referenced directly.
+Other parameters use ``property-param`` notation.
+
+Unset parameters fall back to:
+
+- Their default value (if defined)
+- Type-specific defaults (e.g., 0, false, NULL)
+
+Mapping
+-------
+
+Each ```` is mapped to a ``set`` function. This mapping is implemented
+in the Widget's XML parser.
+See `the LVGL XML parsers `_.
+
+If ````s are used, they are passed to the same ``set`` function.
+If a property is not set on a Widget instance, it is skipped and the Widget's
+built-in default is used.
+
+
+---------
+
+Only used with Widgets, this tag defines enums for parameter values.
.. code-block:: xml
-
-
-Note that the enum values are not important because:
+Enum values are ignored in export; the names are used and resolved by the compiler.
+XML parsers must handle mapping enum names to C enums.
-1. When the code is exported, the enum names will be used, and the compiler generates
- its own value for each enumerator symbol.
-2. When loaded from XML, the Widget's XML parser should convert the enum names to C
- enum fields.
+
+--------
+Also exclusive to Widgets, elements define sub-widgets or internal structures
+(e.g., chart series, dropdown list, tab views).
+They support ```` and ````:
-````
-*************
+- ````s are required and used for creation.
+- ````s are optional and mapped to setters.
-```` tags also apply 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 data series of a chart.
+Elements are referenced as ```` in views.
-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.
+Name parts are separated by `-` (not allowed inside names).
-An element in a ```` can be referenced like this: ````.
-Note that the ``-`` separates two names inside that tag name: the Widget name and the
-element name. ``-`` is not allowed in Widget and element names. Only ``_`` can be
-used to separate words in tag names.
+Element `access` types:
-Example:
+- ``add``: Create multiple elements dynamically.
+- ``get``: Access implicitly created elements.
+- ``set``: Access indexed parts (e.g., table cells).
+
+``type="obj"`` allows children; custom types do not.
+
+Only the API can be defined in XML for elements; implementations must be in C.
+
+access="add"
+~~~~~~~~~~~~
+
+Elements are created via an ``add`` function:
.. 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 a Drop-Down List).
-- ``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 as direct children of the ```` are passed to the
-``add`` function as arguments.
-
-Example:
-
-.. code-block:: xml
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-In a view it can be used like this:
+Used in a view:
.. code-block:: xml
-
-
-
-
-
-
-
+
+
+
-From the API definition the following functions are generated:
+Generates:
.. code-block:: c
lv_obj_t * my_widget_add_indicator(lv_obj_t * parent, lv_color_t color, int32_t max_value);
-
void my_widget_set_indicator_value(lv_obj_t * obj, int32_t value);
-And this is the related C file where the indicator is created:
+access="get"
+~~~~~~~~~~~~
-.. code-block:: c
-
- lv_obj_t * indic1 = my_widget_add_indicator(parent, color, max_value);
- lv_my_widget_set_indicator_value(indic1, value);
-
-
-``access="get"``
-----------------
-
-If the element is created internally and implicitly, it can be retrieved with a
-function like ``lv_dropdown_get_list(obj);``.
-
-```` elements are passed to the ``get`` function as arguments.
-
-Example:
+Used for internal/implicit elements:
.. code-block:: xml
-
-
-
+
+
-In a view:
+Used in a view:
.. code-block:: xml
-
-
-
-
-
-
+
+
+
-Generated API:
+Generates:
.. code-block:: c
lv_obj_t * my_widget_get_control_button(lv_obj_t * parent, int32_t index);
void my_widget_set_control_button_title(lv_obj_t * obj, const char * text);
-And this is a C file where the control button is retrieved:
+access="set"
+~~~~~~~~~~~~
-.. code-block:: c
-
- lv_obj_t * btn1 = lvmy_widget_get_control_button(parent, index);
- my_widget_set_control_button_title(btn1, text);
-
-
-``access="set"``
-----------------
-
-The "set" value is used when elements are created automatically but need to be selected in API calls,
-e.g., ``lv_table_set_cell_value(table, row, col, "text");``.
-
-Example:
+Used for indexed access, like setting values in a table:
.. code-block:: xml
-
-
-
-
-
+
+
+
+
-
-
+
+
-In a view:
+Used in a view:
.. code-block:: xml
-
-
-
-
-
-
+
+
+
-This is the generated header file:
+Generates:
.. code-block:: c
void my_widget_set_item_icon(lv_obj_t * parent, int32_t index, const void * icon_src);
-
void my_widget_set_item_color(lv_obj_t * parent, int32_t index, lv_color_t color);
-And this is the related C file where the item properties are set:
+access="bind"
+~~~~~~~~~~~~~
-.. code-block:: c
-
- my_widget_set_item_icon(parent, index, image1);
- my_widget_set_item_color(parent, index, color);
-
-
-``access="bind"``
------------------
-
-The ``"bind"`` access type is similar to ``"set"``, but instead of directly setting a property, it binds a subject with other optional parameters.
-
-"Bind" elements are used in cases where multiple properties need to be bound to subjects.
-For example, binding subjects to flags such as ``hidden``, ``checkable``, etc. These can't be normal properties, as XML doesn't allow using the same property name more than once.
-For example, the following is invalid:
+Used to bind subjects to widget logic.
.. code-block:: xml
-
+
+
+
+
+
-In ``"bind"`` elements, only ````s can be defined. The ``type`` attribute is not allowed, as these functions do not have return values.
-
-Example:
+Used in a view:
.. code-block:: xml
-
-
-
-
-
-
-
-
+
+
+
-In a view:
-
-.. code-block:: xml
-
-
-
-
-
-
-
-
-This is the generated header file:
+Generates:
.. code-block:: c
void my_widget_bind_color(lv_obj_t * parent, lv_subject_t * subject, lv_color_t color, int32_t ref_value);
-
-And this is the related C file where the item properties are set:
-
-.. code-block:: c
-
- my_widget_bind_color(obj, &subject_1, lv_color_hex(0xff0000), 15);
diff --git a/src/misc/lv_math.c b/src/misc/lv_math.c
index a6d51a0555..757b0ea347 100644
--- a/src/misc/lv_math.c
+++ b/src/misc/lv_math.c
@@ -403,6 +403,8 @@ int64_t lv_pow(int64_t base, int8_t exp)
int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out)
{
+ if(max_in == min_in) return min_out; /*Avoid division by zero later*/
+
if(max_in >= min_in && x >= max_in) return max_out;
if(max_in >= min_in && x <= min_in) return min_out;
diff --git a/src/others/xml/lv_xml_utils.c b/src/others/xml/lv_xml_utils.c
index 2c4d1cd6e2..99ecb03305 100644
--- a/src/others/xml/lv_xml_utils.c
+++ b/src/others/xml/lv_xml_utils.c
@@ -113,15 +113,11 @@ int32_t lv_xml_atoi_split(const char ** str, char delimiter)
if(*s != '\0') s++; /*Skip the delimiter*/
*str = s;
return result;
-
}
-
int32_t lv_xml_atoi(const char * str)
{
-
return lv_xml_atoi_split(&str, '\0');
-
}
int32_t lv_xml_strtol(const char * str, char ** endptr, int32_t base)
diff --git a/src/others/xml/parsers/lv_xml_arc_parser.c b/src/others/xml/parsers/lv_xml_arc_parser.c
index 8bab7ddd21..aa9f661f4d 100644
--- a/src/others/xml/parsers/lv_xml_arc_parser.c
+++ b/src/others/xml/parsers/lv_xml_arc_parser.c
@@ -54,36 +54,14 @@ void lv_xml_arc_apply(lv_xml_parser_state_t * state, const char ** attrs)
const char * name = attrs[i];
const char * value = attrs[i + 1];
- if(lv_streq("angles", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- int32_t v2 = lv_xml_atoi(buf_p);
- lv_arc_set_angles(item, v1, v2);
- }
- else if(lv_streq("bg_angles", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- int32_t v2 = lv_xml_atoi(buf_p);
- lv_arc_set_bg_angles(item, v1, v2);
- }
- else if(lv_streq("range", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- int32_t v2 = lv_xml_atoi(buf_p);
- lv_arc_set_range(item, v1, v2);
- }
- else if(lv_streq("value", name)) {
- lv_arc_set_value(item, lv_xml_atoi(value));
- }
- else if(lv_streq("mode", name)) {
- lv_arc_set_mode(item, mode_text_to_enum_value(value));
- }
+ if(lv_streq("start_angle", name)) lv_arc_set_start_angle(item, lv_xml_atoi(value));
+ else if(lv_streq("end_angle", name)) lv_arc_set_end_angle(item, lv_xml_atoi(value));
+ else if(lv_streq("bg_start_angle", name)) lv_arc_set_bg_start_angle(item, lv_xml_atoi(value));
+ else if(lv_streq("bg_end_angle", name)) lv_arc_set_bg_end_angle(item, lv_xml_atoi(value));
+ else if(lv_streq("value", name)) lv_arc_set_value(item, lv_xml_atoi(value));
+ else if(lv_streq("min_value", name)) lv_arc_set_min_value(item, lv_xml_atoi(value));
+ else if(lv_streq("max_value", name)) lv_arc_set_max_value(item, lv_xml_atoi(value));
+ else if(lv_streq("mode", name)) lv_arc_set_mode(item, mode_text_to_enum_value(value));
else if(lv_streq("bind_value", name)) {
lv_subject_t * subject = lv_xml_get_subject(&state->scope, value);
if(subject) {
@@ -100,7 +78,6 @@ void lv_xml_arc_apply(lv_xml_parser_state_t * state, const char ** attrs)
* STATIC FUNCTIONS
**********************/
-
static lv_arc_mode_t mode_text_to_enum_value(const char * txt)
{
if(lv_streq("normal", txt)) return LV_ARC_MODE_NORMAL;
diff --git a/src/others/xml/parsers/lv_xml_bar_parser.c b/src/others/xml/parsers/lv_xml_bar_parser.c
index 1ee314aeb7..cc9b080e15 100644
--- a/src/others/xml/parsers/lv_xml_bar_parser.c
+++ b/src/others/xml/parsers/lv_xml_bar_parser.c
@@ -56,31 +56,21 @@ void lv_xml_bar_apply(lv_xml_parser_state_t * state, const char ** attrs)
const char * value = attrs[i + 1];
if(lv_streq("value", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- bool v2 = lv_xml_to_bool(buf_p);
- lv_bar_set_value(item, v1, v2);
+ int32_t v = lv_xml_atoi(value);
+ const char * anim_str = lv_xml_get_value_of(attrs, "value-animated");
+ bool anim = anim_str ? lv_xml_to_bool(anim_str) : false;
+ lv_bar_set_value(item, v, anim);
}
- if(lv_streq("start_value", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- bool v2 = lv_xml_to_bool(buf_p);
- lv_bar_set_start_value(item, v1, v2);
+ else if(lv_streq("start_value", name)) {
+ int32_t v = lv_xml_atoi(value);
+ const char * anim_str = lv_xml_get_value_of(attrs, "start_value-animated");
+ bool anim = anim_str ? lv_xml_to_bool(anim_str) : false;
+ lv_bar_set_start_value(item, v, anim);
}
+ if(lv_streq("min_value", name)) lv_bar_set_min_value(item, lv_xml_atoi(value));
+ if(lv_streq("max_value", name)) lv_bar_set_max_value(item, lv_xml_atoi(value));
if(lv_streq("orientation", name)) lv_bar_set_orientation(item, orentation_text_to_enum_value(value));
if(lv_streq("mode", name)) lv_bar_set_mode(item, mode_text_to_enum_value(value));
- if(lv_streq("range", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- int32_t v2 = lv_xml_atoi(buf_p);
- lv_bar_set_range(item, v1, v2);
- }
}
}
diff --git a/src/others/xml/parsers/lv_xml_calendar_parser.c b/src/others/xml/parsers/lv_xml_calendar_parser.c
index 4af1a9ff4e..58d1f2ddc8 100644
--- a/src/others/xml/parsers/lv_xml_calendar_parser.c
+++ b/src/others/xml/parsers/lv_xml_calendar_parser.c
@@ -55,19 +55,11 @@ void lv_xml_calendar_apply(lv_xml_parser_state_t * state, const char ** attrs)
const char * name = attrs[i];
const char * value = attrs[i + 1];
- if(lv_streq("today_date", name)) {
- const char * bufp = value;
- int32_t y = lv_xml_atoi_split(&bufp, ' ');
- int32_t m = lv_xml_atoi_split(&bufp, ' ');
- int32_t d = lv_xml_atoi_split(&bufp, ' ');
- lv_calendar_set_today_date(item, y, m, d);
- }
- else if(lv_streq("shown_month", name)) {
- const char * bufp = value;
- int32_t y = lv_xml_atoi_split(&bufp, ' ');
- int32_t m = lv_xml_atoi_split(&bufp, ' ');
- lv_calendar_set_month_shown(item, y, m);
- }
+ if(lv_streq("today_year", name)) lv_calendar_set_today_year(item, lv_xml_atoi(value));
+ else if(lv_streq("today_month", name)) lv_calendar_set_today_month(item, lv_xml_atoi(value));
+ else if(lv_streq("today_day", name)) lv_calendar_set_today_day(item, lv_xml_atoi(value));
+ else if(lv_streq("shown_year", name)) lv_calendar_set_shown_year(item, lv_xml_atoi(value));
+ else if(lv_streq("shown_month", name)) lv_calendar_set_shown_month(item, lv_xml_atoi(value));
}
}
diff --git a/src/others/xml/parsers/lv_xml_chart_parser.c b/src/others/xml/parsers/lv_xml_chart_parser.c
index 0b06892dc0..df63ee35b2 100644
--- a/src/others/xml/parsers/lv_xml_chart_parser.c
+++ b/src/others/xml/parsers/lv_xml_chart_parser.c
@@ -68,11 +68,11 @@ void lv_xml_chart_apply(lv_xml_parser_state_t * state, const char ** attrs)
}
else if(lv_streq("type", name)) lv_chart_set_type(item, chart_type_to_enum(value));
else if(lv_streq("update_mode", name)) lv_chart_set_update_mode(item, chart_update_mode_to_enum(value));
- else if(lv_streq("div_line_count", name)) {
-
- int32_t value1 = lv_xml_atoi_split(&value, ' ');
- int32_t value2 = lv_xml_atoi_split(&value, ' ');
- lv_chart_set_div_line_count(item, value1, value2);
+ else if(lv_streq("hor_div_line_count", name)) {
+ lv_chart_set_hor_div_line_count(item, lv_xml_atoi(value));
+ }
+ else if(lv_streq("ver_div_line_count", name)) {
+ lv_chart_set_ver_div_line_count(item, lv_xml_atoi(value));
}
}
}
@@ -160,11 +160,8 @@ void lv_xml_chart_axis_apply(lv_xml_parser_state_t * state, const char ** attrs)
const char * name = attrs[i];
const char * value = attrs[i + 1];
- if(lv_streq("range", name)) {
- int32_t min_val = lv_xml_atoi_split(&value, ' ');
- int32_t max_val = lv_xml_atoi_split(&value, ' ');
- lv_chart_set_axis_range(chart, axis, min_val, max_val);
- }
+ if(lv_streq("min_value", name)) lv_chart_set_axis_min_value(chart, axis, lv_xml_atoi(value));
+ if(lv_streq("max_value", name)) lv_chart_set_axis_max_value(chart, axis, lv_xml_atoi(value));
}
}
diff --git a/src/others/xml/parsers/lv_xml_image_parser.c b/src/others/xml/parsers/lv_xml_image_parser.c
index e6ec712484..4cb9af2444 100644
--- a/src/others/xml/parsers/lv_xml_image_parser.c
+++ b/src/others/xml/parsers/lv_xml_image_parser.c
@@ -65,11 +65,8 @@ void lv_xml_image_apply(lv_xml_parser_state_t * state, const char ** attrs)
if(lv_streq("rotation", name)) lv_image_set_rotation(item, lv_xml_atoi(value));
if(lv_streq("scale_x", name)) lv_image_set_scale_x(item, lv_xml_atoi(value));
if(lv_streq("scale_y", name)) lv_image_set_scale_y(item, lv_xml_atoi(value));
- if(lv_streq("pivot", name)) {
- int32_t x = lv_xml_atoi_split(&value, ' ');
- int32_t y = lv_xml_atoi_split(&value, ' ');
- lv_image_set_pivot(item, x, y);
- }
+ if(lv_streq("pivot_x", name)) lv_image_set_pivot_x(item, lv_xml_to_size(value));
+ if(lv_streq("pivot_y", name)) lv_image_set_pivot_y(item, lv_xml_to_size(value));
}
}
diff --git a/src/others/xml/parsers/lv_xml_label_parser.c b/src/others/xml/parsers/lv_xml_label_parser.c
index 9241182339..64d119596f 100644
--- a/src/others/xml/parsers/lv_xml_label_parser.c
+++ b/src/others/xml/parsers/lv_xml_label_parser.c
@@ -57,30 +57,19 @@ void lv_xml_label_apply(lv_xml_parser_state_t * state, const char ** attrs)
const char * value = attrs[i + 1];
if(lv_streq("text", name)) lv_label_set_text(item, value);
- if(lv_streq("long_mode", name)) lv_label_set_long_mode(item, long_mode_text_to_enum_value(value));
- if(lv_streq("bind_text", name)) {
- char buf[256];
- lv_strncpy(buf, value, sizeof(buf));
- char * bufp = buf;
- char * subject_name = lv_xml_split_str(&bufp, ' ');
- if(subject_name) {
- lv_subject_t * subject = lv_xml_get_subject(&state->scope, subject_name);
- if(subject) {
- char * fmt = bufp; /*The second part is the format text*/
- if(fmt && fmt[0] == '\0') fmt = NULL;
- if(fmt) {
- if(fmt[0] == '\'') fmt++;
- size_t fmt_len = lv_strlen(fmt);
- if(fmt_len != 0 && fmt[fmt_len - 1] == '\'') fmt[fmt_len - 1] = '\0';
- fmt = lv_strdup(fmt);
- lv_obj_add_event_cb(item, free_fmt_event_cb, LV_EVENT_DELETE, fmt);
- }
- lv_label_bind_text(item, subject, fmt);
- }
- else {
- LV_LOG_WARN("Subject \"%s\" doesn't exist in label bind_text", value);
- }
+ else if(lv_streq("long_mode", name)) lv_label_set_long_mode(item, long_mode_text_to_enum_value(value));
+ else if(lv_streq("bind_text", name)) {
+ lv_subject_t * subject = lv_xml_get_subject(&state->scope, value);
+ if(subject == NULL) {
+ LV_LOG_WARN("Subject \"%s\" doesn't exist in label bind_text", value);
+ continue;
}
+ const char * fmt = lv_xml_get_value_of(attrs, "bind_text-fmt");
+ if(fmt) {
+ fmt = lv_strdup(fmt);
+ lv_obj_add_event_cb(item, free_fmt_event_cb, LV_EVENT_DELETE, (void *) fmt);
+ }
+ lv_label_bind_text(item, subject, fmt);
}
}
}
diff --git a/src/others/xml/parsers/lv_xml_obj_parser.c b/src/others/xml/parsers/lv_xml_obj_parser.c
index 47f8e3869b..5ac1dee070 100644
--- a/src/others/xml/parsers/lv_xml_obj_parser.c
+++ b/src/others/xml/parsers/lv_xml_obj_parser.c
@@ -167,7 +167,7 @@ void lv_obj_xml_style_apply(lv_xml_parser_state_t * state, const char ** attrs)
lv_strncpy(buf, selector_str, sizeof(buf));
char * bufp = buf;
- const char * next = lv_xml_split_str(&bufp, ' ');
+ const char * next = lv_xml_split_str(&bufp, '|');
while(next) {
/* Handle different states and parts */
@@ -175,7 +175,7 @@ void lv_obj_xml_style_apply(lv_xml_parser_state_t * state, const char ** attrs)
selector |= lv_xml_style_part_to_enum(next);
/* Move to the next token */
- next = lv_xml_split_str(&bufp, ' ');
+ next = lv_xml_split_str(&bufp, '|');
}
}
diff --git a/src/others/xml/parsers/lv_xml_roller_parser.c b/src/others/xml/parsers/lv_xml_roller_parser.c
index 616af0fa7f..a9ce2f6591 100644
--- a/src/others/xml/parsers/lv_xml_roller_parser.c
+++ b/src/others/xml/parsers/lv_xml_roller_parser.c
@@ -55,39 +55,19 @@ void lv_xml_roller_apply(lv_xml_parser_state_t * state, const char ** attrs)
const char * value = attrs[i + 1];
if(lv_streq("selected", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- bool v2 = lv_xml_to_bool(buf_p);
- lv_roller_set_selected(item, v1, v2);
+ int32_t v = lv_xml_atoi(value);
+ const char * anim_str = lv_xml_get_value_of(attrs, "value-animated");
+ bool anim = anim_str ? lv_xml_to_bool(anim_str) : false;
+ lv_roller_set_selected(item, v, anim);
}
if(lv_streq("visible_row_count", name)) {
lv_roller_set_visible_row_count(item, lv_xml_atoi(value));
}
if(lv_streq("options", name)) {
- /*E.g. 'a\nb\nc' true'*/
- size_t opts_len = lv_strlen(value);
- char * opts_buf = lv_malloc(opts_len + 1);
- lv_memcpy(opts_buf, value, opts_len + 1);
- LV_ASSERT_MALLOC(opts_buf);
-
- /*Find the last space and trim the rest*/
- uint32_t space_pos_from_back = 1;
- while(space_pos_from_back < opts_len && value[opts_len - space_pos_from_back] != ' ') {
- space_pos_from_back++;
- }
-
- opts_buf[opts_len - space_pos_from_back - 1] = '\0'; /*Also trim the `'`*/
-
- lv_roller_mode_t mode = mode_text_to_enum_value(&opts_buf[opts_len - space_pos_from_back + 1]);
-
- /*Also skip the leading `'`*/
- lv_roller_set_options(item, opts_buf + 1, mode);
-
- lv_free(opts_buf);
-
+ const char * mode_str = lv_xml_get_value_of(attrs, "options-mode");
+ lv_roller_mode_t mode = mode_str ? mode_text_to_enum_value(mode_str) : LV_ROLLER_MODE_NORMAL;
+ lv_roller_set_options(item, value, mode);
}
else if(lv_streq("bind_value", name)) {
lv_subject_t * subject = lv_xml_get_subject(&state->scope, value);
diff --git a/src/others/xml/parsers/lv_xml_scale_parser.c b/src/others/xml/parsers/lv_xml_scale_parser.c
index bc7482cccf..838a6ddec8 100644
--- a/src/others/xml/parsers/lv_xml_scale_parser.c
+++ b/src/others/xml/parsers/lv_xml_scale_parser.c
@@ -65,11 +65,8 @@ void lv_xml_scale_apply(lv_xml_parser_state_t * state, const char ** attrs)
else if(lv_streq("label_show", name)) lv_scale_set_label_show(item, lv_xml_to_bool(value));
else if(lv_streq("post_draw", name)) lv_scale_set_post_draw(item, lv_xml_to_bool(value));
else if(lv_streq("draw_ticks_on_top", name)) lv_scale_set_draw_ticks_on_top(item, lv_xml_to_bool(value));
- else if(lv_streq("range", name)) {
- int32_t value1 = lv_xml_atoi_split(&value, ' ');
- int32_t value2 = lv_xml_atoi_split(&value, ' ');
- lv_scale_set_range(item, value1, value2);
- }
+ else if(lv_streq("min_value", name)) lv_scale_set_min_value(item, lv_xml_atoi(value));
+ else if(lv_streq("max_value", name)) lv_scale_set_max_value(item, lv_xml_atoi(value));
else if(lv_streq("angle_range", name)) lv_scale_set_angle_range(item, lv_xml_atoi(value));
else if(lv_streq("rotation", name)) lv_scale_set_rotation(item, lv_xml_to_bool(value));
}
@@ -94,11 +91,8 @@ void lv_xml_scale_section_apply(lv_xml_parser_state_t * state, const char ** att
const char * name = attrs[i];
const char * value = attrs[i + 1];
- if(lv_streq("range", name)) {
- int32_t value1 = lv_xml_atoi_split(&value, ' ');
- int32_t value2 = lv_xml_atoi_split(&value, ' ');
- lv_scale_set_section_range(scale, section, value1, value2);
- }
+ if(lv_streq("min_value", name)) lv_scale_set_section_min_value(scale, section, lv_xml_atoi(value));
+ else if(lv_streq("max_value", name)) lv_scale_set_section_max_value(scale, section, lv_xml_atoi(value));
else if(lv_streq("style_main", name)) {
lv_xml_style_t * style_dsc = lv_xml_get_style_by_name(&state->scope, value);
lv_scale_set_section_style_main(scale, section, &style_dsc->style);
diff --git a/src/others/xml/parsers/lv_xml_slider_parser.c b/src/others/xml/parsers/lv_xml_slider_parser.c
index dea62f35da..8faff75dd3 100644
--- a/src/others/xml/parsers/lv_xml_slider_parser.c
+++ b/src/others/xml/parsers/lv_xml_slider_parser.c
@@ -56,14 +56,18 @@ void lv_xml_slider_apply(lv_xml_parser_state_t * state, const char ** attrs)
const char * value = attrs[i + 1];
if(lv_streq("value", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- bool v2 = lv_xml_to_bool(buf_p);
- lv_bar_set_value(item, v1, v2);
+ int32_t v = lv_xml_atoi(value);
+ const char * anim_str = lv_xml_get_value_of(attrs, "value-animated");
+ bool anim = anim_str ? lv_xml_to_bool(anim_str) : false;
+ lv_slider_set_value(item, v, anim);
}
- if(lv_streq("bind_value", name)) {
+ else if(lv_streq("start_value", name)) {
+ int32_t v = lv_xml_atoi(value);
+ const char * anim_str = lv_xml_get_value_of(attrs, "start_value-animated");
+ bool anim = anim_str ? lv_xml_to_bool(anim_str) : false;
+ lv_slider_set_start_value(item, v, anim);
+ }
+ else if(lv_streq("bind_value", name)) {
lv_subject_t * subject = lv_xml_get_subject(&state->scope, value);
if(subject) {
lv_slider_bind_value(item, subject);
@@ -72,26 +76,10 @@ void lv_xml_slider_apply(lv_xml_parser_state_t * state, const char ** attrs)
LV_LOG_WARN("Subject \"%s\" doesn't exist in slider bind_value", value);
}
}
- if(lv_streq("start_value", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- bool v2 = lv_xml_to_bool(buf_p);
- lv_bar_set_start_value(item, v1, v2);
- }
- if(lv_streq("orientation", name)) lv_slider_set_orientation(item, orentation_text_to_enum_value(value));
- if(lv_streq("mode", name)) lv_slider_set_mode(item, mode_text_to_enum_value(value));
- if(lv_streq("range_min", name)) lv_slider_set_range(item, lv_xml_atoi(value), lv_slider_get_max_value(item));
- if(lv_streq("range_max", name)) lv_slider_set_range(item, lv_slider_get_min_value(item), lv_xml_atoi(value));
- if(lv_streq("range", name)) {
- char buf[64];
- lv_strlcpy(buf, value, sizeof(buf));
- char * buf_p = buf;
- int32_t v1 = lv_xml_atoi(lv_xml_split_str(&buf_p, ' '));
- int32_t v2 = lv_xml_atoi(buf_p);
- lv_slider_set_range(item, v1, v2);
- }
+ else if(lv_streq("orientation", name)) lv_slider_set_orientation(item, orentation_text_to_enum_value(value));
+ else if(lv_streq("mode", name)) lv_slider_set_mode(item, mode_text_to_enum_value(value));
+ else if(lv_streq("min_value", name)) lv_slider_set_min_value(item, lv_xml_atoi(value));
+ else if(lv_streq("max_value", name)) lv_slider_set_max_value(item, lv_xml_atoi(value));
}
}
diff --git a/src/others/xml/parsers/lv_xml_table_parser.c b/src/others/xml/parsers/lv_xml_table_parser.c
index 91f55c68f1..d6a82514cb 100644
--- a/src/others/xml/parsers/lv_xml_table_parser.c
+++ b/src/others/xml/parsers/lv_xml_table_parser.c
@@ -58,12 +58,6 @@ void lv_xml_table_apply(lv_xml_parser_state_t * state, const char ** attrs)
if(lv_streq("column_count", name)) lv_table_set_column_count(item, lv_xml_atoi(value));
else if(lv_streq("row_count", name)) lv_table_set_row_count(item, lv_xml_atoi(value));
- else if(lv_streq("selected_cell", name)) {
-
- int32_t value1 = lv_xml_atoi_split(&value, ' ');
- int32_t value2 = lv_xml_atoi_split(&value, ' ');
- lv_table_set_selected_cell(item, value1, value2);
- }
}
}
diff --git a/src/widgets/arc/lv_arc.c b/src/widgets/arc/lv_arc.c
index 6d5f230d9d..201452a3e0 100644
--- a/src/widgets/arc/lv_arc.c
+++ b/src/widgets/arc/lv_arc.c
@@ -273,6 +273,16 @@ void lv_arc_set_range(lv_obj_t * obj, int32_t min, int32_t max)
value_update(obj); /*value has changed relative to the new range*/
}
+void lv_arc_set_min_value(lv_obj_t * obj, int32_t min)
+{
+ lv_arc_set_range(obj, min, lv_arc_get_max_value(obj));
+}
+
+void lv_arc_set_max_value(lv_obj_t * obj, int32_t max)
+{
+ lv_arc_set_range(obj, lv_arc_get_min_value(obj), max);
+}
+
void lv_arc_set_change_rate(lv_obj_t * obj, uint32_t rate)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
diff --git a/src/widgets/arc/lv_arc.h b/src/widgets/arc/lv_arc.h
index f241745ffa..18c2dbc7ad 100644
--- a/src/widgets/arc/lv_arc.h
+++ b/src/widgets/arc/lv_arc.h
@@ -126,6 +126,20 @@ void lv_arc_set_value(lv_obj_t * obj, int32_t value);
*/
void lv_arc_set_range(lv_obj_t * obj, int32_t min, int32_t max);
+/**
+ * Set the minimum values of an arc
+ * @param obj pointer to the arc object
+ * @param min minimum value
+ */
+void lv_arc_set_min_value(lv_obj_t * obj, int32_t min);
+
+/**
+ * Set the maximum values of an arc
+ * @param obj pointer to the arc object
+ * @param max maximum value
+ */
+void lv_arc_set_max_value(lv_obj_t * obj, int32_t max);
+
/**
* Set a change rate to limit the speed how fast the arc should reach the pressed point.
* @param obj pointer to an arc object
diff --git a/src/widgets/bar/lv_bar.c b/src/widgets/bar/lv_bar.c
index b526bd37c6..60686131ab 100644
--- a/src/widgets/bar/lv_bar.c
+++ b/src/widgets/bar/lv_bar.c
@@ -155,6 +155,16 @@ void lv_bar_set_range(lv_obj_t * obj, int32_t min, int32_t max)
lv_obj_invalidate(obj);
}
+void lv_bar_set_min_value(lv_obj_t * obj, int32_t min)
+{
+ lv_bar_set_range(obj, min, lv_bar_get_max_value(obj));
+}
+
+void lv_bar_set_max_value(lv_obj_t * obj, int32_t max)
+{
+ lv_bar_set_range(obj, lv_bar_get_min_value(obj), max);
+}
+
void lv_bar_set_mode(lv_obj_t * obj, lv_bar_mode_t mode)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
diff --git a/src/widgets/bar/lv_bar.h b/src/widgets/bar/lv_bar.h
index 422ba014b0..7e9953e116 100644
--- a/src/widgets/bar/lv_bar.h
+++ b/src/widgets/bar/lv_bar.h
@@ -82,6 +82,20 @@ void lv_bar_set_start_value(lv_obj_t * obj, int32_t start_value, lv_anim_enable_
*/
void lv_bar_set_range(lv_obj_t * obj, int32_t min, int32_t max);
+/**
+ * Set minimum value of a bar
+ * @param obj pointer to the bar object
+ * @param min minimum value
+ */
+void lv_bar_set_min_value(lv_obj_t * obj, int32_t min);
+
+/**
+ * Set maximum value of a bar
+ * @param obj pointer to the bar object
+ * @param max maximum value
+ */
+void lv_bar_set_max_value(lv_obj_t * obj, int32_t max);
+
/**
* Set the type of bar.
* @param obj pointer to bar object
diff --git a/src/widgets/calendar/lv_calendar.c b/src/widgets/calendar/lv_calendar.c
index bcdd23e228..09acf116ad 100644
--- a/src/widgets/calendar/lv_calendar.c
+++ b/src/widgets/calendar/lv_calendar.c
@@ -104,6 +104,28 @@ void lv_calendar_set_today_date(lv_obj_t * obj, uint32_t year, uint32_t month, u
highlight_update(obj);
}
+void lv_calendar_set_today_year(lv_obj_t * obj, uint32_t year)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+ lv_calendar_t * calendar = (lv_calendar_t *)obj;
+ lv_calendar_set_today_date(obj, year, calendar->today.month, calendar->today.day);
+
+}
+
+void lv_calendar_set_today_month(lv_obj_t * obj, uint32_t month)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+ lv_calendar_t * calendar = (lv_calendar_t *)obj;
+ lv_calendar_set_today_date(obj, calendar->today.year, month, calendar->today.day);
+}
+
+void lv_calendar_set_today_day(lv_obj_t * obj, uint32_t day)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+ lv_calendar_t * calendar = (lv_calendar_t *)obj;
+ lv_calendar_set_today_date(obj, calendar->today.year, calendar->today.month, day);
+}
+
void lv_calendar_set_highlighted_dates(lv_obj_t * obj, lv_calendar_date_t highlighted[], size_t date_num)
{
LV_ASSERT_NULL(highlighted);
@@ -212,6 +234,21 @@ void lv_calendar_set_month_shown(lv_obj_t * obj, uint32_t year, uint32_t month)
}
}
+void lv_calendar_set_shown_year(lv_obj_t * obj, uint32_t year)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+ lv_calendar_t * calendar = (lv_calendar_t *)obj;
+ lv_calendar_set_month_shown(obj, year, calendar->showed_date.month);
+
+}
+
+void lv_calendar_set_shown_month(lv_obj_t * obj, uint32_t month)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+ lv_calendar_t * calendar = (lv_calendar_t *)obj;
+ lv_calendar_set_month_shown(obj, calendar->showed_date.year, month);
+}
+
/*=====================
* Getter functions
*====================*/
diff --git a/src/widgets/calendar/lv_calendar.h b/src/widgets/calendar/lv_calendar.h
index c7159a3601..4a26933741 100644
--- a/src/widgets/calendar/lv_calendar.h
+++ b/src/widgets/calendar/lv_calendar.h
@@ -56,7 +56,7 @@ lv_obj_t * lv_calendar_create(lv_obj_t * parent);
*====================*/
/**
- * Set the today's date
+ * Set the today's year, month and day at once
* @param obj pointer to a calendar object
* @param year today's year
* @param month today's month [1..12]
@@ -65,13 +65,48 @@ lv_obj_t * lv_calendar_create(lv_obj_t * parent);
void lv_calendar_set_today_date(lv_obj_t * obj, uint32_t year, uint32_t month, uint32_t day);
/**
- * Set the currently showed
+ * Set the today's year
+ * @param obj pointer to a calendar object
+ * @param year today's year
+ */
+void lv_calendar_set_today_year(lv_obj_t * obj, uint32_t year);
+
+/**
+ * Set the today's year
+ * @param obj pointer to a calendar object
+ * @param month today's month [1..12]
+ */
+void lv_calendar_set_today_month(lv_obj_t * obj, uint32_t month);
+
+/**
+ * Set the today's year
+ * @param obj pointer to a calendar object
+ * @param day today's day [1..31]
+ */
+void lv_calendar_set_today_day(lv_obj_t * obj, uint32_t day);
+
+/**
+ * Set the currently shown year and month at once
* @param obj pointer to a calendar object
- * @param year today's year
- * @param month today's month [1..12]
+ * @param year shown year
+ * @param month shown month [1..12]
*/
void lv_calendar_set_month_shown(lv_obj_t * obj, uint32_t year, uint32_t month);
+/**
+ * Set the currently shown year
+ * @param obj pointer to a calendar object
+ * @param year shown year
+ */
+void lv_calendar_set_shown_year(lv_obj_t * obj, uint32_t year);
+
+/**
+ * Set the currently shown month
+ * @param obj pointer to a calendar object
+ * @param month shown month [1..12]
+ */
+void lv_calendar_set_shown_month(lv_obj_t * obj, uint32_t month);
+
/**
* Set the highlighted dates
* @param obj pointer to a calendar object
diff --git a/src/widgets/chart/lv_chart.c b/src/widgets/chart/lv_chart.c
index 6f17bd373c..6428406134 100644
--- a/src/widgets/chart/lv_chart.c
+++ b/src/widgets/chart/lv_chart.c
@@ -129,28 +129,49 @@ void lv_chart_set_point_count(lv_obj_t * obj, uint32_t cnt)
lv_chart_refresh(obj);
}
-void lv_chart_set_axis_range(lv_obj_t * obj, lv_chart_axis_t axis, int32_t min, int32_t max)
+void lv_chart_set_axis_min_value(lv_obj_t * obj, lv_chart_axis_t axis, int32_t min)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
- max = max == min ? max + 1 : max;
+ lv_chart_t * chart = (lv_chart_t *)obj;
+
+ switch(axis) {
+ case LV_CHART_AXIS_PRIMARY_Y:
+ chart->ymin[0] = min;
+ break;
+ case LV_CHART_AXIS_SECONDARY_Y:
+ chart->ymin[1] = min;
+ break;
+ case LV_CHART_AXIS_PRIMARY_X:
+ chart->xmin[0] = min;
+ break;
+ case LV_CHART_AXIS_SECONDARY_X:
+ chart->xmin[1] = min;
+ break;
+ default:
+ LV_LOG_WARN("Invalid axis: %d", axis);
+ return;
+ }
+
+ lv_chart_refresh(obj);
+}
+
+void lv_chart_set_axis_max_value(lv_obj_t * obj, lv_chart_axis_t axis, int32_t max)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
lv_chart_t * chart = (lv_chart_t *)obj;
switch(axis) {
case LV_CHART_AXIS_PRIMARY_Y:
- chart->ymin[0] = min;
chart->ymax[0] = max;
break;
case LV_CHART_AXIS_SECONDARY_Y:
- chart->ymin[1] = min;
chart->ymax[1] = max;
break;
case LV_CHART_AXIS_PRIMARY_X:
- chart->xmin[0] = min;
chart->xmax[0] = max;
break;
case LV_CHART_AXIS_SECONDARY_X:
- chart->xmin[1] = min;
chart->xmax[1] = max;
break;
default:
@@ -161,6 +182,14 @@ void lv_chart_set_axis_range(lv_obj_t * obj, lv_chart_axis_t axis, int32_t min,
lv_chart_refresh(obj);
}
+void lv_chart_set_axis_range(lv_obj_t * obj, lv_chart_axis_t axis, int32_t min, int32_t max)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+
+ lv_chart_set_axis_min_value(obj, axis, min);
+ lv_chart_set_axis_max_value(obj, axis, max);
+}
+
void lv_chart_set_update_mode(lv_obj_t * obj, lv_chart_update_mode_t update_mode)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
@@ -172,7 +201,7 @@ void lv_chart_set_update_mode(lv_obj_t * obj, lv_chart_update_mode_t update_mode
lv_obj_invalidate(obj);
}
-void lv_chart_set_div_line_count(lv_obj_t * obj, uint8_t hdiv, uint8_t vdiv)
+void lv_chart_set_div_line_count(lv_obj_t * obj, uint32_t hdiv, uint32_t vdiv)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
@@ -185,6 +214,26 @@ void lv_chart_set_div_line_count(lv_obj_t * obj, uint8_t hdiv, uint8_t vdiv)
lv_obj_invalidate(obj);
}
+void lv_chart_set_hor_div_line_count(lv_obj_t * obj, uint32_t cnt)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+
+ lv_chart_t * chart = (lv_chart_t *)obj;
+ if(chart->hdiv_cnt == cnt) return;
+ chart->hdiv_cnt = cnt;
+ lv_obj_invalidate(obj);
+}
+
+void lv_chart_set_ver_div_line_count(lv_obj_t * obj, uint32_t cnt)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+
+ lv_chart_t * chart = (lv_chart_t *)obj;
+ if(chart->vdiv_cnt == cnt) return;
+ chart->vdiv_cnt = cnt;
+ lv_obj_invalidate(obj);
+}
+
lv_chart_type_t lv_chart_get_type(const lv_obj_t * obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
diff --git a/src/widgets/chart/lv_chart.h b/src/widgets/chart/lv_chart.h
index 3f5dc3a710..d62c48cc03 100644
--- a/src/widgets/chart/lv_chart.h
+++ b/src/widgets/chart/lv_chart.h
@@ -94,6 +94,23 @@ void lv_chart_set_point_count(lv_obj_t * obj, uint32_t cnt);
*/
void lv_chart_set_axis_range(lv_obj_t * obj, lv_chart_axis_t axis, int32_t min, int32_t max);
+/**
+ * Set the minimal values on an axis
+ * @param obj pointer to a chart object
+ * @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
+ * @param min minimal value of the y axis
+ */
+void lv_chart_set_axis_min_value(lv_obj_t * obj, lv_chart_axis_t axis, int32_t min);
+
+/**
+ * Set the maximal y values on an axis
+ * @param obj pointer to a chart object
+ * @param axis `LV_CHART_AXIS_PRIMARY_Y` or `LV_CHART_AXIS_SECONDARY_Y`
+ * @param max maximum value of the y axis
+ */
+void lv_chart_set_axis_max_value(lv_obj_t * obj, lv_chart_axis_t axis, int32_t max);
+
+
/**
* Set update mode of the chart object. Affects
* @param obj pointer to a chart object
@@ -107,7 +124,21 @@ void lv_chart_set_update_mode(lv_obj_t * obj, lv_chart_update_mode_t update_mode
* @param hdiv number of horizontal division lines
* @param vdiv number of vertical division lines
*/
-void lv_chart_set_div_line_count(lv_obj_t * obj, uint8_t hdiv, uint8_t vdiv);
+void lv_chart_set_div_line_count(lv_obj_t * obj, uint32_t hdiv, uint32_t vdiv);
+
+/**
+ * Set the number of horizontal division lines
+ * @param obj pointer to a chart object
+ * @param cnt number of horizontal division lines
+ */
+void lv_chart_set_hor_div_line_count(lv_obj_t * obj, uint32_t cnt);
+
+/**
+ * Set the number of vertical division lines
+ * @param obj pointer to a chart object
+ * @param cnt number of vertical division lines
+ */
+void lv_chart_set_ver_div_line_count(lv_obj_t * obj, uint32_t cnt);
/**
* Get the type of a chart
diff --git a/src/widgets/image/lv_image.c b/src/widgets/image/lv_image.c
index 114d48a93c..031b7bae1e 100644
--- a/src/widgets/image/lv_image.c
+++ b/src/widgets/image/lv_image.c
@@ -367,6 +367,22 @@ void lv_image_set_pivot(lv_obj_t * obj, int32_t x, int32_t y)
lv_obj_invalidate_area(obj, &a);
}
+void lv_image_set_pivot_x(lv_obj_t * obj, int32_t x)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+
+ lv_image_t * img = (lv_image_t *)obj;
+ lv_image_set_pivot(obj, x, img->pivot.y);
+}
+
+void lv_image_set_pivot_y(lv_obj_t * obj, int32_t y)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+
+ lv_image_t * img = (lv_image_t *)obj;
+ lv_image_set_pivot(obj, img->pivot.x, y);
+}
+
void lv_image_set_scale(lv_obj_t * obj, uint32_t zoom)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
diff --git a/src/widgets/image/lv_image.h b/src/widgets/image/lv_image.h
index 39cde0c9d8..5a4bb13a13 100644
--- a/src/widgets/image/lv_image.h
+++ b/src/widgets/image/lv_image.h
@@ -135,6 +135,20 @@ void lv_image_set_rotation(lv_obj_t * obj, int32_t angle);
*/
void lv_image_set_pivot(lv_obj_t * obj, int32_t x, int32_t y);
+/**
+ * Set the rotation horizontal center of the image.
+ * @param obj pointer to an image object
+ * @param x rotation center x of the image, or lv_pct()
+ */
+void lv_image_set_pivot_x(lv_obj_t * obj, int32_t x);
+
+/**
+ * Set the rotation vertical center of the image.
+ * @param obj pointer to an image object
+ * @param y rotation center y of the image, or lv_pct()
+ */
+void lv_image_set_pivot_y(lv_obj_t * obj, int32_t y);
+
/**
* Set the zoom factor of the image.
* Note that indexed and alpha only images can't be transformed.
diff --git a/src/widgets/scale/lv_scale.c b/src/widgets/scale/lv_scale.c
index 1cc5aaaabf..db78389d52 100644
--- a/src/widgets/scale/lv_scale.c
+++ b/src/widgets/scale/lv_scale.c
@@ -162,6 +162,24 @@ void lv_scale_set_range(lv_obj_t * obj, int32_t min, int32_t max)
lv_obj_invalidate(obj);
}
+void lv_scale_set_min_value(lv_obj_t * obj, int32_t min)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+ lv_scale_t * scale = (lv_scale_t *)obj;
+ scale->range_min = min;
+
+ lv_obj_invalidate(obj);
+}
+
+void lv_scale_set_max_value(lv_obj_t * obj, int32_t max)
+{
+ LV_ASSERT_OBJ(obj, MY_CLASS);
+ lv_scale_t * scale = (lv_scale_t *)obj;
+ scale->range_max = max;
+
+ lv_obj_invalidate(obj);
+}
+
void lv_scale_set_angle_range(lv_obj_t * obj, uint32_t angle_range)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
@@ -364,6 +382,24 @@ void lv_scale_set_section_range(lv_obj_t * scale, lv_scale_section_t * section,
lv_obj_invalidate(scale);
}
+void lv_scale_set_section_min_value(lv_obj_t * scale, lv_scale_section_t * section, int32_t min)
+{
+ LV_ASSERT_OBJ(scale, MY_CLASS);
+ LV_ASSERT_NULL(section);
+
+ section->range_min = min;
+ lv_obj_invalidate(scale);
+}
+
+void lv_scale_set_section_max_value(lv_obj_t * scale, lv_scale_section_t * section, int32_t max)
+{
+ LV_ASSERT_OBJ(scale, MY_CLASS);
+ LV_ASSERT_NULL(section);
+
+ section->range_max = max;
+ lv_obj_invalidate(scale);
+}
+
void lv_scale_section_set_range(lv_scale_section_t * section, int32_t min, int32_t max)
{
if(NULL == section) return;
diff --git a/src/widgets/scale/lv_scale.h b/src/widgets/scale/lv_scale.h
index ebb98b0a9b..6a8eae1e16 100644
--- a/src/widgets/scale/lv_scale.h
+++ b/src/widgets/scale/lv_scale.h
@@ -120,6 +120,20 @@ void lv_scale_set_label_show(lv_obj_t * obj, bool show_label);
*/
void lv_scale_set_range(lv_obj_t * obj, int32_t min, int32_t max);
+/**
+ * Set minimum values on Scale.
+ * @param obj pointer to Scale Widget
+ * @param min minimum value of Scale
+ */
+void lv_scale_set_min_value(lv_obj_t * obj, int32_t min);
+
+/**
+ * Set maximum values on Scale.
+ * @param obj pointer to Scale Widget
+ * @param min minimum value of Scale
+ */
+void lv_scale_set_max_value(lv_obj_t * obj, int32_t max);
+
/**
* Set angle between the low end and the high end of the Scale.
* (Applies only to round Scales.)
@@ -204,7 +218,7 @@ void lv_scale_set_draw_ticks_on_top(lv_obj_t * obj, bool en);
lv_scale_section_t * lv_scale_add_section(lv_obj_t * obj);
/**
- * DEPRECATED, use lv_scale_set_section_rangeinstead.
+ * DEPRECATED, use lv_scale_set_section_range instead.
* Set range for specified Scale Section
* @param section pointer to Section
* @param range_min Section new minimum value
@@ -216,11 +230,27 @@ void lv_scale_section_set_range(lv_scale_section_t * section, int32_t min, int32
* Set the range of a scale section
* @param scale pointer to scale
* @param section pointer to section
- * @param range_min section new minimum value
- * @param range_max section new maximum value
+ * @param range_min the section's new minimum value
+ * @param range_max the section's new maximum value
*/
void lv_scale_set_section_range(lv_obj_t * scale, lv_scale_section_t * section, int32_t min, int32_t max);
+/**
+ * Set the minimum value of a scale section
+ * @param scale pointer to scale
+ * @param section pointer to section
+ * @param min the section's new minimum value
+ */
+void lv_scale_set_section_min_value(lv_obj_t * scale, lv_scale_section_t * section, int32_t min);
+
+/**
+ * Set the maximum value of a scale section
+ * @param scale pointer to scale
+ * @param section pointer to section
+ * @param max the section's new maximum value
+ */
+void lv_scale_set_section_max_value(lv_obj_t * scale, lv_scale_section_t * section, int32_t max);
+
/**
* DEPRECATED, use lv_scale_set_section_style_main/indicator/items instead.
* Set style for specified part of Section.
diff --git a/src/widgets/slider/lv_slider.c b/src/widgets/slider/lv_slider.c
index 7d6e45bbc4..99a8c54d2d 100644
--- a/src/widgets/slider/lv_slider.c
+++ b/src/widgets/slider/lv_slider.c
@@ -155,6 +155,16 @@ void lv_slider_set_range(lv_obj_t * obj, int32_t min, int32_t max)
lv_bar_set_range(obj, min, max);
}
+void lv_slider_set_min_value(lv_obj_t * obj, int32_t min)
+{
+ lv_bar_set_min_value(obj, min);
+}
+
+void lv_slider_set_max_value(lv_obj_t * obj, int32_t min)
+{
+ lv_bar_set_max_value(obj, min);
+}
+
void lv_slider_set_mode(lv_obj_t * obj, lv_slider_mode_t mode)
{
lv_bar_set_mode(obj, (lv_bar_mode_t)mode);
diff --git a/src/widgets/slider/lv_slider.h b/src/widgets/slider/lv_slider.h
index 1b3892676a..f24bf04a98 100644
--- a/src/widgets/slider/lv_slider.h
+++ b/src/widgets/slider/lv_slider.h
@@ -88,13 +88,27 @@ void lv_slider_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim);
void lv_slider_set_start_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim);
/**
- * Set minimum and the maximum values of a bar
+ * Set the minimum and the maximum values of a bar
* @param obj pointer to the slider object
* @param min minimum value
* @param max maximum value
*/
void lv_slider_set_range(lv_obj_t * obj, int32_t min, int32_t max);
+/**
+ * Set the minimum values of a bar
+ * @param obj pointer to the slider object
+ * @param min minimum value
+ */
+void lv_slider_set_min_value(lv_obj_t * obj, int32_t min);
+
+/**
+ * Set the maximum values of a bar
+ * @param obj pointer to the slider object
+ * @param max maximum value
+ */
+void lv_slider_set_max_value(lv_obj_t * obj, int32_t max);
+
/**
* Set the mode of slider.
* @param obj pointer to a slider object
diff --git a/tests/src/test_assets/xml/view2.xml b/tests/src/test_assets/xml/view2.xml
index 3341d7c813..117b41c9ba 100644
--- a/tests/src/test_assets/xml/view2.xml
+++ b/tests/src/test_assets/xml/view2.xml
@@ -20,10 +20,10 @@
+ min_value="10" max_value="110" width="300">
-
+
diff --git a/tests/src/test_assets/xml/view3.xml b/tests/src/test_assets/xml/view3.xml
index 16d91f6383..24b9216ac2 100644
--- a/tests/src/test_assets/xml/view3.xml
+++ b/tests/src/test_assets/xml/view3.xml
@@ -15,10 +15,10 @@
-
+
-
-
+
+
\ No newline at end of file
diff --git a/tests/src/test_cases/xml/test_xml_arc.c b/tests/src/test_cases/xml/test_xml_arc.c
index 888a328f90..ceb4881f33 100644
--- a/tests/src/test_cases/xml/test_xml_arc.c
+++ b/tests/src/test_cases/xml/test_xml_arc.c
@@ -19,8 +19,10 @@ void test_arc_with_attrs(void)
lv_obj_t * scr = lv_screen_active();
const char * attrs_1[] = {
- "bg_angles", "0 100",
- "range", "-20 20",
+ "bg_start_angle", "0",
+ "bg_end_angle", "100",
+ "min_value", "-20",
+ "max_value", "20",
"value", "10",
"mode", "reverse",
"align", "center",
diff --git a/tests/src/test_cases/xml/test_xml_bar.c b/tests/src/test_cases/xml/test_xml_bar.c
index 11017d3be0..3764381f1d 100644
--- a/tests/src/test_cases/xml/test_xml_bar.c
+++ b/tests/src/test_cases/xml/test_xml_bar.c
@@ -32,7 +32,8 @@ static void test_with_attrs(const char * name)
lv_xml_create(scr, name, attrs_1);
const char * attrs_2[] = {
- "range", "-100 100",
+ "min_value", "-100",
+ "max_value", "100",
"mode", "symmetrical",
"value", "50",
NULL, NULL,
diff --git a/tests/src/test_cases/xml/test_xml_calendar.c b/tests/src/test_cases/xml/test_xml_calendar.c
index ff279fc29c..44fe18b567 100644
--- a/tests/src/test_cases/xml/test_xml_calendar.c
+++ b/tests/src/test_cases/xml/test_xml_calendar.c
@@ -24,8 +24,11 @@ void test_xml_calendar_with_attrs(void)
"height", "200",
"x", "10",
"y", "10",
- "today_date", "2025 05 06",
- "shown_month", "2025 05",
+ "today_year", "2025",
+ "today_month", "05",
+ "today_day", "06",
+ "shown_year", "2025",
+ "shown_month", "05",
NULL, NULL,
};
lv_obj_t * calendar;
diff --git a/tests/src/test_cases/xml/test_xml_chart.c b/tests/src/test_cases/xml/test_xml_chart.c
index e8c2753db1..562304c262 100644
--- a/tests/src/test_cases/xml/test_xml_chart.c
+++ b/tests/src/test_cases/xml/test_xml_chart.c
@@ -34,7 +34,8 @@ void test_xml_chart_with_attrs(void)
const char * primary_y_axis_attrs[] = {
"axis", "primary_y",
- "range", "0 40",
+ "min_value", "0",
+ "max_value", "40",
NULL, NULL,
};
lv_xml_create(chart, "lv_chart-axis", primary_y_axis_attrs);
@@ -59,7 +60,8 @@ void test_xml_chart_with_attrs(void)
const char * secondary_y_axis_attrs[] = {
"axis", "secondary_y",
- "range", "70 90",
+ "min_value", "70",
+ "max_value", "90",
NULL, NULL,
};
lv_xml_create(chart, "lv_chart-axis", secondary_y_axis_attrs);
diff --git a/tests/src/test_cases/xml/test_xml_general.c b/tests/src/test_cases/xml/test_xml_general.c
index 810a0c54d9..e17d0ea820 100644
--- a/tests/src/test_cases/xml/test_xml_general.c
+++ b/tests/src/test_cases/xml/test_xml_general.c
@@ -31,8 +31,8 @@ void test_xml_widget_direct_create(void)
/*Use attributes*/
const char * attrs[] = {
- "range_min", "-100",
- "range_max", "100",
+ "min_value", "-100",
+ "max_value", "100",
"mode", "symmetrical",
"value", "50",
"name", "my_slider",
@@ -72,8 +72,8 @@ void test_xml_widget_create_from_component(void)
/*Use attributes*/
const char * attrs[] = {
- "range_min", "-100",
- "range_max", "100",
+ "min_value", "-100",
+ "max_value", "100",
"mode", "symmetrical",
"value", "50",
NULL, NULL,
diff --git a/tests/src/test_cases/xml/test_xml_label.c b/tests/src/test_cases/xml/test_xml_label.c
index 6f54e96bbe..31da8559fe 100644
--- a/tests/src/test_cases/xml/test_xml_label.c
+++ b/tests/src/test_cases/xml/test_xml_label.c
@@ -36,7 +36,8 @@ void test_xml_label_with_attrs(void)
lv_xml_register_subject(NULL, "s1", &s1);
const char * label2_attrs[] = {
- "bind_text", "s1 'We have %d users'",
+ "bind_text", "s1",
+ "bind_text-fmt", "We have %d users",
"y", "10",
"x", "5",
NULL, NULL,
diff --git a/tests/src/test_cases/xml/test_xml_roller.c b/tests/src/test_cases/xml/test_xml_roller.c
index ed63c435cd..725a1fae17 100644
--- a/tests/src/test_cases/xml/test_xml_roller.c
+++ b/tests/src/test_cases/xml/test_xml_roller.c
@@ -16,13 +16,14 @@ void tearDown(void)
void test_xml_roller_with_attrs(void)
{
-
lv_obj_t * scr = lv_screen_active();
const char * roller_attrs[] = {
"width", "200",
- "options", "'a\nb\nc\nd\ne' infinite",
- "selected", "2 true",
+ "options", "a\nb\nc\nd\ne",
+ "options-mode", "infinite",
+ "selected", "2",
+ "selected-animated", "true",
"visible_line_count", "3",
NULL, NULL,
};
diff --git a/tests/src/test_cases/xml/test_xml_scale.c b/tests/src/test_cases/xml/test_xml_scale.c
index 40041e28f8..720f871699 100644
--- a/tests/src/test_cases/xml/test_xml_scale.c
+++ b/tests/src/test_cases/xml/test_xml_scale.c
@@ -22,7 +22,8 @@ void test_xml_scale_with_attrs(void)
"width", "120",
"height", "120",
"mode", "round_outer",
- "range", "0 150",
+ "min_value", "0",
+ "max_value", "150",
"total_tick_count", "16",
"major_tick_every", "3",
"style_length:indicator", "10",
@@ -34,7 +35,8 @@ void test_xml_scale_with_attrs(void)
lv_obj_center(scale);
const char * section_attrs[] = {
- "range", "10 80",
+ "min_value", "10",
+ "max_value", "80",
NULL, NULL,
};
diff --git a/tests/src/test_cases/xml/test_xml_slider.c b/tests/src/test_cases/xml/test_xml_slider.c
index 07b9371f94..4cc8097e27 100644
--- a/tests/src/test_cases/xml/test_xml_slider.c
+++ b/tests/src/test_cases/xml/test_xml_slider.c
@@ -32,7 +32,8 @@ static void test_with_attrs(const char * name)
lv_xml_create(scr, name, attrs_1);
const char * attrs_2[] = {
- "range", "-100 100",
+ "min_value", "-100",
+ "max_value", "100",
"mode", "symmetrical",
"value", "50",
NULL, NULL,
diff --git a/xmls/lv_arc.xml b/xmls/lv_arc.xml
index a603c0d987..6c65fda3ed 100644
--- a/xmls/lv_arc.xml
+++ b/xmls/lv_arc.xml
@@ -10,24 +10,15 @@ Example
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/xmls/lv_bar.xml b/xmls/lv_bar.xml
index 795f359d7e..209f68c118 100644
--- a/xmls/lv_bar.xml
+++ b/xmls/lv_bar.xml
@@ -17,19 +17,17 @@ Example
-
-
-
-
+
+
-
+
-
-
+
+
diff --git a/xmls/lv_calendar.xml b/xmls/lv_calendar.xml
index 4129b7107f..be735ab0d7 100644
--- a/xmls/lv_calendar.xml
+++ b/xmls/lv_calendar.xml
@@ -5,15 +5,13 @@ Example
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/xmls/lv_chart.xml b/xmls/lv_chart.xml
index 14e77f46e9..eb1d469251 100644
--- a/xmls/lv_chart.xml
+++ b/xmls/lv_chart.xml
@@ -31,11 +31,9 @@
-
-
-
-
-
+
+
+
@@ -52,10 +50,8 @@
-
-
-
-
+
+
\ No newline at end of file
diff --git a/xmls/lv_checkbox.xml b/xmls/lv_checkbox.xml
index bdf1febc4b..9a0ba76ab3 100644
--- a/xmls/lv_checkbox.xml
+++ b/xmls/lv_checkbox.xml
@@ -5,8 +5,6 @@ Example
-
-
-
+
\ No newline at end of file
diff --git a/xmls/lv_image.xml b/xmls/lv_image.xml
index 445df68a83..e154e3e5ed 100644
--- a/xmls/lv_image.xml
+++ b/xmls/lv_image.xml
@@ -27,9 +27,7 @@ Example
-
-
-
-
+
+
\ No newline at end of file
diff --git a/xmls/lv_label.xml b/xmls/lv_label.xml
index 5780833994..d903072132 100644
--- a/xmls/lv_label.xml
+++ b/xmls/lv_label.xml
@@ -16,8 +16,8 @@ Example
-
-
+
+
diff --git a/xmls/lv_roller.xml b/xmls/lv_roller.xml
index e68acb33ed..14870a9d8f 100644
--- a/xmls/lv_roller.xml
+++ b/xmls/lv_roller.xml
@@ -16,7 +16,7 @@ Example
-
+
diff --git a/xmls/lv_scale.xml b/xmls/lv_scale.xml
index 2ec81b9897..e7014ece78 100644
--- a/xmls/lv_scale.xml
+++ b/xmls/lv_scale.xml
@@ -19,10 +19,8 @@
-
-
-
-
+
+
diff --git a/xmls/lv_slider.xml b/xmls/lv_slider.xml
index fbc42bdd8f..d3507222aa 100644
--- a/xmls/lv_slider.xml
+++ b/xmls/lv_slider.xml
@@ -11,10 +11,8 @@ Example
-
-
-
-
+
+
@@ -22,7 +20,7 @@ Example
-
+
diff --git a/xmls/lv_table.xml b/xmls/lv_table.xml
index 1c82c69d49..90b289a5db 100644
--- a/xmls/lv_table.xml
+++ b/xmls/lv_table.xml
@@ -19,10 +19,6 @@
-
-
-
-