docs: update API comments
This commit is contained in:
@@ -587,9 +587,9 @@ static lv_obj_t * create_ctrl_box(lv_obj_t * parent)
|
||||
lv_obj_set_grid_cell(icon, LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
lv_obj_add_event_cb(icon, prev_click_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
play_obj = lv_imgbtn_create(cont);
|
||||
lv_imgbtn_set_src(play_obj, LV_IMGBTN_STATE_RELEASED, NULL, &img_lv_demo_music_btn_play, NULL);
|
||||
lv_imgbtn_set_src(play_obj, LV_IMGBTN_STATE_CHECKED_RELEASED, NULL, &img_lv_demo_music_btn_pause, NULL);
|
||||
play_obj = lv_imagebutton_create(cont);
|
||||
lv_imagebutton_set_src(play_obj, LV_IMAGEBUTTON_STATE_RELEASED, NULL, &img_lv_demo_music_btn_play, NULL);
|
||||
lv_imagebutton_set_src(play_obj, LV_IMAGEBUTTON_STATE_CHECKED_RELEASED, NULL, &img_lv_demo_music_btn_pause, NULL);
|
||||
lv_obj_add_flag(play_obj, LV_OBJ_FLAG_CHECKABLE);
|
||||
lv_obj_set_grid_cell(play_obj, LV_GRID_ALIGN_CENTER, 3, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
|
||||
|
||||
@@ -734,7 +734,7 @@ static void analytics_create(lv_obj_t * parent)
|
||||
|
||||
/*Scale 2*/
|
||||
static const char * scale2_text[] = {"0", "10", "20", "30", "40", "50", "60", "70", "80", "90", NULL};
|
||||
lv_scale_set_round_props(scale2, 360, 0);
|
||||
lv_scale_set_angle_range(scale2, 360);
|
||||
lv_scale_set_text_src(scale2, scale2_text);
|
||||
lv_scale_set_total_tick_count(scale2, 11);
|
||||
lv_scale_set_major_tick_length(scale2, 30);
|
||||
@@ -782,7 +782,8 @@ static void analytics_create(lv_obj_t * parent)
|
||||
lv_scale_set_major_tick_every(scale3, 4);
|
||||
lv_scale_set_minor_tick_length(scale3, 10);
|
||||
lv_scale_set_major_tick_length(scale3, 20);
|
||||
lv_scale_set_round_props(scale3, 225, 135);
|
||||
lv_scale_set_angle_range(scale3, 225);
|
||||
lv_scale_set_rotation(scale3, 135);
|
||||
|
||||
lv_style_init(&scale3_section1_main_style);
|
||||
lv_style_set_arc_width(&scale3_section1_main_style, 8);
|
||||
|
||||
@@ -51,7 +51,7 @@ widgets = {
|
||||
"colorwheel": "Colorwheel",
|
||||
"dropdown": "Dropdown",
|
||||
"img": "Image",
|
||||
"imgbtn": "Image button",
|
||||
"imagebutton": "Image button",
|
||||
"keyboard": "Keyboard",
|
||||
"label": "Label",
|
||||
"led": "LED",
|
||||
|
||||
@@ -65,7 +65,7 @@ and configured with ``lv_anim_set_...()`` functions.
|
||||
lv_anim_set_start_cb(&a, start_cb);
|
||||
|
||||
/*When ready, play the animation backward with this duration. Default is 0 (disabled) [ms]*/
|
||||
lv_anim_set_playback_time(&a, time);
|
||||
lv_anim_set_playback_duration(&a, time);
|
||||
|
||||
/*Delay before playback. Default is 0 (disabled) [ms]*/
|
||||
lv_anim_set_playback_delay(&a, delay);
|
||||
|
||||
@@ -6,8 +6,9 @@ The color module handles all color-related functions like changing color
|
||||
depth, creating colors from hex code, converting between color depths,
|
||||
mixing colors, etc.
|
||||
|
||||
The type :cpp:type:`lv_color_t` is used to store a color. Its fields are set
|
||||
according to :c:macro:`LV_COLOR_DEPTH` in ``lv_conf.h``. (See below)
|
||||
The type :cpp:type:`lv_color_t` is used to store a color in RGB888 format.
|
||||
This type and format is used in almost all APIs regardless to
|
||||
:cpp:expr`LV_COLOR_DEPTH`.
|
||||
|
||||
Creating colors
|
||||
***************
|
||||
@@ -19,13 +20,17 @@ Create colors from Red, Green and Blue channel values:
|
||||
|
||||
.. code:: c
|
||||
|
||||
//All channels are 0-255
|
||||
/*All channels are 0-255*/
|
||||
lv_color_t c = lv_color_make(red, green, blue);
|
||||
|
||||
//From hex code 0x000000..0xFFFFFF interpreted as RED + GREEN + BLUE
|
||||
|
||||
/*Same but can be used for const initialization too */
|
||||
lv_color_t c = LV_COLOR_MAKE(red, green, blue);
|
||||
|
||||
/*From hex code 0x000000..0xFFFFFF interpreted as RED + GREEN + BLUE*/
|
||||
lv_color_t c = lv_color_hex(0x123456);
|
||||
|
||||
//From 3 digits. Same as lv_color_hex(0x112233)
|
||||
/*From 3 digits. Same as lv_color_hex(0x112233)*/
|
||||
lv_color_t c = lv_color_hex3(0x123);
|
||||
|
||||
HSV
|
||||
@@ -52,7 +57,7 @@ LVGL includes `Material Design's palette <https://vuetifyjs.com/en/styles/colors
|
||||
colors. In this system all named colors have a nominal main color as
|
||||
well as four darker and five lighter variants.
|
||||
|
||||
The names of the colors are as follows:
|
||||
The names of the colors are as follows:
|
||||
|
||||
- :c:macro:`LV_PALETTE_RED`
|
||||
- :c:macro:`LV_PALETTE_PINK`
|
||||
@@ -126,62 +131,7 @@ Some special purpose defines are also introduced:
|
||||
You can also use the ``LV_OPA_*`` defines in :cpp:func:`lv_color_mix` as a
|
||||
mixing *ratio*.
|
||||
|
||||
Color types
|
||||
***********
|
||||
|
||||
The following variable types are defined by the color module:
|
||||
|
||||
- :cpp:union:`lv_color1_t` Monochrome color. Also has R, G, B fields for
|
||||
compatibility but they are always the same value (1 byte)
|
||||
- :cpp:union:`lv_color8_t` A structure to store R (3 bit),G (3 bit),B (2 bit)
|
||||
components for 8-bit colors (1 byte)
|
||||
- :cpp:class:`lv_color16_t` A structure to store R (5 bit),G (6 bit),B (5 bit)
|
||||
components for 16-bit colors (2 byte)
|
||||
- :cpp:class:`lv_color32_t` A structure to store R (8 bit),G (8 bit), B (8 bit)
|
||||
components for 24-bit colors (4 byte)
|
||||
- :cpp:type:`lv_color_t` Equal to ``lv_color1/8/16/24_t`` depending on the
|
||||
configured color depth setting
|
||||
- :cpp:type:`lv_color_int_t` ``uint8_t``, ``uint16_t`` or ``uint32_t``
|
||||
depending on the color depth setting. Used to build color arrays from
|
||||
plain numbers.
|
||||
- :cpp:type:`lv_opa_t` A simple ``uint8_t`` type to describe opacity.
|
||||
|
||||
The :cpp:type:`lv_color_t`, :cpp:union:`lv_color1_t`, :cpp:union:`lv_color8_t`, :cpp:class:`lv_color16_t`
|
||||
and :cpp:class:`lv_color32_t` types have four fields:
|
||||
|
||||
- :cpp:member:`red` red channel
|
||||
- :cpp:member:`green` green channel
|
||||
- :cpp:member:`blue` blue channel
|
||||
- :cpp:member:`full` red + green + blue as one number
|
||||
|
||||
You can set the current color depth in *lv_conf.h*, by setting the
|
||||
:c:macro:`LV_COLOR_DEPTH` define to 1 (monochrome), 8, 16 or 32.
|
||||
|
||||
Convert color
|
||||
-------------
|
||||
|
||||
You can convert a color from the current color depth to another. The
|
||||
converter functions return with a number, so you have to use the
|
||||
:cpp:member:`full` field to map a converted color back into a structure:
|
||||
|
||||
.. code:: c
|
||||
|
||||
lv_color_t c;
|
||||
c.red = 0x38;
|
||||
c.green = 0x70;
|
||||
c.blue = 0xCC;
|
||||
|
||||
lv_color1_t c1;
|
||||
c1.full = lv_color_to1(c); /*Return 1 for light colors, 0 for dark colors*/
|
||||
|
||||
lv_color8_t c8;
|
||||
c8.full = lv_color_to8(c); /*Give a 8 bit number with the converted color*/
|
||||
|
||||
lv_color16_t c16;
|
||||
c16.full = lv_color_to16(c); /*Give a 16 bit number with the converted color*/
|
||||
|
||||
lv_color32_t c24;
|
||||
c32.full = lv_color_to32(c); /*Give a 32 bit number with the converted color*/
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
@@ -40,6 +40,7 @@ model. An object's "box" is built from the following parts:
|
||||
- bounding box: the width/height of the elements.
|
||||
- border width: the width of the border.
|
||||
- padding: space between the sides of the object and its children.
|
||||
- margin: space outside of the object (considered only by some layouts)
|
||||
- content: the content area which is the size of the bounding box reduced by the border width and padding.
|
||||
|
||||
.. image:: /misc/boxmodel.png
|
||||
|
||||
@@ -7,15 +7,12 @@ Displays
|
||||
Multiple display support
|
||||
************************
|
||||
|
||||
In LVGL you can have multiple displays, each with their own driver and
|
||||
objects. The only limitation is that every display needs to have the
|
||||
same color depth (as defined in :c:macro:`LV_COLOR_DEPTH`). If the displays are
|
||||
different in this regard the rendered image can be converted to the
|
||||
correct format in the drivers ``flush_cb``.
|
||||
In LVGL you can have multiple displays, each with their own driver,
|
||||
widgets and color depth.
|
||||
|
||||
Creating more displays is easy: just initialize more display buffers and
|
||||
register another driver for every display. When you create the UI, use
|
||||
:cpp:expr:`lv_disp_set_default(disp)` to tell the library on which display to
|
||||
Creating more displays is easy: just use :cpp:func:`lv_display_create` and
|
||||
add set the buffer and the ``flush_cb``. When you create the UI, use
|
||||
:cpp:expr:`lv_display_set_default(disp)` to tell the library on which display to
|
||||
create objects.
|
||||
|
||||
Why would you want multi-display support? Here are some examples:
|
||||
@@ -38,7 +35,7 @@ hidden if you register only one display. By default, the last created
|
||||
:cpp:func:`lv_layer_sys`, :c:macro:`LV_HOR_RES` and :c:macro:`LV_VER_RES` are always applied
|
||||
on the most recently created (default) display. If you pass ``NULL`` as
|
||||
``disp`` parameter to display related functions the default display will
|
||||
usually be used. E.g. :cpp:expr:`lv_disp_trig_activity(NULL)` will trigger a
|
||||
usually be used. E.g. :cpp:expr:`lv_display_trig_activity(NULL)` will trigger a
|
||||
user activity on the default display. (See below in `Inactivity <#Inactivity>`__).
|
||||
|
||||
Mirror display
|
||||
@@ -87,7 +84,7 @@ existing screen copied into the new screen.
|
||||
To load a screen, use :cpp:expr:`lv_screen_load(scr)`. To get the active screen,
|
||||
use :cpp:expr:`lv_screen_active()`. These functions work on the default display. If
|
||||
you want to specify which display to work on, use
|
||||
:cpp:expr:`lv_disp_get_screen_active(disp)` and :cpp:expr:`lv_disp_load_scr(disp, scr)`. A
|
||||
:cpp:expr:`lv_display_get_screen_active(disp)` and :cpp:expr:`lv_display_load_scr(disp, scr)`. A
|
||||
screen can be loaded with animations too. Read more
|
||||
`here <object.html#load-screens>`__.
|
||||
|
||||
@@ -120,7 +117,7 @@ UIs:
|
||||
- Set the screen's bg_opa to 0:
|
||||
:cpp:expr:`lv_obj_set_style_bg_opa(lv_layer_bottom(), LV_OPA_TRANSP, 0)`
|
||||
- Set a color format with alpha channel. E.g.
|
||||
:cpp:expr:`lv_disp_set_color_format(disp, LV_COLOR_FORMAT_NATIVE_ALPHA)`
|
||||
:cpp:expr:`lv_display_set_color_format(disp, LV_COLOR_FORMAT_ARGB8888)`
|
||||
|
||||
Features of displays
|
||||
********************
|
||||
@@ -131,12 +128,12 @@ Inactivity
|
||||
A user's inactivity time is measured on each display. Every use of an
|
||||
`Input device </overview/indev>`__ (if `associated with the display </porting/indev#other-features>`__) counts as an activity. To
|
||||
get time elapsed since the last activity, use
|
||||
:cpp:expr:`lv_disp_get_inactive_time(disp)`. If ``NULL`` is passed, the lowest
|
||||
:cpp:expr:`lv_display_get_inactive_time(disp)`. If ``NULL`` is passed, the lowest
|
||||
inactivity time among all displays will be returned (**NULL isn't just
|
||||
the default display**).
|
||||
|
||||
You can manually trigger an activity using
|
||||
:cpp:expr:`lv_disp_trig_activity(disp)`. If ``disp`` is ``NULL``, the default
|
||||
:cpp:expr:`lv_display_trig_activity(disp)`. If ``disp`` is ``NULL``, the default
|
||||
screen will be used (**and not all displays**).
|
||||
|
||||
Background
|
||||
|
||||
@@ -12,15 +12,17 @@ interesting to the user, e.g. when an object:
|
||||
- has its value changed
|
||||
- is redrawn, etc.
|
||||
|
||||
Add events to the object
|
||||
************************
|
||||
Besides widgets, events can registered from displays and input devices too.
|
||||
|
||||
Add events to a widget
|
||||
**********************
|
||||
|
||||
The user can assign callback functions to an object to see its events.
|
||||
In practice, it looks like this:
|
||||
|
||||
.. code:: c
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(lv_screen_active());
|
||||
lv_obj_t * btn = lv_button_create(lv_screen_active());
|
||||
lv_obj_add_event_cb(btn, my_event_cb, LV_EVENT_CLICKED, NULL); /*Assign an event callback*/
|
||||
|
||||
...
|
||||
@@ -58,11 +60,29 @@ The events will be called in the order as they were added.
|
||||
|
||||
Other objects can use the same *event callback*.
|
||||
|
||||
Remove event(s) from an object
|
||||
******************************
|
||||
In the very same way events can attached to the input devices and displays like this
|
||||
|
||||
.. code:: c
|
||||
|
||||
lv_display_add_event_cb(disp, event_cb, LV_EVENT_RESOLUTION_CHANGED, NULL);
|
||||
lv_indev_add_event_cb(indev, event_cb, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
|
||||
Remove event(s) from widgets
|
||||
****************************
|
||||
|
||||
.. code:: c
|
||||
|
||||
uint32_t i;
|
||||
uint32_t event_cnt = lv_obj_get_event_count(obj);
|
||||
for(i = 0; i < event_cnt; i++) {
|
||||
lv_event_dsc_t * event_dsc = lv_obj_get_event_dsc(obj, i);
|
||||
if(lv_event_dsc_get_cb(event_dsc) == some_event_cb) {
|
||||
lv_obj_remove_event(obj, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Events can be removed from an object with the
|
||||
:cpp:expr:`lv_obj_remove_event(obj, event_cb)` function
|
||||
|
||||
Event codes
|
||||
***********
|
||||
@@ -81,70 +101,82 @@ are sent,
|
||||
|
||||
The following event codes exist:
|
||||
|
||||
|
||||
Input device events
|
||||
-------------------
|
||||
|
||||
- :cpp:enumerator:`LV_EVENT_PRESSED`: An object has been pressed
|
||||
- :cpp:enumerator:`LV_EVENT_PRESSING`: An object is being pressed (called continuously while pressing)
|
||||
- :cpp:enumerator:`LV_EVENT_PRESS_LOST`: An object is still being pressed but slid cursor/finger off of the object
|
||||
- :cpp:enumerator:`LV_EVENT_SHORT_CLICKED`: An object was pressed for a short period of time, then released. Not called if scrolled.
|
||||
- :cpp:enumerator:`LV_EVENT_LONG_PRESSED`: An object has been pressed for at least the ``long_press_time`` specified in the input device driver. Not called if scrolled.
|
||||
- :cpp:enumerator:`LV_EVENT_LONG_PRESSED_REPEAT`: Called after ``long_press_time`` in every ``long_press_repeat_time`` ms. Not called if scrolled.
|
||||
- :cpp:enumerator:`LV_EVENT_CLICKED`: Called on release if an object did not scroll (regardless of long press)
|
||||
- :cpp:enumerator:`LV_EVENT_RELEASED`: Called in every case when an object has been released
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL_BEGIN`: Scrolling begins. The event parameter is ``NULL`` or an :cpp:type:`lv_anim_t` ``*`` with a scroll animation descriptor that can be modified if required.
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL_THROW_BEGIN`: Sent once when the object is released while scrolling but the "momentum" still keeps the content scrolling.
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL_END`: Scrolling ends.
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL`: An object was scrolled
|
||||
- :cpp:enumerator:`LV_EVENT_GESTURE`: A gesture is detected. Get the gesture with :cpp:expr:`lv_indev_get_gesture_dir(lv_indev_active())`
|
||||
- :cpp:enumerator:`LV_EVENT_KEY`: A key is sent to an object. Get the key with :cpp:expr:`lv_indev_get_key(lv_indev_active())`
|
||||
- :cpp:enumerator:`LV_EVENT_FOCUSED`: An object is focused
|
||||
- :cpp:enumerator:`LV_EVENT_DEFOCUSED`: An object is unfocused
|
||||
- :cpp:enumerator:`LV_EVENT_LEAVE`: An object is unfocused but still selected
|
||||
- :cpp:enumerator:`LV_EVENT_HIT_TEST`: Perform advanced hit-testing. Use :cpp:struct:`lv_hit_test_info_t` ``* a =`` :cpp:expr:`lv_event_get_hit_test_info(e)` and check if ``a->point`` can click the object or not. If not set ``a->res = false``
|
||||
- :cpp:enumerator:`LV_EVENT_PRESSED`: The object has been pressed
|
||||
- :cpp:enumerator:`LV_EVENT_PRESSING`: The object is being pressed (called continuously while pressing)
|
||||
- :cpp:enumerator:`LV_EVENT_PRESS_LOST`: The object is still being pressed but slid cursor/finger off of the object
|
||||
- :cpp:enumerator:`LV_EVENT_SHORT_CLICKED`: The object was pressed for a short period of time, then released it. Not called if scrolled.
|
||||
- :cpp:enumerator:`LV_EVENT_LONG_PRESSED`: Object has been pressed for at least `long_press_time`. Not called if scrolled.
|
||||
- :cpp:enumerator:`LV_EVENT_LONG_PRESSED_REPEAT`: Called after `long_press_time` in every `long_press_repeat_time` ms. Not called if scrolled.
|
||||
- :cpp:enumerator:`LV_EVENT_CLICKED`: Called on release if not scrolled (regardless to long press)
|
||||
- :cpp:enumerator:`LV_EVENT_RELEASED`: Called in every cases when the object has been released
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL_BEGIN`: Scrolling begins. The event parameter is a pointer to the animation of the scroll. Can be modified
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL_THROW_BEGIN,
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL_END`: Scrolling ends
|
||||
- :cpp:enumerator:`LV_EVENT_SCROLL`: Scrolling
|
||||
- :cpp:enumerator:`LV_EVENT_GESTURE`: A gesture is detected. Get the gesture with `lv_indev_get_gesture_dir(lv_indev_active());`
|
||||
- :cpp:enumerator:`LV_EVENT_KEY`: A key is sent to the object. Get the key with `lv_indev_get_key(lv_indev_active());`
|
||||
- :cpp:enumerator:`LV_EVENT_FOCUSED`: The object is focused
|
||||
- :cpp:enumerator:`LV_EVENT_DEFOCUSED`: The object is defocused
|
||||
- :cpp:enumerator:`LV_EVENT_LEAVE`: The object is defocused but still selected
|
||||
- :cpp:enumerator:`LV_EVENT_HIT_TEST`: Perform advanced hit-testing
|
||||
- :cpp:enumerator:`LV_EVENT_INDEV_RESET`: Indev has been reset
|
||||
|
||||
Drawing events
|
||||
--------------
|
||||
|
||||
- :cpp:enumerator:`LV_EVENT_COVER_CHECK`: Check if an object fully covers an area. The event parameter is :cpp:struct:`lv_cover_check_info_t` ``*``.
|
||||
- :cpp:enumerator:`LV_EVENT_REFR_EXT_DRAW_SIZE`: Get the required extra draw area around an object (e.g. for a shadow). The event parameter is :cpp:type:`int32_t` ``*`` to store the size. Only overwrite it with a larger value.
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_MAIN_BEGIN`: Starting the main drawing phase.
|
||||
- :cpp:enumerator:`LV_EVENT_COVER_CHECK`: Check if the object fully covers an area. The event parameter is `lv_cover_check_info_t *`.
|
||||
- :cpp:enumerator:`LV_EVENT_REFR_EXT_DRAW_SIZE`: Get the required extra draw area around the object (e.g. for shadow). The event parameter is `int32_t *` to store the size.
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_MAIN_BEGIN`: Starting the main drawing phase
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_MAIN`: Perform the main drawing
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_MAIN_END`: Finishing the main drawing phase
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_POST_BEGIN`: Starting the post draw phase (when all children are drawn)
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_POST`: Perform the post draw phase (when all children are drawn)
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_POST_END`: Finishing the post draw phase (when all children are drawn)
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_PART_BEGIN`: Starting to draw a part. The event parameter is :cpp:struct:`lv_obj_draw_dsc_t` ``*``. Learn more :ref:`drawing`.
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_PART_END`: Finishing to draw a part. The event parameter is :cpp:struct:`lv_obj_draw_dsc_t` ``*``. Learn more :ref:`drawing`.
|
||||
|
||||
In ``LV_EVENT_DRAW_...`` events it's not allowed to adjust the widgets'
|
||||
properties. E.g. you can not call :cpp:func:`lv_obj_set_width`. In other words
|
||||
only ``get`` functions can be called.
|
||||
|
||||
Other events
|
||||
------------
|
||||
|
||||
- :cpp:enumerator:`LV_EVENT_DELETE`: Object is being deleted
|
||||
- :cpp:enumerator:`LV_EVENT_CHILD_CHANGED`: Child was removed/added
|
||||
- :cpp:enumerator:`LV_EVENT_CHILD_CREATED`: Child was created, always bubbles up to all parents
|
||||
- :cpp:enumerator:`LV_EVENT_CHILD_DELETED`: Child was deleted, always bubbles up to all parents
|
||||
- :cpp:enumerator:`LV_EVENT_SIZE_CHANGED`: Object coordinates/size have changed
|
||||
- :cpp:enumerator:`LV_EVENT_STYLE_CHANGED`: Object's style has changed
|
||||
- :cpp:enumerator:`LV_EVENT_BASE_DIR_CHANGED`: The base dir has changed
|
||||
- :cpp:enumerator:`LV_EVENT_GET_SELF_SIZE`: Get the internal size of a widget
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_UNLOAD_START`: A screen unload started, fired immediately when lv_screen_load/lv_screen_load_anim is called
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_LOAD_START`: A screen load started, fired when the screen change delay is expired
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_LOADED`: A screen was loaded, called when all animations are finished
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_UNLOADED`: A screen was unloaded, called when all animations are finished
|
||||
- :cpp:enumerator:`LV_EVENT_DRAW_TASK_ADDED`: Adding a draw task
|
||||
|
||||
Special events
|
||||
--------------
|
||||
|
||||
- :cpp:enumerator:`LV_EVENT_VALUE_CHANGED`: The object's value has changed (i.e. slider moved)
|
||||
- :cpp:enumerator:`LV_EVENT_INSERT`: Text is being inserted into the object. The event data is ``char *`` being inserted.
|
||||
- :cpp:enumerator:`LV_EVENT_INSERT`: A text is inserted to the object. The event data is `char *` being inserted.
|
||||
- :cpp:enumerator:`LV_EVENT_REFRESH`: Notify the object to refresh something on it (for the user)
|
||||
- :cpp:enumerator:`LV_EVENT_READY`: A process has finished
|
||||
- :cpp:enumerator:`LV_EVENT_CANCEL`: A process has been canceled
|
||||
- :cpp:enumerator:`LV_EVENT_CANCEL`: A process has been cancelled
|
||||
|
||||
Other events
|
||||
------------
|
||||
|
||||
- :cpp:enumerator:`LV_EVENT_CREATE`: Object is being created
|
||||
- :cpp:enumerator:`LV_EVENT_DELETE`: Object is being deleted
|
||||
- :cpp:enumerator:`LV_EVENT_CHILD_CHANGED`: Child was removed, added, or its size, position were changed
|
||||
- :cpp:enumerator:`LV_EVENT_CHILD_CREATED`: Child was created, always bubbles up to all parents
|
||||
- :cpp:enumerator:`LV_EVENT_CHILD_DELETED`: Child was deleted, always bubbles up to all parents
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_UNLOAD_START`: A screen unload started, fired immediately when scr_load is called
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_LOAD_START`: A screen load started, fired when the screen change delay is expired
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_LOADED`: A screen was loaded
|
||||
- :cpp:enumerator:`LV_EVENT_SCREEN_UNLOADED`: A screen was unloaded
|
||||
- :cpp:enumerator:`LV_EVENT_SIZE_CHANGED`: Object coordinates/size have changed
|
||||
- :cpp:enumerator:`LV_EVENT_STYLE_CHANGED`: Object's style has changed
|
||||
- :cpp:enumerator:`LV_EVENT_LAYOUT_CHANGED`: The children position has changed due to a layout recalculation
|
||||
- :cpp:enumerator:`LV_EVENT_GET_SELF_SIZE`: Get the internal size of a widget
|
||||
|
||||
Display events
|
||||
--------------
|
||||
|
||||
- :cpp:enumerator:`LV_EVENT_INVALIDATE_AREA,
|
||||
- :cpp:enumerator:`LV_EVENT_RESOLUTION_CHANGED,
|
||||
- :cpp:enumerator:`LV_EVENT_REFR_REQUEST,
|
||||
- :cpp:enumerator:`LV_EVENT_REFR_START,
|
||||
- :cpp:enumerator:`LV_EVENT_REFR_READY,
|
||||
- :cpp:enumerator:`LV_EVENT_RENDER_START,
|
||||
- :cpp:enumerator:`LV_EVENT_RENDER_READY,
|
||||
- :cpp:enumerator:`LV_EVENT_FLUSH_START,
|
||||
- :cpp:enumerator:`LV_EVENT_FLUSH_FINISH,
|
||||
|
||||
|
||||
Custom events
|
||||
-------------
|
||||
@@ -159,7 +191,7 @@ Sending events
|
||||
**************
|
||||
|
||||
To manually send events to an object, use
|
||||
:cpp:expr:`lv_event_send` ``(obj, <EVENT_CODE> &some_data)``.
|
||||
:cpp:expr:`lv_obj_send_event(obj, <EVENT_CODE>, &some_data)`.
|
||||
|
||||
For example, this can be used to manually close a message box by
|
||||
simulating a button press (although there are simpler ways to do this):
|
||||
@@ -170,6 +202,10 @@ simulating a button press (although there are simpler ways to do this):
|
||||
uint32_t btn_id = 0;
|
||||
lv_event_send(mbox, LV_EVENT_VALUE_CHANGED, &btn_id);
|
||||
|
||||
The same works for display and input devices with
|
||||
:cpp:expr:`lv_display_send_event(obj, <EVENT_CODE>, &some_data)` and
|
||||
:cpp:expr:`lv_indev_send_event(obj, <EVENT_CODE>, &some_data)`.
|
||||
|
||||
Refresh event
|
||||
-------------
|
||||
|
||||
|
||||
@@ -63,6 +63,11 @@ however, shared among multiple physical displays.** The ``layer_top`` is
|
||||
always on top of the default screen (:cpp:func:`lv_screen_active`), and
|
||||
``layer_sys`` is on top of ``layer_top``.
|
||||
|
||||
The get these layers use :cpp:func:`lv_layer_top()` and :cpp:func:`lv_layer_sys()`.
|
||||
|
||||
These layers work like any other widget, meaning the can be styles, scrolled,
|
||||
and any kind of widgets can be created on them.
|
||||
|
||||
The ``layer_top`` can be used by the user to create some content visible
|
||||
everywhere. For example, a menu bar, a pop-up, etc. If the ``click``
|
||||
attribute is enabled, then ``layer_top`` will absorb all user clicks and
|
||||
@@ -76,5 +81,15 @@ The ``layer_sys`` is also used for similar purposes in LVGL. For
|
||||
example, it places the mouse cursor above all layers to be sure it's
|
||||
always visible.
|
||||
|
||||
|
||||
Bottom layers
|
||||
*************
|
||||
|
||||
Similarly top and sys. layer bottom layer is also screen size but
|
||||
it's located below the active screen. It's visible only if the active screen's
|
||||
background opacity is < 255.
|
||||
|
||||
The get the bottom layer use :cpp:func:`lv_layer_bottom()`.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
@@ -146,30 +146,6 @@ property. The parents will use their own state to determine the value.
|
||||
So if a button is pressed, and the text color comes from here, the
|
||||
pressed text color will be used.
|
||||
|
||||
Forced value inheritance/default value
|
||||
**************************************
|
||||
|
||||
Sometimes you may want to force a child object to use the parent's value
|
||||
for a given style property. To do this you can use one of the following
|
||||
(depending on what type of style you're using):
|
||||
|
||||
.. code:: c
|
||||
|
||||
/* regular style */
|
||||
lv_style_set_prop_meta(&style, LV_STYLE_TEXT_COLOR, LV_STYLE_PROP_META_INHERIT);
|
||||
/* local style */
|
||||
lv_obj_set_local_style_prop_meta(child, LV_STYLE_TEXT_COLOR, LV_STYLE_PROP_META_INHERIT, LV_PART_MAIN);
|
||||
|
||||
This acts like a value has been set on the style, so setting the value
|
||||
of the property afterwards will remove the flag.
|
||||
|
||||
You may also want to force the default value of a property to be used,
|
||||
without needing to hardcode it in your application. To do this you can
|
||||
use the same API but with :cpp:enumerator:`LV_STYLE_PROP_META_INITIAL` instead. In
|
||||
future versions of LVGL, this will use the value based upon the current
|
||||
theme, but for now it just selects the internal default regardless of
|
||||
theme.
|
||||
|
||||
Parts
|
||||
*****
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ Image sources
|
||||
-------------
|
||||
|
||||
To set the image in a state, use the
|
||||
:cpp:expr:`lv_animimg_set_src(imgbtn, dsc[], num)`.
|
||||
:cpp:expr:`lv_animimg_set_src(imagebutton, dsc[], num)`.
|
||||
|
||||
Events
|
||||
******
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Image button (lv_imgbtn)
|
||||
Image button (lv_imagebutton)
|
||||
========================
|
||||
|
||||
Overview
|
||||
@@ -25,29 +25,29 @@ Image sources
|
||||
-------------
|
||||
|
||||
To set the image in a state, use the
|
||||
:cpp:expr:`lv_imgbtn_set_src(imgbtn, LV_IMGBTN_STATE_..., src_left, src_center, src_right)`.
|
||||
:cpp:expr:`lv_imagebutton_set_src(imagebutton, LV_IMAGEBUTTON_STATE_..., src_left, src_center, src_right)`.
|
||||
|
||||
The image sources work the same as described in the `Image object </widgets/img>`__
|
||||
except that "Symbols" are not supported by the Image button. Any of the sources can ``NULL``.
|
||||
|
||||
The possible states are:
|
||||
|
||||
- :cpp:enumerator:`LV_IMGBTN_STATE_RELEASED`
|
||||
- :cpp:enumerator:`LV_IMGBTN_STATE_PRESSED`
|
||||
- :cpp:enumerator:`LV_IMGBTN_STATE_DISABLED`
|
||||
- :cpp:enumerator:`LV_IMGBTN_STATE_CHECKED_RELEASED`
|
||||
- :cpp:enumerator:`LV_IMGBTN_STATE_CHECKED_PRESSED`
|
||||
- :cpp:enumerator:`LV_IMGBTN_STATE_CHECKED_DISABLED`
|
||||
- :cpp:enumerator:`LV_IMAGEBUTTON_STATE_RELEASED`
|
||||
- :cpp:enumerator:`LV_IMAGEBUTTON_STATE_PRESSED`
|
||||
- :cpp:enumerator:`LV_IMAGEBUTTON_STATE_DISABLED`
|
||||
- :cpp:enumerator:`LV_IMAGEBUTTON_STATE_CHECKED_RELEASED`
|
||||
- :cpp:enumerator:`LV_IMAGEBUTTON_STATE_CHECKED_PRESSED`
|
||||
- :cpp:enumerator:`LV_IMAGEBUTTON_STATE_CHECKED_DISABLED`
|
||||
|
||||
If you set sources only in :cpp:enumerator:`LV_IMGBTN_STATE_RELEASED`, these sources
|
||||
will be used in other states too. If you set e.g. :cpp:enumerator:`LV_IMGBTN_STATE_PRESSED`
|
||||
If you set sources only in :cpp:enumerator:`LV_IMAGEBUTTON_STATE_RELEASED`, these sources
|
||||
will be used in other states too. If you set e.g. :cpp:enumerator:`LV_IMAGEBUTTON_STATE_PRESSED`
|
||||
they will be used in pressed state instead of the released images.
|
||||
|
||||
States
|
||||
------
|
||||
|
||||
Instead of the regular ``lv_obj_add/remove_state()`` functions the
|
||||
:cpp:expr:`lv_imgbtn_set_state(imgbtn, LV_IMGBTN_STATE_...)` functions should be
|
||||
:cpp:expr:`lv_imagebutton_set_state(imagebutton, LV_IMAGEBUTTON_STATE_...)` functions should be
|
||||
used to manually set a state.
|
||||
|
||||
Events
|
||||
@@ -71,7 +71,7 @@ Learn more about :ref:`indev_keys`.
|
||||
Example
|
||||
*******
|
||||
|
||||
.. include:: ../examples/widgets/imgbtn/index.rst
|
||||
.. include:: ../examples/widgets/imgagebutton/index.rst
|
||||
|
||||
API
|
||||
***
|
||||
@@ -20,7 +20,7 @@ Widgets
|
||||
checkbox
|
||||
dropdown
|
||||
image
|
||||
imgbtn
|
||||
imagebutton
|
||||
keyboard
|
||||
label
|
||||
led
|
||||
|
||||
@@ -48,10 +48,10 @@ the last (or most recent) child.
|
||||
Child Count
|
||||
-----------
|
||||
|
||||
Use the function :cpp:expr:`lv_spangroup_get_child_count(spangroup)` to get back
|
||||
Use the function :cpp:expr:`lv_spangroup_get_span_count(spangroup)` to get back
|
||||
the number of spans the group is maintaining.
|
||||
|
||||
e.g. ``uint32_t size = lv_spangroup_get_child_count(spangroup)``
|
||||
e.g. ``uint32_t size = lv_spangroup_get_span_count(spangroup)``
|
||||
|
||||
Text align
|
||||
----------
|
||||
|
||||
@@ -413,9 +413,9 @@
|
||||
|
||||
#define LV_USE_BAR 1
|
||||
|
||||
#define LV_USE_BTN 1
|
||||
#define LV_USE_BUTTON 1
|
||||
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
#define LV_USE_BUTTONMATRIX 1
|
||||
|
||||
#define LV_USE_CALENDAR 1
|
||||
#if LV_USE_CALENDAR
|
||||
@@ -439,9 +439,9 @@
|
||||
|
||||
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMG 1 /*Requires: lv_label*/
|
||||
#define LV_USE_IMAGE 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMGBTN 1
|
||||
#define LV_USE_IMAGEBUTTON 1
|
||||
|
||||
#define LV_USE_KEYBOARD 1
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_SLIDER && LV_USE_CHART && LV_USE_BTN && LV_USE_GRID
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_SLIDER && LV_USE_CHART && LV_USE_BUTTON && LV_USE_GRID
|
||||
|
||||
/**
|
||||
* the example show the use of cubic-bezier3 in animation.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define LV_ATTRIBUTE_IMAGE_IMGBTN_LEFT
|
||||
#endif
|
||||
|
||||
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_LEFT uint8_t imgbtn_left_map[] = {
|
||||
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_LEFT uint8_t imagebutton_left_map[] = {
|
||||
/*Pixel format: Blue: 8 bit, Green: 8 bit, Red: 8 bit, Alpha: 8 bit*/
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x61, 0x03, 0x00, 0x38, 0x5f, 0x14, 0x00, 0x38, 0x5f, 0x23,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x40, 0x00, 0x37, 0x5e, 0xb0, 0x00, 0x30, 0x58, 0xe0, 0x00, 0x2c, 0x55, 0xff,
|
||||
@@ -64,11 +64,11 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
const lv_image_dsc_t imgbtn_left = {
|
||||
const lv_image_dsc_t imagebutton_left = {
|
||||
.header.w = 8,
|
||||
.header.h = 50,
|
||||
.header.cf = LV_COLOR_FORMAT_ARGB8888,
|
||||
.data = imgbtn_left_map,
|
||||
.data = imagebutton_left_map,
|
||||
};
|
||||
|
||||
#endif /* LV_BUILD_EXAMPLES */
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define LV_ATTRIBUTE_IMAGE_IMGBTN_MID
|
||||
#endif
|
||||
|
||||
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_MID uint8_t imgbtn_mid_map[] = {
|
||||
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_MID uint8_t imagebutton_mid_map[] = {
|
||||
/*Pixel format: Blue: 8 bit, Green: 8 bit, Red: 8 bit, Alpha: 8 bit*/
|
||||
0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27, 0x00, 0x38, 0x5f, 0x27,
|
||||
0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff, 0x00, 0x2a, 0x54, 0xff,
|
||||
@@ -63,11 +63,11 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_
|
||||
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04,
|
||||
};
|
||||
|
||||
const lv_image_dsc_t imgbtn_mid = {
|
||||
const lv_image_dsc_t imagebutton_mid = {
|
||||
.header.w = 5,
|
||||
.header.h = 49,
|
||||
.header.cf = LV_COLOR_FORMAT_ARGB8888,
|
||||
.data = imgbtn_mid_map,
|
||||
.data = imagebutton_mid_map,
|
||||
};
|
||||
|
||||
#endif /* LV_BUILD_EXAMPLES */
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
#define LV_ATTRIBUTE_IMAGE_IMGBTN_RIGHT
|
||||
#endif
|
||||
|
||||
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_RIGHT uint8_t imgbtn_right_map[] = {
|
||||
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_RIGHT uint8_t imagebutton_right_map[] =
|
||||
{
|
||||
/*Pixel format: Blue: 8 bit, Green: 8 bit, Red: 8 bit, Alpha: 8 bit*/
|
||||
0x00, 0x38, 0x5f, 0x23, 0x00, 0x38, 0x5f, 0x14, 0x00, 0x38, 0x5f, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x2c, 0x55, 0xff, 0x00, 0x2f, 0x58, 0xdf, 0x00, 0x37, 0x5e, 0xb0, 0x00, 0x38, 0x5f, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@@ -64,11 +65,11 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMAGE_IMGBTN_
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
const lv_image_dsc_t imgbtn_right = {
|
||||
const lv_image_dsc_t imagebutton_right = {
|
||||
.header.w = 8,
|
||||
.header.h = 50,
|
||||
.header.cf = LV_COLOR_FORMAT_ARGB8888,
|
||||
.data = imgbtn_right_map,
|
||||
.data = imagebutton_right_map,
|
||||
};
|
||||
|
||||
#endif /* LV_BUILD_EXAMPLES */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BTN
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BUTTON
|
||||
|
||||
static void btn_event_cb(lv_event_t * e)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_USE_BTN && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_BUTTON && LV_BUILD_EXAMPLES
|
||||
|
||||
static lv_style_t style_btn;
|
||||
static lv_style_t style_button_pressed;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_LODEPNG && LV_USE_IMG && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_LODEPNG && LV_USE_IMAGE && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* Open a PNG image from a file and a variable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_OBSERVER && LV_USE_ARC && LV_USE_LABEL && LV_USE_BTN && LV_USE_SPINNER && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_OBSERVER && LV_USE_ARC && LV_USE_LABEL && LV_USE_BUTTON && LV_USE_SPINNER && LV_BUILD_EXAMPLES
|
||||
|
||||
typedef enum {
|
||||
FW_UPDATE_STATE_IDLE,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMG
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
/**
|
||||
* Using the Size, Position and Padding style properties
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMG
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
/**
|
||||
* Creating a transition
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMG
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
/**
|
||||
* Using multiple styles
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMG
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
/**
|
||||
* Local styles
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMG
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
/**
|
||||
* Add styles to parts and states
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMG
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
static lv_style_t style_btn;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BTN && LV_USE_LABEL
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BUTTON && LV_USE_LABEL
|
||||
|
||||
/**
|
||||
* Opacity and Transformations
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMG
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_IMAGE
|
||||
|
||||
/**
|
||||
* Using the Image style properties
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTN && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_BUTTON && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTN && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_BUTTON && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* Style a button from scratch
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BTN
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BUTTON
|
||||
|
||||
/**
|
||||
* Create a style transition on a button to act like a gum when clicked
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_BUTTONMATRIX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_BUTTONMATRIX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_BTNMATRIX && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_BUTTONMATRIX && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_IMG && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_IMAGE && LV_BUILD_EXAMPLES
|
||||
|
||||
void lv_example_image_1(void)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_IMG && LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_IMAGE && LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
|
||||
static lv_obj_t * create_slider(lv_color_t color);
|
||||
static void slider_event_cb(lv_event_t * e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_IMG && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_IMAGE && LV_BUILD_EXAMPLES
|
||||
|
||||
static void set_angle(void * img, int32_t v)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_IMG && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_IMAGE && LV_BUILD_EXAMPLES
|
||||
|
||||
static void ofs_y_anim(void * img, int32_t v)
|
||||
{
|
||||
|
||||
7
examples/widgets/imagebutton/index.rst
Normal file
7
examples/widgets/imagebutton/index.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
Simple Image button
|
||||
-------------------
|
||||
|
||||
.. lv_example:: widgets/imagebutton/lv_example_imagebutton_1
|
||||
:language: c
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_IMGBTN && LV_BUILD_EXAMPLES
|
||||
#if LV_USE_IMAGEBUTTON && LV_BUILD_EXAMPLES
|
||||
|
||||
void lv_example_imgbtn_1(void)
|
||||
void lv_example_imagebutton_1(void)
|
||||
{
|
||||
LV_IMAGE_DECLARE(imgbtn_left);
|
||||
LV_IMAGE_DECLARE(imgbtn_right);
|
||||
LV_IMAGE_DECLARE(imgbtn_mid);
|
||||
LV_IMAGE_DECLARE(imagebutton_left);
|
||||
LV_IMAGE_DECLARE(imagebutton_right);
|
||||
LV_IMAGE_DECLARE(imagebutton_mid);
|
||||
|
||||
/*Create a transition animation on width transformation and recolor.*/
|
||||
static lv_style_prop_t tr_prop[] = {LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_IMAGE_RECOLOR_OPA, 0};
|
||||
@@ -25,15 +25,16 @@ void lv_example_imgbtn_1(void)
|
||||
lv_style_set_transform_width(&style_pr, 20);
|
||||
|
||||
/*Create an image button*/
|
||||
lv_obj_t * imgbtn1 = lv_imgbtn_create(lv_screen_active());
|
||||
lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, &imgbtn_left, &imgbtn_mid, &imgbtn_right);
|
||||
lv_obj_add_style(imgbtn1, &style_def, 0);
|
||||
lv_obj_add_style(imgbtn1, &style_pr, LV_STATE_PRESSED);
|
||||
lv_obj_t * imagebutton1 = lv_imagebutton_create(lv_screen_active());
|
||||
lv_imagebutton_set_src(imagebutton1, LV_IMAGEBUTTON_STATE_RELEASED, &imagebutton_left, &imagebutton_mid,
|
||||
&imagebutton_right);
|
||||
lv_obj_add_style(imagebutton1, &style_def, 0);
|
||||
lv_obj_add_style(imagebutton1, &style_pr, LV_STATE_PRESSED);
|
||||
|
||||
lv_obj_align(imgbtn1, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_align(imagebutton1, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Create a label on the image button*/
|
||||
lv_obj_t * label = lv_label_create(imgbtn1);
|
||||
lv_obj_t * label = lv_label_create(imagebutton1);
|
||||
lv_label_set_text(label, "Button");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, -4);
|
||||
}
|
||||
@@ -1,38 +1,38 @@
|
||||
# Create an image from the png file
|
||||
try:
|
||||
with open('../../assets/imgbtn_left.png','rb') as f:
|
||||
imgbtn_left_data = f.read()
|
||||
imagebutton_left_data = f.read()
|
||||
except:
|
||||
print("Could not find imgbtn_left.png")
|
||||
print("Could not find imagebutton_left.png")
|
||||
sys.exit()
|
||||
|
||||
imgbtn_left_dsc = lv.image_dsc_t({
|
||||
'data_size': len(imgbtn_left_data),
|
||||
'data': imgbtn_left_data
|
||||
imagebutton_left_dsc = lv.image_dsc_t({
|
||||
'data_size': len(imagebutton_left_data),
|
||||
'data': imagebutton_left_data
|
||||
})
|
||||
|
||||
try:
|
||||
with open('../../assets/imgbtn_mid.png','rb') as f:
|
||||
imgbtn_mid_data = f.read()
|
||||
imagebutton_mid_data = f.read()
|
||||
except:
|
||||
print("Could not find imgbtn_mid.png")
|
||||
print("Could not find imagebutton_mid.png")
|
||||
sys.exit()
|
||||
|
||||
imgbtn_mid_dsc = lv.image_dsc_t({
|
||||
'data_size': len(imgbtn_mid_data),
|
||||
'data': imgbtn_mid_data
|
||||
imagebutton_mid_dsc = lv.image_dsc_t({
|
||||
'data_size': len(imagebutton_mid_data),
|
||||
'data': imagebutton_mid_data
|
||||
})
|
||||
|
||||
try:
|
||||
with open('../../assets/imgbtn_right.png','rb') as f:
|
||||
imgbtn_right_data = f.read()
|
||||
imagebutton_right_data = f.read()
|
||||
except:
|
||||
print("Could not find imgtn_right.png")
|
||||
sys.exit()
|
||||
|
||||
imgbtn_right_dsc = lv.image_dsc_t({
|
||||
'data_size': len(imgbtn_right_data),
|
||||
'data': imgbtn_right_data
|
||||
imagebutton_right_dsc = lv.image_dsc_t({
|
||||
'data_size': len(imagebutton_right_data),
|
||||
'data': imagebutton_right_data
|
||||
})
|
||||
|
||||
# Create a transition animation on width transformation and recolor.
|
||||
@@ -53,15 +53,15 @@ style_pr.set_image_recolor(lv.color_black())
|
||||
style_pr.set_transform_width(20)
|
||||
|
||||
# Create an image button
|
||||
imgbtn1 = lv.imgbtn(lv.screen_active())
|
||||
imgbtn1.set_src(lv.imgbtn.STATE.RELEASED, imgbtn_left_dsc, imgbtn_mid_dsc, imgbtn_right_dsc)
|
||||
imgbtn1.add_style(style_def, 0)
|
||||
imgbtn1.add_style(style_pr, lv.STATE.PRESSED)
|
||||
imagebutton1 = lv.imagebutton(lv.screen_active())
|
||||
imagebutton1.set_src(lv.imagebutton.STATE.RELEASED, imagebutton_left_dsc, imagebutton_mid_dsc, imagebutton_right_dsc)
|
||||
imagebutton1.add_style(style_def, 0)
|
||||
imagebutton1.add_style(style_pr, lv.STATE.PRESSED)
|
||||
|
||||
imgbtn1.align(lv.ALIGN.CENTER, 0, 0)
|
||||
imagebutton1.align(lv.ALIGN.CENTER, 0, 0)
|
||||
|
||||
# Create a label on the image button
|
||||
label = lv.label(imgbtn1)
|
||||
label = lv.label(imagebutton1)
|
||||
label.set_text("Button")
|
||||
label.align(lv.ALIGN.CENTER, 0, -4)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
Simple Image button
|
||||
-------------------
|
||||
|
||||
.. lv_example:: widgets/imgbtn/lv_example_imgbtn_1
|
||||
:language: c
|
||||
|
||||
@@ -78,7 +78,7 @@ void lv_example_image_2(void);
|
||||
void lv_example_image_3(void);
|
||||
void lv_example_image_4(void);
|
||||
|
||||
void lv_example_imgbtn_1(void);
|
||||
void lv_example_imagebutton_1(void);
|
||||
|
||||
void lv_example_keyboard_1(void);
|
||||
void lv_example_keyboard_2(void);
|
||||
|
||||
@@ -40,7 +40,8 @@ void lv_example_scale_3(void)
|
||||
lv_scale_set_minor_tick_length(scale_line, 5);
|
||||
lv_scale_set_range(scale_line, 10, 40);
|
||||
|
||||
lv_scale_set_round_props(scale_line, 270, 135);
|
||||
lv_scale_set_angle_range(scale_line, 270);
|
||||
lv_scale_set_rotation(scale_line, 135);
|
||||
|
||||
needle_line = lv_line_create(scale_line);
|
||||
|
||||
@@ -76,7 +77,8 @@ void lv_example_scale_3(void)
|
||||
lv_scale_set_minor_tick_length(scale_img, 5);
|
||||
lv_scale_set_range(scale_img, 10, 40);
|
||||
|
||||
lv_scale_set_round_props(scale_img, 270, 135);
|
||||
lv_scale_set_angle_range(scale_img, 270);
|
||||
lv_scale_set_rotation(scale_img, 135);
|
||||
|
||||
/* image must point to the right. E.g. -O------>*/
|
||||
needle_img = lv_img_create(scale_img);
|
||||
|
||||
@@ -439,9 +439,9 @@
|
||||
|
||||
#define LV_USE_BAR 1
|
||||
|
||||
#define LV_USE_BTN 1
|
||||
#define LV_USE_BUTTON 1
|
||||
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
#define LV_USE_BUTTONMATRIX 1
|
||||
|
||||
#define LV_USE_CALENDAR 1
|
||||
#if LV_USE_CALENDAR
|
||||
@@ -465,9 +465,9 @@
|
||||
|
||||
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMG 1 /*Requires: lv_label*/
|
||||
#define LV_USE_IMAGE 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMGBTN 1
|
||||
#define LV_USE_IMAGEBUTTON 1
|
||||
|
||||
#define LV_USE_KEYBOARD 1
|
||||
|
||||
|
||||
2
lvgl.h
2
lvgl.h
@@ -61,7 +61,7 @@ extern "C" {
|
||||
#include "src/widgets/checkbox/lv_checkbox.h"
|
||||
#include "src/widgets/dropdown/lv_dropdown.h"
|
||||
#include "src/widgets/image/lv_image.h"
|
||||
#include "src/widgets/imgbtn/lv_imgbtn.h"
|
||||
#include "src/widgets/imagebutton/lv_imagebutton.h"
|
||||
#include "src/widgets/keyboard/lv_keyboard.h"
|
||||
#include "src/widgets/label/lv_label.h"
|
||||
#include "src/widgets/led/lv_led.h"
|
||||
|
||||
@@ -248,12 +248,6 @@ void lv_obj_redraw(lv_layer_t * layer, lv_obj_t * obj)
|
||||
layer->_clip_area = clip_area_ori;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate an area on display to redraw it
|
||||
* @param disp pointer to display where the area should be invalidated (NULL can be used if there is
|
||||
* @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
|
||||
* only one display)
|
||||
*/
|
||||
void _lv_inv_area(lv_display_t * disp, const lv_area_t * area_p)
|
||||
{
|
||||
if(!disp) disp = lv_display_get_default();
|
||||
@@ -327,10 +321,6 @@ void _lv_refr_set_disp_refreshing(lv_display_t * disp)
|
||||
disp_refr = disp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called periodically to handle the refreshing
|
||||
* @param tmr pointer to the timer itself
|
||||
*/
|
||||
void _lv_display_refr_timer(lv_timer_t * tmr)
|
||||
{
|
||||
LV_PROFILER_BEGIN;
|
||||
|
||||
@@ -179,12 +179,6 @@ void * lv_draw_buf_goto_xy(lv_draw_buf_t * buf, uint32_t x, uint32_t y)
|
||||
return data + x * lv_color_format_get_size(buf->header.cf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert draw buffer stride and color format.
|
||||
* @param src source draw buffer
|
||||
* @param stride new stride
|
||||
* @return converted draw buffer
|
||||
*/
|
||||
lv_draw_buf_t * lv_draw_buf_adjust_stride(const lv_draw_buf_t * src, uint32_t stride)
|
||||
{
|
||||
LV_ASSERT_NULL(src);
|
||||
|
||||
@@ -91,14 +91,6 @@ void lv_draw_image(lv_layer_t * layer, const lv_draw_image_dsc_t * dsc, const lv
|
||||
LV_PROFILER_END;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of an image source
|
||||
* @param src pointer to an image source:
|
||||
* - pointer to an 'lv_image_t' variable (image stored internally and compiled into the code)
|
||||
* - a path to a file (e.g. "S:/folder/image.bin")
|
||||
* - or a symbol (e.g. LV_SYMBOL_CLOSE)
|
||||
* @return type of the image source LV_IMAGE_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN
|
||||
*/
|
||||
lv_image_src_t lv_image_src_get_type(const void * src)
|
||||
{
|
||||
lv_image_src_t img_src_type = LV_IMAGE_SRC_UNKNOWN;
|
||||
|
||||
@@ -56,13 +56,6 @@ void _lv_image_decoder_deinit(void)
|
||||
_lv_ll_clear(img_decoder_ll_p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about an image.
|
||||
* Try the created image decoder one by one. Once one is able to get info that info will be used.
|
||||
* @param src the image source. E.g. file name or variable.
|
||||
* @param header the image info will be stored here
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: wasn't able to get info about the image
|
||||
*/
|
||||
lv_result_t lv_image_decoder_get_info(const void * src, lv_image_header_t * header)
|
||||
{
|
||||
lv_memzero(header, sizeof(lv_image_header_t));
|
||||
@@ -168,14 +161,6 @@ lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode an area of image
|
||||
* @param decoder pointer to the decoder where this function belongs
|
||||
* @param dsc pointer to `lv_image_decoder_dsc_t` used in `lv_image_decoder_open`
|
||||
* @param full_area full image area information
|
||||
* @param decoded_area area information to decode (x1, y1, x2, y2)
|
||||
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't decode image area
|
||||
*/
|
||||
lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_area_t * full_area,
|
||||
lv_area_t * decoded_area)
|
||||
{
|
||||
@@ -185,10 +170,6 @@ lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_are
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a decoding session
|
||||
* @param dsc pointer to `lv_image_decoder_dsc_t` used in `lv_image_decoder_open`
|
||||
*/
|
||||
void lv_image_decoder_close(lv_image_decoder_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->decoder) {
|
||||
@@ -218,21 +199,12 @@ lv_image_decoder_t * lv_image_decoder_create(void)
|
||||
return decoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an image decoder
|
||||
* @param decoder pointer to an image decoder
|
||||
*/
|
||||
void lv_image_decoder_delete(lv_image_decoder_t * decoder)
|
||||
{
|
||||
_lv_ll_remove(img_decoder_ll_p, decoder);
|
||||
lv_free(decoder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next image decoder in the linked list of image decoders
|
||||
* @param decoder pointer to an image decoder
|
||||
* @return the next image decoder or NULL if no more image decoder exists
|
||||
*/
|
||||
lv_image_decoder_t * lv_image_decoder_get_next(lv_image_decoder_t * decoder)
|
||||
{
|
||||
if(decoder == NULL)
|
||||
@@ -241,41 +213,21 @@ lv_image_decoder_t * lv_image_decoder_get_next(lv_image_decoder_t * decoder)
|
||||
return _lv_ll_get_next(img_decoder_ll_p, decoder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to get information about the image
|
||||
* @param decoder pointer to an image decoder
|
||||
* @param info_cb a function to collect info about an image (fill an `lv_image_header_t` struct)
|
||||
*/
|
||||
void lv_image_decoder_set_info_cb(lv_image_decoder_t * decoder, lv_image_decoder_info_f_t info_cb)
|
||||
{
|
||||
decoder->info_cb = info_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to open an image
|
||||
* @param decoder pointer to an image decoder
|
||||
* @param open_cb a function to open an image
|
||||
*/
|
||||
void lv_image_decoder_set_open_cb(lv_image_decoder_t * decoder, lv_image_decoder_open_f_t open_cb)
|
||||
{
|
||||
decoder->open_cb = open_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to get decoded area of an image
|
||||
* @param decoder pointer to an image decoder
|
||||
* @param get_area_cb a function to get area of an image
|
||||
*/
|
||||
void lv_image_decoder_set_get_area_cb(lv_image_decoder_t * decoder, lv_image_decoder_get_area_cb_t get_area_cb)
|
||||
{
|
||||
decoder->get_area_cb = get_area_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to close a decoding session. E.g. close files and free other resources.
|
||||
* @param decoder pointer to an image decoder
|
||||
* @param close_cb a function to close a decoding session
|
||||
*/
|
||||
void lv_image_decoder_set_close_cb(lv_image_decoder_t * decoder, lv_image_decoder_close_f_t close_cb)
|
||||
{
|
||||
decoder->close_cb = close_cb;
|
||||
|
||||
@@ -42,13 +42,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(lv_draw_unit_t * draw_unit, cons
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
* @param point1 first point of the line
|
||||
* @param point2 second point of the line
|
||||
* @param clip the line will be drawn only in this area
|
||||
* @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_line(lv_draw_unit_t * draw_unit, const lv_draw_line_dsc_t * dsc)
|
||||
{
|
||||
if(dsc->width == 0) return;
|
||||
|
||||
@@ -106,13 +106,6 @@ LV_ATTRIBUTE_FAST_MEM lv_draw_sw_mask_res_t lv_draw_sw_mask_apply(void * masks[]
|
||||
return changed ? LV_DRAW_SW_MASK_RES_CHANGED : LV_DRAW_SW_MASK_RES_FULL_COVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the data from the parameter.
|
||||
* It's called inside `lv_draw_mask_remove_id` and `lv_draw_mask_remove_custom`
|
||||
* Needs to be called only in special cases when the mask is not added by `lv_draw_mask_add`
|
||||
* and not removed by `lv_draw_mask_remove_id` or `lv_draw_mask_remove_custom`
|
||||
* @param p pointer to a mask parameter
|
||||
*/
|
||||
void lv_draw_sw_mask_free_param(void * p)
|
||||
{
|
||||
lv_mutex_lock(&circle_cache_mutex);
|
||||
@@ -144,17 +137,6 @@ void _lv_draw_sw_mask_cleanup(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*Initialize a line mask from two points.
|
||||
* @param param pointer to a `lv_draw_mask_param_t` to initialize
|
||||
* @param p1x X coordinate of the first point of the line
|
||||
* @param p1y Y coordinate of the first point of the line
|
||||
* @param p2x X coordinate of the second point of the line
|
||||
* @param p2y y coordinate of the second point of the line
|
||||
* @param side and element of `lv_draw_mask_line_side_t` to describe which side to keep.
|
||||
* With `LV_DRAW_SW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
|
||||
* With `LV_DRAW_SW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
|
||||
*/
|
||||
void lv_draw_sw_mask_line_points_init(lv_draw_sw_mask_line_param_t * param, int32_t p1x, int32_t p1y,
|
||||
int32_t p2x,
|
||||
int32_t p2y, lv_draw_sw_mask_line_side_t side)
|
||||
@@ -237,16 +219,6 @@ void lv_draw_sw_mask_line_points_init(lv_draw_sw_mask_line_param_t * param, int3
|
||||
if(param->steep < 0) param->spx = -param->spx;
|
||||
}
|
||||
|
||||
/**
|
||||
*Initialize a line mask from a point and an angle.
|
||||
* @param param pointer to a `lv_draw_mask_param_t` to initialize
|
||||
* @param px X coordinate of a point of the line
|
||||
* @param py X coordinate of a point of the line
|
||||
* @param angle right 0 deg, bottom: 90
|
||||
* @param side and element of `lv_draw_mask_line_side_t` to describe which side to keep.
|
||||
* With `LV_DRAW_SW_MASK_LINE_SIDE_LEFT/RIGHT` and horizontal line all pixels are kept
|
||||
* With `LV_DRAW_SW_MASK_LINE_SIDE_TOP/BOTTOM` and vertical line all pixels are kept
|
||||
*/
|
||||
void lv_draw_sw_mask_line_angle_init(lv_draw_sw_mask_line_param_t * param, int32_t p1x, int32_t py, int16_t angle,
|
||||
lv_draw_sw_mask_line_side_t side)
|
||||
{
|
||||
@@ -265,14 +237,6 @@ void lv_draw_sw_mask_line_angle_init(lv_draw_sw_mask_line_param_t * param, int32
|
||||
lv_draw_sw_mask_line_points_init(param, p1x, py, p2x, p2y, side);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize an angle mask.
|
||||
* @param param pointer to a `lv_draw_mask_param_t` to initialize
|
||||
* @param vertex_x X coordinate of the angle vertex (absolute coordinates)
|
||||
* @param vertex_y Y coordinate of the angle vertex (absolute coordinates)
|
||||
* @param start_angle start angle in degrees. 0 deg on the right, 90 deg, on the bottom
|
||||
* @param end_angle end angle
|
||||
*/
|
||||
void lv_draw_sw_mask_angle_init(lv_draw_sw_mask_angle_param_t * param, int32_t vertex_x, int32_t vertex_y,
|
||||
int32_t start_angle, int32_t end_angle)
|
||||
{
|
||||
@@ -326,13 +290,6 @@ void lv_draw_sw_mask_angle_init(lv_draw_sw_mask_angle_param_t * param, int32_t v
|
||||
lv_draw_sw_mask_line_angle_init(¶m->end_line, vertex_x, vertex_y, end_angle, end_side);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a fade mask.
|
||||
* @param param pointer to an `lv_draw_mask_radius_param_t` to initialize
|
||||
* @param rect coordinates of the rectangle to affect (absolute coordinates)
|
||||
* @param radius radius of the rectangle
|
||||
* @param inv true: keep the pixels inside the rectangle; keep the pixels outside of the rectangle
|
||||
*/
|
||||
void lv_draw_sw_mask_radius_init(lv_draw_sw_mask_radius_param_t * param, const lv_area_t * rect, int32_t radius,
|
||||
bool inv)
|
||||
{
|
||||
@@ -396,15 +353,6 @@ void lv_draw_sw_mask_radius_init(lv_draw_sw_mask_radius_param_t * param, const l
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a fade mask.
|
||||
* @param param pointer to a `lv_draw_mask_param_t` to initialize
|
||||
* @param coords coordinates of the area to affect (absolute coordinates)
|
||||
* @param opa_top opacity on the top
|
||||
* @param y_top at which coordinate start to change to opacity to `opa_bottom`
|
||||
* @param opa_bottom opacity at the bottom
|
||||
* @param y_bottom at which coordinate reach `opa_bottom`.
|
||||
*/
|
||||
void lv_draw_sw_mask_fade_init(lv_draw_sw_mask_fade_param_t * param, const lv_area_t * coords, lv_opa_t opa_top,
|
||||
int32_t y_top,
|
||||
lv_opa_t opa_bottom, int32_t y_bottom)
|
||||
@@ -418,12 +366,6 @@ void lv_draw_sw_mask_fade_init(lv_draw_sw_mask_fade_param_t * param, const lv_ar
|
||||
param->dsc.type = LV_DRAW_SW_MASK_TYPE_FADE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a map mask.
|
||||
* @param param pointer to a `lv_draw_mask_param_t` to initialize
|
||||
* @param coords coordinates of the map (absolute coordinates)
|
||||
* @param map array of bytes with the mask values
|
||||
*/
|
||||
void lv_draw_sw_mask_map_init(lv_draw_sw_mask_map_param_t * param, const lv_area_t * coords, const lv_opa_t * map)
|
||||
{
|
||||
lv_area_copy(¶m->cfg.coords, coords);
|
||||
|
||||
@@ -160,15 +160,6 @@ const uint8_t * lv_font_get_bitmap_fmt_txt(const lv_font_t * font, uint32_t unic
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used as `get_glyph_dsc` callback in lvgl's native font format if the font is uncompressed.
|
||||
* @param font pointer to font
|
||||
* @param dsc_out store the result descriptor here
|
||||
* @param unicode_letter a UNICODE letter code
|
||||
* @param unicode_letter_next the unicode letter succeeding the letter under test
|
||||
* @return true: descriptor is successfully loaded into `dsc_out`.
|
||||
* false: the letter was not found, no data is loaded to `dsc_out`
|
||||
*/
|
||||
bool lv_font_get_glyph_dsc_fmt_txt(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter,
|
||||
uint32_t unicode_letter_next)
|
||||
{
|
||||
@@ -344,6 +335,7 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element)
|
||||
}
|
||||
|
||||
#if LV_USE_FONT_COMPRESSED
|
||||
|
||||
/**
|
||||
* The compress a glyph's bitmap
|
||||
* @param in the compressed bitmap
|
||||
|
||||
@@ -224,12 +224,6 @@ void _lv_indev_scroll_throw_handler(lv_indev_t * indev)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Predict where would a scroll throw end
|
||||
* @param indev pointer to an input device
|
||||
* @param dir `LV_DIR_VER` or `LV_DIR_HOR`
|
||||
* @return the difference compared to the current position when the throw would be finished
|
||||
*/
|
||||
int32_t lv_indev_scroll_throw_predict(lv_indev_t * indev, lv_dir_t dir)
|
||||
{
|
||||
if(indev == NULL) return 0;
|
||||
|
||||
@@ -133,7 +133,7 @@ lv_result_t lv_barcode_update(lv_obj_t * obj, const char * data)
|
||||
|
||||
for(int32_t x = 0; x < barcode_w; x++) {
|
||||
lv_color_t color;
|
||||
color = lv_color_from_int(out_buf[x] ? 0 : 1);
|
||||
color = lv_color_hex(out_buf[x] ? 0 : 1);
|
||||
for(uint16_t i = 0; i < scale; i++) {
|
||||
if(barcode->direction == LV_DIR_HOR) {
|
||||
lv_canvas_set_px(obj, x * scale + i, 0, color, LV_OPA_COVER);
|
||||
|
||||
@@ -98,13 +98,6 @@ void lv_bin_decoder_init(void)
|
||||
lv_image_decoder_set_close_cb(decoder, lv_bin_decoder_close);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info about a lvgl binary image
|
||||
* @param decoder the decoder where this function belongs
|
||||
* @param src the image source: pointer to an `lv_image_dsc_t` variable, a file path or a symbol
|
||||
* @param header store the image data here
|
||||
* @return LV_RESULT_OK: the info is successfully stored in `header`; LV_RESULT_INVALID: unknown format or other error.
|
||||
*/
|
||||
lv_result_t lv_bin_decoder_info(lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header)
|
||||
{
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
@@ -153,13 +146,6 @@ lv_result_t lv_bin_decoder_info(lv_image_decoder_t * decoder, const void * src,
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a lvgl binary image
|
||||
* @param decoder the decoder where this function belongs
|
||||
* @param dsc pointer to decoder descriptor. `src`, `color` are already initialized in it.
|
||||
* @param args arguments of how to decode the image.
|
||||
* @return LV_RESULT_OK: the info is successfully stored in `header`; LV_RESULT_INVALID: unknown format or other error.
|
||||
*/
|
||||
lv_result_t lv_bin_decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc,
|
||||
const lv_image_decoder_args_t * args)
|
||||
{
|
||||
@@ -330,11 +316,6 @@ lv_result_t lv_bin_decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the pending decoding. Free resources etc.
|
||||
* @param decoder pointer to the decoder the function associated with
|
||||
* @param dsc pointer to decoder descriptor
|
||||
*/
|
||||
void lv_bin_decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
||||
{
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
|
||||
@@ -46,11 +46,6 @@ const lv_obj_class_t lv_qrcode_class = {
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an empty QR code (an `lv_canvas`) object.
|
||||
* @param parent point to an object where to create the QR code
|
||||
* @return pointer to the created QR code object
|
||||
*/
|
||||
lv_obj_t * lv_qrcode_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin");
|
||||
@@ -108,7 +103,7 @@ lv_result_t lv_qrcode_update(lv_obj_t * obj, const void * data, uint32_t data_le
|
||||
|
||||
lv_canvas_set_palette(obj, 0, lv_color_to_32(qrcode->dark_color, 0xff));
|
||||
lv_canvas_set_palette(obj, 1, lv_color_to_32(qrcode->light_color, 0xff));
|
||||
lv_color_t c = lv_color_from_int(1);
|
||||
lv_color_t c = lv_color_hex(1);
|
||||
lv_canvas_fill_bg(obj, c, LV_OPA_COVER);
|
||||
|
||||
if(data_len > qrcodegen_BUFFER_LEN_MAX) return LV_RESULT_INVALID;
|
||||
@@ -169,7 +164,7 @@ lv_result_t lv_qrcode_update(lv_obj_t * obj, const void * data, uint32_t data_le
|
||||
if(aligned == false && (x & 0x7) == 0) aligned = true;
|
||||
|
||||
if(aligned == false) {
|
||||
c = lv_color_from_int(a ? 0 : 1);
|
||||
c = lv_color_hex(a ? 0 : 1);
|
||||
lv_canvas_set_px(obj, x, y, c, LV_OPA_COVER);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1317,27 +1317,27 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_USE_BTN
|
||||
#ifndef LV_USE_BUTTON
|
||||
#ifdef _LV_KCONFIG_PRESENT
|
||||
#ifdef CONFIG_LV_USE_BTN
|
||||
#define LV_USE_BTN CONFIG_LV_USE_BTN
|
||||
#ifdef CONFIG_LV_USE_BUTTON
|
||||
#define LV_USE_BUTTON CONFIG_LV_USE_BUTTON
|
||||
#else
|
||||
#define LV_USE_BTN 0
|
||||
#define LV_USE_BUTTON 0
|
||||
#endif
|
||||
#else
|
||||
#define LV_USE_BTN 1
|
||||
#define LV_USE_BUTTON 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_USE_BTNMATRIX
|
||||
#ifndef LV_USE_BUTTONMATRIX
|
||||
#ifdef _LV_KCONFIG_PRESENT
|
||||
#ifdef CONFIG_LV_USE_BTNMATRIX
|
||||
#define LV_USE_BTNMATRIX CONFIG_LV_USE_BTNMATRIX
|
||||
#ifdef CONFIG_LV_USE_BUTTONMATRIX
|
||||
#define LV_USE_BUTTONMATRIX CONFIG_LV_USE_BUTTONMATRIX
|
||||
#else
|
||||
#define LV_USE_BTNMATRIX 0
|
||||
#define LV_USE_BUTTONMATRIX 0
|
||||
#endif
|
||||
#else
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
#define LV_USE_BUTTONMATRIX 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1457,27 +1457,27 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_USE_IMG
|
||||
#ifndef LV_USE_IMAGE
|
||||
#ifdef _LV_KCONFIG_PRESENT
|
||||
#ifdef CONFIG_LV_USE_IMG
|
||||
#define LV_USE_IMG CONFIG_LV_USE_IMG
|
||||
#ifdef CONFIG_LV_USE_IMAGE
|
||||
#define LV_USE_IMAGE CONFIG_LV_USE_IMAGE
|
||||
#else
|
||||
#define LV_USE_IMG 0
|
||||
#define LV_USE_IMAGE 0
|
||||
#endif
|
||||
#else
|
||||
#define LV_USE_IMG 1 /*Requires: lv_label*/
|
||||
#define LV_USE_IMAGE 1 /*Requires: lv_label*/
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_USE_IMGBTN
|
||||
#ifndef LV_USE_IMAGEBUTTON
|
||||
#ifdef _LV_KCONFIG_PRESENT
|
||||
#ifdef CONFIG_LV_USE_IMGBTN
|
||||
#define LV_USE_IMGBTN CONFIG_LV_USE_IMGBTN
|
||||
#ifdef CONFIG_LV_USE_IMAGEBUTTON
|
||||
#define LV_USE_IMAGEBUTTON CONFIG_LV_USE_IMAGEBUTTON
|
||||
#else
|
||||
#define LV_USE_IMGBTN 0
|
||||
#define LV_USE_IMAGEBUTTON 0
|
||||
#endif
|
||||
#else
|
||||
#define LV_USE_IMGBTN 1
|
||||
#define LV_USE_IMAGEBUTTON 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -39,14 +39,6 @@ static bool lv_point_within_circle(const lv_area_t * area, const lv_point_t * p)
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an area
|
||||
* @param area_p pointer to an area
|
||||
* @param x1 left coordinate of the area
|
||||
* @param y1 top coordinate of the area
|
||||
* @param x2 right coordinate of the area
|
||||
* @param y2 bottom coordinate of the area
|
||||
*/
|
||||
void lv_area_set(lv_area_t * area_p, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
|
||||
{
|
||||
area_p->x1 = x1;
|
||||
@@ -55,32 +47,16 @@ void lv_area_set(lv_area_t * area_p, int32_t x1, int32_t y1, int32_t x2, int32_t
|
||||
area_p->y2 = y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void lv_area_set_width(lv_area_t * area_p, int32_t w)
|
||||
{
|
||||
area_p->x2 = area_p->x1 + w - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void lv_area_set_height(lv_area_t * area_p, int32_t h)
|
||||
{
|
||||
area_p->y2 = area_p->y1 + h - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void _lv_area_set_pos(lv_area_t * area_p, int32_t x, int32_t y)
|
||||
{
|
||||
int32_t w = lv_area_get_width(area_p);
|
||||
@@ -91,11 +67,6 @@ void _lv_area_set_pos(lv_area_t * area_p, int32_t x, int32_t y)
|
||||
lv_area_set_height(area_p, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with area of an area (x * y)
|
||||
* @param area_p pointer to an area
|
||||
* @return size of area
|
||||
*/
|
||||
uint32_t lv_area_get_size(const lv_area_t * area_p)
|
||||
{
|
||||
uint32_t size;
|
||||
@@ -121,13 +92,6 @@ void lv_area_move(lv_area_t * area, int32_t x_ofs, int32_t y_ofs)
|
||||
area->y2 += y_ofs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the common parts of two areas
|
||||
* @param res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return false: the two area has NO common parts, res_p is invalid
|
||||
*/
|
||||
bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
/*Get the smaller area from 'a1_p' and 'a2_p'*/
|
||||
@@ -145,13 +109,6 @@ bool _lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area
|
||||
return union_ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get resulting sub areas after removing the common parts of two areas from the first area
|
||||
* @param res_p pointer to an array of areas with a count of 4, the resulting areas will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return number of results or -1 if no intersect
|
||||
*/
|
||||
int8_t _lv_area_diff(lv_area_t res_p[], const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
/*Areas have no common parts*/
|
||||
@@ -217,12 +174,6 @@ int8_t _lv_area_diff(lv_area_t res_p[], const lv_area_t * a1_p, const lv_area_t
|
||||
return res_c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Join two areas into a third which involves the other two
|
||||
* @param res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
*/
|
||||
void _lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
a_res_p->x1 = LV_MIN(a1_p->x1, a2_p->x1);
|
||||
@@ -231,13 +182,6 @@ void _lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t
|
||||
a_res_p->y2 = LV_MAX(a1_p->y2, a2_p->y2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a point is on an area
|
||||
* @param a_p pointer to an area
|
||||
* @param p_p pointer to a point
|
||||
* @param radius radius of area (e.g. for rounded rectangle)
|
||||
* @return false:the point is out of the area
|
||||
*/
|
||||
bool _lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, int32_t radius)
|
||||
{
|
||||
/*First check the basic area*/
|
||||
@@ -298,12 +242,6 @@ bool _lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p, int32_t
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to an other area
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool _lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
{
|
||||
if((a1_p->x1 <= a2_p->x2) && (a1_p->x2 >= a2_p->x1) && (a1_p->y1 <= a2_p->y2) && (a1_p->y2 >= a2_p->y1)) {
|
||||
@@ -314,13 +252,6 @@ bool _lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an area is fully on an other
|
||||
* @param ain_p pointer to an area which could be in 'aholder_p'
|
||||
* @param aholder_p pointer to an area which could involve 'ain_p'
|
||||
* @param radius radius of `aholder_p` (e.g. for rounded rectangle)
|
||||
* @return true: `ain_p` is fully inside `aholder_p`
|
||||
*/
|
||||
bool _lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p, int32_t radius)
|
||||
{
|
||||
bool is_in = false;
|
||||
@@ -351,13 +282,6 @@ bool _lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p, int32_
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an area is fully out of an other
|
||||
* @param aout_p pointer to an area which could be in 'aholder_p'
|
||||
* @param aholder_p pointer to an area which could involve 'ain_p'
|
||||
* @param radius radius of `aholder_p` (e.g. for rounded rectangle)
|
||||
* @return true: `aout_p` is fully outside `aholder_p`
|
||||
*/
|
||||
bool _lv_area_is_out(const lv_area_t * aout_p, const lv_area_t * aholder_p, int32_t radius)
|
||||
{
|
||||
if(aout_p->x2 < aholder_p->x1 || aout_p->y2 < aholder_p->y1 || aout_p->x1 > aholder_p->x2 ||
|
||||
@@ -390,13 +314,6 @@ bool _lv_area_is_equal(const lv_area_t * a, const lv_area_t * b)
|
||||
return a->x1 == b->x1 && a->x2 == b->x2 && a->y1 == b->y1 && a->y2 == b->y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Align an area to an other
|
||||
* @param base an area where the other will be aligned
|
||||
* @param to_align the area to align
|
||||
* @param align `LV_ALIGN_...`
|
||||
* @param res x/y coordinates where `to_align` align area should be placed
|
||||
*/
|
||||
void lv_area_align(const lv_area_t * base, lv_area_t * to_align, lv_align_t align, int32_t ofs_x, int32_t ofs_y)
|
||||
{
|
||||
|
||||
|
||||
@@ -73,13 +73,6 @@ static const uint8_t bracket_right[] = {">)}]"};
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Convert a text to get the characters in the correct visual order according to
|
||||
* Unicode Bidirectional Algorithm
|
||||
* @param str_in the text to process
|
||||
* @param str_out store the result here. Has the be `strlen(str_in)` length
|
||||
* @param base_dir `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
|
||||
*/
|
||||
void _lv_bidi_process(const char * str_in, char * str_out, lv_base_dir_t base_dir)
|
||||
{
|
||||
if(base_dir == LV_BASE_DIR_AUTO) base_dir = _lv_bidi_detect_base_dir(str_in);
|
||||
@@ -128,18 +121,6 @@ lv_base_dir_t _lv_bidi_detect_base_dir(const char * txt)
|
||||
else return LV_BIDI_BASE_DIR_DEF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the logical position of a character in a line
|
||||
* @param str_in the input string. Can be only one line.
|
||||
* @param bidi_txt internally the text is bidi processed which buffer can be get here.
|
||||
* If not required anymore has to freed with `lv_free()`
|
||||
* Can be `NULL` is unused
|
||||
* @param len length of the line in character count
|
||||
* @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
|
||||
* @param visual_pos the visual character position which logical position should be get
|
||||
* @param is_rtl tell the char at `visual_pos` is RTL or LTR context
|
||||
* @return the logical character position
|
||||
*/
|
||||
uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_base_dir_t base_dir,
|
||||
uint32_t visual_pos, bool * is_rtl)
|
||||
{
|
||||
@@ -165,18 +146,6 @@ uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visual position of a character in a line
|
||||
* @param str_in the input string. Can be only one line.
|
||||
* @param bidi_txt internally the text is bidi processed which buffer can be get here.
|
||||
* If not required anymore has to freed with `lv_free()`
|
||||
* Can be `NULL` is unused
|
||||
* @param len length of the line in character count
|
||||
* @param base_dir base direction of the text: `LV_BASE_DIR_LTR` or `LV_BASE_DIR_RTL`
|
||||
* @param logical_pos the logical character position which visual position should be get
|
||||
* @param is_rtl tell the char at `logical_pos` is RTL or LTR context
|
||||
* @return the visual character position
|
||||
*/
|
||||
uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_base_dir_t base_dir,
|
||||
uint32_t logical_pos, bool * is_rtl)
|
||||
{
|
||||
@@ -209,16 +178,6 @@ uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t
|
||||
return (uint16_t) -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bidi process a paragraph of text
|
||||
* @param str_in the string to process
|
||||
* @param str_out store the result here
|
||||
* @param len length of the text
|
||||
* @param base_dir base dir of the text
|
||||
* @param pos_conv_out an `uint16_t` array to store the related logical position of the character.
|
||||
* Can be `NULL` if unused
|
||||
* @param pos_conv_len length of `pos_conv_out` in element count
|
||||
*/
|
||||
void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_base_dir_t base_dir,
|
||||
uint16_t * pos_conv_out, uint16_t pos_conv_len)
|
||||
{
|
||||
|
||||
@@ -117,13 +117,6 @@ lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl)
|
||||
return lv_color_mix(lv_color_black(), c, lvl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a HSV color to RGB
|
||||
* @param h hue [0..359]
|
||||
* @param s saturation [0..100]
|
||||
* @param v value [0..100]
|
||||
* @return the given RGB color in RGB (with LV_COLOR_DEPTH depth)
|
||||
*/
|
||||
lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)
|
||||
{
|
||||
h = (uint32_t)((uint32_t)h * 255) / 360;
|
||||
@@ -182,13 +175,6 @@ lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a 32-bit RGB color to HSV
|
||||
* @param r8 8-bit red
|
||||
* @param g8 8-bit green
|
||||
* @param b8 8-bit blue
|
||||
* @return the given RGB color in HSV
|
||||
*/
|
||||
lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r8, uint8_t g8, uint8_t b8)
|
||||
{
|
||||
uint16_t r = ((uint32_t)r8 << 10) / 255;
|
||||
|
||||
@@ -186,30 +186,52 @@ static inline uint8_t lv_color_format_get_size(lv_color_format_t cf)
|
||||
*/
|
||||
bool lv_color_format_has_alpha(lv_color_format_t src_cf);
|
||||
|
||||
/**
|
||||
* Create an ARGB8888 color from RGB888 + alpha
|
||||
* @param color an RGB888 color
|
||||
* @param opa the alpha value
|
||||
* @return the ARGB8888 color
|
||||
*/
|
||||
lv_color32_t lv_color_to_32(lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Convert an RGB888 color to an integer
|
||||
* @param c an RGB888 color
|
||||
* @return `c` as an integer
|
||||
*/
|
||||
static inline uint32_t lv_color_to_int(lv_color_t c)
|
||||
{
|
||||
uint8_t * tmp = (uint8_t *) &c;
|
||||
return tmp[0] + (tmp[1] << 8) + (tmp[2] << 16);
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_color_from_int(uint32_t v)
|
||||
{
|
||||
void * p = (void *)&v;
|
||||
return *((lv_color_t *)p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two RGB888 color are equal
|
||||
* @param c1 the first color
|
||||
* @param c2 the second color
|
||||
* @return true: equal
|
||||
*/
|
||||
static inline bool lv_color_eq(lv_color_t c1, lv_color_t c2)
|
||||
{
|
||||
return lv_color_to_int(c1) == lv_color_to_int(c2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two ARGB8888 color are equal
|
||||
* @param c1 the first color
|
||||
* @param c2 the second color
|
||||
* @return true: equal
|
||||
*/
|
||||
static inline bool lv_color32_eq(lv_color32_t c1, lv_color32_t c2)
|
||||
{
|
||||
return *((uint32_t *)&c1) == *((uint32_t *)&c2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a color from 0x000000..0xffffff input
|
||||
* @param c the hex input
|
||||
* @return the color
|
||||
*/
|
||||
static inline lv_color_t lv_color_hex(uint32_t c)
|
||||
{
|
||||
lv_color_t ret;
|
||||
@@ -219,6 +241,13 @@ static inline lv_color_t lv_color_hex(uint32_t c)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an RGB888 color
|
||||
* @param r the red channel (0..255)
|
||||
* @param g the green channel (0..255)
|
||||
* @param b the blue channel (0..255)
|
||||
* @return the color
|
||||
*/
|
||||
static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
lv_color_t ret;
|
||||
@@ -228,6 +257,14 @@ static inline lv_color_t lv_color_make(uint8_t r, uint8_t g, uint8_t b)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an ARGB8888 color
|
||||
* @param r the red channel (0..255)
|
||||
* @param g the green channel (0..255)
|
||||
* @param b the blue channel (0..255)
|
||||
* @param a the alpha channel (0..255)
|
||||
* @return the color
|
||||
*/
|
||||
static inline lv_color32_t lv_color32_make(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
||||
{
|
||||
lv_color32_t ret;
|
||||
@@ -238,15 +275,40 @@ static inline lv_color32_t lv_color32_make(uint8_t r, uint8_t g, uint8_t b, uint
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a color from 0x000..0xfff input
|
||||
* @param c the hex input (e.g. 0x123 will be 0x112233)
|
||||
* @return the color
|
||||
*/
|
||||
static inline lv_color_t lv_color_hex3(uint32_t c)
|
||||
{
|
||||
return lv_color_make((uint8_t)(((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), (uint8_t)((c & 0xF0) | ((c & 0xF0) >> 4)),
|
||||
(uint8_t)((c & 0xF) | ((c & 0xF) << 4)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert am RGB888 color to RGB565 stored in `uint16_t`
|
||||
* @param color and RGB888 color
|
||||
* @return `color` as RGB565 on `uin16_t`
|
||||
*/
|
||||
uint16_t lv_color_to_u16(lv_color_t color);
|
||||
|
||||
/**
|
||||
* Convert am RGB888 color to XRGB8888 stored in `uint32_t`
|
||||
* @param color and RGB888 color
|
||||
* @return `color` as XRGB8888 on `uin32_t` (the alpha channel is always set to 0xFF)
|
||||
*/
|
||||
uint32_t lv_color_to_u32(lv_color_t color);
|
||||
|
||||
/**
|
||||
* Mix two RGB565 colors
|
||||
* @param c1 the first color (typically the foreground color)
|
||||
* @param c2 the second color (typically the background color)
|
||||
* @param mix 0..255, or LV_OPA_0/10/20...
|
||||
* @return mix == 0: c2
|
||||
* mix == 255: c1
|
||||
* mix == 128: 0.5 x c1 + 0.5 x c2
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM static inline uint16_t lv_color_16_16_mix(uint16_t c1, uint16_t c2, uint8_t mix)
|
||||
{
|
||||
if(mix == 255) return c1;
|
||||
@@ -266,8 +328,20 @@ LV_ATTRIBUTE_FAST_MEM static inline uint16_t lv_color_16_16_mix(uint16_t c1, uin
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mix white to a color
|
||||
* @param c the base color
|
||||
* @param lvl the intensity of white (0: no change, 255: fully white)
|
||||
* @return the mixed color
|
||||
*/
|
||||
lv_color_t lv_color_lighten(lv_color_t c, lv_opa_t lvl);
|
||||
|
||||
/**
|
||||
* Mix black to a color
|
||||
* @param c the base color
|
||||
* @param lvl the intensity of black (0: no change, 255: fully black)
|
||||
* @return the mixed color
|
||||
*/
|
||||
lv_color_t lv_color_darken(lv_color_t c, lv_opa_t lvl);
|
||||
|
||||
/**
|
||||
@@ -297,10 +371,19 @@ lv_color_hsv_t lv_color_to_hsv(lv_color_t color);
|
||||
|
||||
/*Source: https://vuetifyjs.com/en/styles/colors/#material-colors*/
|
||||
|
||||
/**
|
||||
* A helper for white color
|
||||
* @return a white color
|
||||
*/
|
||||
static inline lv_color_t lv_color_white(void)
|
||||
{
|
||||
return lv_color_make(0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper for black color
|
||||
* @return a black color
|
||||
*/
|
||||
static inline lv_color_t lv_color_black(void)
|
||||
{
|
||||
return lv_color_make(0x00, 0x00, 0x00);
|
||||
|
||||
@@ -39,11 +39,6 @@ static void node_set_next(lv_ll_t * ll_p, lv_ll_node_t * act, lv_ll_node_t * nex
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize linked list
|
||||
* @param ll_p pointer to lv_ll_t variable
|
||||
* @param node_size the size of 1 node in bytes
|
||||
*/
|
||||
void _lv_ll_init(lv_ll_t * ll_p, uint32_t node_size)
|
||||
{
|
||||
ll_p->head = NULL;
|
||||
@@ -59,11 +54,6 @@ void _lv_ll_init(lv_ll_t * ll_p, uint32_t node_size)
|
||||
ll_p->n_size = node_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new head to a linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new head
|
||||
*/
|
||||
void * _lv_ll_ins_head(lv_ll_t * ll_p)
|
||||
{
|
||||
lv_ll_node_t * n_new;
|
||||
@@ -87,12 +77,6 @@ void * _lv_ll_ins_head(lv_ll_t * ll_p)
|
||||
return n_new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new node in front of the n_act node
|
||||
* @param ll_p pointer to linked list
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the new node
|
||||
*/
|
||||
void * _lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act)
|
||||
{
|
||||
lv_ll_node_t * n_new;
|
||||
@@ -118,11 +102,6 @@ void * _lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act)
|
||||
return n_new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new tail to a linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the new tail
|
||||
*/
|
||||
void * _lv_ll_ins_tail(lv_ll_t * ll_p)
|
||||
{
|
||||
lv_ll_node_t * n_new;
|
||||
@@ -145,12 +124,6 @@ void * _lv_ll_ins_tail(lv_ll_t * ll_p)
|
||||
return n_new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the node 'node_p' from 'll_p' linked list.
|
||||
* It does not free the memory of node.
|
||||
* @param ll_p pointer to the linked list of 'node_p'
|
||||
* @param node_p pointer to node in 'll_p' linked list
|
||||
*/
|
||||
void _lv_ll_remove(lv_ll_t * ll_p, void * node_p)
|
||||
{
|
||||
if(ll_p == NULL) return;
|
||||
@@ -184,10 +157,6 @@ void _lv_ll_remove(lv_ll_t * ll_p, void * node_p)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and free all elements from a linked list. The list remain valid but become empty.
|
||||
* @param ll_p pointer to linked list
|
||||
*/
|
||||
void _lv_ll_clear_custom(lv_ll_t * ll_p, void(*cleanup)(void *))
|
||||
{
|
||||
void * i;
|
||||
@@ -209,14 +178,6 @@ void _lv_ll_clear_custom(lv_ll_t * ll_p, void(*cleanup)(void *))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a node to a new linked list
|
||||
* @param ll_ori_p pointer to the original (old) linked list
|
||||
* @param ll_new_p pointer to the new linked list
|
||||
* @param node pointer to a node
|
||||
* @param head true: be the head in the new list
|
||||
* false be the tail in the new list
|
||||
*/
|
||||
void _lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool head)
|
||||
{
|
||||
_lv_ll_remove(ll_ori_p, node);
|
||||
@@ -251,34 +212,18 @@ void _lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool h
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with head node of the linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the head of 'll_p'
|
||||
*/
|
||||
void * _lv_ll_get_head(const lv_ll_t * ll_p)
|
||||
{
|
||||
if(ll_p == NULL) return NULL;
|
||||
return ll_p->head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with tail node of the linked list
|
||||
* @param ll_p pointer to linked list
|
||||
* @return pointer to the tail of 'll_p'
|
||||
*/
|
||||
void * _lv_ll_get_tail(const lv_ll_t * ll_p)
|
||||
{
|
||||
if(ll_p == NULL) return NULL;
|
||||
return ll_p->tail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the pointer of the next node after 'n_act'
|
||||
* @param ll_p pointer to linked list
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the next node
|
||||
*/
|
||||
void * _lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act)
|
||||
{
|
||||
/*Pointer to the next node is stored in the end of this node.
|
||||
@@ -288,12 +233,6 @@ void * _lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act)
|
||||
return *((lv_ll_node_t **)n_act_d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the pointer of the previous node before 'n_act'
|
||||
* @param ll_p pointer to linked list
|
||||
* @param n_act pointer a node
|
||||
* @return pointer to the previous node
|
||||
*/
|
||||
void * _lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act)
|
||||
{
|
||||
/*Pointer to the prev. node is stored in the end of this node.
|
||||
@@ -303,11 +242,6 @@ void * _lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act)
|
||||
return *((lv_ll_node_t **)n_act_d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the length of the linked list.
|
||||
* @param ll_p pointer to linked list
|
||||
* @return length of the linked list
|
||||
*/
|
||||
uint32_t _lv_ll_get_len(const lv_ll_t * ll_p)
|
||||
{
|
||||
uint32_t len = 0;
|
||||
@@ -320,12 +254,6 @@ uint32_t _lv_ll_get_len(const lv_ll_t * ll_p)
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a node before an other node in the same linked list
|
||||
* @param ll_p pointer to a linked list
|
||||
* @param n_act pointer to node to move
|
||||
* @param n_after pointer to a node which should be after `n_act`
|
||||
*/
|
||||
void _lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after)
|
||||
{
|
||||
if(n_act == n_after) return; /*Can't move before itself*/
|
||||
@@ -354,11 +282,6 @@ void _lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after)
|
||||
if(n_before == NULL) ll_p->head = n_act;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a linked list is empty
|
||||
* @param ll_p pointer to a linked list
|
||||
* @return true: the linked list is empty; false: not empty
|
||||
*/
|
||||
bool _lv_ll_is_empty(lv_ll_t * ll_p)
|
||||
{
|
||||
if(ll_p == NULL) return true;
|
||||
|
||||
@@ -65,26 +65,11 @@
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register custom print/write function to call when a log is added.
|
||||
* It can format its "File path", "Line number" and "Description" as required
|
||||
* and send the formatted log message to a console or serial port.
|
||||
* @param print_cb a function pointer to print a log
|
||||
*/
|
||||
void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb)
|
||||
{
|
||||
custom_print_cb = print_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a log
|
||||
* @param level the level of log. (From `lv_log_level_t` enum)
|
||||
* @param file name of the file when the log added
|
||||
* @param line line number in the source code where the log added
|
||||
* @param func name of the function when the log added
|
||||
* @param format printf-like format string
|
||||
* @param ... parameters for `format`
|
||||
*/
|
||||
void _lv_log_add(lv_log_level_t level, const char * file, int line, const char * func, const char * format, ...)
|
||||
{
|
||||
if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/
|
||||
|
||||
@@ -49,11 +49,6 @@ static const uint16_t sin0_90_table[] = {
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Return with sinus of an angle
|
||||
* @param angle
|
||||
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM int32_t lv_trigo_sin(int16_t angle)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
@@ -128,15 +123,6 @@ static int32_t do_cubic_bezier(int32_t t, int32_t a, int32_t b, int32_t c)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the y value of cubic-bezier(x1, y1, x2, y2) function as specified x.
|
||||
* @param x time in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param x1 x of control point 1 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param y1 y of control point 1 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param x2 x of control point 2 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @param y2 y of control point 2 in range of [0..LV_BEZIER_VAL_MAX]
|
||||
* @return the value calculated
|
||||
*/
|
||||
int32_t lv_cubic_bezier(int32_t x, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
|
||||
{
|
||||
int32_t ax, bx, cx, ay, by, cy;
|
||||
@@ -219,16 +205,6 @@ found:
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the square root of a number
|
||||
* @param x integer which square root should be calculated
|
||||
* @param q store the result here. q->i: integer part, q->f: fractional part in 1/256 unit
|
||||
* @param mask optional to skip some iterations if the magnitude of the root is known.
|
||||
* Set to 0x8000 by default.
|
||||
* If root < 16: mask = 0x80
|
||||
* If root < 256: mask = 0x800
|
||||
* Else: mask = 0x8000
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask)
|
||||
{
|
||||
x = x << 8; /*To get 4 bit precision. (sqrt(256) = 16 = 4 bit)*/
|
||||
@@ -246,12 +222,6 @@ LV_ATTRIBUTE_FAST_MEM void lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask)
|
||||
q->f = (root & 0xf) << 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the atan2 of a vector.
|
||||
* @param x
|
||||
* @param y
|
||||
* @return the angle in degree calculated from the given parameters in range of [0..360]
|
||||
*/
|
||||
uint16_t lv_atan2(int x, int y)
|
||||
{
|
||||
/**
|
||||
@@ -329,12 +299,6 @@ uint16_t lv_atan2(int x, int y)
|
||||
return degree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the integer exponents.
|
||||
* @param base
|
||||
* @param power
|
||||
* @return base raised to the power exponent
|
||||
*/
|
||||
int64_t lv_pow(int64_t base, int8_t exp)
|
||||
{
|
||||
int64_t result = 1;
|
||||
@@ -348,15 +312,6 @@ int64_t lv_pow(int64_t base, int8_t exp)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mapped of a number given an input and output range
|
||||
* @param x integer which mapped value should be calculated
|
||||
* @param min_in min input range
|
||||
* @param max_in max input range
|
||||
* @param min_out min output range
|
||||
* @param max_out max output range
|
||||
* @return the mapped number
|
||||
*/
|
||||
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 && x >= max_in) return max_out;
|
||||
|
||||
@@ -34,23 +34,6 @@
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/** Searches base[0] to base[n - 1] for an item that matches *key.
|
||||
*
|
||||
* @note The function cmp must return negative if its first
|
||||
* argument (the search key) is less than its second (a table entry),
|
||||
* zero if equal, and positive if greater.
|
||||
*
|
||||
* @note Items in the array must be in ascending order.
|
||||
*
|
||||
* @param key Pointer to item being searched for
|
||||
* @param base Pointer to first element to search
|
||||
* @param n Number of elements
|
||||
* @param size Size of each element
|
||||
* @param cmp Pointer to comparison function (see #unicode_list_compare as a comparison function
|
||||
* example)
|
||||
*
|
||||
* @return a pointer to a matching item, or NULL if none exists.
|
||||
*/
|
||||
void * _lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size,
|
||||
int32_t (*cmp)(const void * pRef, const void * pElement))
|
||||
{
|
||||
|
||||
@@ -421,11 +421,6 @@ lv_obj_t * lv_ime_pinyin_create(lv_obj_t * parent)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the keyboard of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @param dict pointer to a Pinyin input method keyboard
|
||||
*/
|
||||
void lv_ime_pinyin_set_keyboard(lv_obj_t * obj, lv_obj_t * kb)
|
||||
{
|
||||
if(kb) {
|
||||
@@ -442,11 +437,6 @@ void lv_ime_pinyin_set_keyboard(lv_obj_t * obj, lv_obj_t * kb)
|
||||
lv_obj_align_to(pinyin_ime->cand_panel, pinyin_ime->kb, LV_ALIGN_OUT_TOP_MID, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @param dict pointer to a Pinyin input method dictionary
|
||||
*/
|
||||
void lv_ime_pinyin_set_dict(lv_obj_t * obj, lv_pinyin_dict_t * dict)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -454,11 +444,6 @@ void lv_ime_pinyin_set_dict(lv_obj_t * obj, lv_pinyin_dict_t * dict)
|
||||
init_pinyin_dict(obj, dict);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mode, 26-key input(k26) or 9-key input(k9).
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @param mode the mode from 'lv_keyboard_mode_t'
|
||||
*/
|
||||
void lv_ime_pinyin_set_mode(lv_obj_t * obj, lv_ime_pinyin_mode_t mode)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -482,11 +467,6 @@ void lv_ime_pinyin_set_mode(lv_obj_t * obj, lv_ime_pinyin_mode_t mode)
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the dictionary of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin IME object
|
||||
* @return pointer to the Pinyin IME keyboard
|
||||
*/
|
||||
lv_obj_t * lv_ime_pinyin_get_kb(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -496,11 +476,6 @@ lv_obj_t * lv_ime_pinyin_get_kb(lv_obj_t * obj)
|
||||
return pinyin_ime->kb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the dictionary of Pinyin input method.
|
||||
* @param obj pointer to a Pinyin input method object
|
||||
* @return pointer to the Pinyin input method candidate panel
|
||||
*/
|
||||
lv_obj_t * lv_ime_pinyin_get_cand_panel(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
@@ -39,12 +39,6 @@
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Get the buffer needed for object snapshot image.
|
||||
* @param obj the object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @return the buffer size needed in bytes
|
||||
*/
|
||||
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_color_format_t cf)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
@@ -71,15 +65,6 @@ uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_color_format_t cf)
|
||||
return lv_draw_buf_width_to_stride(w, cf) * h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take snapshot for object with its children, save image info to provided buffer.
|
||||
* @param obj the object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @param dsc image descriptor to store the image result.
|
||||
* @param buf the buffer to store image data.
|
||||
* @param buf_size provided buffer size in bytes.
|
||||
* @return LV_RESULT_OK on success, LV_RESULT_INVALID on error.
|
||||
*/
|
||||
lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc, void * buf,
|
||||
uint32_t buf_size)
|
||||
{
|
||||
@@ -152,12 +137,6 @@ lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_ima
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take snapshot for object with its children, alloc the memory needed.
|
||||
* @param obj the object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @return a pointer to an image descriptor, or NULL if failed.
|
||||
*/
|
||||
lv_image_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf)
|
||||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
@@ -186,11 +165,6 @@ lv_image_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf)
|
||||
return dsc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the snapshot image returned by @ref lv_snapshot_take
|
||||
* It will firstly free the data image takes, then the image descriptor.
|
||||
* @param dsc the image descriptor generated by lv_snapshot_take.
|
||||
*/
|
||||
void lv_snapshot_free(lv_image_dsc_t * dsc)
|
||||
{
|
||||
if(!dsc)
|
||||
|
||||
@@ -59,11 +59,6 @@ lv_result_t lv_mem_test_core(void);
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Allocate a memory dynamically
|
||||
* @param size size of the memory to allocate in bytes
|
||||
* @return pointer to the allocated memory
|
||||
*/
|
||||
void * lv_malloc(size_t size)
|
||||
{
|
||||
LV_TRACE_MEM("allocating %lu bytes", (unsigned long)size);
|
||||
@@ -121,10 +116,6 @@ void * lv_malloc_zeroed(size_t size)
|
||||
return alloc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free an allocated data
|
||||
* @param data pointer to an allocated memory
|
||||
*/
|
||||
void lv_free(void * data)
|
||||
{
|
||||
LV_TRACE_MEM("freeing %p", data);
|
||||
@@ -134,13 +125,6 @@ void lv_free(void * data)
|
||||
lv_free_core(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reallocate a memory with a new size. The old content will be kept.
|
||||
* @param data pointer to an allocated memory.
|
||||
* Its content will be copied to the new memory block and freed
|
||||
* @param new_size the desired new size in byte
|
||||
* @return pointer to the new memory
|
||||
*/
|
||||
void * lv_realloc(void * data_p, size_t new_size)
|
||||
{
|
||||
LV_TRACE_MEM("reallocating %p with %lu size", data_p, (unsigned long)new_size);
|
||||
|
||||
@@ -232,13 +232,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style(obj, &theme->styles.white, 0);
|
||||
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
|
||||
}
|
||||
#if LV_USE_BTN
|
||||
#if LV_USE_BUTTON
|
||||
else if(lv_obj_check_type(obj, &lv_button_class)) {
|
||||
lv_obj_add_style(obj, &theme->styles.dark, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
#if LV_USE_BUTTONMATRIX
|
||||
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
|
||||
#if LV_USE_MSGBOX
|
||||
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
|
||||
|
||||
@@ -799,7 +799,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
|
||||
lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
|
||||
}
|
||||
#if LV_USE_BTN
|
||||
#if LV_USE_BUTTON
|
||||
else if(lv_obj_check_type(obj, &lv_button_class)) {
|
||||
|
||||
#if LV_USE_TABVIEW
|
||||
@@ -843,7 +843,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
#if LV_USE_BUTTONMATRIX
|
||||
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
|
||||
@@ -40,11 +40,6 @@ lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj)
|
||||
return lv_display_get_theme(disp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the active theme on an object
|
||||
* @param obj pointer to an object
|
||||
* @param name the name of the theme element to apply. E.g. `LV_THEME_BTN`
|
||||
*/
|
||||
void lv_theme_apply(lv_obj_t * obj)
|
||||
{
|
||||
lv_theme_t * th = lv_theme_get_from_obj(obj);
|
||||
@@ -55,24 +50,11 @@ void lv_theme_apply(lv_obj_t * obj)
|
||||
apply_theme_recursion(th, obj); /*Apply the theme including the base theme(s)*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a base theme for a theme.
|
||||
* The styles from the base them will be added before the styles of the current theme.
|
||||
* Arbitrary long chain of themes can be created by setting base themes.
|
||||
* @param new_theme pointer to theme which base should be set
|
||||
* @param base pointer to the base theme
|
||||
*/
|
||||
void lv_theme_set_parent(lv_theme_t * new_theme, lv_theme_t * base)
|
||||
{
|
||||
new_theme->parent = base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback for a theme.
|
||||
* The callback is used to add styles to different objects
|
||||
* @param theme pointer to theme which callback should be set
|
||||
* @param cb pointer to the callback
|
||||
*/
|
||||
void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb)
|
||||
{
|
||||
theme->apply_cb = apply_cb;
|
||||
|
||||
@@ -271,7 +271,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
lv_obj_add_style(obj, &theme->styles.card, 0);
|
||||
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
|
||||
}
|
||||
#if LV_USE_BTN
|
||||
#if LV_USE_BUTTON
|
||||
else if(lv_obj_check_type(obj, &lv_button_class)) {
|
||||
lv_obj_add_style(obj, &theme->styles.card, 0);
|
||||
lv_obj_add_style(obj, &theme->styles.pr, LV_STATE_PRESSED);
|
||||
@@ -282,7 +282,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_BTNMATRIX
|
||||
#if LV_USE_BUTTONMATRIX
|
||||
else if(lv_obj_check_type(obj, &lv_buttonmatrix_class)) {
|
||||
#if LV_USE_MSGBOX
|
||||
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) {
|
||||
|
||||
@@ -35,10 +35,6 @@
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* You have to call this function periodically
|
||||
* @param tick_period the call period of this function in milliseconds
|
||||
*/
|
||||
LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period)
|
||||
{
|
||||
lv_tick_state_t * state_p = &state;
|
||||
@@ -47,10 +43,6 @@ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period)
|
||||
state_p->sys_time += tick_period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds since start up
|
||||
* @return the elapsed milliseconds
|
||||
*/
|
||||
uint32_t lv_tick_get(void)
|
||||
{
|
||||
lv_tick_state_t * state_p = &state;
|
||||
@@ -72,11 +64,6 @@ uint32_t lv_tick_get(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the elapsed milliseconds since a previous time stamp
|
||||
* @param prev_tick a previous time stamp (return value of lv_tick_get() )
|
||||
* @return the elapsed milliseconds since 'prev_tick'
|
||||
*/
|
||||
uint32_t lv_tick_elaps(uint32_t prev_tick)
|
||||
{
|
||||
uint32_t act_time = lv_tick_get();
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#if LV_USE_ANIMIMG != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if LV_USE_IMG == 0
|
||||
#error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMG 1) "
|
||||
#if LV_USE_IMAGE == 0
|
||||
#error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMAGE 1) "
|
||||
#endif
|
||||
|
||||
#include "../../draw/lv_image_decoder.h"
|
||||
|
||||
@@ -18,8 +18,8 @@ extern "C" {
|
||||
#if LV_USE_ANIMIMG != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if LV_USE_IMG == 0
|
||||
#error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMG 1)"
|
||||
#if LV_USE_IMAGE == 0
|
||||
#error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMAGE 1)"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
@@ -32,7 +32,7 @@ extern "C" {
|
||||
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_animimg_class;
|
||||
|
||||
/*Data of image*/
|
||||
/*Data of the animimage*/
|
||||
typedef struct {
|
||||
lv_image_t img;
|
||||
lv_anim_t anim;
|
||||
@@ -69,29 +69,29 @@ lv_obj_t * lv_animimg_create(lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Set the image animation images source.
|
||||
* @param img pointer to an animation image object
|
||||
* @param dsc pointer to a series images
|
||||
* @param num images' number
|
||||
* @param img pointer to an animation image object
|
||||
* @param dsc pointer to a series images
|
||||
* @param num images' number
|
||||
*/
|
||||
void lv_animimg_set_src(lv_obj_t * img, const void * dsc[], size_t num);
|
||||
|
||||
/**
|
||||
* Startup the image animation.
|
||||
* @param obj pointer to an animation image object
|
||||
* @param obj pointer to an animation image object
|
||||
*/
|
||||
void lv_animimg_start(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Set the image animation duration time. unit:ms
|
||||
* @param img pointer to an animation image object
|
||||
* @param duration the duration
|
||||
* @param img pointer to an animation image object
|
||||
* @param duration the duration in milliseconds
|
||||
*/
|
||||
void lv_animimg_set_duration(lv_obj_t * img, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Set the image animation repeatedly play times.
|
||||
* @param img pointer to an animation image object
|
||||
* @param count the number of times to repeat the animation
|
||||
* @param img pointer to an animation image object
|
||||
* @param count the number of times to repeat the animation
|
||||
*/
|
||||
void lv_animimg_set_repeat_count(lv_obj_t * img, uint32_t count);
|
||||
|
||||
@@ -101,29 +101,29 @@ void lv_animimg_set_repeat_count(lv_obj_t * img, uint32_t count);
|
||||
|
||||
/**
|
||||
* Get the image animation images source.
|
||||
* @param img pointer to an animation image object
|
||||
* @return a pointer that will point to a series images
|
||||
* @param img pointer to an animation image object
|
||||
* @return a pointer that will point to a series images
|
||||
*/
|
||||
const void ** lv_animimg_get_src(lv_obj_t * img);
|
||||
|
||||
/**
|
||||
* Get the image animation images source.
|
||||
* @param img pointer to an animation image object
|
||||
* @return the number of source images
|
||||
* @param img pointer to an animation image object
|
||||
* @return the number of source images
|
||||
*/
|
||||
uint8_t lv_animimg_get_src_count(lv_obj_t * img);
|
||||
|
||||
/**
|
||||
* Get the image animation duration time. unit:ms
|
||||
* @param img pointer to an animation image object
|
||||
* @return the animation duration time
|
||||
* @param img pointer to an animation image object
|
||||
* @return the animation duration time
|
||||
*/
|
||||
uint32_t lv_animimg_get_duration(lv_obj_t * img);
|
||||
|
||||
/**
|
||||
* Get the image animation repeat play times.
|
||||
* @param img pointer to an animation image object
|
||||
* @return the repeat count
|
||||
* @param img pointer to an animation image object
|
||||
* @return the repeat count
|
||||
*/
|
||||
uint32_t lv_animimg_get_repeat_count(lv_obj_t * img);
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ void lv_arc_set_bg_angles(lv_obj_t * obj, lv_value_precise_t start, lv_value_pre
|
||||
lv_arc_set_bg_start_angle(obj, start);
|
||||
}
|
||||
|
||||
void lv_arc_set_rotation(lv_obj_t * obj, uint32_t rotation)
|
||||
void lv_arc_set_rotation(lv_obj_t * obj, int32_t rotation)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_arc_t * arc = (lv_arc_t *)obj;
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef uint8_t lv_arc_mode_t;
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
uint32_t rotation;
|
||||
int32_t rotation;
|
||||
lv_value_precise_t indic_angle_start;
|
||||
lv_value_precise_t indic_angle_end;
|
||||
lv_value_precise_t bg_angle_start;
|
||||
@@ -66,8 +66,8 @@ LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_arc_class;
|
||||
|
||||
/**
|
||||
* Create an arc object
|
||||
* @param parent pointer to an object, it will be the parent of the new arc
|
||||
* @return pointer to the created arc
|
||||
* @param parent pointer to an object, it will be the parent of the new arc
|
||||
* @return pointer to the created arc
|
||||
*/
|
||||
lv_obj_t * lv_arc_create(lv_obj_t * parent);
|
||||
|
||||
@@ -81,74 +81,74 @@ lv_obj_t * lv_arc_create(lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Set the start angle of an arc. 0 deg: right, 90 bottom, etc.
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle. (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
void lv_arc_set_start_angle(lv_obj_t * obj, lv_value_precise_t start);
|
||||
|
||||
/**
|
||||
* Set the end angle of an arc. 0 deg: right, 90 bottom, etc.
|
||||
* @param obj pointer to an arc object
|
||||
* @param end the end angle
|
||||
* @param obj pointer to an arc object
|
||||
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
void lv_arc_set_end_angle(lv_obj_t * obj, lv_value_precise_t end);
|
||||
|
||||
/**
|
||||
* Set the start and end angles
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
void lv_arc_set_angles(lv_obj_t * obj, lv_value_precise_t start, lv_value_precise_t end);
|
||||
|
||||
/**
|
||||
* Set the start angle of an arc background. 0 deg: right, 90 bottom, etc.
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
void lv_arc_set_bg_start_angle(lv_obj_t * obj, lv_value_precise_t start);
|
||||
|
||||
/**
|
||||
* Set the start angle of an arc background. 0 deg: right, 90 bottom etc.
|
||||
* @param obj pointer to an arc object
|
||||
* @param end the end angle
|
||||
* @param obj pointer to an arc object
|
||||
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
void lv_arc_set_bg_end_angle(lv_obj_t * obj, lv_value_precise_t end);
|
||||
|
||||
/**
|
||||
* Set the start and end angles of the arc background
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle
|
||||
* @param end the end angle
|
||||
* @param obj pointer to an arc object
|
||||
* @param start the start angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
* @param end the end angle (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
void lv_arc_set_bg_angles(lv_obj_t * obj, lv_value_precise_t start, lv_value_precise_t end);
|
||||
|
||||
/**
|
||||
* Set the rotation for the whole arc
|
||||
* @param obj pointer to an arc object
|
||||
* @param rotation rotation angle
|
||||
* @param obj pointer to an arc object
|
||||
* @param rotation rotation angle
|
||||
*/
|
||||
void lv_arc_set_rotation(lv_obj_t * obj, uint32_t rotation);
|
||||
void lv_arc_set_rotation(lv_obj_t * obj, int32_t rotation);
|
||||
|
||||
/**
|
||||
* Set the type of arc.
|
||||
* @param obj pointer to arc object
|
||||
* @param type arc's mode
|
||||
* @param obj pointer to arc object
|
||||
* @param type arc's mode
|
||||
*/
|
||||
void lv_arc_set_mode(lv_obj_t * obj, lv_arc_mode_t type);
|
||||
|
||||
/**
|
||||
* Set a new value on the arc
|
||||
* @param obj pointer to an arc object
|
||||
* @param value new value
|
||||
* @param obj pointer to an arc object
|
||||
* @param value new value
|
||||
*/
|
||||
void lv_arc_set_value(lv_obj_t * obj, int32_t value);
|
||||
|
||||
/**
|
||||
* Set minimum and the maximum values of an arc
|
||||
* @param obj pointer to the arc object
|
||||
* @param min minimum value
|
||||
* @param max maximum value
|
||||
* @param obj pointer to the arc object
|
||||
* @param min minimum value
|
||||
* @param max maximum value
|
||||
*/
|
||||
void lv_arc_set_range(lv_obj_t * obj, int32_t min, int32_t max);
|
||||
|
||||
@@ -160,11 +160,11 @@ void lv_arc_set_range(lv_obj_t * obj, int32_t min, int32_t max);
|
||||
void lv_arc_set_change_rate(lv_obj_t * obj, uint32_t rate);
|
||||
|
||||
/**
|
||||
* Set an offset for the knob from the main arc object
|
||||
* @param arc pointer to an arc object
|
||||
* @param offset knob offset from main arc
|
||||
* Set an offset angle for the knob
|
||||
* @param obj pointer to an arc object
|
||||
* @param offset knob offset from main arc in degrees
|
||||
*/
|
||||
void lv_arc_set_knob_offset(lv_obj_t * arc, int32_t offset);
|
||||
void lv_arc_set_knob_offset(lv_obj_t * obj, int32_t offset);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
@@ -172,29 +172,29 @@ void lv_arc_set_knob_offset(lv_obj_t * arc, int32_t offset);
|
||||
|
||||
/**
|
||||
* Get the start angle of an arc.
|
||||
* @param obj pointer to an arc object
|
||||
* @return the start angle [0..360]
|
||||
* @param obj pointer to an arc object
|
||||
* @return the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
lv_value_precise_t lv_arc_get_angle_start(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the end angle of an arc.
|
||||
* @param obj pointer to an arc object
|
||||
* @return the end angle [0..360]
|
||||
* @param obj pointer to an arc object
|
||||
* @return the end angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
lv_value_precise_t lv_arc_get_angle_end(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the start angle of an arc background.
|
||||
* @param obj pointer to an arc object
|
||||
* @return the start angle [0..360]
|
||||
* @param obj pointer to an arc object
|
||||
* @return the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
lv_value_precise_t lv_arc_get_bg_angle_start(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the end angle of an arc background.
|
||||
* @param obj pointer to an arc object
|
||||
* @return the end angle [0..360]
|
||||
* @param obj pointer to an arc object
|
||||
* @return the end angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.)
|
||||
*/
|
||||
lv_value_precise_t lv_arc_get_bg_angle_end(lv_obj_t * obj);
|
||||
|
||||
@@ -207,15 +207,15 @@ int32_t lv_arc_get_value(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the minimum value of an arc
|
||||
* @param obj pointer to an arc object
|
||||
* @return the minimum value of the arc
|
||||
* @param obj pointer to an arc object
|
||||
* @return the minimum value of the arc
|
||||
*/
|
||||
int32_t lv_arc_get_min_value(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the maximum value of an arc
|
||||
* @param obj pointer to an arc object
|
||||
* @return the maximum value of the arc
|
||||
* @param obj pointer to an arc object
|
||||
* @return the maximum value of the arc
|
||||
*/
|
||||
int32_t lv_arc_get_max_value(const lv_obj_t * obj);
|
||||
|
||||
@@ -234,7 +234,7 @@ lv_arc_mode_t lv_arc_get_mode(const lv_obj_t * obj);
|
||||
int32_t lv_arc_get_rotation(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the current knob offset
|
||||
* Get the current knob angle offset
|
||||
* @param obj pointer to an arc object
|
||||
* @return arc's current knob offset
|
||||
*/
|
||||
|
||||
@@ -68,8 +68,8 @@ LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_bar_class;
|
||||
|
||||
/**
|
||||
* Create a bar object
|
||||
* @param parent pointer to an object, it will be the parent of the new bar
|
||||
* @return pointer to the created bar
|
||||
* @param parent pointer to an object, it will be the parent of the new bar
|
||||
* @return pointer to the created bar
|
||||
*/
|
||||
lv_obj_t * lv_bar_create(lv_obj_t * parent);
|
||||
|
||||
@@ -79,9 +79,9 @@ lv_obj_t * lv_bar_create(lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Set a new value on the bar
|
||||
* @param obj pointer to a bar object
|
||||
* @param value new value
|
||||
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
|
||||
* @param obj pointer to a bar object
|
||||
* @param value new value
|
||||
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
|
||||
*/
|
||||
void lv_bar_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*********************/
|
||||
|
||||
#include "lv_button.h"
|
||||
#if LV_USE_BTN != 0
|
||||
#if LV_USE_BUTTON != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_BTN != 0
|
||||
#if LV_USE_BUTTON != 0
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
@@ -47,7 +47,7 @@ lv_obj_t * lv_button_create(lv_obj_t * parent);
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_BTN*/
|
||||
#endif /*LV_USE_BUTTON*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_buttonmatrix.h"
|
||||
#if LV_USE_BTNMATRIX != 0
|
||||
#if LV_USE_BUTTONMATRIX != 0
|
||||
|
||||
#include "../../misc/lv_assert.h"
|
||||
#include "../../indev/lv_indev.h"
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_BTNMATRIX != 0
|
||||
#if LV_USE_BUTTONMATRIX != 0
|
||||
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
@@ -111,7 +111,7 @@ void lv_buttonmatrix_set_ctrl_map(lv_obj_t * obj, const lv_buttonmatrix_ctrl_t c
|
||||
/**
|
||||
* Set the selected buttons
|
||||
* @param obj pointer to button matrix object
|
||||
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
|
||||
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
|
||||
*/
|
||||
void lv_buttonmatrix_set_selected_button(lv_obj_t * obj, uint32_t btn_id);
|
||||
|
||||
@@ -213,7 +213,7 @@ bool lv_buttonmatrix_get_one_checked(const lv_obj_t * obj);
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_BTNMATRIX*/
|
||||
#endif /*LV_USE_BUTTONMATRIX*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
|
||||
@@ -53,6 +53,11 @@ LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_class;
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a calendar widget
|
||||
* @param parent pointer to an object, it will be the parent of the new calendar
|
||||
* @return pointer the created calendar
|
||||
*/
|
||||
lv_obj_t * lv_calendar_create(lv_obj_t * parent);
|
||||
|
||||
/*======================
|
||||
@@ -105,44 +110,45 @@ void lv_calendar_set_day_names(lv_obj_t * obj, const char ** day_names);
|
||||
/**
|
||||
* Get the button matrix object of the calendar.
|
||||
* It shows the dates and day names.
|
||||
* @param obj pointer to a calendar object
|
||||
* @return pointer to a the button matrix
|
||||
* @param obj pointer to a calendar object
|
||||
* @return pointer to a the button matrix
|
||||
*/
|
||||
lv_obj_t * lv_calendar_get_btnmatrix(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the today's date
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return return pointer to an `lv_calendar_date_t` variable containing the date of today.
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return return pointer to an `lv_calendar_date_t` variable containing the date of today.
|
||||
*/
|
||||
const lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar);
|
||||
|
||||
/**
|
||||
* Get the currently showed
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.
|
||||
*/
|
||||
const lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar);
|
||||
|
||||
/**
|
||||
* Get the highlighted dates
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to an `lv_calendar_date_t` array containing the dates.
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to an `lv_calendar_date_t` array containing the dates.
|
||||
*/
|
||||
lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar);
|
||||
|
||||
/**
|
||||
* Get the number of the highlighted dates
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return number of highlighted days
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return number of highlighted days
|
||||
*/
|
||||
size_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar);
|
||||
|
||||
/**
|
||||
* Get the currently pressed day
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param date store the pressed date here
|
||||
* @return LV_RESULT_OK: there is a valid pressed date; LV_RESULT_INVALID: there is no pressed data
|
||||
* @param calendar pointer to a calendar object
|
||||
* @param date store the pressed date here
|
||||
* @return LV_RESULT_OK: there is a valid pressed date
|
||||
* LV_RESULT_INVALID: there is no pressed data
|
||||
*/
|
||||
lv_result_t lv_calendar_get_pressed_date(const lv_obj_t * calendar, lv_calendar_date_t * date);
|
||||
|
||||
|
||||
@@ -65,17 +65,29 @@ lv_obj_t * lv_canvas_create(lv_obj_t * parent);
|
||||
*/
|
||||
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, int32_t w, int32_t h, lv_color_format_t cf);
|
||||
|
||||
/**
|
||||
* Set a pixel's color and opacity
|
||||
* @param obj pointer to a canvas
|
||||
* @param x X coordinate of the pixel
|
||||
* @param y Y coordinate of the pixel
|
||||
* @param color the color
|
||||
* @param opa the opacity
|
||||
* @note The following color formats are supported
|
||||
* LV_COLOR_FORMAT_I1/2/4/8, LV_COLOR_FORMAT_A8,
|
||||
* LV_COLOR_FORMAT_RGB565, LV_COLOR_FORMAT_RGB888,
|
||||
* LV_COLOR_FORMAT_XRGB8888, LV_COLOR_FORMAT_ARGB8888
|
||||
*/
|
||||
void lv_canvas_set_px(lv_obj_t * obj, int32_t x, int32_t y, lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Set the palette color of a canvas with index format. Valid only for `LV_IMAGE_CF_INDEXED1/2/4/8`
|
||||
* @param canvas pointer to canvas object
|
||||
* @param id the palette color to set:
|
||||
* - for `LV_IMAGE_CF_INDEXED1`: 0..1
|
||||
* - for `LV_IMAGE_CF_INDEXED2`: 0..3
|
||||
* - for `LV_IMAGE_CF_INDEXED4`: 0..15
|
||||
* - for `LV_IMAGE_CF_INDEXED8`: 0..255
|
||||
* @param c the color to set
|
||||
* Set the palette color of a canvas for index format. Valid only for `LV_COLOR_FORMAT_I1/2/4/8`
|
||||
* @param canvas pointer to canvas object
|
||||
* @param id the palette color to set:
|
||||
* - for `LV_COLOR_FORMAT_I1`: 0..1
|
||||
* - for `LV_COLOR_FORMAT_I2`: 0..3
|
||||
* - for `LV_COLOR_FORMAT_I4`: 0..15
|
||||
* - for `LV_COLOR_FORMAT_I8`: 0..255
|
||||
* @param c the color to set
|
||||
*/
|
||||
void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color32_t c);
|
||||
|
||||
@@ -83,12 +95,19 @@ void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color32_t c);
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get a pixel's color and opacity
|
||||
* @param obj pointer to a canvas
|
||||
* @param x X coordinate of the pixel
|
||||
* @param y Y coordinate of the pixel
|
||||
* @return ARGB8888 color of the pixel
|
||||
*/
|
||||
lv_color32_t lv_canvas_get_px(lv_obj_t * obj, int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Get the image of the canvas as a pointer to an `lv_image_dsc_t` variable.
|
||||
* @param canvas pointer to a canvas object
|
||||
* @return pointer to the image descriptor.
|
||||
* @param canvas pointer to a canvas object
|
||||
* @return pointer to the image descriptor.
|
||||
*/
|
||||
lv_image_dsc_t * lv_canvas_get_image(lv_obj_t * canvas);
|
||||
|
||||
@@ -107,26 +126,38 @@ const void * lv_canvas_get_buf(lv_obj_t * canvas);
|
||||
|
||||
/**
|
||||
* Copy a buffer to the canvas
|
||||
* @param canvas pointer to a canvas object
|
||||
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color
|
||||
* @param canvas pointer to a canvas object
|
||||
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color
|
||||
* format
|
||||
* @param x left side of the destination position
|
||||
* @param y top side of the destination position
|
||||
* @param w width of the buffer to copy
|
||||
* @param h height of the buffer to copy
|
||||
* @param x left side of the destination position
|
||||
* @param y top side of the destination position
|
||||
* @param w width of the buffer to copy
|
||||
* @param h height of the buffer to copy
|
||||
*/
|
||||
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, int32_t x, int32_t y, int32_t w,
|
||||
int32_t h);
|
||||
/**
|
||||
* Fill the canvas with color
|
||||
* @param canvas pointer to a canvas
|
||||
* @param color the background color
|
||||
* @param opa the desired opacity
|
||||
* @param canvas pointer to a canvas
|
||||
* @param color the background color
|
||||
* @param opa the desired opacity
|
||||
*/
|
||||
void lv_canvas_fill_bg(lv_obj_t * obj, lv_color_t color, lv_opa_t opa);
|
||||
|
||||
/**
|
||||
* Initialize a layer to use LVGL's generic draw functions (lv_draw_rect/label/...) on the canvas.
|
||||
* Needs to be usd in pair with `lv_canvas_finish_layer`.
|
||||
* @param canvas pointer to a canvas
|
||||
* @param layer pointer to a layer variable to initialize
|
||||
*/
|
||||
void lv_canvas_init_layer(lv_obj_t * canvas, lv_layer_t * layer);
|
||||
|
||||
/**
|
||||
* Wait until all the drawings are finished on layer.
|
||||
* Needs to be usd in pair with `lv_canvas_init_layer`.
|
||||
* @param canvas pointer to a canvas
|
||||
* @param layer pointer to a layer to finalize
|
||||
*/
|
||||
void lv_canvas_finish_layer(lv_obj_t * canvas, lv_layer_t * layer);
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -389,13 +389,6 @@ lv_chart_series_t * lv_chart_get_series_next(const lv_obj_t * obj, const lv_char
|
||||
* Cursor
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Add a cursor with a given color
|
||||
* @param chart pointer to chart object
|
||||
* @param color color of the cursor
|
||||
* @param dir direction of the cursor. `LV_DIR_RIGHT/LEFT/TOP/DOWN/HOR/VER/ALL`. OR-ed values are possible
|
||||
* @return pointer to the created cursor
|
||||
*/
|
||||
lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * obj, lv_color_t color, lv_dir_t dir)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -414,13 +407,6 @@ lv_chart_cursor_t * lv_chart_add_cursor(lv_obj_t * obj, lv_color_t color, lv_di
|
||||
return cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the coordinate of the cursor with respect
|
||||
* to the origin of series area of the chart.
|
||||
* @param chart pointer to a chart object.
|
||||
* @param cursor pointer to the cursor.
|
||||
* @param pos the new coordinate of cursor relative to the series area
|
||||
*/
|
||||
void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_point_t * pos)
|
||||
{
|
||||
LV_ASSERT_NULL(cursor);
|
||||
@@ -431,13 +417,6 @@ void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_po
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the coordinate of the cursor with respect
|
||||
* to the origin of series area of the chart.
|
||||
* @param chart pointer to a chart object.
|
||||
* @param cursor pointer to the cursor.
|
||||
* @param pos the new coordinate of cursor relative to the series area
|
||||
*/
|
||||
void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_chart_series_t * ser, uint32_t point_id)
|
||||
{
|
||||
LV_ASSERT_NULL(cursor);
|
||||
@@ -449,13 +428,7 @@ void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_
|
||||
cursor->ser = ser;
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
/**
|
||||
* Get the coordinate of the cursor with respect
|
||||
* to the origin of series area of the chart.
|
||||
* @param chart pointer to a chart object
|
||||
* @param cursor pointer to cursor
|
||||
* @return coordinate of the cursor as lv_point_t
|
||||
*/
|
||||
|
||||
lv_point_t lv_chart_get_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor)
|
||||
{
|
||||
LV_ASSERT_NULL(cursor);
|
||||
|
||||
@@ -52,7 +52,7 @@ lv_obj_t * lv_checkbox_create(lv_obj_t * parent);
|
||||
/**
|
||||
* Set the text of a check box. `txt` will be copied and may be deallocated
|
||||
* after this function returns.
|
||||
* @param obj pointer to a check box
|
||||
* @param obj pointer to a check box
|
||||
* @param txt the text of the check box. NULL to refresh with the current text.
|
||||
*/
|
||||
void lv_checkbox_set_text(lv_obj_t * obj, const char * txt);
|
||||
@@ -60,7 +60,7 @@ void lv_checkbox_set_text(lv_obj_t * obj, const char * txt);
|
||||
/**
|
||||
* Set the text of a check box. `txt` must not be deallocated during the life
|
||||
* of this checkbox.
|
||||
* @param obj pointer to a check box
|
||||
* @param obj pointer to a check box
|
||||
* @param txt the text of the check box.
|
||||
*/
|
||||
void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt);
|
||||
@@ -71,7 +71,7 @@ void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt);
|
||||
|
||||
/**
|
||||
* Get the text of a check box
|
||||
* @param obj pointer to check box object
|
||||
* @param obj pointer to check box object
|
||||
* @return pointer to the text of the check box
|
||||
*/
|
||||
const char * lv_checkbox_get_text(const lv_obj_t * obj);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_image.h"
|
||||
#if LV_USE_IMG != 0
|
||||
#if LV_USE_IMAGE != 0
|
||||
|
||||
#include "../../stdlib/lv_string.h"
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
*********************/
|
||||
#include "../../lv_conf_internal.h"
|
||||
|
||||
#if LV_USE_IMG != 0
|
||||
#if LV_USE_IMAGE != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if LV_USE_LABEL == 0
|
||||
@@ -321,7 +321,7 @@ lv_image_align_t lv_image_get_align(lv_obj_t * obj);
|
||||
/** Use this macro to declare an image in a C file*/
|
||||
#define LV_IMAGE_DECLARE(var_name) extern const lv_image_dsc_t var_name
|
||||
|
||||
#endif /*LV_USE_IMG*/
|
||||
#endif /*LV_USE_IMAGE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
|
||||
345
src/widgets/imagebutton/lv_imagebutton.c
Normal file
345
src/widgets/imagebutton/lv_imagebutton.c
Normal file
@@ -0,0 +1,345 @@
|
||||
/**
|
||||
* @file lv_imagebutton.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_imagebutton.h"
|
||||
|
||||
#if LV_USE_IMAGEBUTTON != 0
|
||||
|
||||
#include "../../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS &lv_imagebutton_class
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_imagebutton_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void draw_main(lv_event_t * e);
|
||||
static void lv_imagebutton_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
static void refr_image(lv_obj_t * imagebutton);
|
||||
static lv_imagebutton_state_t suggest_state(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
|
||||
static lv_imagebutton_state_t get_state(const lv_obj_t * imagebutton);
|
||||
static void update_src_info(lv_imagebutton_src_info_t * info, const void * src);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
const lv_obj_class_t lv_imagebutton_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.instance_size = sizeof(lv_imagebutton_t),
|
||||
.constructor_cb = lv_imagebutton_constructor,
|
||||
.event_cb = lv_imagebutton_event,
|
||||
.name = "imagebutton",
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_obj_t * lv_imagebutton_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
void lv_imagebutton_set_src(lv_obj_t * obj, lv_imagebutton_state_t state, const void * src_left, const void * src_mid,
|
||||
const void * src_right)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
|
||||
update_src_info(&imagebutton->src_left[state], src_left);
|
||||
update_src_info(&imagebutton->src_mid[state], src_mid);
|
||||
update_src_info(&imagebutton->src_right[state], src_right);
|
||||
|
||||
refr_image(obj);
|
||||
}
|
||||
|
||||
void lv_imagebutton_set_state(lv_obj_t * obj, lv_imagebutton_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_state_t obj_state = LV_STATE_DEFAULT;
|
||||
if(state == LV_IMAGEBUTTON_STATE_PRESSED ||
|
||||
state == LV_IMAGEBUTTON_STATE_CHECKED_PRESSED) obj_state |= LV_STATE_PRESSED;
|
||||
if(state == LV_IMAGEBUTTON_STATE_DISABLED ||
|
||||
state == LV_IMAGEBUTTON_STATE_CHECKED_DISABLED) obj_state |= LV_STATE_DISABLED;
|
||||
if(state == LV_IMAGEBUTTON_STATE_CHECKED_DISABLED || state == LV_IMAGEBUTTON_STATE_CHECKED_PRESSED ||
|
||||
state == LV_IMAGEBUTTON_STATE_CHECKED_RELEASED) {
|
||||
obj_state |= LV_STATE_CHECKED;
|
||||
}
|
||||
|
||||
lv_obj_remove_state(obj, LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_DISABLED);
|
||||
lv_obj_add_state(obj, obj_state);
|
||||
|
||||
refr_image(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
const void * lv_imagebutton_get_src_left(lv_obj_t * obj, lv_imagebutton_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
|
||||
return imagebutton->src_left[state].img_src;
|
||||
}
|
||||
|
||||
const void * lv_imagebutton_get_src_middle(lv_obj_t * obj, lv_imagebutton_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
|
||||
return imagebutton->src_mid[state].img_src;
|
||||
}
|
||||
|
||||
const void * lv_imagebutton_get_src_right(lv_obj_t * obj, lv_imagebutton_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
|
||||
return imagebutton->src_right[state].img_src;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_imagebutton_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
/*Initialize the allocated 'ext'*/
|
||||
|
||||
lv_memzero(&imagebutton->src_mid, sizeof(imagebutton->src_mid));
|
||||
lv_memzero(&imagebutton->src_left, sizeof(imagebutton->src_left));
|
||||
lv_memzero(&imagebutton->src_right, sizeof(imagebutton->src_right));
|
||||
}
|
||||
|
||||
static void lv_imagebutton_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
lv_result_t res = lv_obj_event_base(&lv_imagebutton_class, e);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_PRESSED || code == LV_EVENT_RELEASED || code == LV_EVENT_PRESS_LOST) {
|
||||
refr_image(obj);
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_MAIN) {
|
||||
draw_main(e);
|
||||
}
|
||||
else if(code == LV_EVENT_COVER_CHECK) {
|
||||
lv_cover_check_info_t * info = lv_event_get_param(e);
|
||||
if(info->res != LV_COVER_RES_MASKED) info->res = LV_COVER_RES_NOT_COVER;
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_self_size_info(e);
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
lv_imagebutton_state_t state = suggest_state(obj, get_state(obj));
|
||||
if(imagebutton->src_left[state].img_src == NULL &&
|
||||
imagebutton->src_mid[state].img_src != NULL &&
|
||||
imagebutton->src_right[state].img_src == NULL) {
|
||||
p->x = LV_MAX(p->x, imagebutton->src_mid[state].header.w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_main(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
lv_layer_t * layer = lv_event_get_layer(e);
|
||||
|
||||
/*Just draw_main an image*/
|
||||
lv_imagebutton_state_t state = suggest_state(obj, get_state(obj));
|
||||
|
||||
/*Simply draw the middle src if no tiled*/
|
||||
lv_imagebutton_src_info_t * src_info = &imagebutton->src_left[state];
|
||||
|
||||
int32_t tw = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
int32_t th = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
|
||||
lv_area_t coords;
|
||||
lv_area_copy(&coords, &obj->coords);
|
||||
lv_area_increase(&coords, tw, th);
|
||||
|
||||
lv_draw_image_dsc_t img_dsc;
|
||||
lv_draw_image_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_image_dsc(obj, LV_PART_MAIN, &img_dsc);
|
||||
|
||||
lv_area_t coords_part;
|
||||
int32_t left_w = 0;
|
||||
int32_t right_w = 0;
|
||||
|
||||
if(src_info->img_src) {
|
||||
left_w = src_info->header.w;
|
||||
coords_part.x1 = coords.x1;
|
||||
coords_part.y1 = coords.y1;
|
||||
coords_part.x2 = coords.x1 + src_info->header.w - 1;
|
||||
coords_part.y2 = coords.y1 + src_info->header.h - 1;
|
||||
img_dsc.src = src_info->img_src;
|
||||
lv_draw_image(layer, &img_dsc, &coords_part);
|
||||
}
|
||||
|
||||
src_info = &imagebutton->src_right[state];
|
||||
if(src_info->img_src) {
|
||||
right_w = src_info->header.w;
|
||||
coords_part.x1 = coords.x2 - src_info->header.w + 1;
|
||||
coords_part.y1 = coords.y1;
|
||||
coords_part.x2 = coords.x2;
|
||||
coords_part.y2 = coords.y1 + src_info->header.h - 1;
|
||||
img_dsc.src = src_info->img_src;
|
||||
lv_draw_image(layer, &img_dsc, &coords_part);
|
||||
}
|
||||
|
||||
src_info = &imagebutton->src_mid[state];
|
||||
if(src_info->img_src) {
|
||||
lv_area_t clip_area_center;
|
||||
clip_area_center.x1 = coords.x1 + left_w;
|
||||
clip_area_center.x2 = coords.x2 - right_w;
|
||||
clip_area_center.y1 = coords.y1;
|
||||
clip_area_center.y2 = coords.y2;
|
||||
|
||||
bool comm_res;
|
||||
comm_res = _lv_area_intersect(&clip_area_center, &clip_area_center, &layer->_clip_area);
|
||||
if(comm_res) {
|
||||
int32_t i;
|
||||
|
||||
const lv_area_t clip_area_ori = layer->_clip_area;
|
||||
layer->_clip_area = clip_area_center;
|
||||
|
||||
coords_part.x1 = coords.x1 + left_w;
|
||||
coords_part.y1 = coords.y1;
|
||||
coords_part.x2 = coords_part.x1 + src_info->header.w - 1;
|
||||
coords_part.y2 = coords_part.y1 + src_info->header.h - 1;
|
||||
|
||||
for(i = coords_part.x1; i < (int32_t)(clip_area_center.x2 + src_info->header.w - 1); i += src_info->header.w) {
|
||||
img_dsc.src = src_info->img_src;
|
||||
lv_draw_image(layer, &img_dsc, &coords_part);
|
||||
coords_part.x1 = coords_part.x2 + 1;
|
||||
coords_part.x2 += src_info->header.w;
|
||||
}
|
||||
layer->_clip_area = clip_area_ori;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void refr_image(lv_obj_t * obj)
|
||||
{
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
lv_imagebutton_state_t state = suggest_state(obj, get_state(obj));
|
||||
|
||||
const void * src = imagebutton->src_mid[state].img_src;
|
||||
if(src == NULL) return;
|
||||
|
||||
lv_obj_refresh_self_size(obj);
|
||||
lv_obj_set_height(obj, imagebutton->src_mid[state].header.h); /*Keep the user defined width*/
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* If `src` is not defined for the current state try to get a state which is related to the current but has `src`.
|
||||
* E.g. if the PRESSED src is not set but the RELEASED does, use the RELEASED.
|
||||
* @param imagebutton pointer to an image button
|
||||
* @param state the state to convert
|
||||
* @return the suggested state
|
||||
*/
|
||||
static lv_imagebutton_state_t suggest_state(lv_obj_t * obj, lv_imagebutton_state_t state)
|
||||
{
|
||||
lv_imagebutton_t * imagebutton = (lv_imagebutton_t *)obj;
|
||||
if(imagebutton->src_mid[state].img_src == NULL) {
|
||||
switch(state) {
|
||||
case LV_IMAGEBUTTON_STATE_PRESSED:
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_RELEASED].img_src) return LV_IMAGEBUTTON_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMAGEBUTTON_STATE_CHECKED_RELEASED:
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_RELEASED].img_src) return LV_IMAGEBUTTON_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMAGEBUTTON_STATE_CHECKED_PRESSED:
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_CHECKED_RELEASED].img_src) return LV_IMAGEBUTTON_STATE_CHECKED_RELEASED;
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_PRESSED].img_src) return LV_IMAGEBUTTON_STATE_PRESSED;
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_RELEASED].img_src) return LV_IMAGEBUTTON_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMAGEBUTTON_STATE_DISABLED:
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_RELEASED].img_src) return LV_IMAGEBUTTON_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMAGEBUTTON_STATE_CHECKED_DISABLED:
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_CHECKED_RELEASED].img_src) return LV_IMAGEBUTTON_STATE_CHECKED_RELEASED;
|
||||
if(imagebutton->src_mid[LV_IMAGEBUTTON_STATE_RELEASED].img_src) return LV_IMAGEBUTTON_STATE_RELEASED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static lv_imagebutton_state_t get_state(const lv_obj_t * imagebutton)
|
||||
{
|
||||
LV_ASSERT_OBJ(imagebutton, MY_CLASS);
|
||||
|
||||
lv_state_t obj_state = lv_obj_get_state(imagebutton);
|
||||
|
||||
if(obj_state & LV_STATE_DISABLED) {
|
||||
if(obj_state & LV_STATE_CHECKED) return LV_IMAGEBUTTON_STATE_CHECKED_DISABLED;
|
||||
else return LV_IMAGEBUTTON_STATE_DISABLED;
|
||||
}
|
||||
|
||||
if(obj_state & LV_STATE_CHECKED) {
|
||||
if(obj_state & LV_STATE_PRESSED) return LV_IMAGEBUTTON_STATE_CHECKED_PRESSED;
|
||||
else return LV_IMAGEBUTTON_STATE_CHECKED_RELEASED;
|
||||
}
|
||||
else {
|
||||
if(obj_state & LV_STATE_PRESSED) return LV_IMAGEBUTTON_STATE_PRESSED;
|
||||
else return LV_IMAGEBUTTON_STATE_RELEASED;
|
||||
}
|
||||
}
|
||||
|
||||
static void update_src_info(lv_imagebutton_src_info_t * info, const void * src)
|
||||
{
|
||||
if(!src) {
|
||||
lv_memzero(info, sizeof(lv_imagebutton_src_info_t));
|
||||
return;
|
||||
}
|
||||
|
||||
lv_result_t res = lv_image_decoder_get_info(src, &info->header);
|
||||
if(res != LV_RESULT_OK) {
|
||||
LV_LOG_WARN("can't get info");
|
||||
return;
|
||||
}
|
||||
|
||||
info->img_src = src;
|
||||
}
|
||||
|
||||
#endif
|
||||
134
src/widgets/imagebutton/lv_imagebutton.h
Normal file
134
src/widgets/imagebutton/lv_imagebutton.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @file lv_imagebutton.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_IMAGEBUTTON_H
|
||||
#define LV_IMAGEBUTTON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
#if LV_USE_IMAGEBUTTON != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
typedef enum {
|
||||
LV_IMAGEBUTTON_STATE_RELEASED,
|
||||
LV_IMAGEBUTTON_STATE_PRESSED,
|
||||
LV_IMAGEBUTTON_STATE_DISABLED,
|
||||
LV_IMAGEBUTTON_STATE_CHECKED_RELEASED,
|
||||
LV_IMAGEBUTTON_STATE_CHECKED_PRESSED,
|
||||
LV_IMAGEBUTTON_STATE_CHECKED_DISABLED,
|
||||
_LV_IMAGEBUTTON_STATE_NUM,
|
||||
} lv_imagebutton_state_t;
|
||||
|
||||
typedef struct {
|
||||
const void * img_src;
|
||||
lv_image_header_t header;
|
||||
} lv_imagebutton_src_info_t;
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of image button*/
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_imagebutton_src_info_t src_mid[_LV_IMAGEBUTTON_STATE_NUM]; /*Store center images to each state*/
|
||||
lv_imagebutton_src_info_t src_left[_LV_IMAGEBUTTON_STATE_NUM]; /*Store left side images to each state*/
|
||||
lv_imagebutton_src_info_t src_right[_LV_IMAGEBUTTON_STATE_NUM]; /*Store right side images to each state*/
|
||||
} lv_imagebutton_t;
|
||||
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_imagebutton_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an image button object
|
||||
* @param parent pointer to an object, it will be the parent of the new image button
|
||||
* @return pointer to the created image button
|
||||
*/
|
||||
lv_obj_t * lv_imagebutton_create(lv_obj_t * parent);
|
||||
|
||||
/*======================
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set images for a state of the image button
|
||||
* @param imagebutton pointer to an image button object
|
||||
* @param state for which state set the new image
|
||||
* @param src_left pointer to an image source for the left side of the button (a C array or path to
|
||||
* a file)
|
||||
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C
|
||||
* array or path to a file)
|
||||
* @param src_right pointer to an image source for the right side of the button (a C array or path
|
||||
* to a file)
|
||||
*/
|
||||
void lv_imagebutton_set_src(lv_obj_t * imagebutton, lv_imagebutton_state_t state, const void * src_left,
|
||||
const void * src_mid,
|
||||
const void * src_right);
|
||||
|
||||
/**
|
||||
* Use this function instead of `lv_obj_add/remove_state` to set a state manually
|
||||
* @param imagebutton pointer to an image button object
|
||||
* @param state the new state
|
||||
*/
|
||||
void lv_imagebutton_set_state(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the left image in a given state
|
||||
* @param imagebutton pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the left image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imagebutton_get_src_left(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
|
||||
|
||||
/**
|
||||
* Get the middle image in a given state
|
||||
* @param imagebutton pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the middle image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imagebutton_get_src_middle(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
|
||||
|
||||
/**
|
||||
* Get the right image in a given state
|
||||
* @param imagebutton pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the left image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imagebutton_get_src_right(lv_obj_t * imagebutton, lv_imagebutton_state_t state);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_IMAGEBUTTON*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_IMAGEBUTTON_H*/
|
||||
@@ -1,377 +0,0 @@
|
||||
/**
|
||||
* @file lv_imgbtn.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_imgbtn.h"
|
||||
|
||||
#if LV_USE_IMGBTN != 0
|
||||
|
||||
#include "../../stdlib/lv_string.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS &lv_imgbtn_class
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_imgbtn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void draw_main(lv_event_t * e);
|
||||
static void lv_imgbtn_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
static void refr_image(lv_obj_t * imgbtn);
|
||||
static lv_imgbtn_state_t suggest_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
|
||||
static lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn);
|
||||
static void update_src_info(lv_imgbtn_src_info_t * info, const void * src);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
const lv_obj_class_t lv_imgbtn_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.instance_size = sizeof(lv_imgbtn_t),
|
||||
.constructor_cb = lv_imgbtn_constructor,
|
||||
.event_cb = lv_imgbtn_event,
|
||||
.name = "imgbtn",
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an image button object
|
||||
* @param parent pointer to an object, it will be the parent of the new image button
|
||||
* @return pointer to the created image button
|
||||
*/
|
||||
lv_obj_t * lv_imgbtn_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set images for a state of the image button
|
||||
* @param obj pointer to an image button object
|
||||
* @param state for which state set the new image
|
||||
* @param src_left pointer to an image source for the left side of the button (a C array or path to
|
||||
* a file)
|
||||
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C
|
||||
* array or path to a file)
|
||||
* @param src_right pointer to an image source for the right side of the button (a C array or path
|
||||
* to a file)
|
||||
*/
|
||||
void lv_imgbtn_set_src(lv_obj_t * obj, lv_imgbtn_state_t state, const void * src_left, const void * src_mid,
|
||||
const void * src_right)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
|
||||
update_src_info(&imgbtn->src_left[state], src_left);
|
||||
update_src_info(&imgbtn->src_mid[state], src_mid);
|
||||
update_src_info(&imgbtn->src_right[state], src_right);
|
||||
|
||||
refr_image(obj);
|
||||
}
|
||||
|
||||
void lv_imgbtn_set_state(lv_obj_t * obj, lv_imgbtn_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_state_t obj_state = LV_STATE_DEFAULT;
|
||||
if(state == LV_IMGBTN_STATE_PRESSED || state == LV_IMGBTN_STATE_CHECKED_PRESSED) obj_state |= LV_STATE_PRESSED;
|
||||
if(state == LV_IMGBTN_STATE_DISABLED || state == LV_IMGBTN_STATE_CHECKED_DISABLED) obj_state |= LV_STATE_DISABLED;
|
||||
if(state == LV_IMGBTN_STATE_CHECKED_DISABLED || state == LV_IMGBTN_STATE_CHECKED_PRESSED ||
|
||||
state == LV_IMGBTN_STATE_CHECKED_RELEASED) {
|
||||
obj_state |= LV_STATE_CHECKED;
|
||||
}
|
||||
|
||||
lv_obj_remove_state(obj, LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_DISABLED);
|
||||
lv_obj_add_state(obj, obj_state);
|
||||
|
||||
refr_image(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the left image in a given state
|
||||
* @param obj pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the left image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imgbtn_get_src_left(lv_obj_t * obj, lv_imgbtn_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
|
||||
return imgbtn->src_left[state].img_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the middle image in a given state
|
||||
* @param obj pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the middle image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imgbtn_get_src_middle(lv_obj_t * obj, lv_imgbtn_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
|
||||
return imgbtn->src_mid[state].img_src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the right image in a given state
|
||||
* @param obj pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the left image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imgbtn_get_src_right(lv_obj_t * obj, lv_imgbtn_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
|
||||
return imgbtn->src_right[state].img_src;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void lv_imgbtn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
/*Initialize the allocated 'ext'*/
|
||||
|
||||
lv_memzero(&imgbtn->src_mid, sizeof(imgbtn->src_mid));
|
||||
lv_memzero(&imgbtn->src_left, sizeof(imgbtn->src_left));
|
||||
lv_memzero(&imgbtn->src_right, sizeof(imgbtn->src_right));
|
||||
}
|
||||
|
||||
static void lv_imgbtn_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
lv_result_t res = lv_obj_event_base(&lv_imgbtn_class, e);
|
||||
if(res != LV_RESULT_OK) return;
|
||||
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_PRESSED || code == LV_EVENT_RELEASED || code == LV_EVENT_PRESS_LOST) {
|
||||
refr_image(obj);
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_MAIN) {
|
||||
draw_main(e);
|
||||
}
|
||||
else if(code == LV_EVENT_COVER_CHECK) {
|
||||
lv_cover_check_info_t * info = lv_event_get_param(e);
|
||||
if(info->res != LV_COVER_RES_MASKED) info->res = LV_COVER_RES_NOT_COVER;
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_self_size_info(e);
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
lv_imgbtn_state_t state = suggest_state(obj, get_state(obj));
|
||||
if(imgbtn->src_left[state].img_src == NULL &&
|
||||
imgbtn->src_mid[state].img_src != NULL &&
|
||||
imgbtn->src_right[state].img_src == NULL) {
|
||||
p->x = LV_MAX(p->x, imgbtn->src_mid[state].header.w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_main(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
lv_layer_t * layer = lv_event_get_layer(e);
|
||||
|
||||
/*Just draw_main an image*/
|
||||
lv_imgbtn_state_t state = suggest_state(obj, get_state(obj));
|
||||
|
||||
/*Simply draw the middle src if no tiled*/
|
||||
lv_imgbtn_src_info_t * src_info = &imgbtn->src_left[state];
|
||||
|
||||
int32_t tw = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
int32_t th = lv_obj_get_style_transform_height(obj, LV_PART_MAIN);
|
||||
lv_area_t coords;
|
||||
lv_area_copy(&coords, &obj->coords);
|
||||
lv_area_increase(&coords, tw, th);
|
||||
|
||||
lv_draw_image_dsc_t img_dsc;
|
||||
lv_draw_image_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_image_dsc(obj, LV_PART_MAIN, &img_dsc);
|
||||
|
||||
lv_area_t coords_part;
|
||||
int32_t left_w = 0;
|
||||
int32_t right_w = 0;
|
||||
|
||||
if(src_info->img_src) {
|
||||
left_w = src_info->header.w;
|
||||
coords_part.x1 = coords.x1;
|
||||
coords_part.y1 = coords.y1;
|
||||
coords_part.x2 = coords.x1 + src_info->header.w - 1;
|
||||
coords_part.y2 = coords.y1 + src_info->header.h - 1;
|
||||
img_dsc.src = src_info->img_src;
|
||||
lv_draw_image(layer, &img_dsc, &coords_part);
|
||||
}
|
||||
|
||||
src_info = &imgbtn->src_right[state];
|
||||
if(src_info->img_src) {
|
||||
right_w = src_info->header.w;
|
||||
coords_part.x1 = coords.x2 - src_info->header.w + 1;
|
||||
coords_part.y1 = coords.y1;
|
||||
coords_part.x2 = coords.x2;
|
||||
coords_part.y2 = coords.y1 + src_info->header.h - 1;
|
||||
img_dsc.src = src_info->img_src;
|
||||
lv_draw_image(layer, &img_dsc, &coords_part);
|
||||
}
|
||||
|
||||
src_info = &imgbtn->src_mid[state];
|
||||
if(src_info->img_src) {
|
||||
lv_area_t clip_area_center;
|
||||
clip_area_center.x1 = coords.x1 + left_w;
|
||||
clip_area_center.x2 = coords.x2 - right_w;
|
||||
clip_area_center.y1 = coords.y1;
|
||||
clip_area_center.y2 = coords.y2;
|
||||
|
||||
bool comm_res;
|
||||
comm_res = _lv_area_intersect(&clip_area_center, &clip_area_center, &layer->_clip_area);
|
||||
if(comm_res) {
|
||||
int32_t i;
|
||||
|
||||
const lv_area_t clip_area_ori = layer->_clip_area;
|
||||
layer->_clip_area = clip_area_center;
|
||||
|
||||
coords_part.x1 = coords.x1 + left_w;
|
||||
coords_part.y1 = coords.y1;
|
||||
coords_part.x2 = coords_part.x1 + src_info->header.w - 1;
|
||||
coords_part.y2 = coords_part.y1 + src_info->header.h - 1;
|
||||
|
||||
for(i = coords_part.x1; i < (int32_t)(clip_area_center.x2 + src_info->header.w - 1); i += src_info->header.w) {
|
||||
img_dsc.src = src_info->img_src;
|
||||
lv_draw_image(layer, &img_dsc, &coords_part);
|
||||
coords_part.x1 = coords_part.x2 + 1;
|
||||
coords_part.x2 += src_info->header.w;
|
||||
}
|
||||
layer->_clip_area = clip_area_ori;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void refr_image(lv_obj_t * obj)
|
||||
{
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
lv_imgbtn_state_t state = suggest_state(obj, get_state(obj));
|
||||
|
||||
const void * src = imgbtn->src_mid[state].img_src;
|
||||
if(src == NULL) return;
|
||||
|
||||
lv_obj_refresh_self_size(obj);
|
||||
lv_obj_set_height(obj, imgbtn->src_mid[state].header.h); /*Keep the user defined width*/
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* If `src` is not defined for the current state try to get a state which is related to the current but has `src`.
|
||||
* E.g. if the PRESSED src is not set but the RELEASED does, use the RELEASED.
|
||||
* @param imgbtn pointer to an image button
|
||||
* @param state the state to convert
|
||||
* @return the suggested state
|
||||
*/
|
||||
static lv_imgbtn_state_t suggest_state(lv_obj_t * obj, lv_imgbtn_state_t state)
|
||||
{
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
if(imgbtn->src_mid[state].img_src == NULL) {
|
||||
switch(state) {
|
||||
case LV_IMGBTN_STATE_PRESSED:
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_RELEASED].img_src) return LV_IMGBTN_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMGBTN_STATE_CHECKED_RELEASED:
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_RELEASED].img_src) return LV_IMGBTN_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMGBTN_STATE_CHECKED_PRESSED:
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_CHECKED_RELEASED].img_src) return LV_IMGBTN_STATE_CHECKED_RELEASED;
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_PRESSED].img_src) return LV_IMGBTN_STATE_PRESSED;
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_RELEASED].img_src) return LV_IMGBTN_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMGBTN_STATE_DISABLED:
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_RELEASED].img_src) return LV_IMGBTN_STATE_RELEASED;
|
||||
break;
|
||||
case LV_IMGBTN_STATE_CHECKED_DISABLED:
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_CHECKED_RELEASED].img_src) return LV_IMGBTN_STATE_CHECKED_RELEASED;
|
||||
if(imgbtn->src_mid[LV_IMGBTN_STATE_RELEASED].img_src) return LV_IMGBTN_STATE_RELEASED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn)
|
||||
{
|
||||
LV_ASSERT_OBJ(imgbtn, MY_CLASS);
|
||||
|
||||
lv_state_t obj_state = lv_obj_get_state(imgbtn);
|
||||
|
||||
if(obj_state & LV_STATE_DISABLED) {
|
||||
if(obj_state & LV_STATE_CHECKED) return LV_IMGBTN_STATE_CHECKED_DISABLED;
|
||||
else return LV_IMGBTN_STATE_DISABLED;
|
||||
}
|
||||
|
||||
if(obj_state & LV_STATE_CHECKED) {
|
||||
if(obj_state & LV_STATE_PRESSED) return LV_IMGBTN_STATE_CHECKED_PRESSED;
|
||||
else return LV_IMGBTN_STATE_CHECKED_RELEASED;
|
||||
}
|
||||
else {
|
||||
if(obj_state & LV_STATE_PRESSED) return LV_IMGBTN_STATE_PRESSED;
|
||||
else return LV_IMGBTN_STATE_RELEASED;
|
||||
}
|
||||
}
|
||||
|
||||
static void update_src_info(lv_imgbtn_src_info_t * info, const void * src)
|
||||
{
|
||||
if(!src) {
|
||||
lv_memzero(info, sizeof(lv_imgbtn_src_info_t));
|
||||
return;
|
||||
}
|
||||
|
||||
lv_result_t res = lv_image_decoder_get_info(src, &info->header);
|
||||
if(res != LV_RESULT_OK) {
|
||||
LV_LOG_WARN("can't get info");
|
||||
return;
|
||||
}
|
||||
|
||||
info->img_src = src;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,133 +0,0 @@
|
||||
/**
|
||||
* @file lv_imgbtn.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_IMGBTN_H
|
||||
#define LV_IMGBTN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../core/lv_obj.h"
|
||||
|
||||
#if LV_USE_IMGBTN != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
typedef enum {
|
||||
LV_IMGBTN_STATE_RELEASED,
|
||||
LV_IMGBTN_STATE_PRESSED,
|
||||
LV_IMGBTN_STATE_DISABLED,
|
||||
LV_IMGBTN_STATE_CHECKED_RELEASED,
|
||||
LV_IMGBTN_STATE_CHECKED_PRESSED,
|
||||
LV_IMGBTN_STATE_CHECKED_DISABLED,
|
||||
_LV_IMGBTN_STATE_NUM,
|
||||
} lv_imgbtn_state_t;
|
||||
|
||||
typedef struct {
|
||||
const void * img_src;
|
||||
lv_image_header_t header;
|
||||
} lv_imgbtn_src_info_t;
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Data of image button*/
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_imgbtn_src_info_t src_mid[_LV_IMGBTN_STATE_NUM]; /*Store center images to each state*/
|
||||
lv_imgbtn_src_info_t src_left[_LV_IMGBTN_STATE_NUM]; /*Store left side images to each state*/
|
||||
lv_imgbtn_src_info_t src_right[_LV_IMGBTN_STATE_NUM]; /*Store right side images to each state*/
|
||||
} lv_imgbtn_t;
|
||||
|
||||
LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_imgbtn_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create an image button object
|
||||
* @param parent pointer to an object, it will be the parent of the new image button
|
||||
* @return pointer to the created image button
|
||||
*/
|
||||
lv_obj_t * lv_imgbtn_create(lv_obj_t * parent);
|
||||
|
||||
/*======================
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set images for a state of the image button
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state for which state set the new image
|
||||
* @param src_left pointer to an image source for the left side of the button (a C array or path to
|
||||
* a file)
|
||||
* @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C
|
||||
* array or path to a file)
|
||||
* @param src_right pointer to an image source for the right side of the button (a C array or path
|
||||
* to a file)
|
||||
*/
|
||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid,
|
||||
const void * src_right);
|
||||
|
||||
/**
|
||||
* Use this function instead of `lv_obj_add/remove_state` to set a state manually
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state the new state
|
||||
*/
|
||||
void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the left image in a given state
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the left image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
|
||||
|
||||
/**
|
||||
* Get the middle image in a given state
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the middle image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
|
||||
|
||||
/**
|
||||
* Get the right image in a given state
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state the state where to get the image (from `lv_button_state_t`) `
|
||||
* @return pointer to the left image source (a C array or path to a file)
|
||||
*/
|
||||
const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_IMGBTN*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_IMGBTN_H*/
|
||||
@@ -177,11 +177,6 @@ static const lv_buttonmatrix_ctrl_t * kb_ctrl[10] = {
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a Keyboard object
|
||||
* @param parent pointer to an object, it will be the parent of the new keyboard
|
||||
* @return pointer to the created keyboard
|
||||
*/
|
||||
lv_obj_t * lv_keyboard_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin");
|
||||
@@ -194,11 +189,6 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * parent)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param ta pointer to a Text Area object to write there
|
||||
*/
|
||||
void lv_keyboard_set_textarea(lv_obj_t * obj, lv_obj_t * ta)
|
||||
{
|
||||
if(ta) {
|
||||
@@ -221,11 +211,6 @@ void lv_keyboard_set_textarea(lv_obj_t * obj, lv_obj_t * ta)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new a mode (text or number map)
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param mode the mode from 'lv_keyboard_mode_t'
|
||||
*/
|
||||
void lv_keyboard_set_mode(lv_obj_t * obj, lv_keyboard_mode_t mode)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -236,11 +221,6 @@ void lv_keyboard_set_mode(lv_obj_t * obj, lv_keyboard_mode_t mode)
|
||||
lv_keyboard_update_map(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the button title in a popover when pressed.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param en whether "popovers" mode is enabled
|
||||
*/
|
||||
void lv_keyboard_set_popovers(lv_obj_t * obj, bool en)
|
||||
{
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
@@ -253,13 +233,6 @@ void lv_keyboard_set_popovers(lv_obj_t * obj, bool en)
|
||||
lv_keyboard_update_ctrl_map(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new map for the keyboard
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param mode keyboard map to alter 'lv_keyboard_mode_t'
|
||||
* @param map pointer to a string array to describe the map.
|
||||
* See 'lv_buttonmatrix_set_map()' for more info.
|
||||
*/
|
||||
void lv_keyboard_set_map(lv_obj_t * obj, lv_keyboard_mode_t mode, const char * map[],
|
||||
const lv_buttonmatrix_ctrl_t ctrl_map[])
|
||||
{
|
||||
@@ -273,11 +246,6 @@ void lv_keyboard_set_map(lv_obj_t * obj, lv_keyboard_mode_t mode, const char * m
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return pointer to the assigned Text Area object
|
||||
*/
|
||||
lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -285,11 +253,6 @@ lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * obj)
|
||||
return keyboard->ta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new a mode (text or number map)
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return the current mode from 'lv_keyboard_mode_t'
|
||||
*/
|
||||
lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -297,11 +260,6 @@ lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * obj)
|
||||
return keyboard->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether "popovers" mode is enabled or not.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return true: "popovers" mode is enabled; false: disabled
|
||||
*/
|
||||
bool lv_buttonmatrix_get_popovers(const lv_obj_t * obj)
|
||||
{
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
@@ -312,13 +270,6 @@ bool lv_buttonmatrix_get_popovers(const lv_obj_t * obj)
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Default keyboard event to add characters to the Text area and change the map.
|
||||
* If a custom `event_cb` is added to the keyboard this function can be called from it to handle the
|
||||
* button clicks
|
||||
* @param kb pointer to a keyboard
|
||||
* @param event the triggering event
|
||||
*/
|
||||
void lv_keyboard_def_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
@@ -18,12 +18,12 @@ extern "C" {
|
||||
#if LV_USE_KEYBOARD
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if LV_USE_BTNMATRIX == 0
|
||||
#error "lv_kb: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) "
|
||||
#if LV_USE_BUTTONMATRIX == 0
|
||||
#error "lv_buttonmatrix is required. Enable it in lv_conf.h (LV_USE_BUTTONMATRIX 1) "
|
||||
#endif
|
||||
|
||||
#if LV_USE_TEXTAREA == 0
|
||||
#error "lv_kb: lv_ta is required. Enable it in lv_conf.h (LV_USE_TEXTAREA 1) "
|
||||
#error "lv_textare is required. Enable it in lv_conf.h (LV_USE_TEXTAREA 1) "
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
@@ -72,8 +72,8 @@ LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_keyboard_class;
|
||||
|
||||
/**
|
||||
* Create a Keyboard object
|
||||
* @param parent pointer to an object, it will be the parent of the new keyboard
|
||||
* @return pointer to the created keyboard
|
||||
* @param parent pointer to an object, it will be the parent of the new keyboard
|
||||
* @return pointer to the created keyboard
|
||||
*/
|
||||
lv_obj_t * lv_keyboard_create(lv_obj_t * parent);
|
||||
|
||||
@@ -83,32 +83,32 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param ta pointer to a Text Area object to write there
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param ta pointer to a Text Area object to write there
|
||||
*/
|
||||
void lv_keyboard_set_textarea(lv_obj_t * kb, lv_obj_t * ta);
|
||||
|
||||
/**
|
||||
* Set a new a mode (text or number map)
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param mode the mode from 'lv_keyboard_mode_t'
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param mode the mode from 'lv_keyboard_mode_t'
|
||||
*/
|
||||
void lv_keyboard_set_mode(lv_obj_t * kb, lv_keyboard_mode_t mode);
|
||||
|
||||
/**
|
||||
* Show the button title in a popover when pressed.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param en whether "popovers" mode is enabled
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param en whether "popovers" mode is enabled
|
||||
*/
|
||||
void lv_keyboard_set_popovers(lv_obj_t * kb, bool en);
|
||||
|
||||
/**
|
||||
* Set a new map for the keyboard
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param mode keyboard map to alter 'lv_keyboard_mode_t'
|
||||
* @param map pointer to a string array to describe the map.
|
||||
* See 'lv_buttonmatrix_set_map()' for more info.
|
||||
* @param ctrl_map
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param mode keyboard map to alter 'lv_keyboard_mode_t'
|
||||
* @param map pointer to a string array to describe the map.
|
||||
* See 'lv_buttonmatrix_set_map()' for more info.
|
||||
* @param ctrl_map See 'lv_buttonmatrix_set_ctrl_map()' for more info.
|
||||
|
||||
*/
|
||||
void lv_keyboard_set_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const char * map[],
|
||||
@@ -120,29 +120,29 @@ void lv_keyboard_set_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const char * ma
|
||||
|
||||
/**
|
||||
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return pointer to the assigned Text Area object
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return pointer to the assigned Text Area object
|
||||
*/
|
||||
lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * kb);
|
||||
|
||||
/**
|
||||
* Set a new a mode (text or number map)
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return the current mode from 'lv_keyboard_mode_t'
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return the current mode from 'lv_keyboard_mode_t'
|
||||
*/
|
||||
lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * kb);
|
||||
|
||||
/**
|
||||
* Tell whether "popovers" mode is enabled or not.
|
||||
* @param obj pointer to a Keyboard object
|
||||
* @return true: "popovers" mode is enabled; false: disabled
|
||||
* @param obj pointer to a Keyboard object
|
||||
* @return true: "popovers" mode is enabled; false: disabled
|
||||
*/
|
||||
bool lv_buttonmatrix_get_popovers(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the current map of a keyboard
|
||||
* @param kb pointer to a keyboard object
|
||||
* @return the current map
|
||||
* @param kb pointer to a keyboard object
|
||||
* @return the current map
|
||||
*/
|
||||
static inline const char ** lv_keyboard_get_map_array(const lv_obj_t * kb)
|
||||
{
|
||||
|
||||
@@ -50,11 +50,6 @@ const lv_obj_class_t lv_led_class = {
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a led object
|
||||
* @param parent pointer to an object, it will be the parent of the new led
|
||||
* @return pointer to the created led
|
||||
*/
|
||||
lv_obj_t * lv_led_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin");
|
||||
@@ -67,11 +62,6 @@ lv_obj_t * lv_led_create(lv_obj_t * parent)
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the color of the LED
|
||||
* @param led pointer to a LED object
|
||||
* @param color the color of the LED
|
||||
*/
|
||||
void lv_led_set_color(lv_obj_t * obj, lv_color_t color)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -81,11 +71,6 @@ void lv_led_set_color(lv_obj_t * obj, lv_color_t color)
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the brightness of a LED object
|
||||
* @param led pointer to a LED object
|
||||
* @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light)
|
||||
*/
|
||||
void lv_led_set_brightness(lv_obj_t * obj, uint8_t bright)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
@@ -99,28 +84,16 @@ void lv_led_set_brightness(lv_obj_t * obj, uint8_t bright)
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Light on a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_on(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_brightness(led, LV_LED_BRIGHT_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Light off a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_off(lv_obj_t * led)
|
||||
{
|
||||
lv_led_set_brightness(led, LV_LED_BRIGHT_MIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the state of a LED
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_toggle(lv_obj_t * obj)
|
||||
{
|
||||
uint8_t bright = lv_led_get_brightness(obj);
|
||||
@@ -134,11 +107,6 @@ void lv_led_toggle(lv_obj_t * obj)
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the brightness of a LED object
|
||||
* @param led pointer to LED object
|
||||
* @return bright 0 (max. dark) ... 255 (max. light)
|
||||
*/
|
||||
uint8_t lv_led_get_brightness(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
@@ -49,8 +49,8 @@ LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_led_class;
|
||||
|
||||
/**
|
||||
* Create a led object
|
||||
* @param parent pointer to an object, it will be the parent of the new led
|
||||
* @return pointer to the created led
|
||||
* @param parent pointer to an object, it will be the parent of the new led
|
||||
* @return pointer to the created led
|
||||
*/
|
||||
lv_obj_t * lv_led_create(lv_obj_t * parent);
|
||||
|
||||
@@ -63,33 +63,33 @@ void lv_led_set_color(lv_obj_t * led, lv_color_t color);
|
||||
|
||||
/**
|
||||
* Set the brightness of a LED object
|
||||
* @param led pointer to a LED object
|
||||
* @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light)
|
||||
* @param led pointer to a LED object
|
||||
* @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light)
|
||||
*/
|
||||
void lv_led_set_brightness(lv_obj_t * led, uint8_t bright);
|
||||
|
||||
/**
|
||||
* Light on a LED
|
||||
* @param led pointer to a LED object
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_on(lv_obj_t * led);
|
||||
|
||||
/**
|
||||
* Light off a LED
|
||||
* @param led pointer to a LED object
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_off(lv_obj_t * led);
|
||||
|
||||
/**
|
||||
* Toggle the state of a LED
|
||||
* @param led pointer to a LED object
|
||||
* @param led pointer to a LED object
|
||||
*/
|
||||
void lv_led_toggle(lv_obj_t * led);
|
||||
|
||||
/**
|
||||
* Get the brightness of a LED object
|
||||
* @param obj pointer to LED object
|
||||
* @return bright 0 (max. dark) ... 255 (max. light)
|
||||
* @param obj pointer to LED object
|
||||
* @return bright 0 (max. dark) ... 255 (max. light)
|
||||
*/
|
||||
uint8_t lv_led_get_brightness(const lv_obj_t * obj);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user