mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-26 02:37:01 +08:00
feat(observer): add float subject type (#8388)
This commit is contained in:
committed by
GitHub
parent
1ef1d23342
commit
ae0a3bc822
@@ -17,7 +17,7 @@ This implementation consists of:
|
||||
|
||||
:Subjects: (in global memory or heap) are "logic packages", each containing the
|
||||
value being "observed" and its type (integer (``int32_t``), a string, a
|
||||
pointer, an :cpp:type:`lv_color_t`, or a group);
|
||||
pointer, an :cpp:type:`lv_color_t`, a :cpp_type:`float`, or a group);
|
||||
|
||||
:Observers: (zero or more per Subject, always dynamically-allocated) are always
|
||||
attached to exactly one Subject, and provide user-defined notifications
|
||||
@@ -114,6 +114,7 @@ To initialize a Subject use ``lv_subject_init_<type>(&subject, params, init_valu
|
||||
The following initialization functions exist, one for each of the Subject types:
|
||||
|
||||
:Integer: void :cpp:expr:`lv_subject_init_int(subject, int_value)`
|
||||
:Float: void :cpp:expr:`lv_subject_init_float(subject, float_value)`
|
||||
:String: void :cpp:expr:`lv_subject_init_string(subject, buf, prev_buf, buf_size, initial_string)`
|
||||
:Pointer: void :cpp:expr:`lv_subject_init_pointer(subject, ptr)`
|
||||
:Color: void :cpp:expr:`lv_subject_init_color(subject, color)`
|
||||
@@ -141,6 +142,7 @@ The following functions are used to get a Subject's current value:
|
||||
|
||||
|
||||
:Integer: int32_t :cpp:expr:`lv_subject_get_int(subject)`
|
||||
:Float: float :cpp:expr:`lv_subject_get_float(subject)`
|
||||
:String: const char * :cpp:expr:`lv_subject_get_string(subject)`
|
||||
:Pointer: const void * :cpp:expr:`lv_subject_get_pointer(subject)`
|
||||
:Color: lv_color_t :cpp:expr:`lv_subject_get_color(subject)`
|
||||
@@ -153,6 +155,7 @@ The following functions are used to get a Subject's previous value:
|
||||
|
||||
|
||||
:Integer: int32_t :cpp:expr:`lv_subject_get_previous_int(subject)`
|
||||
:Float: float :cpp:expr:`lv_subject_get_previous_float(subject)`
|
||||
:String: const char * :cpp:expr:`lv_subject_get_previous_string(subject)`
|
||||
:Pointer: const void * :cpp:expr:`lv_subject_get_previous_pointer(subject)`
|
||||
:Color: lv_color_t :cpp:expr:`lv_subject_get_previous_color(subject)`
|
||||
@@ -492,11 +495,14 @@ printf-like format specifier and be one of the following:
|
||||
cross-platform equivalent where ``xx`` can be ``8``,
|
||||
``16``, ``32`` or ``64``, depending on the platform).
|
||||
|
||||
If NULL is passed for the ``format_string`` argument:
|
||||
:float Subject: "%f" format specifier, or e.g. "%0.2f" to display two digits after the decimal point.
|
||||
|
||||
|
||||
If ``NULL`` is passed for the ``format_string`` argument:
|
||||
|
||||
:string or pointer Subject: Updates expect the pointer to point to a NUL-terminated string.
|
||||
|
||||
:integer Subject: The Label will display an empty string (i.e. nothing).
|
||||
:integer Subject: The Label will simply display the number. Equivalent to "%d".
|
||||
:float Subject: The Label will display the value with "%0.1f" format string.
|
||||
|
||||
**Example:** "%d |deg|\C"
|
||||
|
||||
@@ -509,6 +515,9 @@ value directly. Note that this is a two-way binding (Subject <===> Widget) so a
|
||||
user's direct interaction with the Arc Widget updates the Subject's value and vice
|
||||
versa. (Requires :c:macro:`LV_USE_ARC` to be configured to ``1``.)
|
||||
|
||||
It support integer and float subjects.
|
||||
|
||||
|
||||
- :cpp:expr:`lv_arc_bind_value(arc, &subject)`
|
||||
|
||||
|
||||
@@ -520,6 +529,8 @@ value directly. Note that this is a two-way binding (Subject <===> Widget) so a
|
||||
user's direct interaction with the Slider Widget updates the Subject's value and vice
|
||||
versa. (Requires :c:macro:`LV_USE_SLIDER` to be configured to ``1``.)
|
||||
|
||||
It support integer and float subjects.
|
||||
|
||||
- :cpp:expr:`lv_slider_bind_value(slider, &subject)`
|
||||
|
||||
|
||||
@@ -531,6 +542,8 @@ value directly. Note that this is a two-way binding (Subject <===> Widget) so a
|
||||
user's direct interaction with the Slider Widget updates the Subject's value and vice
|
||||
versa. (Requires :c:macro:`LV_USE_ROLLER` to be configured to ``1``.)
|
||||
|
||||
It support only integer subjects.
|
||||
|
||||
- :cpp:expr:`lv_roller_bind_value(roller, &subject)`
|
||||
|
||||
|
||||
@@ -542,6 +555,8 @@ value directly. Note that this is a two-way binding (Subject <===> Widget) so a
|
||||
user's direct interaction with the Drop-Down Widget updates the Subject's value and
|
||||
vice versa. (Requires :c:macro:`LV_USE_DROPDOWN` to be configured to ``1``.)
|
||||
|
||||
It support only integer subjects.
|
||||
|
||||
- :cpp:expr:`lv_dropdown_bind_value(dropdown, &subject)`
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user