mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 00:51:49 +08:00
add all widgets and widget examples
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
C
|
||||
^
|
||||
|
||||
Simple Image button
|
||||
"""""""""""""""""""
|
||||
|
||||
.. lv_example:: lv_ex_widgets/lv_ex_imgbtn/lv_ex_imgbtn_1
|
||||
:language: c
|
||||
|
||||
MicroPython
|
||||
^^^^^^^^^^^
|
||||
|
||||
No examples yet.
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_IMGBTN
|
||||
|
||||
void lv_example_imgbtn_1(void)
|
||||
{
|
||||
LV_IMG_DECLARE(imgbtn_left);
|
||||
LV_IMG_DECLARE(imgbtn_right);
|
||||
LV_IMG_DECLARE(imgbtn_mid);
|
||||
|
||||
|
||||
/* Create a transition animation on width transformation.*/
|
||||
static lv_style_prop_t tr_prop[] = {LV_STYLE_TRANSFORM_WIDTH, 0};
|
||||
static lv_style_transition_dsc_t tr;
|
||||
lv_style_transition_dsc_init(&tr, tr_prop, &lv_anim_path_def, 300, 0);
|
||||
|
||||
static lv_style_t style_def;
|
||||
lv_style_init(&style_def);
|
||||
lv_style_set_text_color(&style_def, LV_COLOR_WHITE);
|
||||
lv_style_set_transition(&style_def, &tr);
|
||||
|
||||
/*Darken the button when pressed and make it wider*/
|
||||
static lv_style_t style_pr;
|
||||
lv_style_init(&style_pr);
|
||||
lv_style_set_img_recolor_opa(&style_pr, LV_OPA_30);
|
||||
lv_style_set_img_recolor(&style_pr, LV_COLOR_BLACK);
|
||||
lv_style_set_transform_width(&style_pr, 20);
|
||||
|
||||
/*Create an image button*/
|
||||
lv_obj_t * imgbtn1 = lv_imgbtn_create(lv_scr_act());
|
||||
lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, &imgbtn_left, &imgbtn_mid, &imgbtn_right);
|
||||
lv_obj_add_style(imgbtn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_def);
|
||||
lv_obj_add_style(imgbtn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
|
||||
|
||||
lv_obj_align(imgbtn1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Create a label on the image button*/
|
||||
lv_obj_t * label = lv_label_create(imgbtn1, NULL);
|
||||
lv_label_set_text(label, "Button");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, -4);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@ void lv_example_tabview_1(void)
|
||||
{
|
||||
/*Create a Tab view object*/
|
||||
lv_obj_t *tabview;
|
||||
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_RIGHT, 50);
|
||||
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_TOP, 50);
|
||||
|
||||
/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
|
||||
lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1");
|
||||
|
||||
Reference in New Issue
Block a user