A39模拟器
This commit is contained in:
25
MXC-A39/lvgl/examples/widgets/label/index.rst
Normal file
25
MXC-A39/lvgl/examples/widgets/label/index.rst
Normal file
@ -0,0 +1,25 @@
|
||||
C
|
||||
^
|
||||
|
||||
Line wrap, recoloring and scrolling
|
||||
"""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/label/lv_example_label_1
|
||||
:language: c
|
||||
|
||||
Text shadow
|
||||
""""""""""""
|
||||
|
||||
.. lv_example:: widgets/label/lv_example_label_2
|
||||
:language: c
|
||||
|
||||
Show LTR, RTL and Chinese texts
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/label/lv_example_label_3
|
||||
:language: c
|
||||
|
||||
MicroPython
|
||||
^^^^^^^^^^^
|
||||
|
||||
No examples yet.
|
26
MXC-A39/lvgl/examples/widgets/label/lv_example_label_1.c
Normal file
26
MXC-A39/lvgl/examples/widgets/label/lv_example_label_1.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_LABEL && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* Show line wrap, re-color, line align and text scrolling.
|
||||
*/
|
||||
void lv_example_label_1(void)
|
||||
{
|
||||
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 "
|
||||
"and wrap long text automatically.");
|
||||
lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/
|
||||
lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40);
|
||||
|
||||
|
||||
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. ");
|
||||
lv_obj_align(label2, LV_ALIGN_CENTER, 0, 40);
|
||||
}
|
||||
|
||||
#endif
|
14
MXC-A39/lvgl/examples/widgets/label/lv_example_label_1.py
Normal file
14
MXC-A39/lvgl/examples/widgets/label/lv_example_label_1.py
Normal file
@ -0,0 +1,14 @@
|
||||
label1 = lv.label(lv.scr_act())
|
||||
label1.set_long_mode(lv.label.LONG.BREAK) # Break the long lines
|
||||
label1.set_recolor(True) # Enable re-coloring by commands in the text
|
||||
label1.set_align(lv.label.ALIGN.CENTER) # Center aligned lines
|
||||
label1.set_text("#000080 Re-color# #0000ff words# #6666ff of a# label " +
|
||||
"and wrap long text automatically.")
|
||||
label1.set_width(150)
|
||||
label1.align(None, lv.ALIGN.CENTER, 0, -30)
|
||||
|
||||
label2 = lv.label(lv.scr_act())
|
||||
label2.set_long_mode(lv.label.LONG.SROLL_CIRC) # Circular scroll
|
||||
label2.set_width(150)
|
||||
label2.set_text("It is a circularly scrolling text. ")
|
||||
label2.align(None, lv.ALIGN.CENTER, 0, 30)
|
36
MXC-A39/lvgl/examples/widgets/label/lv_example_label_2.c
Normal file
36
MXC-A39/lvgl/examples/widgets/label/lv_example_label_2.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_LABEL && LV_BUILD_EXAMPLES
|
||||
|
||||
/**
|
||||
* Create a fake text shadow
|
||||
*/
|
||||
void lv_example_label_2(void)
|
||||
{
|
||||
/*Create a style for the shadow*/
|
||||
static lv_style_t style_shadow;
|
||||
lv_style_init(&style_shadow);
|
||||
lv_style_set_text_opa(&style_shadow, LV_OPA_30);
|
||||
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());
|
||||
lv_obj_add_style(shadow_label, &style_shadow, 0);
|
||||
|
||||
/*Create the main label*/
|
||||
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"
|
||||
"newlines and spaces.");
|
||||
|
||||
/*Set the same text for the shadow label*/
|
||||
lv_label_set_text(shadow_label, lv_label_get_text(main_label));
|
||||
|
||||
/*Position the main label*/
|
||||
lv_obj_align(main_label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/*Shift the second label down and to the right by 2 pixel*/
|
||||
lv_obj_align_to(shadow_label, main_label, LV_ALIGN_TOP_LEFT, 2, 2);
|
||||
}
|
||||
|
||||
#endif
|
24
MXC-A39/lvgl/examples/widgets/label/lv_example_label_2.py
Normal file
24
MXC-A39/lvgl/examples/widgets/label/lv_example_label_2.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Create a style for the shadow
|
||||
label_style = lv.style_t()
|
||||
lv.style_copy(label_style, lv.style_plain)
|
||||
label_style.text.opa = lv.OPA._50
|
||||
|
||||
# Create a label for the shadow first (it's in the background)
|
||||
shadow_label = lv.label(lv.scr_act())
|
||||
shadow_label.set_style(lv.label.STYLE.MAIN, label_style)
|
||||
|
||||
# Create the main label
|
||||
main_label = lv.label(lv.scr_act())
|
||||
main_label.set_text("A simple method to create\n" +
|
||||
"shadows on text\n" +
|
||||
"It even works with\n\n" +
|
||||
"newlines and spaces.")
|
||||
|
||||
# Set the same text for the shadow label
|
||||
shadow_label.set_text(main_label.get_text())
|
||||
|
||||
# Position the main label
|
||||
main_label.align(None, lv.ALIGN.CENTER, 0, 0)
|
||||
|
||||
# Shift the second label down and to the right by 1 pixel
|
||||
shadow_label.align(main_label, lv.ALIGN.IN_TOP_LEFT, 1, 1)
|
29
MXC-A39/lvgl/examples/widgets/label/lv_example_label_3.c
Normal file
29
MXC-A39/lvgl/examples/widgets/label/lv_example_label_3.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_LABEL && LV_BUILD_EXAMPLES && LV_FONT_DEJAVU_16_PERSIAN_HEBREW && LV_FONT_SIMSUN_16_CJK && LV_USE_BIDI
|
||||
|
||||
/**
|
||||
* Show mixed LTR, RTL and Chiease label
|
||||
*/
|
||||
void lv_example_label_3(void)
|
||||
{
|
||||
lv_obj_t * ltr_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(ltr_label, "In modern terminology, a microcontroller is similar to a system on a chip (SoC).");
|
||||
lv_obj_set_style_text_font(ltr_label, &lv_font_montserrat_16, 0);
|
||||
lv_obj_set_width(ltr_label, 310);
|
||||
lv_obj_align(ltr_label, LV_ALIGN_TOP_LEFT, 5, 5);
|
||||
|
||||
lv_obj_t * rtl_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(rtl_label, "מעבד, או בשמו המלא יחידת עיבוד מרכזית (באנגלית: CPU - Central Processing Unit).");
|
||||
lv_obj_set_style_base_dir(rtl_label, LV_BASE_DIR_RTL, 0);
|
||||
lv_obj_set_style_text_font(rtl_label, &lv_font_dejavu_16_persian_hebrew, 0);
|
||||
lv_obj_set_width(rtl_label, 310);
|
||||
lv_obj_align(rtl_label, LV_ALIGN_LEFT_MID, 5, 0);
|
||||
|
||||
lv_obj_t * cz_label = lv_label_create(lv_scr_act());
|
||||
lv_label_set_text(cz_label, "嵌入式系统(Embedded System),\n是一种嵌入机械或电气系统内部、具有专一功能和实时计算性能的计算机系统。");
|
||||
lv_obj_set_style_text_font(cz_label, &lv_font_simsun_16_cjk, 0);
|
||||
lv_obj_set_width(cz_label, 310);
|
||||
lv_obj_align(cz_label, LV_ALIGN_BOTTOM_LEFT, 5, -5);
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user