api(style) remove content style proeprties
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
void lv_example_arc_1(void)
|
||||
{
|
||||
/*Create an Arc*/
|
||||
lv_obj_t * arc = lv_arc_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * arc = lv_arc_create(lv_scr_act());
|
||||
lv_arc_set_end_angle(arc, 200);
|
||||
lv_obj_set_size(arc, 150, 150);
|
||||
lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
@@ -26,7 +26,7 @@ static void arc_loader(lv_timer_t * t)
|
||||
void lv_example_arc_2(void)
|
||||
{
|
||||
/*Create an Arc*/
|
||||
lv_obj_t * arc = lv_arc_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * arc = lv_arc_create(lv_scr_act());
|
||||
lv_arc_set_bg_angles(arc, 0, 360);
|
||||
lv_arc_set_angles(arc, 270, 270);
|
||||
lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void lv_example_bar_1(void)
|
||||
{
|
||||
lv_obj_t * bar1 = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * bar1 = lv_bar_create(lv_scr_act());
|
||||
lv_obj_set_size(bar1, 200, 20);
|
||||
lv_obj_align(bar1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_bar_set_value(bar1, 70, LV_ANIM_OFF);
|
||||
|
||||
@@ -21,7 +21,7 @@ void lv_example_bar_2(void)
|
||||
lv_style_set_bg_color(&style_indic, lv_color_blue());
|
||||
lv_style_set_radius(&style_indic, 3);
|
||||
|
||||
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * bar = lv_bar_create(lv_scr_act());
|
||||
lv_obj_remove_style(bar, LV_PART_ANY, LV_STATE_ANY, NULL); /*To have a clean start*/
|
||||
lv_obj_add_style(bar, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
|
||||
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
|
||||
|
||||
@@ -7,7 +7,7 @@ static void set_temp(void * bar, int32_t temp)
|
||||
|
||||
static char buf[10]; /*Only the pointer t saved so must be static*/
|
||||
lv_snprintf(buf, sizeof(buf), "%d°C", temp);
|
||||
lv_obj_set_style_content_text(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
|
||||
// lv_obj_set_style_content_text(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,11 +22,11 @@ void lv_example_bar_3(void)
|
||||
lv_style_set_bg_color(&style_indic, lv_color_red());
|
||||
lv_style_set_bg_grad_color(&style_indic, lv_color_blue());
|
||||
lv_style_set_bg_grad_dir(&style_indic, LV_GRAD_DIR_VER);
|
||||
lv_style_set_content_align(&style_indic, LV_ALIGN_OUT_LEFT_TOP);
|
||||
lv_style_set_content_ofs_x(&style_indic, -3);
|
||||
lv_style_set_content_color(&style_indic, lv_color_grey());
|
||||
// lv_style_set_content_align(&style_indic, LV_ALIGN_OUT_LEFT_TOP);
|
||||
// lv_style_set_content_ofs_x(&style_indic, -3);
|
||||
// lv_style_set_content_color(&style_indic, lv_color_grey());
|
||||
|
||||
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * bar = lv_bar_create(lv_scr_act());
|
||||
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
|
||||
lv_obj_set_size(bar, 20, 200);
|
||||
lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
@@ -14,7 +14,7 @@ void lv_example_bar_4(void)
|
||||
lv_style_set_bg_img_tiled(&style_indic, true);
|
||||
lv_style_set_bg_img_opa(&style_indic, LV_OPA_30);
|
||||
|
||||
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * bar = lv_bar_create(lv_scr_act());
|
||||
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
|
||||
|
||||
lv_obj_set_size(bar, 260, 20);
|
||||
|
||||
@@ -6,25 +6,20 @@
|
||||
*/
|
||||
void lv_example_bar_5(void)
|
||||
{
|
||||
static lv_style_t style_bg;
|
||||
lv_style_init(&style_bg);
|
||||
lv_style_set_content_ofs_y(&style_bg, -3);
|
||||
lv_style_set_content_align(&style_bg, LV_ALIGN_OUT_TOP_MID);
|
||||
|
||||
lv_obj_t * bar_ltr = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * bar_ltr = lv_bar_create(lv_scr_act());
|
||||
lv_obj_set_size(bar_ltr, 200, 20);
|
||||
lv_bar_set_value(bar_ltr, 70, LV_ANIM_OFF);
|
||||
lv_obj_align(bar_ltr, NULL, LV_ALIGN_CENTER, 0, -30);
|
||||
lv_obj_add_style(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
|
||||
lv_obj_set_style_content_text(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, "Left to Right base direction");
|
||||
// lv_obj_add_style(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
|
||||
// lv_obj_set_style_content_text(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, "Left to Right base direction");
|
||||
|
||||
lv_obj_t * bar_rtl = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * bar_rtl = lv_bar_create(lv_scr_act());
|
||||
lv_obj_set_base_dir(bar_rtl, LV_BIDI_DIR_RTL);
|
||||
lv_obj_set_size(bar_rtl, 200, 20);
|
||||
lv_bar_set_value(bar_rtl, 70, LV_ANIM_OFF);
|
||||
lv_obj_align(bar_rtl, NULL, LV_ALIGN_CENTER, 0, 30);
|
||||
lv_obj_add_style(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
|
||||
lv_obj_set_style_content_text(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, "Right to Left base direction");
|
||||
// lv_obj_add_style(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
|
||||
// lv_obj_set_style_content_text(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, "Right to Left base direction");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,73 +1,73 @@
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_BAR && LV_BUILD_EXAMPLES
|
||||
|
||||
static void set_value(void *bar, int32_t v)
|
||||
{
|
||||
lv_bar_set_value(bar, v, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
{
|
||||
if(e == LV_EVENT_DRAW_POST_END) {
|
||||
lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
|
||||
lv_draw_label_dsc_t dsc;
|
||||
lv_draw_label_dsc_init(&dsc);
|
||||
dsc.font = LV_FONT_DEFAULT;
|
||||
|
||||
char buf[8];
|
||||
lv_snprintf(buf, sizeof(buf), "%d", lv_bar_get_value(obj));
|
||||
|
||||
lv_point_t txt_size;
|
||||
lv_txt_get_size(&txt_size, buf, dsc.font, dsc.letter_space, dsc.line_space, LV_COORD_MAX, dsc.flag);
|
||||
|
||||
lv_area_t txt_area;
|
||||
/*If the indicator is long enough put the text inside on the right*/
|
||||
if(lv_area_get_width(&bar->indic_area) > txt_size.x + 20) {
|
||||
txt_area.x2 = bar->indic_area.x2 - 5;
|
||||
txt_area.x1 = txt_area.x2 - txt_size.x + 1;
|
||||
dsc.color = lv_color_white();
|
||||
}
|
||||
/*If the indicator is still short put the text out of it on the right*/
|
||||
else {
|
||||
txt_area.x1 = bar->indic_area.x2 + 5;
|
||||
txt_area.x2 = txt_area.x1 + txt_size.x - 1;
|
||||
dsc.color = lv_color_black();
|
||||
}
|
||||
|
||||
txt_area.y1 = bar->indic_area.y1 + (lv_area_get_height(&bar->indic_area) - txt_size.y) / 2;
|
||||
txt_area.y2 = txt_area.y1 + txt_size.y - 1;
|
||||
|
||||
const lv_area_t * clip_area = lv_event_get_param();
|
||||
lv_draw_label(&txt_area, clip_area, &dsc, buf, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom drawer on bar to display the current value
|
||||
*/
|
||||
void lv_example_bar_6(void)
|
||||
{
|
||||
static lv_style_t style_bg;
|
||||
lv_style_init(&style_bg);
|
||||
lv_style_set_content_ofs_y(&style_bg, -3);
|
||||
lv_style_set_content_align(&style_bg, LV_ALIGN_OUT_TOP_MID);
|
||||
|
||||
lv_obj_t * bar = lv_bar_create(lv_scr_act(), NULL);
|
||||
lv_obj_add_event_cb(bar, event_cb, NULL);
|
||||
lv_obj_set_size(bar, 200, 20);
|
||||
lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, bar);
|
||||
lv_anim_set_values(&a, 0, 100);
|
||||
lv_anim_set_exec_cb(&a, set_value);
|
||||
lv_anim_set_time(&a, 2000);
|
||||
lv_anim_set_playback_time(&a, 2000);
|
||||
lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
|
||||
lv_anim_start(&a);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
//#include "../../../lvgl.h"
|
||||
//#if LV_USE_BAR && LV_BUILD_EXAMPLES
|
||||
//
|
||||
//static void set_value(void *bar, int32_t v)
|
||||
//{
|
||||
// lv_bar_set_value(bar, v, LV_ANIM_OFF);
|
||||
//}
|
||||
//
|
||||
//static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
//{
|
||||
// if(e == LV_EVENT_DRAW_POST_END) {
|
||||
// lv_bar_t * bar = (lv_bar_t *)obj;
|
||||
//
|
||||
// lv_draw_label_dsc_t dsc;
|
||||
// lv_draw_label_dsc_init(&dsc);
|
||||
// dsc.font = LV_FONT_DEFAULT;
|
||||
//
|
||||
// char buf[8];
|
||||
// lv_snprintf(buf, sizeof(buf), "%d", lv_bar_get_value(obj));
|
||||
//
|
||||
// lv_point_t txt_size;
|
||||
// lv_txt_get_size(&txt_size, buf, dsc.font, dsc.letter_space, dsc.line_space, LV_COORD_MAX, dsc.flag);
|
||||
//
|
||||
// lv_area_t txt_area;
|
||||
// /*If the indicator is long enough put the text inside on the right*/
|
||||
// if(lv_area_get_width(&bar->indic_area) > txt_size.x + 20) {
|
||||
// txt_area.x2 = bar->indic_area.x2 - 5;
|
||||
// txt_area.x1 = txt_area.x2 - txt_size.x + 1;
|
||||
// dsc.color = lv_color_white();
|
||||
// }
|
||||
// /*If the indicator is still short put the text out of it on the right*/
|
||||
// else {
|
||||
// txt_area.x1 = bar->indic_area.x2 + 5;
|
||||
// txt_area.x2 = txt_area.x1 + txt_size.x - 1;
|
||||
// dsc.color = lv_color_black();
|
||||
// }
|
||||
//
|
||||
// txt_area.y1 = bar->indic_area.y1 + (lv_area_get_height(&bar->indic_area) - txt_size.y) / 2;
|
||||
// txt_area.y2 = txt_area.y1 + txt_size.y - 1;
|
||||
//
|
||||
// const lv_area_t * clip_area = lv_event_get_param();
|
||||
// lv_draw_label(&txt_area, clip_area, &dsc, buf, NULL);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * Custom drawer on bar to display the current value
|
||||
// */
|
||||
//void lv_example_bar_6(void)
|
||||
//{
|
||||
// static lv_style_t style_bg;
|
||||
// lv_style_init(&style_bg);
|
||||
// lv_style_set_content_ofs_y(&style_bg, -3);
|
||||
// lv_style_set_content_align(&style_bg, LV_ALIGN_OUT_TOP_MID);
|
||||
//
|
||||
// lv_obj_t * bar = lv_bar_create(lv_scr_act());
|
||||
// lv_obj_add_event_cb(bar, event_cb, NULL);
|
||||
// lv_obj_set_size(bar, 200, 20);
|
||||
// lv_obj_align(bar, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
//
|
||||
// lv_anim_t a;
|
||||
// lv_anim_init(&a);
|
||||
// lv_anim_set_var(&a, bar);
|
||||
// lv_anim_set_values(&a, 0, 100);
|
||||
// lv_anim_set_exec_cb(&a, set_value);
|
||||
// lv_anim_set_time(&a, 2000);
|
||||
// lv_anim_set_playback_time(&a, 2000);
|
||||
// lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
|
||||
// lv_anim_start(&a);
|
||||
//
|
||||
//}
|
||||
//
|
||||
//#endif
|
||||
|
||||
@@ -16,24 +16,21 @@ void lv_example_btn_1(void)
|
||||
{
|
||||
lv_obj_t * label;
|
||||
//
|
||||
// lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
|
||||
// lv_obj_add_event_cb(btn1, event_handler, NULL);
|
||||
// lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -40);
|
||||
//
|
||||
// label = lv_label_create(btn1, NULL);
|
||||
// lv_label_set_text(label, "Button");
|
||||
// lv_obj_center(label);
|
||||
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(btn1, event_handler, NULL);
|
||||
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -40);
|
||||
|
||||
lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), NULL);
|
||||
label = lv_label_create(btn1);
|
||||
lv_label_set_text(label, "Button");
|
||||
lv_obj_center(label);
|
||||
|
||||
lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(btn2, event_handler, NULL);
|
||||
lv_obj_align(btn2, NULL, LV_ALIGN_CENTER, 0, 40);
|
||||
lv_obj_add_flag(btn2, LV_OBJ_FLAG_CHECKABLE);
|
||||
// lv_obj_set_height(btn2, LV_SIZE_CONTENT);
|
||||
lv_obj_set_height(btn2, LV_SIZE_CONTENT);
|
||||
|
||||
|
||||
label = lv_label_create(btn2, NULL);
|
||||
label = lv_label_create(btn2);
|
||||
lv_label_set_text(label, "Toggle");
|
||||
// lv_obj_update_layout(btn2);
|
||||
// lv_obj_update_layout(cont);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -37,13 +37,13 @@ void lv_example_btn_2(void)
|
||||
lv_style_set_bg_color(&style_pr, lv_color_blue_darken_2());
|
||||
lv_style_set_bg_grad_color(&style_pr, lv_color_blue_darken_4());
|
||||
|
||||
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
|
||||
lv_obj_remove_style(btn1, LV_PART_ANY, LV_STATE_ANY, NULL);
|
||||
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
|
||||
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
|
||||
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn1, NULL);
|
||||
lv_obj_t * label = lv_label_create(btn1);
|
||||
lv_label_set_text(label, "Button");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../../../lvgl.h"
|
||||
#include <stdio.h>
|
||||
#if LV_USE_BTN
|
||||
#if LV_BUILD_EXAMPLES && LV_USE_BTN
|
||||
|
||||
/**
|
||||
* Create a style transition on a button to act like a gum when clicked
|
||||
@@ -9,7 +9,7 @@ void lv_example_btn_3(void)
|
||||
{
|
||||
/*Properties to transition*/
|
||||
static lv_style_prop_t props[] = {
|
||||
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, LV_STYLE_CONTENT_LETTER_SPACE, 0
|
||||
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, LV_STYLE_TEXT_LETTER_SPACE, 0
|
||||
};
|
||||
|
||||
/*Define animation paths*/
|
||||
@@ -42,16 +42,15 @@ void lv_example_btn_3(void)
|
||||
lv_style_init(&style_pr);
|
||||
lv_style_set_transform_width(&style_pr, 10);
|
||||
lv_style_set_transform_height(&style_pr, -10);
|
||||
lv_style_set_content_letter_space(&style_pr, 10);
|
||||
lv_style_set_text_letter_space(&style_pr, 10);
|
||||
lv_style_set_transition(&style_pr, &transition_dsc_pr);
|
||||
|
||||
|
||||
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
|
||||
lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -80);
|
||||
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
|
||||
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_def);
|
||||
|
||||
/*Instead of creating a label add a values string*/
|
||||
lv_obj_set_style_content_text(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, "Gum");
|
||||
lv_obj_t * label = lv_label_create(btn1);
|
||||
lv_label_set_text(label, "Gum");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@ static const char * btnm_map[] = {"1", "2", "3", "4", "5", "\n",
|
||||
|
||||
void lv_example_btnmatrix_1(void)
|
||||
{
|
||||
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
|
||||
lv_btnmatrix_set_map(btnm1, btnm_map);
|
||||
lv_btnmatrix_set_btn_width(btnm1, 10, 2); /*Make "Action1" twice as wide as "Action2"*/
|
||||
lv_btnmatrix_set_btn_ctrl(btnm1, 10, LV_BTNMATRIX_CTRL_CHECKABLE);
|
||||
|
||||
@@ -62,7 +62,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
*/
|
||||
void lv_example_btnmatrix_2(void)
|
||||
{
|
||||
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(btnm, event_cb, NULL);
|
||||
lv_obj_align(btnm, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void lv_example_btnmatrix_3(void)
|
||||
|
||||
static const char * map[] = {LV_SYMBOL_LEFT, "1", "2", "3", "4", "5", LV_SYMBOL_RIGHT, ""};
|
||||
|
||||
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
|
||||
lv_btnmatrix_set_map(btnm, map);
|
||||
lv_obj_add_style(btnm, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
|
||||
lv_obj_add_style(btnm, LV_PART_ITEMS, LV_STATE_DEFAULT, &style_btn);
|
||||
|
||||
@@ -27,7 +27,7 @@ void lv_example_canvas_1(void)
|
||||
|
||||
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);
|
||||
lv_obj_align(canvas, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_canvas_fill_bg(canvas, lv_color_grey_lighten_3(), LV_OPA_COVER);
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
void lv_example_canvas_2(void)
|
||||
{
|
||||
/*Create a button to better see the transparency*/
|
||||
lv_btn_create(lv_scr_act(), NULL);
|
||||
lv_btn_create(lv_scr_act());
|
||||
|
||||
/*Create a buffer for the canvas*/
|
||||
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_INDEXED_1BIT(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
|
||||
/*Create a canvas and initialize its the palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_INDEXED_1BIT);
|
||||
lv_canvas_set_palette(canvas, 0, LV_COLOR_CHROMA_KEY);
|
||||
lv_canvas_set_palette(canvas, 1, lv_color_red());
|
||||
|
||||
@@ -5,7 +5,7 @@ void lv_example_chart_1(void)
|
||||
{
|
||||
/*Create a chart*/
|
||||
lv_obj_t * chart;
|
||||
chart = lv_chart_create(lv_scr_act(), NULL);
|
||||
chart = lv_chart_create(lv_scr_act());
|
||||
lv_obj_set_size(chart, 200, 150);
|
||||
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/
|
||||
|
||||
@@ -60,7 +60,7 @@ static void add_data(lv_timer_t * timer)
|
||||
void lv_example_chart_2(void)
|
||||
{
|
||||
/*Create a chart1*/
|
||||
chart1 = lv_chart_create(lv_scr_act(), NULL);
|
||||
chart1 = lv_chart_create(lv_scr_act());
|
||||
lv_obj_set_size(chart1, 200, 150);
|
||||
lv_obj_align(chart1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_chart_set_type(chart1, LV_CHART_TYPE_LINE); /*Show lines and points too*/
|
||||
|
||||
@@ -20,7 +20,7 @@ void lv_example_chart_3(void)
|
||||
{
|
||||
/*Create a chart*/
|
||||
lv_obj_t * chart;
|
||||
chart = lv_chart_create(lv_scr_act(), NULL);
|
||||
chart = lv_chart_create(lv_scr_act());
|
||||
lv_obj_set_size(chart, 200, 150);
|
||||
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_chart_set_type(chart, LV_CHART_TYPE_BAR);
|
||||
|
||||
@@ -26,15 +26,15 @@ static void event_cb(lv_obj_t * chart, lv_event_t e)
|
||||
lv_coord_t value = y_array[id];
|
||||
|
||||
char buf[16];
|
||||
lv_snprintf(buf, sizeof(buf), "$%d", value);
|
||||
lv_snprintf(buf, sizeof(buf), LV_SYMBOL_DUMMY"$%d", value);
|
||||
|
||||
lv_draw_rect_dsc_t draw_rect_dsc;
|
||||
lv_draw_rect_dsc_init(&draw_rect_dsc);
|
||||
draw_rect_dsc.bg_color = lv_color_black();
|
||||
draw_rect_dsc.bg_opa = LV_OPA_50;
|
||||
draw_rect_dsc.radius = 3;
|
||||
draw_rect_dsc.content_text = buf;
|
||||
draw_rect_dsc.content_color = lv_color_white();
|
||||
draw_rect_dsc.bg_img_src = buf;
|
||||
draw_rect_dsc.bg_img_recolor = lv_color_white();
|
||||
|
||||
lv_area_t a;
|
||||
a.x1 = chart->coords.x1 + p.x - 20;
|
||||
@@ -57,7 +57,7 @@ void lv_example_chart_4(void)
|
||||
{
|
||||
/*Create a chart*/
|
||||
lv_obj_t * chart;
|
||||
chart = lv_chart_create(lv_scr_act(), NULL);
|
||||
chart = lv_chart_create(lv_scr_act());
|
||||
lv_obj_set_size(chart, 200, 150);
|
||||
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ static void slider_y_event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
void lv_example_chart_5(void)
|
||||
{
|
||||
/*Create a chart*/
|
||||
chart = lv_chart_create(lv_scr_act(), NULL);
|
||||
chart = lv_chart_create(lv_scr_act());
|
||||
lv_obj_set_size(chart, 200, 150);
|
||||
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, -30, -30);
|
||||
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, -1000, 1000);
|
||||
@@ -84,13 +84,13 @@ void lv_example_chart_5(void)
|
||||
lv_chart_set_ext_array(chart, ser, (lv_coord_t *)ecg_sample);
|
||||
|
||||
lv_obj_t * slider;
|
||||
slider = lv_slider_create(lv_scr_act(), NULL);
|
||||
slider = lv_slider_create(lv_scr_act());
|
||||
lv_slider_set_range(slider, LV_IMG_ZOOM_NONE, LV_IMG_ZOOM_NONE * 10);
|
||||
lv_obj_add_event_cb(slider, slider_x_event_cb, NULL);
|
||||
lv_obj_set_size(slider, lv_obj_get_width(chart), 10);
|
||||
lv_obj_align(slider, chart, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
|
||||
|
||||
slider = lv_slider_create(lv_scr_act(), NULL);
|
||||
slider = lv_slider_create(lv_scr_act());
|
||||
lv_slider_set_range(slider, LV_IMG_ZOOM_NONE, LV_IMG_ZOOM_NONE * 10);
|
||||
lv_obj_add_event_cb(slider, slider_y_event_cb, NULL);
|
||||
lv_obj_set_size(slider, 10, lv_obj_get_height(chart));
|
||||
|
||||
@@ -57,7 +57,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
*/
|
||||
void lv_example_chart_6(void)
|
||||
{
|
||||
chart = lv_chart_create(lv_scr_act(), NULL);
|
||||
chart = lv_chart_create(lv_scr_act());
|
||||
lv_obj_set_size(chart, 200, 150);
|
||||
lv_obj_align(chart, NULL, LV_ALIGN_CENTER, 0, -10);
|
||||
|
||||
@@ -77,7 +77,7 @@ void lv_example_chart_6(void)
|
||||
|
||||
lv_chart_set_zoom_x(chart, 500);
|
||||
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(label, "Click on a point");
|
||||
lv_obj_align(label, chart, LV_ALIGN_OUT_TOP_MID, 0, -5);
|
||||
|
||||
|
||||
@@ -16,21 +16,21 @@ void lv_example_checkbox_1(void)
|
||||
lv_obj_set_flex_place(lv_scr_act(), LV_FLEX_PLACE_CENTER, LV_FLEX_PLACE_START, LV_FLEX_PLACE_CENTER);
|
||||
|
||||
lv_obj_t * cb;
|
||||
cb = lv_checkbox_create(lv_scr_act(), NULL);
|
||||
cb = lv_checkbox_create(lv_scr_act());
|
||||
lv_checkbox_set_text(cb, "Apple");
|
||||
lv_obj_add_event_cb(cb, event_handler, NULL);
|
||||
|
||||
cb = lv_checkbox_create(lv_scr_act(), NULL);
|
||||
cb = lv_checkbox_create(lv_scr_act());
|
||||
lv_checkbox_set_text(cb, "Banana");
|
||||
lv_obj_add_state(cb, LV_STATE_CHECKED);
|
||||
lv_obj_add_event_cb(cb, event_handler, NULL);
|
||||
|
||||
cb = lv_checkbox_create(lv_scr_act(), NULL);
|
||||
cb = lv_checkbox_create(lv_scr_act());
|
||||
lv_checkbox_set_text(cb, "Lemon");
|
||||
lv_obj_add_state(cb, LV_STATE_DISABLED);
|
||||
lv_obj_add_event_cb(cb, event_handler, NULL);
|
||||
|
||||
cb = lv_checkbox_create(lv_scr_act(), NULL);
|
||||
cb = lv_checkbox_create(lv_scr_act());
|
||||
lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED);
|
||||
lv_checkbox_set_text(cb, "Melon");
|
||||
lv_obj_add_event_cb(cb, event_handler, NULL);
|
||||
|
||||
@@ -16,7 +16,7 @@ void lv_example_dropdown_1(void)
|
||||
{
|
||||
|
||||
/*Create a normal drop down list*/
|
||||
lv_obj_t * dd = lv_dropdown_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * dd = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_options(dd, "Apple\n"
|
||||
"Banana\n"
|
||||
"Orange\n"
|
||||
|
||||
@@ -15,23 +15,23 @@ void lv_example_dropdown_2(void)
|
||||
"Raspberry";
|
||||
|
||||
lv_obj_t * dd;
|
||||
dd = lv_dropdown_create(lv_scr_act(), NULL);
|
||||
dd = lv_dropdown_create(lv_scr_act());
|
||||
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);
|
||||
dd = lv_dropdown_create(lv_scr_act());
|
||||
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);
|
||||
dd = lv_dropdown_create(lv_scr_act());
|
||||
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);
|
||||
dd = lv_dropdown_create(lv_scr_act());
|
||||
lv_dropdown_set_options_static(dd, opts);
|
||||
lv_dropdown_set_dir(dd, LV_DIR_LEFT);
|
||||
lv_dropdown_set_symbol(dd, LV_SYMBOL_LEFT);
|
||||
|
||||
@@ -16,7 +16,7 @@ static void event_cb(lv_obj_t * dropdown, lv_event_t e)
|
||||
void lv_example_dropdown_3(void)
|
||||
{
|
||||
/*Create a drop down list*/
|
||||
lv_obj_t * dropdown = lv_dropdown_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * dropdown = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_align(dropdown, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10);
|
||||
lv_dropdown_set_options(dropdown, "New project\n"
|
||||
"New file\n"
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
void lv_example_img_1(void)
|
||||
{
|
||||
LV_IMG_DECLARE(img_cogwheel_argb);
|
||||
lv_obj_t * img1 = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * img1 = lv_img_create(lv_scr_act());
|
||||
lv_img_set_src(img1, &img_cogwheel_argb);
|
||||
lv_obj_align(img1, NULL, LV_ALIGN_CENTER, 0, -20);
|
||||
lv_obj_set_size(img1, 200, 200);
|
||||
|
||||
lv_obj_t * img2 = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * img2 = lv_img_create(lv_scr_act());
|
||||
lv_img_set_src(img2, LV_SYMBOL_OK "Accept");
|
||||
lv_obj_align(img2, img1, LV_ALIGN_OUT_BOTTOM_MID, 0, 20);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void lv_example_img_2(void)
|
||||
|
||||
/*Now create the actual image*/
|
||||
LV_IMG_DECLARE(img_cogwheel_argb)
|
||||
img1 = lv_img_create(lv_scr_act(), NULL);
|
||||
img1 = lv_img_create(lv_scr_act());
|
||||
lv_img_set_src(img1, &img_cogwheel_argb);
|
||||
lv_obj_align(img1, NULL, LV_ALIGN_IN_RIGHT_MID, -20, 0);
|
||||
|
||||
@@ -53,7 +53,7 @@ static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
|
||||
static lv_obj_t * create_slider(lv_color_t color)
|
||||
{
|
||||
lv_obj_t * slider = lv_slider_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * slider = lv_slider_create(lv_scr_act());
|
||||
lv_slider_set_range(slider, 0, 255);
|
||||
lv_obj_set_size(slider, 10, 200);
|
||||
lv_obj_set_style_bg_color(slider, LV_PART_KNOB, LV_STATE_DEFAULT, color);
|
||||
|
||||
@@ -20,7 +20,7 @@ void lv_example_img_3(void)
|
||||
LV_IMG_DECLARE(img_cogwheel_argb);
|
||||
|
||||
/*Now create the actual image*/
|
||||
lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * img = lv_img_create(lv_scr_act());
|
||||
lv_img_set_src(img, &img_cogwheel_argb);
|
||||
lv_obj_align(img, NULL, LV_ALIGN_CENTER, 50, 50);
|
||||
lv_img_set_pivot(img, 0, 0); /*Rotate around the top left corner*/
|
||||
|
||||
@@ -20,7 +20,7 @@ void lv_example_img_4(void)
|
||||
lv_style_set_img_recolor_opa(&style, LV_OPA_COVER);
|
||||
lv_style_set_img_recolor(&style, lv_color_black());
|
||||
|
||||
lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * img = lv_img_create(lv_scr_act());
|
||||
lv_obj_add_style(img, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
|
||||
lv_img_set_src(img, &img_skew_strip);
|
||||
lv_obj_set_size(img, 150, 100);
|
||||
|
||||
@@ -33,7 +33,7 @@ void lv_example_imgbtn_1(void)
|
||||
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_obj_t * label = lv_label_create(imgbtn1);
|
||||
lv_label_set_text(label, "Button");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, -4);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ void lv_example_keyboard_1(void)
|
||||
|
||||
/*Create a text area. The keyboard will write here*/
|
||||
lv_obj_t * ta;
|
||||
ta = lv_textarea_create(lv_scr_act(), NULL);
|
||||
ta = lv_textarea_create(lv_scr_act());
|
||||
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10);
|
||||
lv_obj_add_event_cb(ta, ta_event_cb, kb);
|
||||
lv_textarea_set_placeholder_text(ta, "Hello");
|
||||
|
||||
ta = lv_textarea_create(lv_scr_act(), NULL);
|
||||
ta = lv_textarea_create(lv_scr_act());
|
||||
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10);
|
||||
lv_obj_add_event_cb(ta, ta_event_cb, kb);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
void lv_example_label_1(void)
|
||||
{
|
||||
lv_obj_t * label1 = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * label1 = lv_label_create(lv_scr_act());
|
||||
lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/
|
||||
lv_label_set_recolor(label1, true); /*Enable re-coloring by commands in the text*/
|
||||
lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center"
|
||||
@@ -16,7 +16,7 @@ void lv_example_label_1(void)
|
||||
lv_obj_align(label1, NULL, LV_ALIGN_CENTER, 0, -40);
|
||||
|
||||
|
||||
lv_obj_t * label2 = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * label2 = lv_label_create(lv_scr_act());
|
||||
lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
|
||||
lv_obj_set_width(label2, 150);
|
||||
lv_label_set_text(label2, "It is a circularly scrolling text. ");
|
||||
|
||||
@@ -13,11 +13,11 @@ void lv_example_label_2(void)
|
||||
lv_style_set_text_color(&style_shadow, lv_color_black());
|
||||
|
||||
/*Create a label for the shadow first (it's in the background)*/
|
||||
lv_obj_t * shadow_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * shadow_label = lv_label_create(lv_scr_act());
|
||||
lv_obj_add_style(shadow_label, LV_PART_MAIN, LV_STATE_DEFAULT, &style_shadow);
|
||||
|
||||
/*Create the main label*/
|
||||
lv_obj_t * main_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * main_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(main_label, "A simple method to create\n"
|
||||
"shadows on a text.\n"
|
||||
"It even works with\n\n"
|
||||
|
||||
@@ -15,7 +15,7 @@ void lv_example_line_1(void)
|
||||
|
||||
/*Create a line and apply the new style*/
|
||||
lv_obj_t * line1;
|
||||
line1 = lv_line_create(lv_scr_act(), NULL);
|
||||
line1 = lv_line_create(lv_scr_act());
|
||||
lv_line_set_points(line1, line_points, 5); /*Set the points*/
|
||||
lv_obj_add_style(line1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_line); /*Set the points*/
|
||||
lv_obj_align(line1, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
@@ -19,7 +19,7 @@ void lv_example_list_1(void)
|
||||
uint32_t t = lv_tick_get();
|
||||
int i;
|
||||
for(i = 0; i < 3; i++) {
|
||||
// lv_btn_create(lv_scr_act(), NULL);
|
||||
// lv_btn_create(lv_scr_act());
|
||||
lv_list_add_btn(list1, LV_SYMBOL_FILE, "New", event_handler);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ static void set_value(void * indic, int32_t v)
|
||||
*/
|
||||
void lv_example_meter_1(void)
|
||||
{
|
||||
meter = lv_meter_create(lv_scr_act(), NULL);
|
||||
meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Add a scale first*/
|
||||
|
||||
@@ -14,7 +14,7 @@ static void set_value(void * indic, int32_t v)
|
||||
*/
|
||||
void lv_example_meter_2(void)
|
||||
{
|
||||
meter = lv_meter_create(lv_scr_act(), NULL);
|
||||
meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Remove the circle from the middle*/
|
||||
|
||||
@@ -14,7 +14,7 @@ static void set_value(void * indic, int32_t v)
|
||||
*/
|
||||
void lv_example_meter_3(void)
|
||||
{
|
||||
meter = lv_meter_create(lv_scr_act(), NULL);
|
||||
meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Create a scale for the minutes*/
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
void lv_example_meter_4(void)
|
||||
{
|
||||
lv_obj_t * meter = lv_meter_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * meter = lv_meter_create(lv_scr_act());
|
||||
lv_obj_align(meter, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Remove the background and the circle from the middle*/
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
void lv_example_obj_1(void)
|
||||
{
|
||||
lv_obj_t * obj1;
|
||||
obj1 = lv_obj_create(lv_scr_act(), NULL);
|
||||
obj1 = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(obj1, 100, 50);
|
||||
lv_obj_align(obj1, NULL, LV_ALIGN_CENTER, -60, -30);
|
||||
|
||||
@@ -15,7 +15,7 @@ void lv_example_obj_1(void)
|
||||
lv_style_set_shadow_color(&style_shadow, lv_color_blue());
|
||||
|
||||
lv_obj_t * obj3;
|
||||
obj3 = lv_obj_create(lv_scr_act(), NULL);
|
||||
obj3 = lv_obj_create(lv_scr_act());
|
||||
lv_obj_add_style(obj3, LV_PART_MAIN, LV_STATE_DEFAULT, &style_shadow);
|
||||
lv_obj_align(obj3, NULL, LV_ALIGN_CENTER, 60, 30);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
*/
|
||||
void lv_example_roller_1(void)
|
||||
{
|
||||
lv_obj_t *roller1 = lv_roller_create(lv_scr_act(), NULL);
|
||||
lv_obj_t *roller1 = lv_roller_create(lv_scr_act());
|
||||
lv_roller_set_options(roller1,
|
||||
"January\n"
|
||||
"February\n"
|
||||
|
||||
@@ -24,7 +24,7 @@ void lv_example_roller_2(void)
|
||||
lv_obj_t *roller;
|
||||
|
||||
/*A roller on the left with left aligned text, and custom width*/
|
||||
roller = lv_roller_create(lv_scr_act(), NULL);
|
||||
roller = lv_roller_create(lv_scr_act());
|
||||
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(roller, 2);
|
||||
lv_obj_set_width(roller, 100);
|
||||
@@ -35,7 +35,7 @@ void lv_example_roller_2(void)
|
||||
lv_roller_set_selected(roller, 2, LV_ANIM_OFF);
|
||||
|
||||
/*A roller on the middle with center aligned text, and auto (default) width*/
|
||||
roller = lv_roller_create(lv_scr_act(), NULL);
|
||||
roller = lv_roller_create(lv_scr_act());
|
||||
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(roller, 3);
|
||||
lv_obj_add_style(roller, LV_PART_SELECTED, LV_STATE_DEFAULT, &style_sel);
|
||||
@@ -44,7 +44,7 @@ void lv_example_roller_2(void)
|
||||
lv_roller_set_selected(roller, 5, LV_ANIM_OFF);
|
||||
|
||||
/*A roller on the right with right aligned text, and custom width*/
|
||||
roller = lv_roller_create(lv_scr_act(), NULL);
|
||||
roller = lv_roller_create(lv_scr_act());
|
||||
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
|
||||
lv_roller_set_visible_row_count(roller, 4);
|
||||
lv_obj_set_width(roller, 80);
|
||||
|
||||
@@ -10,12 +10,12 @@ static lv_obj_t * slider_label;
|
||||
void lv_example_slider_1(void)
|
||||
{
|
||||
/*Create a slider in the center of the display*/
|
||||
lv_obj_t * slider = lv_slider_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * slider = lv_slider_create(lv_scr_act());
|
||||
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_add_event_cb(slider, slider_event_cb, NULL);
|
||||
|
||||
/*Create a label below the slider*/
|
||||
slider_label = lv_label_create(lv_scr_act(), NULL);
|
||||
slider_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(slider_label, "0%");
|
||||
|
||||
lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
|
||||
|
||||
static lv_style_t style_pr;
|
||||
static lv_style_t style_def;
|
||||
|
||||
/**
|
||||
* Show the current value when the slider if pressed using a fancy style transition.
|
||||
*/
|
||||
void lv_example_slider_2(void)
|
||||
{
|
||||
lv_style_init(&style_def);
|
||||
lv_style_set_content_opa(&style_def, LV_OPA_TRANSP);
|
||||
lv_style_set_content_align(&style_def, LV_ALIGN_OUT_TOP_MID);
|
||||
|
||||
lv_style_init(&style_pr);
|
||||
lv_style_set_content_opa(&style_pr, LV_OPA_COVER);
|
||||
lv_style_set_content_ofs_y(&style_pr, -15);
|
||||
|
||||
/*Create a slider in the center of the display*/
|
||||
lv_obj_t * slider;
|
||||
slider = lv_slider_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_add_event_cb(slider, slider_event_cb, NULL);
|
||||
|
||||
lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_DEFAULT, &style_def);
|
||||
lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_PRESSED, &style_pr);
|
||||
}
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
static char buf[8];
|
||||
lv_snprintf(buf, sizeof(buf), "%u", lv_slider_get_value(slider));
|
||||
lv_obj_set_style_content_text(slider, LV_PART_KNOB, LV_STATE_DEFAULT, buf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
//#include "../../../lvgl.h"
|
||||
//#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
//
|
||||
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
|
||||
//
|
||||
//static lv_style_t style_pr;
|
||||
//static lv_style_t style_def;
|
||||
//
|
||||
///**
|
||||
// * Show the current value when the slider if pressed using a fancy style transition.
|
||||
// */
|
||||
//void lv_example_slider_2(void)
|
||||
//{
|
||||
// lv_style_init(&style_def);
|
||||
// lv_style_set_content_opa(&style_def, LV_OPA_TRANSP);
|
||||
// lv_style_set_content_align(&style_def, LV_ALIGN_OUT_TOP_MID);
|
||||
//
|
||||
// lv_style_init(&style_pr);
|
||||
// lv_style_set_content_opa(&style_pr, LV_OPA_COVER);
|
||||
// lv_style_set_content_ofs_y(&style_pr, -15);
|
||||
//
|
||||
// /*Create a slider in the center of the display*/
|
||||
// lv_obj_t * slider;
|
||||
// slider = lv_slider_create(lv_scr_act());
|
||||
// lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_add_event_cb(slider, slider_event_cb, NULL);
|
||||
//
|
||||
// lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_DEFAULT, &style_def);
|
||||
// lv_obj_add_style(slider, LV_PART_KNOB, LV_STATE_PRESSED, &style_pr);
|
||||
//}
|
||||
//
|
||||
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
//{
|
||||
// if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
// static char buf[8];
|
||||
// lv_snprintf(buf, sizeof(buf), "%u", lv_slider_get_value(slider));
|
||||
// lv_obj_set_style_content_text(slider, LV_PART_KNOB, LV_STATE_DEFAULT, buf);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//#endif
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
|
||||
|
||||
/**
|
||||
* Show the current value when the slider if pressed (using only styles).
|
||||
*
|
||||
*/
|
||||
void lv_example_slider_3(void)
|
||||
{
|
||||
/*Create a slider in the center of the display*/
|
||||
lv_obj_t * slider;
|
||||
slider = lv_slider_create(lv_scr_act(), NULL);
|
||||
lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_add_event_cb(slider, slider_event_cb, NULL);
|
||||
lv_slider_set_mode(slider, LV_SLIDER_MODE_RANGE);
|
||||
|
||||
lv_slider_set_value(slider, 70, LV_ANIM_OFF);
|
||||
lv_slider_set_left_value(slider, 20, LV_ANIM_OFF);
|
||||
|
||||
/*Now use only a local style.*/
|
||||
lv_obj_set_style_content_ofs_y(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, -20);
|
||||
lv_obj_set_style_content_color(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, lv_color_grey_darken_3());
|
||||
|
||||
/*To update the value text*/
|
||||
lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
}
|
||||
|
||||
static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
{
|
||||
if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
static char buf[8];
|
||||
lv_snprintf(buf, sizeof(buf), "%d - %d", lv_slider_get_value(slider), lv_slider_get_left_value(slider));
|
||||
lv_obj_set_style_content_text(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
//#include "../../../lvgl.h"
|
||||
//#if LV_USE_SLIDER && LV_BUILD_EXAMPLES
|
||||
//
|
||||
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event);
|
||||
//
|
||||
///**
|
||||
// * Show the current value when the slider if pressed (using only styles).
|
||||
// *
|
||||
// */
|
||||
//void lv_example_slider_3(void)
|
||||
//{
|
||||
// /*Create a slider in the center of the display*/
|
||||
// lv_obj_t * slider;
|
||||
// slider = lv_slider_create(lv_scr_act());
|
||||
// lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
// lv_obj_add_event_cb(slider, slider_event_cb, NULL);
|
||||
// lv_slider_set_mode(slider, LV_SLIDER_MODE_RANGE);
|
||||
//
|
||||
// lv_slider_set_value(slider, 70, LV_ANIM_OFF);
|
||||
// lv_slider_set_left_value(slider, 20, LV_ANIM_OFF);
|
||||
//
|
||||
// /*Now use only a local style.*/
|
||||
// lv_obj_set_style_content_ofs_y(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, -20);
|
||||
// lv_obj_set_style_content_color(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, lv_color_grey_darken_3());
|
||||
//
|
||||
// /*To update the value text*/
|
||||
// lv_event_send(slider, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
//}
|
||||
//
|
||||
//static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
|
||||
//{
|
||||
// if(event == LV_EVENT_VALUE_CHANGED) {
|
||||
// static char buf[8];
|
||||
// lv_snprintf(buf, sizeof(buf), "%d - %d", lv_slider_get_value(slider), lv_slider_get_left_value(slider));
|
||||
// lv_obj_set_style_content_text(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, buf);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//#endif
|
||||
|
||||
@@ -32,16 +32,16 @@ void lv_example_spinbox_1(void)
|
||||
|
||||
lv_coord_t h = lv_obj_get_height(spinbox);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
||||
lv_obj_set_size(btn, h, h);
|
||||
lv_obj_align(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
|
||||
lv_obj_set_style_content_text(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
|
||||
lv_obj_set_style_bg_img_src(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
|
||||
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, NULL);
|
||||
|
||||
btn = lv_btn_create(lv_scr_act(), NULL);
|
||||
btn = lv_btn_create(lv_scr_act());
|
||||
lv_obj_set_size(btn, h, h);
|
||||
lv_obj_align(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
|
||||
lv_obj_set_style_content_text(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_MINUS);
|
||||
lv_obj_set_style_bg_img_src(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_MINUS);
|
||||
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,18 +15,18 @@ void lv_example_switch_1(void)
|
||||
|
||||
lv_obj_t * sw;
|
||||
|
||||
sw = lv_switch_create(lv_scr_act(), NULL);
|
||||
sw = lv_switch_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(sw, event_handler, NULL);
|
||||
|
||||
sw = lv_switch_create(lv_scr_act(), NULL);
|
||||
sw = lv_switch_create(lv_scr_act());
|
||||
lv_obj_add_state(sw, LV_STATE_CHECKED);
|
||||
lv_obj_add_event_cb(sw, event_handler, NULL);
|
||||
|
||||
sw = lv_switch_create(lv_scr_act(), NULL);
|
||||
sw = lv_switch_create(lv_scr_act());
|
||||
lv_obj_add_state(sw, LV_STATE_DISABLED);
|
||||
lv_obj_add_event_cb(sw, event_handler, NULL);
|
||||
|
||||
sw = lv_switch_create(lv_scr_act(), NULL);
|
||||
sw = lv_switch_create(lv_scr_act());
|
||||
lv_obj_add_state(sw, LV_STATE_CHECKED | LV_STATE_DISABLED);
|
||||
lv_obj_add_event_cb(sw, event_handler, NULL);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
|
||||
|
||||
void lv_example_table_1(void)
|
||||
{
|
||||
lv_obj_t * table = lv_table_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * table = lv_table_create(lv_scr_act());
|
||||
|
||||
/*Fill the first column*/
|
||||
lv_table_set_cell_value(table, 0, 0, "Name");
|
||||
|
||||
@@ -58,7 +58,7 @@ void lv_example_table_2(void)
|
||||
|
||||
uint32_t t = lv_tick_get();
|
||||
|
||||
lv_obj_t * table = lv_table_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * table = lv_table_create(lv_scr_act());
|
||||
|
||||
/*Set a smaller height to the table. It'll make it scrollable*/
|
||||
lv_obj_set_size(table, 150, 200);
|
||||
@@ -87,7 +87,7 @@ void lv_example_table_2(void)
|
||||
|
||||
uint32_t elaps = lv_tick_elaps(t);
|
||||
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text_fmt(label, "%d bytes are used by the table\n"
|
||||
"and %d items were added in %d ms",
|
||||
mem_used, ITEM_CNT, elaps);
|
||||
|
||||
@@ -13,7 +13,7 @@ void lv_example_tabview_1(void)
|
||||
lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");
|
||||
|
||||
/*Add content to the tabs*/
|
||||
lv_obj_t * label = lv_label_create(tab1, NULL);
|
||||
lv_obj_t * label = lv_label_create(tab1);
|
||||
lv_label_set_text(label, "This the first tab\n\n"
|
||||
"If the content\n"
|
||||
"of a tab\n"
|
||||
@@ -30,10 +30,10 @@ void lv_example_tabview_1(void)
|
||||
"\n"
|
||||
"Can you see it?");
|
||||
|
||||
label = lv_label_create(tab2, NULL);
|
||||
label = lv_label_create(tab2);
|
||||
lv_label_set_text(label, "Second tab");
|
||||
|
||||
label = lv_label_create(tab3, NULL);
|
||||
label = lv_label_create(tab3);
|
||||
lv_label_set_text(label, "Third tab");
|
||||
|
||||
lv_obj_scroll_to_view_recursive(label, LV_ANIM_ON);
|
||||
|
||||
@@ -17,7 +17,7 @@ static void btnm_event_handler(lv_obj_t * obj, lv_event_t event)
|
||||
|
||||
void lv_example_textarea_1(void)
|
||||
{
|
||||
lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * ta = lv_textarea_create(lv_scr_act());
|
||||
lv_textarea_set_one_line(ta, true);
|
||||
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
|
||||
lv_obj_add_state(ta, LV_STATE_FOCUSED); /*To be sure the cursor is visible*/
|
||||
@@ -27,7 +27,7 @@ void lv_example_textarea_1(void)
|
||||
"7", "8", "9", "\n",
|
||||
LV_SYMBOL_BACKSPACE, "0", LV_SYMBOL_NEW_LINE, ""};
|
||||
|
||||
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
|
||||
lv_obj_set_size(btnm, 200, 150);
|
||||
lv_obj_align(btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -10);
|
||||
lv_obj_add_event_cb(btnm, btnm_event_handler, ta);
|
||||
|
||||
@@ -8,7 +8,7 @@ static lv_obj_t * kb;
|
||||
void lv_example_textarea_2(void)
|
||||
{
|
||||
/*Create the password box*/
|
||||
lv_obj_t * pwd_ta = lv_textarea_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * pwd_ta = lv_textarea_create(lv_scr_act());
|
||||
lv_textarea_set_text(pwd_ta, "");
|
||||
lv_textarea_set_password_mode(pwd_ta, true);
|
||||
lv_textarea_set_one_line(pwd_ta, true);
|
||||
@@ -17,18 +17,18 @@ void lv_example_textarea_2(void)
|
||||
lv_obj_add_event_cb(pwd_ta, ta_event_cb, NULL);
|
||||
|
||||
/*Create a label and position it above the text box*/
|
||||
lv_obj_t * pwd_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * pwd_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(pwd_label, "Password:");
|
||||
lv_obj_align(pwd_label, pwd_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
|
||||
|
||||
/*Create the one-line mode text area*/
|
||||
lv_obj_t * oneline_ta = lv_textarea_create(lv_scr_act(), pwd_ta);
|
||||
lv_obj_t * oneline_ta = lv_textarea_create(lv_scr_act());
|
||||
lv_textarea_set_password_mode(oneline_ta, false);
|
||||
lv_obj_align(oneline_ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -5, 20);
|
||||
|
||||
|
||||
/*Create a label and position it above the text box*/
|
||||
lv_obj_t * oneline_label = lv_label_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * oneline_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(oneline_label, "Text:");
|
||||
lv_obj_align(oneline_label, oneline_ta, LV_ALIGN_OUT_TOP_LEFT, 0, 0);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ static lv_obj_t * kb;
|
||||
void lv_example_textarea_3(void)
|
||||
{
|
||||
/*Create the text area*/
|
||||
lv_obj_t * ta = lv_textarea_create(lv_scr_act(), NULL);
|
||||
lv_obj_t * ta = lv_textarea_create(lv_scr_act());
|
||||
lv_obj_add_event_cb(ta, ta_event_cb, NULL);
|
||||
lv_textarea_set_accepted_chars(ta, "0123456789:");
|
||||
lv_textarea_set_max_length(ta, 5);
|
||||
|
||||
@@ -12,7 +12,7 @@ void lv_example_tileview_1(void)
|
||||
|
||||
/*Tile1: just a label*/
|
||||
lv_obj_t * tile1 = lv_tileview_add_tile(tv, 0, 0, LV_DIR_BOTTOM);
|
||||
lv_obj_t * label = lv_label_create(tile1, NULL);
|
||||
lv_obj_t * label = lv_label_create(tile1);
|
||||
lv_label_set_text(label, "Scroll down");
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
@@ -20,9 +20,9 @@ void lv_example_tileview_1(void)
|
||||
/*Tile2: a button*/
|
||||
lv_obj_t * tile2 = lv_tileview_add_tile(tv, 0, 1, LV_DIR_TOP | LV_DIR_RIGHT);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(tile2, NULL);
|
||||
lv_obj_t * btn = lv_btn_create(tile2);
|
||||
|
||||
label = lv_label_create(btn, NULL);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Scroll up or right");
|
||||
|
||||
lv_obj_set_size(btn, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||
|
||||
@@ -18,7 +18,7 @@ void lv_example_win_1(void)
|
||||
lv_win_add_btn(win, LV_SYMBOL_CLOSE, 60, event_handler);
|
||||
|
||||
lv_obj_t * cont = lv_win_get_content(win); /*Content can be aded here*/
|
||||
lv_obj_t * label = lv_label_create(cont, NULL);
|
||||
lv_obj_t * label = lv_label_create(cont);
|
||||
lv_label_set_text(label, "This is\n"
|
||||
"a pretty\n"
|
||||
"long text\n"
|
||||
|
||||
Reference in New Issue
Block a user