update asserts

This commit is contained in:
Gabor Kiss-Vamosi
2021-02-08 09:53:03 +01:00
parent 956a367dbc
commit 7bec13c2b9
173 changed files with 4906 additions and 696 deletions

View File

@@ -0,0 +1,35 @@
#include "../../../lvgl.h"
#include <stdio.h>
#if LV_USE_DROPDOWN
static void event_handler(lv_obj_t * obj, lv_event_t event)
{
if(event == LV_EVENT_VALUE_CHANGED) {
char buf[32];
lv_dropdown_get_selected_str(obj, buf, sizeof(buf));
printf("Option: %s\n", buf);
}
}
void lv_example_dropdown_1(void)
{
/*Create a normal drop down list*/
lv_obj_t * dd = lv_dropdown_create(lv_scr_act(), NULL);
lv_dropdown_set_options(dd, "Apple\n"
"Banana\n"
"Orange\n"
"Cherry\n"
"Grape\n"
"Raspberry\n"
"Melon\n"
"Orange\n"
"Lemon\n"
"Nuts");
lv_obj_align(dd, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
lv_obj_add_event_cb(dd, event_handler, NULL);
}
#endif

View File

@@ -0,0 +1,21 @@
def event_handler(obj, event):
if event == lv.EVENT.VALUE_CHANGED:
option = " "*10 # should be large enough to store the option
obj.get_selected_str(option, len(option))
# .strip() removes trailing spaces
print("Option: \"%s\"" % option.strip())
# Create a drop down list
ddlist = lv.ddlist(lv.scr_act())
ddlist.set_options("\n".join([
"Apple",
"Banana",
"Orange",
"Melon",
"Grape",
"Raspberry"]))
ddlist.set_fix_width(150)
ddlist.set_draw_arrow(True)
ddlist.align(None, lv.ALIGN.IN_TOP_MID, 0, 20)
ddlist.set_event_cb(event_handler)

View File

@@ -0,0 +1,42 @@
#include "../../../lvgl.h"
#include <stdio.h>
#if LV_USE_DROPDOWN
/**
* Create a drop down, up, left and right menus
*/
void lv_example_dropdown_2(void)
{
static const char * opts = "Apple\n"
"Banana\n"
"Orange\n"
"Melon\n"
"Grape\n"
"Raspberry";
lv_obj_t * dd;
dd = lv_dropdown_create(lv_scr_act(), NULL);
lv_dropdown_set_options_static(dd, opts);
lv_obj_align(dd, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
dd = lv_dropdown_create(lv_scr_act(), NULL);
lv_dropdown_set_options_static(dd, opts);
lv_dropdown_set_dir(dd, LV_DIR_BOTTOM);
lv_dropdown_set_symbol(dd, LV_SYMBOL_UP);
lv_obj_align(dd, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10);
dd = lv_dropdown_create(lv_scr_act(), NULL);
lv_dropdown_set_options_static(dd, opts);
lv_dropdown_set_dir(dd, LV_DIR_RIGHT);
lv_dropdown_set_symbol(dd, LV_SYMBOL_RIGHT);
lv_obj_align(dd, NULL, LV_ALIGN_IN_LEFT_MID, 10, 0);
dd = lv_dropdown_create(lv_scr_act(), NULL);
lv_dropdown_set_options_static(dd, opts);
lv_dropdown_set_dir(dd, LV_DIR_LEFT);
lv_dropdown_set_symbol(dd, LV_SYMBOL_LEFT);
lv_obj_align(dd, NULL, LV_ALIGN_IN_RIGHT_MID, -10, 0);
}
#endif

View File

@@ -0,0 +1,23 @@
# Create a drop UP list by applying auto realign
# Create a drop down list
ddlist = lv.ddlist(lv.scr_act())
ddlist.set_options("\n".join([
"Apple",
"Banana",
"Orange",
"Melon",
"Grape",
"Raspberry"]))
ddlist.set_fix_width(150)
ddlist.set_fix_height(150)
ddlist.set_draw_arrow(True)
# Enable auto-realign when the size changes.
# It will keep the bottom of the ddlist fixed
ddlist.set_auto_realign(True)
# It will be called automatically when the size changes
ddlist.align(None, lv.ALIGN.IN_BOTTOM_MID, 0, -20)

View File

@@ -0,0 +1,34 @@
#include "../../../lvgl.h"
#include <stdio.h>
#if LV_USE_DROPDOWN
/**
* Create a menu from a drop-down list and show some drop-down list features and styling
*/
void lv_example_dropdown_3(void)
{
/*Create a drop down list*/
lv_obj_t * dd = lv_dropdown_create(lv_scr_act(), NULL);
lv_obj_align(dd, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10);
lv_dropdown_set_options(dd, "New\n"
"Open\n"
"Edit\n"
"Close\n"
"Preferences\n"
"Exit");
/*Set a fixed text to display on the button of the drop-down list*/
lv_dropdown_set_text(dd, "Menu");
/*Use a custom image as down icon*/
LV_IMG_DECLARE(img_caret_down)
lv_dropdown_set_symbol(dd, &img_caret_down);
/* Remove the style of the selected part on the list.
* In a menu we don't need to show the last clicked item*/
lv_obj_t * list = lv_dropdown_get_list(dd);
lv_obj_remove_style(list, LV_PART_SELECTED, LV_STATE_DEFAULT, NULL);
}
#endif